Support creating .pkg installers using the debug build configuration.

Users reporting bugs will be able to use these packages to install debug
builds of Background Music without having to install from source. This
is mainly useful because debug builds have more detailed logging.
Hopefully we'll get around to adding an option to enable debug logging
at runtime, but this should work well enough for now.

Also:
 - Use newer macOS images in Travis CI builds.
 - Fix an xcrun command in build_and_install.sh that was accidentally
   being started in the background.
 - Fix build_and_install.sh building libPublicUtility.a twice for no
   reason.
This commit is contained in:
Kyle Neideck 2018-06-05 00:40:02 +10:00
parent ed06a257a8
commit cb9cdb00b6
No known key found for this signature in database
GPG key ID: CAA8D9B8E39EC18C
6 changed files with 96 additions and 37 deletions

View file

@ -2,16 +2,16 @@ language: objective-c
matrix:
include:
- os: osx
osx_image: xcode9.2
osx_image: xcode9.3
xcode_sdk: macosx10.13
sudo: required
env: DEPLOY=true
- os: osx
osx_image: xcode9.1
osx_image: xcode9.2
xcode_sdk: macosx10.13
sudo: required
- os: osx
osx_image: xcode9
osx_image: xcode9.1
xcode_sdk: macosx10.13
sudo: required
- os: osx
@ -69,8 +69,13 @@ script:
- if ls -la "/Library/LaunchDaemons/com.bearisdriving.BGM.XPCHelper.plist"; then false; fi
# Return early if we're not testing packaging on this OS X version.
- if [[ "$PACKAGE" == "false" ]]; then exit 0; fi
# Build the .pkg installer. (Print the logs if it fails.)
- ./package.sh || (cat build_and_install.log && false)
# Build the .pkg installer. Print the build logs if it fails. If this build is for a tag with
# "DEBUG" in its name, build a debug package. (More detailed logging, no optimization, etc.)
- if [[ "$TRAVIS_TAG" =~ .*DEBUG.* ]]; then
./package.sh -d || (cat build_and_install.log && travis_terminate 1);
else
./package.sh || (cat build_and_install.log && travis_terminate 1);
fi
# Install the .pkg.
- sudo installer -pkg Background-Music-*/BackgroundMusic-*.pkg -target / -verbose -dumplog
# Check the BGM dirs and files were installed again.

View file

@ -37,6 +37,12 @@
<FileRef
location = "group:uninstall.sh">
</FileRef>
<FileRef
location = "group:package.sh">
</FileRef>
<FileRef
location = "group:pkg">
</FileRef>
<FileRef
location = "group:Images">
</FileRef>

View file

