mirror of
https://github.com/kyleneideck/BackgroundMusic
synced 2024-11-10 06:34:22 +00:00
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:
parent
ed06a257a8
commit
cb9cdb00b6
6 changed files with 96 additions and 37 deletions
15
.travis.yml
15
.travis.yml
|
@ -2,16 +2,16 @@ language: objective-c
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: osx
|
- os: osx
|
||||||
osx_image: xcode9.2
|
osx_image: xcode9.3
|
||||||
xcode_sdk: macosx10.13
|
xcode_sdk: macosx10.13
|
||||||
sudo: required
|
sudo: required
|
||||||
env: DEPLOY=true
|
env: DEPLOY=true
|
||||||
- os: osx
|
- os: osx
|
||||||
osx_image: xcode9.1
|
osx_image: xcode9.2
|
||||||
xcode_sdk: macosx10.13
|
xcode_sdk: macosx10.13
|
||||||
sudo: required
|
sudo: required
|
||||||
- os: osx
|
- os: osx
|
||||||
osx_image: xcode9
|
osx_image: xcode9.1
|
||||||
xcode_sdk: macosx10.13
|
xcode_sdk: macosx10.13
|
||||||
sudo: required
|
sudo: required
|
||||||
- os: osx
|
- os: osx
|
||||||
|
@ -69,8 +69,13 @@ script:
|
||||||
- if ls -la "/Library/LaunchDaemons/com.bearisdriving.BGM.XPCHelper.plist"; then false; fi
|
- 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.
|
# Return early if we're not testing packaging on this OS X version.
|
||||||
- if [[ "$PACKAGE" == "false" ]]; then exit 0; fi
|
- if [[ "$PACKAGE" == "false" ]]; then exit 0; fi
|
||||||
# Build the .pkg installer. (Print the logs if it fails.)
|
# Build the .pkg installer. Print the build logs if it fails. If this build is for a tag with
|
||||||
- ./package.sh || (cat build_and_install.log && false)
|
# "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.
|
# Install the .pkg.
|
||||||
- sudo installer -pkg Background-Music-*/BackgroundMusic-*.pkg -target / -verbose -dumplog
|
- sudo installer -pkg Background-Music-*/BackgroundMusic-*.pkg -target / -verbose -dumplog
|
||||||
# Check the BGM dirs and files were installed again.
|
# Check the BGM dirs and files were installed again.
|
||||||
|
|
6
BGM.xcworkspace/contents.xcworkspacedata
generated
6
BGM.xcworkspace/contents.xcworkspacedata
generated
|
@ -37,6 +37,12 @@
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:uninstall.sh">
|
location = "group:uninstall.sh">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
|
<FileRef
|
||||||
|
location = "group:package.sh">
|
||||||
|
</FileRef>
|
||||||
|
<FileRef
|
||||||
|
location = "group:pkg">
|
||||||
|
</FileRef>
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Images">
|
location = "group:Images">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
|
|
|
@ -412,6 +412,7 @@
|
||||||
errorCode:(OSStatus)errorCode
|
errorCode:(OSStatus)errorCode
|
||||||
revertTo:(AudioDeviceID*)revertTo {
|
revertTo:(AudioDeviceID*)revertTo {
|
||||||
// Using LogWarning from PublicUtility instead of NSLog here crashes from a bad access. Not sure why.
|
// 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. "
|
NSLog(@"BGMAudioDeviceManager::failedToSetOutputDevice: Couldn't set device with ID %u as output device. "
|
||||||
"%s%d. %@",
|
"%s%d. %@",
|
||||||
deviceID,
|
deviceID,
|
||||||
|
|
|
@ -145,7 +145,7 @@ if ! [[ -x "${XCODEBUILD}" ]]; then
|
||||||
fi
|
fi
|
||||||
# This check is last because it takes 10 seconds or so if it fails.
|
# This check is last because it takes 10 seconds or so if it fails.
|
||||||
if ! [[ -x "${XCODEBUILD}" ]]; then
|
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
|
fi
|
||||||
|
|
||||||
RECOMMENDED_MIN_XCODE_VERSION=8
|
RECOMMENDED_MIN_XCODE_VERSION=8
|
||||||
|
@ -245,8 +245,11 @@ parse_options() {
|
||||||
CONFIGURATION="Debug"
|
CONFIGURATION="Debug"
|
||||||
;;
|
;;
|
||||||
b)
|
b)
|
||||||
|
# Just build; don't install.
|
||||||
XCODEBUILD_ACTION="build"
|
XCODEBUILD_ACTION="build"
|
||||||
# The dirs xcodebuild will build in.
|
# 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"
|
APP_PATH="./BGMApp/build"
|
||||||
DRIVER_PATH="./BGMDriver/build"
|
DRIVER_PATH="./BGMDriver/build"
|
||||||
;;
|
;;
|
||||||
|
@ -606,14 +609,17 @@ if [[ "${XCODEBUILD_ACTION}" == "install" ]]; then
|
||||||
SUDO="sudo"
|
SUDO="sudo"
|
||||||
ACTIONING="Installing"
|
ACTIONING="Installing"
|
||||||
else
|
else
|
||||||
|
# No need to sudo if we're only building.
|
||||||
SUDO=""
|
SUDO=""
|
||||||
ACTIONING="Building"
|
ACTIONING="Building"
|
||||||
fi
|
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
|
if [[ "${CONFIGURATION}" == "Debug" ]]; then
|
||||||
ENABLE_ASAN=YES
|
ENABLE_ASAN="${ENABLE_ASAN:-YES}"
|
||||||
else
|
else
|
||||||
ENABLE_ASAN=NO
|
ENABLE_ASAN="${ENABLE_ASAN:-NO}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# BGMDriver
|
# BGMDriver
|
||||||
|
@ -623,16 +629,6 @@ echo "[1/3] ${ACTIONING} the virtual audio device $(bold_face ${DRIVER_DIR}) to"
|
||||||
| tee -a ${LOG_FILE}
|
| tee -a ${LOG_FILE}
|
||||||
|
|
||||||
# Disable the -e shell option and error trap for build commands so we can handle errors differently.
|
# 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
|
(disable_error_handling
|
||||||
# Build and install BGMDriver
|
# Build and install BGMDriver
|
||||||
${SUDO} "${XCODEBUILD}" -scheme "Background Music Device" \
|
${SUDO} "${XCODEBUILD}" -scheme "Background Music Device" \
|
||||||
|
|
82
package.sh
82
package.sh
|
@ -19,10 +19,11 @@
|
||||||
#
|
#
|
||||||
# package.sh
|
# package.sh
|
||||||
#
|
#
|
||||||
# Copyright © 2017 Kyle Neideck
|
# Copyright © 2017, 2018 Kyle Neideck
|
||||||
# Copyright © 2016, 2017 Takayama Fumihiko
|
# Copyright © 2016, 2017 Takayama Fumihiko
|
||||||
#
|
#
|
||||||
# Build Background Music and package it into a .pkg file and a .zip of the debug symbols (dSYM).
|
# 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
|
# Based on https://github.com/tekezo/Karabiner-Elements/blob/master/make-package.sh
|
||||||
#
|
#
|
||||||
|
@ -46,26 +47,63 @@ set_permissions() {
|
||||||
|
|
||||||
# --------------------------------------------------
|
# --------------------------------------------------
|
||||||
|
|
||||||
# Build
|
# Use the release configuration by default.
|
||||||
bash build_and_install.sh -b
|
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 \
|
version="$(/usr/libexec/PlistBuddy \
|
||||||
-c "Print CFBundleShortVersionString" \
|
-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.
|
# Everything in out_dir at the end of this script will be released in the Travis CI builds.
|
||||||
out_dir="Background-Music-$version"
|
out_dir="Background-Music-$version"
|
||||||
rm -rf "$out_dir"
|
rm -rf "$out_dir"
|
||||||
mkdir "$out_dir"
|
mkdir "$out_dir"
|
||||||
|
|
||||||
# Separate the debug symbols and the .app
|
if [[ $debug_build == NO ]]; then
|
||||||
echo "Archiving debug symbols"
|
# Separate the debug symbols and the .app bundle.
|
||||||
|
echo "Archiving debug symbols"
|
||||||
|
|
||||||
dsym_archive="$out_dir/Background Music.dSYM-$version.zip"
|
dsym_archive="$out_dir/Background Music.dSYM-$version.zip"
|
||||||
mv "BGMApp/build/Release/Background Music.app/Contents/MacOS/Background Music.dSYM" \
|
mv "BGMApp/${build_output_path}/Background Music.app/Contents/MacOS/Background Music.dSYM" \
|
||||||
"Background Music.dSYM"
|
"Background Music.dSYM"
|
||||||
zip -r "$dsym_archive" "Background Music.dSYM"
|
zip -r "$dsym_archive" "Background Music.dSYM"
|
||||||
rm -r "Background Music.dSYM"
|
rm -r "Background Music.dSYM"
|
||||||
|
fi
|
||||||
|
|
||||||
# --------------------------------------------------
|
# --------------------------------------------------
|
||||||
|
|
||||||
|
@ -75,10 +113,11 @@ rm -rf "pkgroot"
|
||||||
mkdir -p "pkgroot"
|
mkdir -p "pkgroot"
|
||||||
|
|
||||||
mkdir -p "pkgroot/Library/Audio/Plug-Ins/HAL"
|
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"
|
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)"
|
scripts_dir="$(mktemp -d)"
|
||||||
cp "pkg/preinstall" "$scripts_dir"
|
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/com.bearisdriving.BGM.XPCHelper.plist.template" "$scripts_dir"
|
||||||
cp "BGMApp/BGMXPCHelper/safe_install_dir.sh" "$scripts_dir"
|
cp "BGMApp/BGMXPCHelper/safe_install_dir.sh" "$scripts_dir"
|
||||||
cp "BGMApp/BGMXPCHelper/post_install.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"
|
set_permissions "pkgroot"
|
||||||
chmod 755 "pkgroot/Applications/Background Music.app/Contents/MacOS/Background Music"
|
chmod 755 "pkgroot/Applications/Background Music.app/Contents/MacOS/Background Music"
|
||||||
|
@ -133,9 +172,16 @@ rm -rf "pkgres"
|
||||||
rm -f "pkg/Distribution.xml"
|
rm -f "pkg/Distribution.xml"
|
||||||
|
|
||||||
# Print checksums
|
# Print checksums
|
||||||
echo "MD5 checksums:"
|
if [[ $debug_build == YES ]]; then
|
||||||
md5 {"$pkg","$dsym_archive"}
|
echo "MD5 checksum:"
|
||||||
echo "SHA256 checksums:"
|
md5 "$pkg"
|
||||||
shasum -a 256 {"$pkg","$dsym_archive"}
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,14 @@
|
||||||
# along with Background Music. If not, see <http://www.gnu.org/licenses/>.
|
# along with Background Music. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#
|
#
|
||||||
# preinstall
|
# postinstall
|
||||||
#
|
#
|
||||||
# Copyright © 2017 Kyle Neideck
|
# Copyright © 2017 Kyle Neideck
|
||||||
#
|
#
|
||||||
|
|
||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin; export PATH
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin; export PATH
|
||||||
|
|
||||||
|
coreaudiod_plist="/System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist"
|
||||||
dest_volume="$3"
|
dest_volume="$3"
|
||||||
xpc_helper_path="$(bash safe_install_dir.sh -y)"
|
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" "."
|
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: 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
|
# 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
|
# 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.
|
# The installer plays a sound when it finishes, so give BGMApp a second to launch.
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue