]> git.rm.cloudns.org Git - xonotic/xonotic.git/commitdiff
add a VERY rough script to pack a demo file into a self running executable
authorRudolf Polzer <divverent@xonotic.org>
Wed, 19 Sep 2012 09:55:28 +0000 (11:55 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Wed, 19 Sep 2012 09:55:28 +0000 (11:55 +0200)
misc/tools/demopacker.sh [new file with mode: 0755]

diff --git a/misc/tools/demopacker.sh b/misc/tools/demopacker.sh
new file mode 100755 (executable)
index 0000000..d49c400
--- /dev/null
@@ -0,0 +1,86 @@
+#!/bin/sh
+
+xonotic=$1; shift
+strip=$1; shift
+demo=$1; shift
+# rest: command line options to use
+
+demobase=${demo##*/}
+
+cp "$demo" data/"$demobase"
+
+strace -qo strace.txt -f -e trace=open ./all run -nohome -readonly -forceqmenu -window -demo "$demobase"
+
+allfiles()
+{
+       <strace.txt \
+               grep '^[0-9]*  *open("' strace.txt |\
+               cut -d '"' -f 2 |\
+               grep '^data/[^/]*\.pk3dir/' |\
+               sort -u
+}
+allfiles=`allfiles`
+
+include_as()
+{
+       mkdir -p "output/$1"
+       rmdir "output/$1"
+       cat > "output/$1"
+}
+
+rm -rf output
+
+while [ -n "$allfiles" ]; do
+       l=$allfiles
+       allfiles=
+       for f in $l; do
+               [ -f "$f" ] || continue
+               fn=${f#*/*/}
+               case "$f" in
+                       */csprogs.dat)
+                               # spam, skip it
+                               ;;
+                       */unifont-*.ttf)
+                               # spam, skip it
+                               ;;
+                       *.mapinfo)
+                               <"$f" include_as "$fn"
+
+                               # also include the map pk3 content
+                               n=${f##*/}
+                               n=${n%.*}
+                               rm -rf data/temp-$n
+                               mkdir data/temp-$n
+                               (
+                                       cd data/temp-$n
+                                       unzip ../../data/"$n"-*.pk3
+                               )
+                               allfiles=$allfiles" `find data/temp-$n -type f`"
+                               ;;
+                       *)
+                               <"$f" include_as "$fn"
+                               ;;
+               esac
+       done
+done
+
+export do_jpeg=true
+export dp_jpeg_if_not_dds=false
+export jpeg_qual_rgb=80
+export jpeg_qual_a=95
+export do_dds=false
+export do_ogg=true
+export ogg_ogg=true
+export ogg_qual=1
+export del_src=true
+export git_src_repo=
+cd output
+find . -type f -print0 | xargs -0 ../misc/tools/cached-converter.sh
+cd ..
+mv data/"$demobase" output/
+echo "-xonotic -nohome -readonly -forceqmenu +bind ESC quit -demo $demobase" > output/darkplaces.opt
+rm output.pk3
+( cd output && zip -9r ../output.pk3 . )
+cp "$xonotic" output.exe
+$strip --strip-unneeded output.exe
+cat output.pk3 >> output.exe