mirror of
https://github.com/kyleneideck/BackgroundMusic
synced 2024-11-10 06:34:22 +00:00
Add an archive option (-a) to build_and_install.sh.
Archiving is the standard way to build a release for distribution using Xcode. package.sh now uses this option when it creates a release package. This change is mainly to keep the Run settings in the Xcode schemes from affecting the release builds, which means we can commit the schemes with more sensible settings. Also, disable AddressSanitizer in the BGMDevice scheme, which was stopping coreaudiod from launching because its sandbox won't allow the process to load the AddressSanitizer dylib.
This commit is contained in:
parent
08d428c948
commit
8de821d4aa
11 changed files with 193 additions and 80 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,6 +9,7 @@ cmake-build-debug/
|
|||
BGM.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
|
||||
Images/*.aux
|
||||
Images/*.log
|
||||
/archive/
|
||||
|
||||
# Everything below is from https://github.com/github/gitignore/blob/master/Objective-C.gitignore
|
||||
|
||||
|
|
13
.travis.yml
13
.travis.yml
|
@ -2,7 +2,7 @@ language: objective-c
|
|||
matrix:
|
||||
include:
|
||||
- os: osx
|
||||
osx_image: xcode11.2
|
||||
osx_image: xcode11.3
|
||||
xcode_sdk: macosx10.14
|
||||
sudo: required
|
||||
env: DEPLOY=true
|
||||
|
@ -18,10 +18,6 @@ matrix:
|
|||
osx_image: xcode9.4
|
||||
xcode_sdk: macosx10.13
|
||||
sudo: required
|
||||
- os: osx
|
||||
osx_image: xcode9.3
|
||||
xcode_sdk: macosx10.13
|
||||
sudo: required
|
||||
- os: osx
|
||||
osx_image: xcode9.2
|
||||
xcode_sdk: macosx10.13
|
||||
|
@ -31,11 +27,6 @@ matrix:
|
|||
# osx_image: xcode8.3
|
||||
# xcode_sdk: macosx10.12
|
||||
# sudo: required
|
||||
- os: osx
|
||||
osx_image: xcode7.3
|
||||
xcode_sdk: macosx10.11
|
||||
sudo: required
|
||||
env: PACKAGE=false
|
||||
# branches:
|
||||
# only:
|
||||
# - master
|
||||
|
@ -105,7 +96,7 @@ script:
|
|||
# Post on IRC when Travis builds finish.
|
||||
notifications:
|
||||
irc: "irc.freenode.org#backgroundmusic"
|
||||
# Upload the .pkg and dSYM zip to GitHub.
|
||||
# Upload the .pkg and archives to GitHub.
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
|
|
|
@ -1710,6 +1710,7 @@
|
|||
27379B991C7F57DB0084A24C /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEPLOYMENT_POSTPROCESSING = NO;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
|
@ -1723,12 +1724,14 @@
|
|||
INSTALL_PATH = /usr/local/libexec;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.bearisdriving.BGM.XPCHelper;
|
||||
PRODUCT_NAME = BGMXPCHelper;
|
||||
STRIP_INSTALLED_PRODUCT = NO;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
27379B9A1C7F57DB0084A24C /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEPLOYMENT_POSTPROCESSING = YES;
|
||||
INFOPLIST_FILE = BGMXPCHelper/Info.plist;
|
||||
INSTALL_GROUP = wheel;
|
||||
|
@ -1737,12 +1740,14 @@
|
|||
LLVM_LTO = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.bearisdriving.BGM.XPCHelper;
|
||||
PRODUCT_NAME = BGMXPCHelper;
|
||||
STRIP_INSTALLED_PRODUCT = NO;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
27379B9B1C7F57DB0084A24C /* DebugOpt */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEPLOYMENT_POSTPROCESSING = NO;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
|
@ -1756,6 +1761,7 @@
|
|||
INSTALL_PATH = /usr/local/libexec;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.bearisdriving.BGM.XPCHelper;
|
||||
PRODUCT_NAME = BGMXPCHelper;
|
||||
STRIP_INSTALLED_PRODUCT = NO;
|
||||
};
|
||||
name = DebugOpt;
|
||||
};
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
# post_install.sh
|
||||
# BGMXPCHelper
|
||||
#
|
||||
# Copyright © 2016-2018 Kyle Neideck
|
||||
# Copyright © 2016-2020 Kyle Neideck
|
||||
#
|
||||
# Installs BGMXPCHelper's launchd plist file and "bootstraps" (registers/enables) it with launchd.
|
||||
#
|
||||
|
@ -68,7 +68,13 @@ fi
|
|||
# If DEPLOYMENT_POSTPROCESSING is true, xcodebuild calls this script even if you're just building
|
||||
# (and not also installing). I'm not sure why, as we have the "run script only when installing"
|
||||
# option enabled.
|
||||
if ! [[ -z ${ACTION} ]] && [[ "${ACTION}" != "install" ]]; then
|
||||
#
|
||||
# REAL_ACTION is a workaround for xcodebuild setting ACTION to "install" even if we're actually
|
||||
# making an archive.
|
||||
#
|
||||
# TODO: Archiving BGMXPCHelper from Xcode instead of using build_and_install.sh still fails.
|
||||
if ( ! [[ -z ${ACTION} ]] && [[ "${ACTION}" != "install" ]] ) || \
|
||||
( ! [[ -z ${REAL_ACTION} ]] && [[ "${REAL_ACTION}" == "archive" ]] ); then
|
||||
echo "$0 should only be called during an install. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -774,13 +774,14 @@
|
|||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INFOPLIST_FILE = BGMDriver/Info.plist;
|
||||
INSTALL_GROUP = wheel;
|
||||
INSTALL_OWNER = root;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Audio/Plug-Ins/HAL";
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.bearisdriving.BGM.Driver;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = NO;
|
||||
WRAPPER_EXTENSION = driver;
|
||||
};
|
||||
name = Debug;
|
||||
|
@ -809,12 +810,13 @@
|
|||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INFOPLIST_FILE = BGMDriver/Info.plist;
|
||||
INSTALL_GROUP = wheel;
|
||||
INSTALL_OWNER = root;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Audio/Plug-Ins/HAL";
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.bearisdriving.BGM.Driver;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = NO;
|
||||
WRAPPER_EXTENSION = driver;
|
||||
};
|
||||
name = Release;
|
||||
|
@ -845,6 +847,7 @@
|
|||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -869,6 +872,7 @@
|
|||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
|
|
@ -70,9 +70,8 @@
|
|||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
debugAsWhichUser = "root"
|
||||
enableAddressSanitizer = "YES"
|
||||
enableASanStackUseAfterReturn = "YES"
|
||||
enableUBSanitizer = "YES"
|
||||
disableMainThreadChecker = "YES"
|
||||
launchStyle = "1"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
|
|
|
@ -38,9 +38,7 @@
|
|||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
enableAddressSanitizer = "YES"
|
||||
enableASanStackUseAfterReturn = "YES"
|
||||
enableUBSanitizer = "YES"
|
||||
disableMainThreadChecker = "YES"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#
|
||||
# build_and_install.sh
|
||||
#
|
||||
# Copyright © 2016-2019 Kyle Neideck
|
||||
# Copyright © 2016-2020 Kyle Neideck
|
||||
# Copyright © 2016 Nick Jacques
|
||||
#
|
||||
# Builds and installs BGMApp, BGMDriver and BGMXPCHelper. Requires xcodebuild and Xcode.
|
||||
|
@ -117,14 +117,20 @@ echo -n > ${LOG_FILE}
|
|||
|
||||
COREAUDIOD_PLIST="/System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist"
|
||||
|
||||
# Output locations for installing. These are overwritten later if building or archiving.
|
||||
#
|
||||
# TODO: Should (can?) we use xcodebuild to get these from the Xcode project rather than duplicating
|
||||
# them?
|
||||
APP_PATH="/Applications"
|
||||
APP_DIR="Background Music.app"
|
||||
DRIVER_PATH="/Library/Audio/Plug-Ins/HAL"
|
||||
DRIVER_DIR="Background Music Device.driver"
|
||||
# XPC_HELPER_OUTPUT_PATH is set below because it depends on the system (when installing).
|
||||
XPC_HELPER_DIR="BGMXPCHelper.xpc"
|
||||
|
||||
# The root output directory when archiving.
|
||||
ARCHIVES_DIR="archives"
|
||||
|
||||
GENERAL_ERROR_MSG="Internal script error. Probably a bug in this script."
|
||||
BUILD_FAILED_ERROR_MSG="A build command failed. Probably a compilation error."
|
||||
BGMAPP_FAILED_TO_START_ERROR_MSG="Background Music (${APP_PATH}/${APP_DIR}) didn't seem to start \
|
||||
|
@ -154,6 +160,7 @@ usage() {
|
|||
echo "Usage: $0 [options]" >&2
|
||||
echo -e "\t-n Don't clean before building/installing." >&2
|
||||
echo -e "\t-d Debug build. (Release is the default.)" >&2
|
||||
echo -e "\t-a Build and archive, don't install. See Xcode docs for info about archiving." >&2
|
||||
echo -e "\t-b Build only, don't install." >&2
|
||||
echo -e "\t-w Ignore compiler warnings. (They're treated as errors by default.)" >&2
|
||||
echo -e "\t-x [options] Extra options to pass to xcodebuild." >&2
|
||||
|
@ -236,7 +243,7 @@ show_spinner() {
|
|||
}
|
||||
|
||||
parse_options() {
|
||||
while getopts ":ndbwx:ch" opt; do
|
||||
while getopts ":ndabwx:ch" opt; do
|
||||
case $opt in
|
||||
n)
|
||||
CLEAN=""
|
||||
|
@ -244,6 +251,15 @@ parse_options() {
|
|||
d)
|
||||
CONFIGURATION="Debug"
|
||||
;;
|
||||
a)
|
||||
# The "archive" action makes a build for distribution. It's the same as the archive
|
||||
# option in Xcode. It won't install.
|
||||
XCODEBUILD_ACTION="archive"
|
||||
# The dirs xcodebuild will put the archives in.
|
||||
APP_PATH="$ARCHIVES_DIR/BGMApp.xcarchive"
|
||||
XPC_HELPER_OUTPUT_PATH="$ARCHIVES_DIR/BGMApp.xcarchive"
|
||||
DRIVER_PATH="$ARCHIVES_DIR/BGMDriver.xcarchive"
|
||||
;;
|
||||
b)
|
||||
# Just build; don't install.
|
||||
XCODEBUILD_ACTION="build"
|
||||
|
@ -251,6 +267,7 @@ parse_options() {
|
|||
# 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"
|
||||
XPC_HELPER_OUTPUT_PATH="./BGMApp/build"
|
||||
DRIVER_PATH="./BGMDriver/build"
|
||||
;;
|
||||
w)
|
||||
|
@ -509,7 +526,7 @@ log_debug_info() {
|
|||
"(\"$(git show -s --format=%s HEAD 2>&1)\")" >> ${LOG_FILE}
|
||||
|
||||
echo "Using xcodebuild: ${XCODEBUILD}" >> ${LOG_FILE}
|
||||
echo "Using BGMXPCHelper path: ${XPC_HELPER_PATH}" >> ${LOG_FILE}
|
||||
echo "Using BGMXPCHelper output path: ${XPC_HELPER_OUTPUT_PATH}" >> ${LOG_FILE}
|
||||
|
||||
xcode-select --version >> ${LOG_FILE} 2>&1
|
||||
echo "Xcode path: $(xcode-select --print-path 2>&1)" >> ${LOG_FILE}
|
||||
|
@ -553,7 +570,7 @@ fi
|
|||
|
||||
# Print initial message.
|
||||
if [[ "${XCODEBUILD_ACTION}" == "install" ]]; then
|
||||
XPC_HELPER_PATH="$(BGMApp/BGMXPCHelper/safe_install_dir.sh)"
|
||||
XPC_HELPER_OUTPUT_PATH="$(BGMApp/BGMXPCHelper/safe_install_dir.sh)"
|
||||
|
||||
echo "$(bold_face About to install Background Music). Please pause all audio, if you can."
|
||||
[[ "${CONFIGURATION}" == "Debug" ]] && echo "Debug build."
|
||||
|
@ -561,12 +578,13 @@ if [[ "${XCODEBUILD_ACTION}" == "install" ]]; then
|
|||
echo "This script will install:"
|
||||
echo " - ${APP_PATH}/${APP_DIR}"
|
||||
echo " - ${DRIVER_PATH}/${DRIVER_DIR}"
|
||||
echo " - ${XPC_HELPER_PATH}/${XPC_HELPER_DIR}"
|
||||
echo " - ${XPC_HELPER_OUTPUT_PATH}/${XPC_HELPER_DIR}"
|
||||
echo " - /Library/LaunchDaemons/com.bearisdriving.BGM.XPCHelper.plist"
|
||||
echo
|
||||
elif [[ "${XCODEBUILD_ACTION}" == "build" ]]; then
|
||||
XPC_HELPER_PATH="${APP_PATH}"
|
||||
|
||||
elif [[ "${XCODEBUILD_ACTION}" == "archive" ]]; then
|
||||
echo "$(bold_face Building and archiving Background Music...)"
|
||||
echo
|
||||
else
|
||||
echo "$(bold_face Building Background Music...)"
|
||||
echo
|
||||
fi
|
||||
|
@ -597,8 +615,9 @@ if ! is_alive ${CHECK_XCODE_TASK_PID}; then
|
|||
enable_error_handling
|
||||
fi
|
||||
|
||||
# Update the user's sudo timestamp if we're going to need to sudo at some point. This prompts the
|
||||
# user for their password.
|
||||
if [[ "${XCODEBUILD_ACTION}" == "install" ]]; then
|
||||
# Update the user's sudo timestamp. (Prompts the user for their password.)
|
||||
# Don't call sudo -v if this is a Travis CI build.
|
||||
if ([[ -z ${TRAVIS:-} ]] || [[ "${TRAVIS}" != true ]]) && ! sudo -v; then
|
||||
echo "$(tput setaf 9)ERROR$(tput sgr0): This script must be run by a user with" \
|
||||
|
@ -617,15 +636,22 @@ while [[ ${NEED_TO_HANDLE_CHECK_XCODE_RESULT} -ne 0 ]]; do
|
|||
enable_error_handling
|
||||
done
|
||||
|
||||
log_debug_info $*
|
||||
log_debug_info "$@"
|
||||
|
||||
# Set some variables that control the compilation commands below.
|
||||
if [[ "${XCODEBUILD_ACTION}" == "install" ]]; then
|
||||
SUDO="sudo"
|
||||
ACTIONING="Installing"
|
||||
DSTROOT_ARG="DSTROOT=/"
|
||||
elif [[ "${XCODEBUILD_ACTION}" == "archive" ]]; then
|
||||
SUDO=""
|
||||
ACTIONING="Building and archiving"
|
||||
DSTROOT_ARG=""
|
||||
else
|
||||
# No need to sudo if we're only building.
|
||||
SUDO=""
|
||||
ACTIONING="Building"
|
||||
DSTROOT_ARG=""
|
||||
fi
|
||||
|
||||
# Enable AddressSanitizer in debug builds to catch memory bugs. Allow ENABLE_ASAN to be set as an
|
||||
|
@ -657,6 +683,26 @@ if [[ "${CLEAN}" != "" ]]; then
|
|||
BGMApp/build manually and running '$0 -n' to skip the cleaning step."
|
||||
fi
|
||||
|
||||
# Prints the -archivePath option if we're archiving (i.e. making a .xcarchive). Does nothing if not.
|
||||
# Params:
|
||||
# - The name for the archive. The .xcarchive extension will be added.
|
||||
archivePath() {
|
||||
if [[ "${XCODEBUILD_ACTION}" == "archive" ]]; then
|
||||
echo "-archivePath"
|
||||
echo "$ARCHIVES_DIR/$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# Prints the INSTALL_OWNER and INSTALL_GROUP arguments to use for the xcodebuild commands.
|
||||
ownershipArgs() {
|
||||
if [[ "${XCODEBUILD_ACTION}" != "install" ]]; then
|
||||
# Stop xcodebuild from trying to chown the files in the archive to root when making an
|
||||
# archive, so we don't need to use sudo.
|
||||
echo "INSTALL_OWNER="
|
||||
echo "INSTALL_GROUP="
|
||||
fi
|
||||
}
|
||||
|
||||
# BGMDriver
|
||||
|
||||
echo "[1/3] ${ACTIONING} the virtual audio device $(bold_face ${DRIVER_DIR}) to" \
|
||||
|
@ -664,13 +710,15 @@ echo "[1/3] ${ACTIONING} the virtual audio device $(bold_face ${DRIVER_DIR}) to"
|
|||
| tee -a ${LOG_FILE}
|
||||
|
||||
(disable_error_handling
|
||||
# Build and install BGMDriver.
|
||||
# Build and, if requested, archive or install BGMDriver.
|
||||
${SUDO} "${XCODEBUILD}" -scheme "Background Music Device" \
|
||||
-configuration ${CONFIGURATION} \
|
||||
-enableAddressSanitizer ${ENABLE_ASAN} \
|
||||
$(archivePath BGMDriver) \
|
||||
BUILD_DIR=./build \
|
||||
RUN_CLANG_STATIC_ANALYZER=0 \
|
||||
DSTROOT="/" \
|
||||
$(ownershipArgs) \
|
||||
${DSTROOT_ARG} \
|
||||
${XCODEBUILD_OPTIONS} \
|
||||
"${XCODEBUILD_ACTION}" >> ${LOG_FILE} 2>&1) &
|
||||
|
||||
|
@ -678,17 +726,30 @@ show_spinner "${BUILD_FAILED_ERROR_MSG}"
|
|||
|
||||
# BGMXPCHelper
|
||||
|
||||
echo "[2/3] ${ACTIONING} $(bold_face ${XPC_HELPER_DIR}) to $(bold_face ${XPC_HELPER_PATH})" \
|
||||
echo "[2/3] ${ACTIONING} $(bold_face ${XPC_HELPER_DIR}) to $(bold_face ${XPC_HELPER_OUTPUT_PATH})" \
|
||||
| tee -a ${LOG_FILE}
|
||||
|
||||
xpcHelperInstallPathArg() {
|
||||
if [[ "${XCODEBUILD_ACTION}" == "install" ]]; then
|
||||
echo "INSTALL_PATH=${XPC_HELPER_OUTPUT_PATH}"
|
||||
fi
|
||||
}
|
||||
|
||||
# The Xcode project file is configured so that xcodebuild will call post_install.sh after it
|
||||
# finishes building. It calls post_install.sh with the ACTION env var set to "install" when
|
||||
# XCODEBUILD_ACTION is set to "archive" here. The REAL_ACTION arg in this command is a workaround
|
||||
# that lets post_install.sh know when we're archiving.
|
||||
(disable_error_handling
|
||||
${SUDO} "${XCODEBUILD}" -scheme BGMXPCHelper \
|
||||
-configuration ${CONFIGURATION} \
|
||||
-enableAddressSanitizer ${ENABLE_ASAN} \
|
||||
$(archivePath BGMXPCHelper) \
|
||||
BUILD_DIR=./build \
|
||||
RUN_CLANG_STATIC_ANALYZER=0 \
|
||||
DSTROOT="/" \
|
||||
INSTALL_PATH="${XPC_HELPER_PATH}" \
|
||||
$(xpcHelperInstallPathArg) \
|
||||
$(ownershipArgs) \
|
||||
REAL_ACTION="${XCODEBUILD_ACTION}" \
|
||||
${DSTROOT_ARG} \
|
||||
${XCODEBUILD_OPTIONS} \
|
||||
"${XCODEBUILD_ACTION}" >> ${LOG_FILE} 2>&1) &
|
||||
|
||||
|
@ -703,9 +764,11 @@ echo "[3/3] ${ACTIONING} $(bold_face ${APP_DIR}) to $(bold_face ${APP_PATH})" \
|
|||
${SUDO} "${XCODEBUILD}" -scheme "Background Music" \
|
||||
-configuration ${CONFIGURATION} \
|
||||
-enableAddressSanitizer ${ENABLE_ASAN} \
|
||||
$(archivePath BGMApp) \
|
||||
BUILD_DIR=./build \
|
||||
RUN_CLANG_STATIC_ANALYZER=0 \
|
||||
DSTROOT="/" \
|
||||
$(ownershipArgs) \
|
||||
${DSTROOT_ARG} \
|
||||
${XCODEBUILD_OPTIONS} \
|
||||
"${XCODEBUILD_ACTION}" >> ${LOG_FILE} 2>&1) &
|
||||
|
||||
|
@ -764,6 +827,13 @@ if [[ "${XCODEBUILD_ACTION}" == "install" ]]; then
|
|||
sleep 1
|
||||
done) &
|
||||
show_spinner "${BGMAPP_FAILED_TO_START_ERROR_MSG}" 5
|
||||
elif [[ "${XCODEBUILD_ACTION}" == "archive" ]]; then
|
||||
# Copy the dSYMs (debug symbols) into the correct directories in the archives. I haven't been
|
||||
# able to figure out why Xcode isn't doing this automatically.
|
||||
cp -r "BGMDriver/build/Release/Background Music Device.driver.dSYM" "$DRIVER_PATH/dSYMs"
|
||||
cp -r "BGMApp/build/Release/BGMXPCHelper.xpc.dSYM" "$XPC_HELPER_OUTPUT_PATH/dSYMs"
|
||||
mv "$APP_PATH/Products/Applications/Background Music.app/Contents/MacOS/Background Music.dSYM" \
|
||||
"$APP_PATH/dSYMs"
|
||||
fi
|
||||
|
||||
echo "Done."
|
||||
|
|
55
package.sh
55
package.sh
|
@ -19,11 +19,11 @@
|
|||
#
|
||||
# package.sh
|
||||
#
|
||||
# Copyright © 2017, 2018 Kyle Neideck
|
||||
# Copyright © 2017-2020 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.
|
||||
# Builds Background Music and packages it into a .pkg file. Call this script with -d to use the
|
||||
# debug build configuration.
|
||||
#
|
||||
# Based on https://github.com/tekezo/Karabiner-Elements/blob/master/make-package.sh
|
||||
#
|
||||
|
@ -47,16 +47,19 @@ set_permissions() {
|
|||
|
||||
# --------------------------------------------------
|
||||
|
||||
# Use the release configuration by default.
|
||||
# Use the release configuration and archive by default.
|
||||
debug_build=NO
|
||||
build_output_path="build/Release"
|
||||
bgmapp_build_output_path="archives/BGMApp.xcarchive/Products/Applications"
|
||||
bgmxpchelper_build_output_path="archives/BGMXPCHelper.xcarchive/Products/usr/local/libexec"
|
||||
bgmdriver_build_output_path="archives/BGMDriver.xcarchive/Products/Library/Audio/Plug-Ins/HAL"
|
||||
|
||||
# Handle the options passed to this script.
|
||||
while getopts ":d" opt; do
|
||||
case $opt in
|
||||
d)
|
||||
debug_build=YES
|
||||
build_output_path="build/Debug"
|
||||
bgmapp_build_output_path="BGMApp/build/Debug"
|
||||
bgmdriver_build_output_path="BGMDriver/build/Debug"
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
|
@ -75,7 +78,7 @@ if [[ $debug_build == YES ]]; then
|
|||
ENABLE_ASAN=NO bash build_and_install.sh -b -d
|
||||
build_status=$?
|
||||
else
|
||||
bash build_and_install.sh -b
|
||||
bash build_and_install.sh -a
|
||||
build_status=$?
|
||||
fi
|
||||
|
||||
|
@ -87,23 +90,17 @@ fi
|
|||
# Read the version string from the build.
|
||||
version="$(/usr/libexec/PlistBuddy \
|
||||
-c "Print CFBundleShortVersionString" \
|
||||
"BGMApp/${build_output_path}/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"
|
||||
|
||||
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_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"
|
||||
fi
|
||||
# Put the archives in a zip file. This file is mainly useful because the debug symbols (dSYMs) are
|
||||
# in it.
|
||||
echo "Making archives zip"
|
||||
zip -r "$out_dir/background-music-xcarchives-$version.zip" "archives"
|
||||
|
||||
# --------------------------------------------------
|
||||
|
||||
|
@ -113,11 +110,11 @@ rm -rf "pkgroot"
|
|||
mkdir -p "pkgroot"
|
||||
|
||||
mkdir -p "pkgroot/Library/Audio/Plug-Ins/HAL"
|
||||
cp -R "BGMDriver/${build_output_path}/Background Music Device.driver" \
|
||||
cp -R "${bgmdriver_build_output_path}/Background Music Device.driver" \
|
||||
"pkgroot/Library/Audio/Plug-Ins/HAL/"
|
||||
|
||||
mkdir -p "pkgroot/Applications"
|
||||
cp -R "BGMApp/${build_output_path}/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"
|
||||
|
@ -125,7 +122,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_output_path}/BGMXPCHelper.xpc" "$scripts_dir"
|
||||
cp -R "${bgmxpchelper_build_output_path}/BGMXPCHelper.xpc" "$scripts_dir"
|
||||
|
||||
set_permissions "pkgroot"
|
||||
chmod 755 "pkgroot/Applications/Background Music.app/Contents/MacOS/Background Music"
|
||||
|
@ -177,16 +174,8 @@ rm -rf "pkgres"
|
|||
rm -f "pkg/Distribution.xml"
|
||||
|
||||
# Print checksums
|
||||
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
|
||||
|
||||
echo "MD5 checksum:"
|
||||
md5 "$pkg"
|
||||
echo "SHA256 checksum:"
|
||||
shasum -a 256 "$pkg"
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
</must-close>
|
||||
</pkg-ref>
|
||||
|
||||
<background file="FermataIcon.pdf" alignment="bottomleft" />
|
||||
<background file="FermataIcon.pdf" alignment="bottomleft" mime-type="application/pdf" />
|
||||
</installer-gui-script>
|
||||
|
||||
|
||||
|
|
|
@ -19,24 +19,29 @@
|
|||
#
|
||||
# postinstall
|
||||
#
|
||||
# Copyright © 2017-2019 Kyle Neideck
|
||||
# Copyright © 2017-2020 Kyle Neideck
|
||||
#
|
||||
|
||||
# Make sure we use the built-in versions of programs, for consistency. Probably not necessary
|
||||
# because the installer will set $PATH in a similar way, but it doesn't hurt.
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin; export PATH
|
||||
|
||||
function log {
|
||||
logger "$@"
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
coreaudiod_plist="/System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist"
|
||||
dest_volume="$3"
|
||||
xpc_helper_path="$(bash safe_install_dir.sh -y)"
|
||||
|
||||
logger "Installing BGMXPCHelper to $xpc_helper_path"
|
||||
log "Installing BGMXPCHelper to $xpc_helper_path"
|
||||
cp -Rf "BGMXPCHelper.xpc" "$xpc_helper_path"
|
||||
|
||||
# TODO: Fail the install and show an error message if this fails.
|
||||
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
|
||||
|
@ -49,7 +54,28 @@ bash "post_install.sh" "$xpc_helper_path" "BGMXPCHelper.xpc/Contents/MacOS/BGMXP
|
|||
(launchctl unload "$coreaudiod_plist" &>/dev/null && \
|
||||
launchctl load "$coreaudiod_plist" &>/dev/null) || \
|
||||
killall coreaudiod &>/dev/null) && \
|
||||
sleep 5
|
||||
sleep 2
|
||||
|
||||
# Wait until coreaudiod has restarted and BGMDevice is ready to use.
|
||||
retries=5
|
||||
while [[ $retries -gt 0 ]]; do
|
||||
if ! system_profiler SPAudioDataType | grep "Background Music" >/dev/null 2>&1; then
|
||||
retries=$((retries - 1))
|
||||
if [[ $retries -gt 0 ]]; then
|
||||
log "Background Music device not found. Trying again in 3 seconds..."
|
||||
sleep 3
|
||||
else
|
||||
# TODO: We might be able to use <installation-check> to show error messages in the
|
||||
# installer GUI instead of just logging them. See
|
||||
# <https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html#//apple_ref/doc/uid/TP40005370-CH100-SW12>.
|
||||
log "Background Music device not found. Installation failed."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# BGMDevice is installed and available, so we can continue the script.
|
||||
retries=0
|
||||
fi
|
||||
done
|
||||
|
||||
# Try opening BGMApp using its bundle ID first so the installer can declare it as "relocatable".
|
||||
# That way, if the user moves BGMApp and then installs a newer version of Background Music, the
|
||||
|
@ -57,14 +83,37 @@ bash "post_install.sh" "$xpc_helper_path" "BGMXPCHelper.xpc/Contents/MacOS/BGMXP
|
|||
#
|
||||
# Use launchctl to make sure we don't run BGMApp as the installer user.
|
||||
#
|
||||
# If we can't open BGMApp, it very likely didn't install properly, so we fail the install.
|
||||
# If we can't open BGMApp, it's very likely it didn't install properly, so we fail the install.
|
||||
logged_in_user_id="$(id -u "${USER}")"
|
||||
launchctl asuser "${logged_in_user_id}" \
|
||||
open -b com.bearisdriving.BGM.App || \
|
||||
launchctl asuser "${logged_in_user_id}" \
|
||||
open "${dest_volume}/Applications/Background Music.app" || \
|
||||
osascript -e 'tell application "Background Music" to activate' || \
|
||||
did_open_bgmapp=false
|
||||
|
||||
# TODO: If they have multiple copies of BGMApp, this might open one of the old ones.
|
||||
log "Opening Background Music.app by bundle ID"
|
||||
if launchctl asuser "${logged_in_user_id}" \
|
||||
open -b com.bearisdriving.BGM.App; then
|
||||
did_open_bgmapp=true
|
||||
fi
|
||||
|
||||
if [[ $did_open_bgmapp != "true" ]]; then
|
||||
log "Opening ${dest_volume}/Applications/Background Music.app"
|
||||
if launchctl asuser "${logged_in_user_id}" \
|
||||
open "${dest_volume}/Applications/Background Music.app"; then
|
||||
did_open_bgmapp=true
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $did_open_bgmapp != "true" ]]; then
|
||||
log "Opening Background Music.app using AppleScript"
|
||||
if osascript -e 'tell application "Background Music" to activate'; then
|
||||
did_open_bgmapp=true
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $did_open_bgmapp != "true" ]]; then
|
||||
log "Failed to open Background Music.app"
|
||||
# Fail the install.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# The installer plays a sound when it finishes, so give BGMApp a second to launch.
|
||||
sleep 1
|
||||
|
|
Loading…
Reference in a new issue