2020-09-01 22:26:26 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2021-08-07 21:14:51 +00:00
|
|
|
if ! [ -x "$(command -v zip)" ]; then
|
|
|
|
printf "'zip' is not installed.\n"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
if ! [ -x "$(command -v tree)" ]; then
|
|
|
|
printf "'tree' is not installed.\n"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2021-03-15 10:43:15 +00:00
|
|
|
if [ $# -lt 0 ]; then
|
|
|
|
printf "At least supply the name of the mod/game dir you want to pack.\n"
|
|
|
|
exit
|
|
|
|
fi
|
2020-09-01 22:26:26 +00:00
|
|
|
|
2021-03-15 10:43:15 +00:00
|
|
|
GAME_DIR="$1"
|
|
|
|
BUILD_DIR=$1-$(date +%m-%d-%Y)
|
|
|
|
OLD_DIR=$(pwd)
|
2020-09-01 22:26:26 +00:00
|
|
|
|
2021-03-15 10:43:15 +00:00
|
|
|
if [ -f "$GAME_DIR"/src/Makefile ]; then
|
|
|
|
mkdir -p "$BUILD_DIR/$GAME_DIR"
|
|
|
|
mkdir -p "$BUILD_DIR/platform"
|
|
|
|
cd $GAME_DIR/src
|
|
|
|
make
|
|
|
|
else
|
|
|
|
printf "Not a valid game to bundle.\n"
|
|
|
|
exit
|
|
|
|
fi
|
2020-09-01 22:26:26 +00:00
|
|
|
|
2021-03-15 10:43:15 +00:00
|
|
|
cd "$OLD_DIR"
|
2020-09-01 22:26:26 +00:00
|
|
|
|
2021-03-15 10:43:15 +00:00
|
|
|
# build the pk3s
|
|
|
|
find ./$GAME_DIR -name *.pk3dir | xargs -I @ sh -c 'echo `basename "@"`' | while read PK3DIR; do
|
|
|
|
# strip the .pk3dir from the folder name to get the final .pk3 basename
|
|
|
|
PK3NAME=$(echo $PK3DIR | cut -f 1 -d '.')
|
2020-09-01 22:26:26 +00:00
|
|
|
|
2021-03-15 10:43:15 +00:00
|
|
|
# go into the pk3dir and compile your zip
|
|
|
|
cd "./$GAME_DIR/$PK3DIR"
|
|
|
|
tree -fi > ./build_contents.txt
|
|
|
|
sed -i '/build_contents/d' ./build_contents.txt
|
|
|
|
sed -i '/directories,/d' ./build_contents.txt
|
|
|
|
zip -0 "$PK3NAME".pk3 -@ < ./build_contents.txt
|
|
|
|
rm ./build_contents.txt
|
2020-09-01 22:26:26 +00:00
|
|
|
|
2021-03-15 10:43:15 +00:00
|
|
|
# Go back and move it over into the build directory
|
|
|
|
cd "$OLD_DIR"
|
|
|
|
mv "./$GAME_DIR/$PK3DIR/$PK3NAME.pk3" "./$BUILD_DIR/$GAME_DIR/$PK3NAME.pk3"
|
|
|
|
done;
|
2021-08-07 21:14:51 +00:00
|
|
|
|
2021-08-29 14:03:48 +00:00
|
|
|
# copy over the shell scripts inside the game-dir
|
|
|
|
find ./$GAME_DIR -name 'install_*.sh' | xargs -I @ sh -c 'echo `basename "@"`' | while read SCRIPTNAME; do
|
|
|
|
cp "./$GAME_DIR/$SCRIPTNAME" "./$BUILD_DIR/$GAME_DIR/$SCRIPTNAME"
|
|
|
|
done;
|
|
|
|
|
2021-03-15 10:43:15 +00:00
|
|
|
cp "./$GAME_DIR/progs.dat" "./$BUILD_DIR/$GAME_DIR/progs.dat"
|
|
|
|
cp "./$GAME_DIR/csprogs.dat" "./$BUILD_DIR/$GAME_DIR/csprogs.dat"
|
2021-06-01 10:40:53 +00:00
|
|
|
cp "./$GAME_DIR/menu.dat" "./$BUILD_DIR/$GAME_DIR/menu.dat"
|
2020-09-01 22:26:26 +00:00
|
|
|
|
2021-05-22 13:22:13 +00:00
|
|
|
if [ "$EXCLUDE_PLATFORM" ]; then
|
|
|
|
cp ./$GAME_DIR.fmf ./$BUILD_DIR/$GAME_DIR.fmf
|
|
|
|
else
|
|
|
|
find 'platform' -name '*.pk3dir' | xargs -I @ sh -c 'echo `basename "@"`' | while read PK3DIR; do
|
|
|
|
# strip the .pk3dir from the folder name to get the final .pk3 basename
|
|
|
|
PK3NAME=$(echo $PK3DIR | cut -f 1 -d '.')
|
2021-01-23 21:51:25 +00:00
|
|
|
|
2021-05-22 13:22:13 +00:00
|
|
|
# go into the pk3dir and compile your zip
|
|
|
|
cd "./platform/$PK3DIR"
|
|
|
|
tree -fi > ./build_contents.txt
|
|
|
|
sed -i '/build_contents/d' ./build_contents.txt
|
|
|
|
sed -i '/directories,/d' ./build_contents.txt
|
|
|
|
zip -0 "$PK3NAME".pk3 -@ < ./build_contents.txt
|
|
|
|
rm ./build_contents.txt
|
2020-09-01 22:26:26 +00:00
|
|
|
|
2021-05-22 13:22:13 +00:00
|
|
|
# Go back and move it over into the build directory
|
|
|
|
cd "$OLD_DIR"
|
|
|
|
mv "./platform/$PK3DIR/$PK3NAME.pk3" "./$BUILD_DIR/platform/$PK3NAME.pk3"
|
|
|
|
done;
|
|
|
|
cp "./platform/platform_default.cfg" "./$BUILD_DIR/platform/platform_default.cfg"
|
|
|
|
cp "./platform/readme.txt" "./$BUILD_DIR/platform/readme.txt"
|
|
|
|
cp "./platform/menu.dat" "./$BUILD_DIR/platform/menu.dat"
|
|
|
|
rm "./$BUILD_DIR/platform/test_maps.pk3"
|
2021-02-02 10:45:42 +00:00
|
|
|
|
2022-10-03 00:11:19 +00:00
|
|
|
# copy manifest over
|
|
|
|
if [ -f "./$GAME_DIR/manifest.fmf" ]; then
|
|
|
|
cp "./$GAME_DIR/manifest.fmf" ./$BUILD_DIR/default.fmf
|
|
|
|
else
|
|
|
|
cp ./default.fmf ./$BUILD_DIR/default.fmf
|
|
|
|
fi
|
|
|
|
|
2021-06-01 10:40:53 +00:00
|
|
|
sed -i "s|base|$GAME_DIR|g" ./$BUILD_DIR/default.fmf
|
2021-05-22 13:22:13 +00:00
|
|
|
cp ./doc/release-readme ./$BUILD_DIR/README.txt
|
|
|
|
fi
|
2021-02-02 10:45:42 +00:00
|
|
|
|
2021-06-01 10:40:53 +00:00
|
|
|
tree ./$BUILD_DIR
|
2021-08-07 21:14:51 +00:00
|
|
|
printf "DONE, press ENTER to create .zip with gpg signature (or CTRL+C to cancel)\n"
|
2021-06-01 10:40:53 +00:00
|
|
|
read cont
|
2021-03-15 10:43:15 +00:00
|
|
|
zip -9 -r "$BUILD_DIR".zip "./$BUILD_DIR"
|
2021-08-07 21:14:51 +00:00
|
|
|
|
|
|
|
if ! [ -x "$(command -v gpg)" ]; then
|
|
|
|
printf "'gpg' is not installed.\n"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2021-03-15 10:43:15 +00:00
|
|
|
gpg --output "./$BUILD_DIR.sig" --detach-sig "./$BUILD_DIR.zip"
|