We are executing a scheduled maintenance on database services beginning at 9:00 UTC. We expect the maintenance window to be less than 1 hour. Please note that any CI jobs that start before the maintenance window but complete during the window period will fail and may need to be started again. https://gitlab.com/gitlab-com/gl-infra/production/-/issues/4018

Commit e2c10899 authored by Manuel Moos's avatar Manuel Moos
Browse files

Merge: Build script for macOS bundle

Implements #86

See merge request !116
parents 5d316e99 5da83658
Pipeline #254569908 passed with stages
in 26 minutes and 1 second
......@@ -23,8 +23,8 @@ SUBDIRS = src resource batch config desktop docker/build
# special tasks to do if we're building the master server
if BUILDMASTER
masterInstallTasks= cd $(DESTDIR)$(bindir); mv armagetronad_main_master$(EXEEXT) @prognamebase@-master$(executable_suffix)
masterUninstallTasks=rm -f $(DESTDIR)$(bindir)/@prognamebase@-master$(executable_suffix)
masterInstallTasks= cd "$(DESTDIR)$(bindir)"; mv armagetronad_main_master$(EXEEXT) @prognamebase@-master$(executable_suffix)
masterUninstallTasks=rm -f "$(DESTDIR)$(bindir)"/@prognamebase@-master$(executable_suffix)
else
masterInstallTasks=echo 'No tasks for the master server'
masterUninstallTasks=echo 'No tasks for the master server'
......@@ -96,9 +96,9 @@ uninstall_location=$(DESTDIR)${bindir}/${uninstaller}
# generate and install uninstallation script
install-uninstall: @srcdir@/batch/make/uninstall Makefile
$(install_sh_PROGRAM) $< $(uninstall_location)
rm $(uninstall_location)
ROOTDIR=$(ROOTDIR) DESTDIR=$(DESTDIR) MAKE="$(MAKE)" PREFIX="${prefix}" PROGTITLE="${progtitle}" PROGNAME="${progname}" SCRIPTDIR="${scriptdir}" sh $< $(uninstall_location) "$(external_uninstall_cmd)"
$(install_sh_PROGRAM) $< "$(uninstall_location)"
rm "$(uninstall_location)"
ROOTDIR=$(ROOTDIR) DESTDIR="$(DESTDIR)" MAKE="$(MAKE)" PREFIX="${prefix}" PROGTITLE="${progtitle}" PROGNAME="${progname}" SCRIPTDIR="${scriptdir}" sh $< "$(uninstall_location)" "$(external_uninstall_cmd)"
else
install-uninstall:
endif
......@@ -107,7 +107,7 @@ endif
install-exec-hook: install-uninstall
# rename executable to armagetronad-VERSION and link to armagetronad
if BUILDMAIN
cd $(DESTDIR)${bindir}; mv armagetronad_main$(EXEEXT) @progname@$(executable_suffix)
cd "$(DESTDIR)${bindir}"; mv armagetronad_main$(EXEEXT) @progname@$(executable_suffix)
endif
# delegate to special tasks
......@@ -116,12 +116,12 @@ endif
install-data-hook:
# install systemwide files
if USE_SYSINSTALL
DESTDIR=$(DESTDIR) ROOTDIR=$(ROOTDIR) bash $(DESTDIR)${scriptdir}/sysinstall install $(prefix)
DESTDIR="$(DESTDIR)" ROOTDIR=$(ROOTDIR) bash "$(DESTDIR)${scriptdir}"/sysinstall install $(prefix)
endif
uninstall-hook:
# delete executable and uninstaller
rm -f $(DESTDIR)${bindir}/@progname@$(executable_suffix)
rm -f "$(DESTDIR)${bindir}"/@progname@$(executable_suffix)
# delegate to special tasks
$(masterUninstallTasks)
......@@ -137,7 +137,7 @@ endif
uninstall-first:
# uninstall systemwide files
if USE_SYSINSTALL
if test -z "$(AA_FAKE_UNINSTALL)"; then DESTDIR=$(DESTDIR) ROOTDIR=$(ROOTDIR) bash $(DESTDIR)${scriptdir}/sysinstall uninstall $(prefix); fi
if test -z "$(AA_FAKE_UNINSTALL)"; then DESTDIR="$(DESTDIR)" ROOTDIR=$(ROOTDIR) bash "$(DESTDIR)${scriptdir}"/sysinstall uninstall $(prefix); fi
endif
install-first:
......
......@@ -40,7 +40,7 @@ for KDEDIR in /opt/kde* /opt/kde/* /usr/kde* /usr/kde/* /usr/local/kde* /usr/loc
test -x ${KDEDIR}/bin/kde-config && PATH=${PATH}:${KDEDIR}/bin
done
THISSCRIPT=`which $0`
THISSCRIPT="`which "$0"`"
MODE="$1"
shift
......@@ -104,9 +104,9 @@ function stop_server()
# no options accepted, paths with relative components can be problematic.
function mkdir_p()
{
parent=`dirname "$1"`
test -d ${parent} || mkdir_p ${parent}
test -d $1 || mkdir $1
parent="`dirname "$1"`"
test -d "${parent}" || mkdir_p "${parent}"
test -d "$1" || mkdir "$1"
}
# install or uninstall a symbolic link depending on mode
......@@ -115,23 +115,23 @@ function mkdir_p()
function install_link()
{
# right now, the source should be here:
source_now=${DESTDIR}$1
source_now="${DESTDIR}$1"
# but it will be moved here before it is used:
source_final=${ROOTDIR}$1
source_final="${ROOTDIR}$1"
# the link should go here:
target=${DESTDIR}$2
target="${DESTDIR}$2"
# if we don't link, but copy, the copy source needs to be the current source position
echo "@LN_S@" | grep "cp" > /dev/null && source_final=${source_now}
echo "@LN_S@" | grep "cp" > /dev/null && source_final="${source_now}"
if test "$MODE" = "install"; then
if test -r ${source_now}; then
mkdir_p `dirname ${target}`
test -f ${target} || @LN_S@ -f ${source_final} ${target} || exit 1
if test -r "${source_now}"; then
mkdir_p "`dirname ${target}`"
test -f "${target}" || @LN_S@ -f "${source_final}" "${target}" || exit 1
fi
else
if test -L ${target} ; then
rm -f ${target} || exit 1
if test -L "${target}" ; then
rm -f "${target}" || exit 1
fi
fi
}
......@@ -168,33 +168,33 @@ function kde_get_write_path()
echo ${FIRST}
}
SOURCE=$DESTDIR$PREFIX
SOURCE="$DESTDIR$PREFIX"
#@datadir@
#@prefix@
if test -z "$SOURCE"; then
# determine prefix directory from executable location
SCRIPTDIR=`dirname $THISSCRIPT`
SOURCE=`dirname $SCRIPTDIR`
SOURCE=`dirname $SOURCE`
SOURCE=`dirname $SOURCE`
SOURCE=`dirname $SOURCE`
DESTDIR=`echo $SOURCE | sed -e "s,${prefix},,"`
SCRIPTDIR="`dirname $THISSCRIPT`"
SOURCE="`dirname $SCRIPTDIR`"
SOURCE="`dirname $SOURCE`"
SOURCE="`dirname $SOURCE`"
SOURCE="`dirname $SOURCE`"
DESTDIR="`echo $SOURCE | sed -e "s,${prefix},,"`"
BINDIR=${SOURCE}/bin
else
SCRIPTDIR=`relocate @scriptdir@`
BINDIR=`relocate @bindir@`
SCRIPTDIR="`relocate @scriptdir@`"
BINDIR="`relocate @bindir@`"
fi
# determine data locations
EXECUTABLE=${DESTDIR}${BINDIR}/@progname@@executable_suffix@
CONFIGDIR=`relocate @aa_sysconfdir@`
VARDIR=`relocate @aa_localstatedir@`
EXECUTABLE="${DESTDIR}${BINDIR}/@progname@@executable_suffix@"
CONFIGDIR="`relocate @aa_sysconfdir@`"
VARDIR="`relocate @aa_localstatedir@`"
# determine location of scripts
test -d $DESTDIR$SCRIPTDIR || { echo "Script directory not found."; exit 1; }
test -d "$DESTDIR$SCRIPTDIR" || { echo "Script directory not found."; exit 1; }
# transscribe true location into scripts
if test $MODE = install; then
......@@ -202,23 +202,23 @@ if test $MODE = install; then
sedcommands=$(eval echo "RELOCATECOMMANDS
")
# echo ${sedcommands}
for script in $DESTDIR$SCRIPTDIR/* $DESTDIR$CONFIGDIR/rc.config; do
if test $script != $DESTDIR$SCRIPTDIR/sysinstall; then
sed -e ${sedcommands} < $script > $script.trans || exit 1
mv $script.trans $script
chmod 755 $script
for script in "$DESTDIR$SCRIPTDIR"/* "$DESTDIR$CONFIGDIR"/rc.config; do
if test "$script" != "$DESTDIR$SCRIPTDIR"/sysinstall; then
sed -e ${sedcommands} < "$script" > "$script.trans" || exit 1
mv "$script.trans" "$script"
chmod 755 "$script"
fi
done
fi
# install init scripts into /etc/init.d
INITSCRIPTDIR=$DESTDIR@initdir@
INITSCRIPTDIR="$DESTDIR@initdir@"
if test @enable_initscripts@ = yes ; then
# stop running servers on uninstall
if test ${MODE} = uninstall; then
echo Making sure servers are stopped...
stop_server $DESTDIR$SCRIPTDIR/rcd_master
stop_server $DESTDIR$SCRIPTDIR/rcd_server
stop_server "$DESTDIR$SCRIPTDIR/rcd_master"
stop_server "$DESTDIR$SCRIPTDIR/rcd_server"
fi
# install/uninstall scripts
......@@ -233,11 +233,11 @@ if test @enable_initscripts@ = yes ; then
#install shortcut script (TODO: I bet there's a canonical path for sbin)
AACTL=${PREFIX}/sbin/aactl
AAMCTL=${PREFIX}/sbin/aamasterctl
install_link ${SCRIPTDIR}/rcd_server ${AACTL}
install_link ${SCRIPTDIR}/rcd_master ${AAMCTL}
install_link "${SCRIPTDIR}/rcd_server" ${AACTL}
install_link "${SCRIPTDIR}/rcd_master" ${AAMCTL}
if test `cat /etc/rc.local | grep TAG_ARMAGETRONAD | wc -c` = 0; then
if test -r $DESTDIR$SCRIPTDIR/rcd_server; then
if test -r "$DESTDIR$SCRIPTDIR/rcd_server"; then
cat >> /etc/rc.local <<EOF
# Armagetron Advanced #TAG_ARMAGETRONAD
if [ X"\${armagetronad}" != X"NO" -a -x ${AACTL} ]; then #TAG_ARMAGETRONAD
......@@ -245,7 +245,7 @@ if [ X"\${armagetronad}" != X"NO" -a -x ${AACTL} ]; then #TAG_ARMAGETRONAD
fi #TAG_ARMAGETRONAD
EOF
fi
if test -r $DESTDIR$SCRIPTDIR/rcd_master; then
if test -r "$DESTDIR$SCRIPTDIR/rcd_master"; then
cat >> /etc/rc.local <<EOF
if [ X"\${armagetronad_master}" != X"NO" -a -x ${AAMCTL} ]; then #TAG_ARMAGETRONAD
${AAMCTL} start #TAG_ARMAGETRONAD
......@@ -257,10 +257,10 @@ EOF
# Inserting configuration IF AA should be started at system boot, default = NO
if test `cat /etc/rc.conf.local | grep TAG_ARMAGETRONAD | wc -c` = 0; then
if test -r $DESTDIR$SCRIPTDIR/rcd_server; then
if test -r "$DESTDIR$SCRIPTDIR/rcd_server"; then
echo 'armagetronad="NO" #TAG_ARMAGETRONAD, change "NO" to "YES" to autostart an armagetronad game server' >> /etc/rc.conf.local
fi
if test -r $DESTDIR$SCRIPTDIR/rcd_master; then
if test -r "$DESTDIR$SCRIPTDIR/rcd_master"; then
echo 'armagetronad_master="NO" #TAG_ARMAGETRONAD, change "NO" to "YES" to autostart an armagetronad master server' >> /etc/rc.conf.local
fi
fi
......@@ -272,11 +272,11 @@ EOF
fi
else
# for the rest of the world. Link the starter scripts to the init script dir.
if mkdir_p ${DESTDIR}@initdir@ > /dev/null 2>&1 && test -w ${DESTDIR}@initdir@; then
install_link $SCRIPTDIR/rcd_master @initdir@/@prognamebase@-master
install_link $SCRIPTDIR/rcd_master @initdir@/@prognamebase@-master-@version@
install_link $SCRIPTDIR/rcd_server @initdir@/@progname@
install_link $SCRIPTDIR/rcd_server @initdir@/@progname@-@version@
if mkdir_p "${DESTDIR}@initdir@" > /dev/null 2>&1 && test -w "${DESTDIR}@initdir@"; then
install_link "$SCRIPTDIR/rcd_master" @initdir@/@prognamebase@-master
install_link "$SCRIPTDIR/rcd_master" @initdir@/@prognamebase@-master-@version@
install_link "$SCRIPTDIR/rcd_server" @initdir@/@progname@
install_link "$SCRIPTDIR/rcd_server" @initdir@/@progname@-@version@
else
echo -e "\nWarning: unable to ${MODE} start script symlinks in ${DESTDIR}@initdir@, it's not writable.\n"
fi
......@@ -285,16 +285,16 @@ fi
# install etc configuration (if it's not already there)
if test @enable_etc@ = yes && echo @aa_sysconfdir@ | grep -v "^/etc/" > /dev/null; then
if mkdir_p $DESTDIR/etc > /dev/null 2>&1 && test -w $DESTDIR/etc; then
if mkdir_p "$DESTDIR/etc" > /dev/null 2>&1 && test -w "$DESTDIR/etc"; then
echo ${INSTALLING} configuration directories in $DESTDIR/etc...
install_link $CONFIGDIR /etc/@progname@
test -z "@progdir_suffix@" || install_link $CONFIGDIR /etc/@progname@-@progdir_suffix@
install_link "$CONFIGDIR" /etc/@progname@
test -z "@progdir_suffix@" || install_link "$CONFIGDIR" /etc/@progname@-@progdir_suffix@
fi
fi
# link executable files
install_link ${BINDIR}/@progname@-@version@ ${BINDIR}/@progname@
install_link ${BINDIR}/@prognamebase@-master-@version@ ${BINDIR}/@prognamebase@-master
install_link "${BINDIR}/@progname@-@version@" "${BINDIR}/@progname@"
install_link "${BINDIR}/@prognamebase@-master-@version@" "${BINDIR}/@prognamebase@-master"
# install desktop files
if test @enable_desktop@ = yes; then
......@@ -305,19 +305,19 @@ if test @enable_desktop@ = yes; then
if test @prognamebase@ = armagetronad; then
true # echo no rebranding
else
for f in large small medium; do mv ${DESTDIR}${DESKTOPSOURCE}/icons/$f/armagetronad.png ${DESTDIR}${DESKTOPSOURCE}/icons/$f/@prognamebase@.png; done
mv ${DESTDIR}${DESKTOPSOURCE}/armagetronad.desktop ${DESTDIR}${DESKTOPSOURCE}/@prognamebase@.desktop
for f in large small medium; do mv "${DESTDIR}${DESKTOPSOURCE}/icons/$f/armagetronad.png" "${DESTDIR}${DESKTOPSOURCE}/icons/$f/@prognamebase@.png"; done
mv "${DESTDIR}${DESKTOPSOURCE}/armagetronad.desktop" "${DESTDIR}${DESKTOPSOURCE}/@prognamebase@.desktop"
fi
fi
# add KDE icons and desktop link
if kde-config --install icon > /dev/null 2>&1; then
ICONSDEST=`kde_get_write_path icon ${DESTDIR}`
ICONSDEST="`kde_get_write_path icon "${DESTDIR}"`"
if test -z "${ICONSDEST}"; then
echo "No permission to write to KDE icons directory."
else
echo "${INSTALLING} KDE icon in ${ICONSDEST}..."
install_link ${DESKTOPSOURCE}/icons/large/@prognamebase@.png ${ICONSDEST}/@progname@.png
install_link "${DESKTOPSOURCE}/icons/large/@prognamebase@.png" "${ICONSDEST}/@progname@.png"
fi
DESKTOPDEST=`kde_get_write_path apps ${DESTDIR}`
......@@ -325,7 +325,7 @@ if test @enable_desktop@ = yes; then
echo "No permission to write to KDE application menu directory."
else
echo "${INSTALLING} KDE start menu entry in ${DESKTOPDEST}..."
install_link ${DESKTOPSOURCE}/@prognamebase@.desktop ${DESKTOPDEST}/@progname@.desktop
install_link "${DESKTOPSOURCE}/@prognamebase@.desktop" "${DESKTOPDEST}/@progname@.desktop"
fi
fi
fi
......@@ -337,7 +337,7 @@ if test @enable_restoreold@ = yes && test ${MODE} = uninstall; then
NEWEST=""
for CANDIDATE in $SOURCE/@progname@* $SOURCE/share/@progname@* $SOURCE/share/games/@progname@* $SOURCE/games/@progname@*; do
SCRIPTCANDIDATE=$CANDIDATE${scriptsuffix}/sysinstall
if test "$CANDIDATE"${scriptsuffix} != "$SCRIPTDIR" && echo "$CANDIDATE" | grep -v "@progname@-dedicated" > /dev/null && test "$THISSCRIPT" != "`which $SCRIPTCANDIDATE 2>/dev/null`" && test -r "$SCRIPTCANDIDATE"; then
if test "$CANDIDATE"${scriptsuffix} != "$SCRIPTDIR" && echo "$CANDIDATE" | grep -v "@progname@-dedicated" > /dev/null && test "$THISSCRIPT" != "`which "$SCRIPTCANDIDATE" 2>/dev/null`" && test -r "$SCRIPTCANDIDATE"; then
test "$SCRIPTCANDIDATE" -nt "$NEWEST" && NEWEST=$SCRIPTCANDIDATE
fi
done
......@@ -358,9 +358,9 @@ NEWVARDIR=`relocate @aa_localstatedir@`
if test ${MODE} = install && test @enable_migratestate@ != no; then
# locate old configuration
OLDVARDIR=`relocate @oldvardir@`
if test -d ${ROOTDIR}${OLDVARDIR}; then
if test -d "${ROOTDIR}${OLDVARDIR}"; then
# locate new configuration
if ! test -r ${ROOTDIR}${NEWVARDIR}/won_rounds.txt && test ${OLDVARDIR} != ${NEWVARDIR}; then
if ! test -r "${ROOTDIR}${NEWVARDIR}/won_rounds.txt" && test "${OLDVARDIR}" != "${NEWVARDIR}"; then
# move or copy it over
command=cp
verb=copying
......@@ -369,8 +369,8 @@ if test ${MODE} = install && test @enable_migratestate@ != no; then
verb=movimg
fi
echo "Old dynamic data found in ${OLDVARDIR}, ${verb} it to ${NEWVARDIR}."
mkdir_p ${DESTDIR}${NEWVARDIR}
${command} ${ROOTDIR}${OLDVARDIR}/* ${DESTDIR}${NEWVARDIR}/
mkdir_p "${DESTDIR}${NEWVARDIR}"
${command} "${ROOTDIR}${OLDVARDIR}"/* "${DESTDIR}${NEWVARDIR}/"
fi
fi
fi
......
......@@ -950,6 +950,8 @@ src/doc/Makefile src/doc/net/Makefile src/doc/Doxyfile
src/doc/html.m4
src/thirdparty/Makefile
src/thirdparty/particles/Makefile
src/macosx/entrypoint.sh
src/macosx/build_bundle.sh
resource/Makefile
config/Makefile
desktop/Makefile
......
......@@ -21,15 +21,15 @@ linked_included.%: included
install-data-local: linked_included.install
# copy processed included resources into target directory
mkdir -p ${DESTDIR}${resourcedir}/included
cp -r $</* ${DESTDIR}${resourcedir}/included
find ${DESTDIR}${resourcedir} -type d -exec chmod 755 \{\} \;
find ${DESTDIR}${resourcedir} -type f -exec chmod 644 \{\} \;
mkdir -p "${DESTDIR}${resourcedir}/included"
cp -r $</* "${DESTDIR}${resourcedir}/included"
find "${DESTDIR}${resourcedir}" -type d -exec chmod 755 \{\} \;
find "${DESTDIR}${resourcedir}" -type f -exec chmod 644 \{\} \;
rm -f $<
uninstall-local:
# remove resources
rm -rf ${DESTDIR}${resourcedir}/included
rm -rf "${DESTDIR}${resourcedir}/included"
dist-hook: linked_included.dist
# copy processed included resources into distribution
......
#!/bin/bash
set -x
DIR=$1
test -z "${DIR}" && DIR="`pwd`"
TITLE="@progtitle@@progtitle_server@"
BUNDLE="${DIR}/${TITLE}.app"
mkdir -p "${BUNDLE}" || exit $?
# add launcher
cp `dirname $0`/entrypoint.sh "${BUNDLE}/${TITLE}" || exit $?
chmod 755 "${BUNDLE}/${TITLE}" || exit $?
# add plist with @v@ -> value and progtitle replacements
REL_SRCDIR=`echo @srcdir@ | sed -e s,^@top_builddir@/,,` || exit $?
sed < "${REL_SRCDIR}/Info.plist" > "${BUNDLE}/Info.plist" -e "s,Armagetron Advanced,${TITLE},g" || exit $?
mkdir -p "${BUNDLE}/English.lproj" || exit $?
sed < "${REL_SRCDIR}/English.lproj/InfoPlist.strings.in" > "${BUNDLE}/English.lproj/InfoPlist.strings" \
-e "s,Armagetron Advanced,${TITLE},g" \
-e "s,@vers[i]on@,@version@,g" \
-e "s,@year@,`date +%Y`,g" \
|| exit $?
# add icons
REL_TOP_SRCDIR=`echo @top_srcdir@ | sed -e s,^@top_builddir@/,,` || exit $?
cp "${REL_TOP_SRCDIR}/MacOS/Armagetron Advanced.icns" "${BUNDLE}/${TITLE}.icns"
# install game into bundle
DESTDIR="${BUNDLE}" make install || exit $?
# bundle libraries
(cd "${BUNDLE}"; dylibbundler -od -b -x "./@prefix@/bin/@progname@" -d "./@prefix@/libs/") || exit $?
# zip
(cd "${BUNDLE}" && zip -r ../@progname@-@version@.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}/@progname@-@version@.dmg"
rm -f "${DMG}"
ICON="${REL_TOP_SRCDIR}/MacOS/Armagetron Advanced.icns"
BG="${REL_TOP_SRCDIR}/MacOS/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 "@progtitle@" -srcfolder "${BUNDLE}" -ov -format UDIF "${DMG}"
rm -rf "${DMG_SRC}"
#!/bin/zsh
cd "`dirname "$0"`"
.@prefix@/bin/@progname@ "$@"
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment