Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 117 lines (100 sloc) 2.766 kb
c8c8353 Make source archives, optionally stripped down.
Darren Salt authored
1 #! /bin/sh
2
3 set -e
4
5 cd "$(dirname "$0")"
6
7 PACKAGE_NAME="$(sed -e '/^#define PRODUCT_NAME_LOWER/! d; s/[^\"]*\"//; s/\".*$//; s/[^0-9a-z.]/-/g' src/engine/qcommon/q_shared.h)"
8 PACKAGE_VERSION="$(sed -e '/^#define PRODUCT_VERSION/! d; s/[^\"]*\"//; s/\".*$//; s/[^0-9a-z.]/-/g' src/engine/qcommon/q_shared.h)"
9 PACKAGE="$PACKAGE_NAME-$PACKAGE_VERSION"
10
11 STRIP_SOURCES=
12 STRIP_BINARIES=
13 STRIP_ASSETS=
14 STRIP_DEAD=
15 FORMAT=tar.xz
16
17 while test $# != 0; do
18 case "$1" in
19 strip-sources)
20 STRIP_SOURCES=1
21 ;;
22 strip-binaries)
23 STRIP_BINARIES=1
24 ;;
25 strip-assets)
26 STRIP_ASSETS=1
27 ;;
28 strip-unused)
29 STRIP_UNUSED=1
30 ;;
31 strip)
32 STRIP_SOURCES=1
33 STRIP_BINARIES=1
34 STRIP_ASSETS=1
35 STRIP_DEAD=1
36 ;;
37 7z|zip|tar.gz|tar.bz2|tar.xz)
38 FORMAT="$1"
39 ;;
40 -\?|-h|--help)
41 echo "$(basename "$0") [options]"
42 echo ' builds an optionally stripped-down source archive file'
43 echo 'Source control options (at least one):'
44 echo ' strip-sources - remove library code copies'
45 echo ' strip-binaries - remove DLLs etc.'
46 echo ' strip-assets - remove various images etc. found in the pak files'
47 echo ' strip-unused - remove some "dead" code'
48 echo ' strip - all of the above'
49 echo 'Archive file formats (select one):'
50 echo ' 7z zip tar.gz tar.bz2 tar.xz'
51 echo 'Other options:'
52 exit 0
53 ;;
54 *)
55 echo 'Unrecognised argument "'"$1"'"'
56 exit 2
57 ;;
58 esac
59 shift
60 done
61
62 cleanup()
63 {
64 rm -rf "$PACKAGE"
65 }
66
67 trap cleanup EXIT
68
69 if test ! -d .git || test "$(git clean -ndf | grep -v '\.#'; git status -s)" != ''; then
70 echo 'I need a clean tree!'
71 exit 2
72 fi
73
74 # copy the files
75 mkdir $PACKAGE
76 cp -al $(ls -1 | grep -v $PACKAGE) $PACKAGE
77 rm $PACKAGE/tarball.sh
78
79 # kill backup files etc.
80 find $PACKAGE \( -name '.*' -o -name '*~' -o -name '*.orig' -o -name '*.rej' \) -delete
81
82 # purge all but *required* libraries
83 test "$STRIP_SOURCES" = '' ||
84 rm -rf $(ls -1d $PACKAGE/src/libs/* | grep -v '/\(cpuinfo\|openexr\|picomodel\)')
85
86 # purge binaries
87 test "$STRIP_BINARIES" = '' || {
88 rm -rf $PACKAGE/bin
89 find $PACKAGE \( -name '*.dll' -o -name '*.lib' \) -delete
90 }
91
92 # purge (most) assets
93 test "$STRIP_ASSETS" = '' || {
94 rm -rf $PACKAGE/main $PACKAGE/src/gamelogic/*/ui/*[^h]
95 }
96
97 # remove some disabled-by-default code
98 test "$STRIP_DEAD" = '' || {
99 rm -rf $PACKAGE/src/gamelogic/etmain $PACKAGE/src/gamelogic/base
100 }
101
102 # kill empty directories
103 rmdir --ignore-fail-on-non-empty $(find $PACKAGE -type d | sort -r)
104
105 # now build the archive
106 case "$FORMAT" in
107 7z)
108 7z a -r $PACKAGE.7z $PACKAGE
109 ;;
110 zip)
111 zip -9r $PACKAGE.zip $PACKAGE
112 ;;
113 tar.*)
114 tar cvaf $PACKAGE.$FORMAT $PACKAGE
115 ;;
116 esac
Something went wrong with that request. Please try again.