Last active
June 14, 2022 18:38
-
-
Save PainedPsyche/eb0470558c41c28ed7e9c3aceeb9131b to your computer and use it in GitHub Desktop.
Attempt at modifying build_server_proot.sh to use a volume containing fivem repository mounted from the host system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
# update local package lists | |
apk update | |
# install build dependencies | |
apk add curl git xz sudo rsync openssh-client | |
curl -sLo alpine-minirootfs-3.14.2-x86_64.tar.gz https://dl-cdn.alpinelinux.org/alpine/v3.14/releases/x86_64/alpine-minirootfs-3.14.2-x86_64.tar.gz | |
# start building | |
# make a temporary build user | |
id -u build &>/dev/null || adduser -D -u 1000 build | |
if [ ! -d alpine ]; then | |
mkdir alpine | |
fi | |
cd alpine | |
tar xf ../alpine-minirootfs-3.14.2-x86_64.tar.gz | |
cd .. | |
chown -R build:build . | |
# change ownership of the build root | |
chown -R build:build . | |
# build | |
mount --bind /dev $PWD/alpine/dev | |
mount --bind /sys $PWD/alpine/sys | |
mount --bind /proc $PWD/alpine/proc | |
mount --bind /tmp $PWD/alpine/tmp | |
mount --bind /root $PWD/alpine/root | |
mkdir $PWD/alpine/src | |
mount --bind $PWD $PWD/alpine/src | |
echo "mounted all dirs" | |
echo nameserver 1.1.1.1 > $PWD/alpine/etc/resolv.conf | |
echo nameserver 8.8.8.8 >> $PWD/alpine/etc/resolv.conf | |
echo "started build in /ext" | |
cd ext/system-resources/ | |
/bin/sh build.sh | |
cd ../../ | |
echo "invoking chroot..." | |
chroot $PWD/alpine/ /bin/sh /src/code/tools/ci/build_server_2.sh | |
umount $PWD/alpine/dev | |
umount $PWD/alpine/sys | |
umount $PWD/alpine/proc | |
umount $PWD/alpine/tmp | |
umount $PWD/alpine/root | |
umount $PWD/alpine/src | |
rm -r $PWD/alpine/src | |
# patch elf interpreter | |
cp -a $PWD/alpine/lib/ld-musl-x86_64.so.1 $PWD/alpine/opt/cfx-server/ | |
# package system resources | |
mkdir -p $PWD/alpine/opt/cfx-server/citizen/system_resources/ | |
cp -a $PWD/ext/system-resources/data/* $PWD/alpine/opt/cfx-server/citizen/system_resources/ | |
# package artifacts | |
cp -a $PWD/data/server_proot/* . | |
chmod +x $PWD/run.sh | |
# again change ownership | |
chown -R build:build $PWD/. | |
# upload debug info | |
cd $PWD/ext/symbol-upload | |
mkdir -p /tmp/symbols | |
dotnet restore | |
dotnet run -- -o/tmp/symbols $PWD/../../alpine/opt/cfx-server/*.so $PWD/../../alpine/opt/cfx-server/FXServer $PWD/../../alpine/opt/cfx-server/*.dbg $PWD/../../alpine/lib/*.so* $PWD/../../alpine/usr/lib/*.so* $PWD/../../alpine/usr/lib/debug/lib/*.debug | |
eval $(ssh-agent -s) | |
echo "$SSH_SYMBOLS_PRIVATE_KEY" | tr -d '\r' | ssh-add - | |
mkdir -p ~/.ssh | |
chmod 700 ~/.ssh | |
rsync -rav -e "$RSH_SYMBOLS_COMMAND" /tmp/symbols/ $SSH_SYMBOLS_TARGET || true | |
cd ../../ | |
# delete bundled debug info | |
rm -f $PWD/alpine/opt/cfx-server/*.dbg | |
XZ_OPT=-T0 tar cJf fx.tar.xz alpine/ run.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment