Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make source archives, optionally stripped down.
With a fully stripped-down archive: * external libraries are required; * daemonmap won't be compilable (zlib); * ET and base Trem won't be compilable. The debian directory is left in place, though really it should be removed for release purposes.
- Loading branch information
Darren Salt
committed
Mar 27, 2012
1 parent
7a22f7a
commit c8c8353
Showing
1 changed file
with
116 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#! /bin/sh | ||
|
||
set -e | ||
|
||
cd "$(dirname "$0")" | ||
|
||
PACKAGE_NAME="$(sed -e '/^#define PRODUCT_NAME_LOWER/! d; s/[^\"]*\"//; s/\".*$//; s/[^0-9a-z.]/-/g' src/engine/qcommon/q_shared.h)" | ||
PACKAGE_VERSION="$(sed -e '/^#define PRODUCT_VERSION/! d; s/[^\"]*\"//; s/\".*$//; s/[^0-9a-z.]/-/g' src/engine/qcommon/q_shared.h)" | ||
PACKAGE="$PACKAGE_NAME-$PACKAGE_VERSION" | ||
|
||
STRIP_SOURCES= | ||
STRIP_BINARIES= | ||
STRIP_ASSETS= | ||
STRIP_DEAD= | ||
FORMAT=tar.xz | ||
|
||
while test $# != 0; do | ||
case "$1" in | ||
strip-sources) | ||
STRIP_SOURCES=1 | ||
;; | ||
strip-binaries) | ||
STRIP_BINARIES=1 | ||
;; | ||
strip-assets) | ||
STRIP_ASSETS=1 | ||
;; | ||
strip-unused) | ||
STRIP_UNUSED=1 | ||
;; | ||
strip) | ||
STRIP_SOURCES=1 | ||
STRIP_BINARIES=1 | ||
STRIP_ASSETS=1 | ||
STRIP_DEAD=1 | ||
;; | ||
7z|zip|tar.gz|tar.bz2|tar.xz) | ||
FORMAT="$1" | ||
;; | ||
-\?|-h|--help) | ||
echo "$(basename "$0") [options]" | ||
echo ' builds an optionally stripped-down source archive file' | ||
echo 'Source control options (at least one):' | ||
echo ' strip-sources - remove library code copies' | ||
echo ' strip-binaries - remove DLLs etc.' | ||
echo ' strip-assets - remove various images etc. found in the pak files' | ||
echo ' strip-unused - remove some "dead" code' | ||
echo ' strip - all of the above' | ||
echo 'Archive file formats (select one):' | ||
echo ' 7z zip tar.gz tar.bz2 tar.xz' | ||
echo 'Other options:' | ||
exit 0 | ||
;; | ||
*) | ||
echo 'Unrecognised argument "'"$1"'"' | ||
exit 2 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
cleanup() | ||
{ | ||
rm -rf "$PACKAGE" | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
if test ! -d .git || test "$(git clean -ndf | grep -v '\.#'; git status -s)" != ''; then | ||
echo 'I need a clean tree!' | ||
exit 2 | ||
fi | ||
|
||
# copy the files | ||
mkdir $PACKAGE | ||
cp -al $(ls -1 | grep -v $PACKAGE) $PACKAGE | ||
rm $PACKAGE/tarball.sh | ||
|
||
# kill backup files etc. | ||
find $PACKAGE \( -name '.*' -o -name '*~' -o -name '*.orig' -o -name '*.rej' \) -delete | ||
|
||
# purge all but *required* libraries | ||
test "$STRIP_SOURCES" = '' || | ||
rm -rf $(ls -1d $PACKAGE/src/libs/* | grep -v '/\(cpuinfo\|openexr\|picomodel\)') | ||
|
||
# purge binaries | ||
test "$STRIP_BINARIES" = '' || { | ||
rm -rf $PACKAGE/bin | ||
find $PACKAGE \( -name '*.dll' -o -name '*.lib' \) -delete | ||
} | ||
|
||
# purge (most) assets | ||
test "$STRIP_ASSETS" = '' || { | ||
rm -rf $PACKAGE/main $PACKAGE/src/gamelogic/*/ui/*[^h] | ||
} | ||
|
||
# remove some disabled-by-default code | ||
test "$STRIP_DEAD" = '' || { | ||
rm -rf $PACKAGE/src/gamelogic/etmain $PACKAGE/src/gamelogic/base | ||
} | ||
|
||
# kill empty directories | ||
rmdir --ignore-fail-on-non-empty $(find $PACKAGE -type d | sort -r) | ||
|
||
# now build the archive | ||
case "$FORMAT" in | ||
7z) | ||
7z a -r $PACKAGE.7z $PACKAGE | ||
;; | ||
zip) | ||
zip -9r $PACKAGE.zip $PACKAGE | ||
;; | ||
tar.*) | ||
tar cvaf $PACKAGE.$FORMAT $PACKAGE | ||
;; | ||
esac |