From cc7f0bdf106dfa82e1b0a841db8af6522fe7bbca Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Sat, 7 Apr 2012 21:12:44 +0100
Subject: Allowing differently placed tarballs, to let us share hashes between
 .deb builds


diff --git a/Swift/Packaging/Debian/package.sh b/Swift/Packaging/Debian/package.sh
index 5bc9fbc..d693c0f 100755
--- a/Swift/Packaging/Debian/package.sh
+++ b/Swift/Packaging/Debian/package.sh
@@ -1,5 +1,8 @@
 #!/bin/sh
 
+#If you want to share tar output (note: necessary if you want multiple archs with the same hashed tarballs)
+# set SHARED_DIR - YOU MUST MAKE SURE YOU HAVE A TRAILING / ON SHARED_DIR
+
 set -e -x
 
 export PYTHONPATH=../../../BuildTools/SCons
@@ -8,6 +11,12 @@ DEBIAN_VERSION=`../../../BuildTools/DebianizeVersion.py $VERSION`
 DIRNAME=swift-im-$DEBIAN_VERSION
 SWIFTEN_SOVERSION=`../../../BuildTools/GetBuildVersion.py swift --major`
 
+if [ -z "$SHARED_DIR" ]; then
+	echo "Using standalone output"
+else
+	echo "Using shared output in ${SHARED_DIR}"
+fi
+
 if [ -z "$DEBIAN_VERSION" ]; then
 	echo "Unable to determine version"
 	exit -1
@@ -18,28 +27,44 @@ rm -f swift-im_*
 rm -f libswiften*
 rm -rf swift-im-*
 
-echo "Checking out a fresh copy ..."
-rm -rf $DIRNAME
-git clone ../../../.git $DIRNAME
+TARBALLBARE="swift-im_$DEBIAN_VERSION.orig.tar.gz"
+TARBALL="${SHARED_DIR}${TARBALLBARE}"
 
-# Remove development files & 3rdParty files
-rm -rf $DIRNAME/.git
-find $DIRNAME -name .gitignore | xargs rm -f
-find $DIRNAME/3rdParty -type f | grep -v uuid | grep -v SConscript | xargs rm -f
-find $DIRNAME/3rdParty -depth -empty -type d -exec rmdir {} \;
-rm -rf $DIRNAME/3rdParty/SCons
-rm -rf $DIRNAME/Swift/Packaging/Debian
+if [ -f $TARBALL ]; then
+	echo "Found existing tarball for the right version, using ${TARBALL}"
+	echo "Cleaning out any previous builds in ${DIRNAME} and re-extracting"
+	rm -rf $DIRNAME
+	cp $TARBALL tmp.tmp
+	mv tmp.tmp $TARBALLBARE
+	tar xzf $TARBALLBARE
+else
+	echo "No shared tarball found"
+	echo "Checking out a fresh copy ..."
+	rm -rf $DIRNAME
+	git clone ../../../.git $DIRNAME
+
+	# Remove development files & 3rdParty files
+	rm -rf $DIRNAME/.git
+	find $DIRNAME -name .gitignore | xargs rm -f
+	find $DIRNAME/3rdParty -type f | grep -v uuid | grep -v SConscript | xargs rm -f
+	find $DIRNAME/3rdParty -depth -empty -type d -exec rmdir {} \;
+	rm -rf $DIRNAME/3rdParty/SCons
+	rm -rf $DIRNAME/Swift/Packaging/Debian
 
-# Initialize the build version
-echo $VERSION > $DIRNAME/VERSION.swift
+	# Initialize the build version
+	echo $VERSION > $DIRNAME/VERSION.swift
 
-# Fork local Boost UUID copy
-# FIXME: This shouldn't be necessary, but SCons isn't picking up the generated headers for compilation
-mkdir -p $DIRNAME/3rdParty/Boost/uuid/boost
-cp -r $DIRNAME/3rdParty/Boost/src/boost/uuid $DIRNAME/3rdParty/Boost/uuid/boost
+	# Fork local Boost UUID copy
+	# FIXME: This shouldn't be necessary, but SCons isn't picking up the generated headers for compilation
+	mkdir -p $DIRNAME/3rdParty/Boost/uuid/boost
+	cp -r $DIRNAME/3rdParty/Boost/src/boost/uuid $DIRNAME/3rdParty/Boost/uuid/boost
+
+	# Create orig tarball
+	tar czf $TARBALLBARE $DIRNAME
+	cp $TARBALLBARE tmp.tmp
+	mv tmp.tmp $TARBALL
+fi
 
-# Create orig tarball
-tar czf swift-im_$DEBIAN_VERSION.orig.tar.gz $DIRNAME
 
 # Detect dependencies
 WEBKIT_DEPENDENCY=", libqtwebkit-dev (>= 2.0.0)"
-- 
cgit v0.10.2-6-g49f6