]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/demopacker.sh
Add a command ./all serverbench dedicated to quickly run serverbench.
[xonotic/xonotic.git] / misc / tools / demopacker.sh
1 #!/bin/sh
2
3 xonotic=$1; shift
4 demo=$1; shift
5 # rest: command line options to use
6
7 demobase=${demo##*/}
8
9 cp "$demo" data/"$demobase"
10
11 USE_RLWRAP=no strace -qo strace.txt -f -e trace=open ./all run -nohome -readonly -forceqmenu -window "$@" -demo "$demobase"
12
13 allfiles()
14 {
15         <strace.txt \
16                 grep '^[0-9]*  *open("' strace.txt |\
17                 cut -d '"' -f 2 |\
18                 grep '^data/[^/]*\.pk3dir/' |\
19                 sort -u
20 }
21 allfiles=`allfiles`
22
23 include_as()
24 {
25         mkdir -p "output/$1"
26         rmdir "output/$1"
27         cat > "output/$1"
28 }
29
30 rm -rf output
31
32 while [ -n "$allfiles" ]; do
33         l=$allfiles
34         allfiles=
35         for f in $l; do
36                 [ -f "$f" ] || continue
37                 fn=${f#*/*/}
38                 case "$f" in
39                         */csprogs.dat)
40                                 # spam, skip it
41                                 ;;
42                         */unifont-*.ttf)
43                                 # spam, skip it
44                                 ;;
45                         *.mapinfo)
46                                 <"$f" include_as "$fn"
47
48                                 # also include the map pk3 content
49                                 n=${f##*/}
50                                 n=${n%.*}
51                                 rm -rf data/temp-$n
52                                 mkdir data/temp-$n
53                                 (
54                                         cd data/temp-$n
55                                         unzip ../../data/"$n"-*.pk3
56                                 )
57                                 allfiles=$allfiles" `find data/temp-$n -type f`"
58                                 ;;
59                         *)
60                                 <"$f" include_as "$fn"
61                                 ;;
62                 esac
63         done
64 done
65
66 export do_jpeg=true
67 export dp_jpeg_if_not_dds=false
68 export jpeg_qual_rgb=70
69 export jpeg_qual_a=90
70 export do_dds=false
71 export do_ogg=true
72 export ogg_ogg=true
73 export ogg_qual=1
74 export del_src=true
75 export git_src_repo=
76 cd output
77 find . -type f -print0 | xargs -0 ../misc/tools/cached-converter.sh
78 cd ..
79 mv data/"$demobase" output/
80 echo "-xonotic -nohome -readonly -forceqmenu +bind ESCAPE quit $* -demo $demobase" > output/darkplaces.opt
81 rm output.pk3
82 ( cd output && 7za a -tzip -mx=9 ../output.pk3 . )
83 cp "$xonotic" output.exe
84 cat output.pk3 >> output.exe