@ -412,6 +412,7 @@
errorCode:(OSStatus)errorCode
revertTo:(AudioDeviceID*)revertTo {
// Using LogWarning from PublicUtility instead of NSLog here crashes from a bad access. Not sure why.
// TODO: Possibly caused by a bug in CADebugMacros.cpp. See commit ab9d4cd.
NSLog(@"BGMAudioDeviceManager::failedToSetOutputDevice: Couldn't set device with ID %u as output device. "
"%s%d. %@",
deviceID,

View file

@ -145,7 +145,7 @@ if ! [[ -x "${XCODEBUILD}" ]]; then
fi
# This check is last because it takes 10 seconds or so if it fails.
if ! [[ -x "${XCODEBUILD}" ]]; then
XCODEBUILD=$(/usr/bin/xcrun --find xcodebuild &2>>${LOG_FILE} || true)
XCODEBUILD="$(/usr/bin/xcrun --find xcodebuild 2>>${LOG_FILE} || true)"
fi
RECOMMENDED_MIN_XCODE_VERSION=8
@ -245,8 +245,11 @@ parse_options() {
CONFIGURATION="Debug"
;;
b)
# Just build; don't install.
XCODEBUILD_ACTION="build"
# The dirs xcodebuild will build in.
# TODO: If these dirs were created by running this script without -b, they'll be
# owned by root and xcodebuild will fail.
APP_PATH="./BGMApp/build"
DRIVER_PATH="./BGMDriver/build"
;;
@ -606,14 +609,17 @@ if [[ "${XCODEBUILD_ACTION}" == "install" ]]; then
SUDO="sudo"
ACTIONING="Installing"
else
# No need to sudo if we're only building.
SUDO=""
ACTIONING="Building"
fi
# Enable AddressSanitizer in debug builds to catch memory bugs. Allow ENABLE_ASAN to be set as an
# environment variable by only setting it here if it isn't already set. (Used by package.sh.)
if [[ "${CONFIGURATION}" == "Debug" ]]; then
ENABLE_ASAN=YES
ENABLE_ASAN="${ENABLE_ASAN:-YES}"
else
ENABLE_ASAN=NO
ENABLE_ASAN="${ENABLE_ASAN:-NO}"
fi
# BGMDriver
@ -623,16 +629,6 @@ echo "[1/3] ${ACTIONING} the virtual audio device $(bold_face ${DRIVER_DIR}) to"
| tee -a ${LOG_FILE}
# Disable the -e shell option and error trap for build commands so we can handle errors differently.
(disable_error_handling
# Build Apple's PublicUtility classes as a static library.
${SUDO} "${XCODEBUILD}" -scheme "PublicUtility" \
-configuration ${CONFIGURATION} \
-enableAddressSanitizer ${ENABLE_ASAN} \
BUILD_DIR=./build \
RUN_CLANG_STATIC_ANALYZER=0 \
${XCODEBUILD_OPTIONS} \
${CLEAN} build >> ${LOG_FILE} 2>&1) &
(disable_error_handling
# Build and install BGMDriver
${SUDO} "${XCODEBUILD}" -scheme "Background Music Device" \

View file

@ -19,10 +19,11 @@
#
# package.sh
#
# Copyright © 2017 Kyle Neideck
# Copyright © 2017, 2018 Kyle Neideck
# Copyright © 2016, 2017 Takayama Fumihiko
#
# Build Background Music and package it into a .pkg file and a .zip of the debug symbols (dSYM).
# Call this script with -d to use the debug build configuration.
#
# Based on https://github.com/tekezo/Karabiner-Elements/blob/master/make-package.sh
#
@ -46,26 +47,63 @@ set_permissions() {
# --------------------------------------------------
# Build
bash build_and_install.sh -b
# Use the release configuration by default.
debug_build=NO
build_output_path="build/Release"
# Handle the options passed to this script.
while getopts ":d" opt; do
case $opt in
d)
debug_build=YES
build_output_path="build/Debug"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
# Build
if [[ $debug_build == YES ]]; then
# Disable AddressSanitizer so we can distribute debug packages to users reporting bugs without
# worrying about loading the AddressSanitizer dylib in coreaudiod.
#
# TODO: Would debug packages be more useful if they were built with optimization (i.e. using the
# DebugOpt configuration instead of Debug)?
ENABLE_ASAN=NO bash build_and_install.sh -b -d
build_status=$?
else
bash build_and_install.sh -b
build_status=$?
fi
# Exit if the build failed.
if [[ $build_status -ne 0 ]]; then
exit $build_status
fi
# Read the version string from the build.
version="$(/usr/libexec/PlistBuddy \
-c "Print CFBundleShortVersionString" \
"BGMApp/build/Release/Background Music.app/Contents/Info.plist")"
"BGMApp/${build_output_path}/Background Music.app/Contents/Info.plist")"
# Everything in out_dir at the end of this script will be released in the Travis CI builds.
out_dir="Background-Music-$version"
rm -rf "$out_dir"
mkdir "$out_dir"
# Separate the debug symbols and the .app
echo "Archiving debug symbols"
if [[ $debug_build == NO ]]; then
# Separate the debug symbols and the .app bundle.
echo "Archiving debug symbols"
dsym_archive="$out_dir/Background Music.dSYM-$version.zip"
mv "BGMApp/build/Release/Background Music.app/Contents/MacOS/Background Music.dSYM" \
dsym_archive="$out_dir/Background Music.dSYM-$version.zip"
mv "BGMApp/${build_output_path}/Background Music.app/Contents/MacOS/Background Music.dSYM" \
"Background Music.dSYM"
zip -r "$dsym_archive" "Background Music.dSYM"
rm -r "Background Music.dSYM"
zip -r "$dsym_archive" "Background Music.dSYM"
rm -r "Background Music.dSYM"
fi
# --------------------------------------------------
@ -75,10 +113,11 @@ rm -rf "pkgroot"
mkdir -p "pkgroot"
mkdir -p "pkgroot/Library/Audio/Plug-Ins/HAL"
cp -R "BGMDriver/build/Release/Background Music Device.driver" "pkgroot/Library/Audio/Plug-Ins/HAL/"
cp -R "BGMDriver/${build_output_path}/Background Music Device.driver" \
"pkgroot/Library/Audio/Plug-Ins/HAL/"
mkdir -p "pkgroot/Applications"
cp -R "BGMApp/build/Release/Background Music.app" "pkgroot/Applications"
cp -R "BGMApp/${build_output_path}/Background Music.app" "pkgroot/Applications"
scripts_dir="$(mktemp -d)"
cp "pkg/preinstall" "$scripts_dir"
@ -86,7 +125,7 @@ cp "pkg/postinstall" "$scripts_dir"
cp "BGMApp/BGMXPCHelper/com.bearisdriving.BGM.XPCHelper.plist.template" "$scripts_dir"
cp "BGMApp/BGMXPCHelper/safe_install_dir.sh" "$scripts_dir"
cp "BGMApp/BGMXPCHelper/post_install.sh" "$scripts_dir"
cp -R "BGMApp/build/Release/BGMXPCHelper.xpc" "$scripts_dir"
cp -R "BGMApp/${build_output_path}/BGMXPCHelper.xpc" "$scripts_dir"
set_permissions "pkgroot"
chmod 755 "pkgroot/Applications/Background Music.app/Contents/MacOS/Background Music"
@ -133,9 +172,16 @@ rm -rf "pkgres"
rm -f "pkg/Distribution.xml"
# Print checksums
echo "MD5 checksums:"
md5 {"$pkg","$dsym_archive"}
echo "SHA256 checksums:"
shasum -a 256 {"$pkg","$dsym_archive"}
if [[ $debug_build == YES ]]; then
echo "MD5 checksum:"
md5 "$pkg"
echo "SHA256 checksum:"
shasum -a 256 "$pkg"
else
echo "MD5 checksums:"
md5 {"$pkg","$dsym_archive"}
echo "SHA256 checksums:"
shasum -a 256 {"$pkg","$dsym_archive"}
fi

View file

@ -17,13 +17,14 @@
# along with Background Music. If not, see <http://www.gnu.org/licenses/>.
#
# preinstall
# postinstall
#
# Copyright © 2017 Kyle Neideck
#
PATH=/bin:/sbin:/usr/bin:/usr/sbin; export PATH
coreaudiod_plist="/System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist"
dest_volume="$3"
xpc_helper_path="$(bash safe_install_dir.sh -y)"
@ -34,6 +35,8 @@ cp -Rf "BGMXPCHelper.xpc" "$xpc_helper_path"
bash "post_install.sh" "$xpc_helper_path" "BGMXPCHelper.xpc/Contents/MacOS/BGMXPCHelper" "."
# TODO: Verify the installed files, their permissions, the _BGMXPCHelper user/group, etc.
# TODO: Instead of just sleeping for 5 seconds, wait until coreaudiod is restarted and BGMDevice is
# ready to use.
# The extra or-clauses are fallback versions of the command that restarts coreaudiod. Apparently
# some of these commands don't work with older versions of launchctl, so I figure there's no
@ -52,4 +55,6 @@ open "${dest_volume}/Applications/Background Music.app"
# The installer plays a sound when it finishes, so give BGMApp a second to launch.
sleep 1
exit 0