From: Tangles Date: Wed, 3 Jan 2018 02:52:26 +0000 (+1100) Subject: add install-to-chroot for hardfought.org X-Git-Tag: v1.6.1-roc-dev~42 X-Git-Url: https://skyeroc.xyz/gitweb/?a=commitdiff_plain;h=4a7e6c91bcf9083d34fefbe5731e5149eccdaf55;p=dgamelaunch add install-to-chroot for hardfought.org --- diff --git a/install-to-chroot.sh b/install-to-chroot.sh new file mode 100755 index 0000000..cf9aaff --- /dev/null +++ b/install-to-chroot.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# +# Ideas and some parts from the original dgl-create-chroot (by joshk@triplehelix.org, modifications by jilles@stack.nl) +# More by +# More by Michael Andrew Streib +# Licensed under the MIT License +# https://opensource.org/licenses/MIT + +# autonamed chroot directory. Can rename. +DATESTAMP=`date +%Y%m%d-%H%M%S` +NAO_CHROOT="/opt/nethack/hardfought.org" +# already compiled versions of dgl and nethack +DGL_GIT="/home/build/dgamelaunch" +# the user & group from dgamelaunch config file. +USRGRP="games:games" +# END OF CONFIG +############################################################################## + +errorexit() +{ + echo "Error: $@" >&2 + exit 1 +} + +findlibs() +{ + for i in "$@"; do + if [ -z "`ldd "$i" | grep 'not a dynamic executable'`" ]; then + echo $(ldd "$i" | awk '{ print $3 }' | egrep -v ^'\(' | grep lib) + echo $(ldd "$i" | grep 'ld-linux' | awk '{ print $1 }') + fi + done +} + +set -e + +umask 022 + +DGL_BIN="$DGL_GIT/dgamelaunch" +if [ -n "$DGL_BIN" -a ! -e "$DGL_BIN" ]; then + errorexit "Cannot find dgl binary $DGL_BIN" +fi + +if [ -n "$DGL_BIN" -a -e "$DGL_BIN" ]; then + echo "Copying $DGL_BIN" + cd "$NAO_CHROOT" + DGLBINFILE="`basename $DGL_BIN`-$DATESTAMP" + cp "$DGL_BIN" "$DGLBINFILE" + ln -fs "$DGLBINFILE" dgamelaunch + LIBS="$LIBS `findlibs $DGL_BIN`" +fi + +LIBS=`for lib in $LIBS; do echo $lib; done | sort | uniq` +echo "Copying libraries:" $LIBS +for lib in $LIBS; do + mkdir -p "$NAO_CHROOT`dirname $lib`" + if [ -f "$NAO_CHROOT$lib" ] + then + echo "$NAO_CHROOT$lib already exists - skipping." + else + cp $lib "$NAO_CHROOT$lib" + fi +done + +echo "Finished." +