macOS DMG Build problems when building inside the source tree
I was finally able to build a DMG from the latest trunk, i.e. aa3e04757503cedee8a352757b8fbf67ffd85284 :tada:
```bash
./bootstrap.sh
./configure --disable-debug \
--disable-dependency-tracking \
--disable-silent-rules \
--disable-zthreadtest \
--disable-sysinstall \
--disable-uninstall \
--disable-restoreold \
--enable-automakedefaults \
--disable-useradd \
--disable-initscripts \
--disable-etc
sh desktop/os-x/build_bundle.sh
```
There was only one minor problem: `build_bundle.sh` was rendered as follows.
<details><summary>build_bundle.sh</summary><p>
```sh
#!/bin/bash
set -x
DIR=$1
test -z "${DIR}" && DIR="`pwd`"
TITLE="Armagetron Advanced"
BUNDLE="${DIR}/${TITLE}.app"
rm -rf "${BUNDLE}"
mkdir -p "${BUNDLE}" || exit $?
# add plist with @v@ -> value and progtitle replacements
REL_SRCDIR=`echo . | sed -e s,^../../,,` || exit $?
cp "`dirname $0`/Info.plist" "${BUNDLE}/" || exit $?
# add icons
REL_TOP_SRCDIR=`echo ../.. | sed -e s,^../../,a,` || exit $?
cp "${REL_TOP_SRCDIR}/desktop/os-x/armagetronad.icns" "${BUNDLE}/${TITLE}.icns"
# install game into bundle
DESTDIR="${BUNDLE}" make install || exit $?
# bundle libraries
(cd "${BUNDLE}"; dylibbundler -od -b -x ".//usr/local/bin/armagetronad" -d ".//usr/local/libs/" -i /usr/lib/) || exit $?
# for debugging pure app bundle builds
# exit 0
# zip
(cd "${BUNDLE}" && zip -r ../armagetronad-0.4.0_alpha_z5260.macOS.zip .) || exit $?
# pack dmg
# mkdir pack
# cp -a "${BUNDLE}" pack || exit $?
# --sandbox-safe
# --icon "$ICON" 200 190 \
# DMG_SRC=pack
DMG_SRC=${BUNDLE}
DMG="${DIR}/armagetronad-0.4.0_alpha_z5260.dmg"
rm -f "${DMG}"
ICON="${REL_TOP_SRCDIR}/desktop/os-x/armagetronad.icns"
BG="${REL_TOP_SRCDIR}/desktop/os-x/background.png"
create-dmg \
--volicon "$ICON" \
--app-drop-link 470 180 --window-pos 200 112 --window-size 650 330 \
--icon "${TITLE}.app" 220 80 \
--icon-size 100 \
--hide-extension "${TITLE}.app" \
--background ${BG} \
"${DMG}" "${DMG_SRC}" || exit $?
# alternative, native way, less powerful
# hdiutil create -volname "Armagetron Advanced" -srcfolder "${BUNDLE}" -ov -format UDIF "${DMG}"
rm -rf "${DMG_SRC}"
```
</p>
</details>
But since I'm running the script from the project root directory it could not find the icons and pictures for the DMG, i.e. `ICON` and `BG`. This is because the path points to `../..`, which is outside the project root directory.
I manually patched the `REL_TOP_SRCDIR` variable to `REL_TOP_SRCDIR=.` and this worked. I was able to build a working DMG on both, and x64 and amd64 MacBook.
Here are the builds:
- [armagetronad-0.4.0_alpha_z5260_arm64.dmg](/uploads/9c4f2972218b7fba711937b6eaa47846/armagetronad-0.4.0_alpha_z5260_arm64.dmg)
- [armagetronad-0.4.0_alpha_z5260_x86.dmg](/uploads/2064fee56b8a2d62fe2637a38fed55f5/armagetronad-0.4.0_alpha_z5260_x86.dmg)
Did I do something wrong that the `build_bundle.sh` script was incorrectly populated?
issue