diff mbox

[3/3] builddeb: support creating source-only package with git archive

Message ID 1456147056-767-3-git-send-email-ricardo.salveti@linaro.org
State Accepted
Commit 188a76d2f84a943ad59de6e5dc1d5c9f25dd2ac2
Headers show

Commit Message

Ricardo Salveti Feb. 22, 2016, 1:17 p.m. UTC
With git archive the bootstrap steps are not required when creating the
orig tarball, allowing the user to create a source package without
having the build-deps available at the host machine.

As debian/rules is also calling autoreconf now, it's not required to
have the cached autoconf/automake files in order to produce the build.

To create the source package simply call 'scripts/builddeb source'.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
---
 scripts/builddeb            | 13 +++++++++++--
 scripts/common_pkg_build.sh | 22 +++++++++++++++++++---
 2 files changed, 30 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/scripts/builddeb b/scripts/builddeb
index 829fd1d..bce74cb 100755
--- a/scripts/builddeb
+++ b/scripts/builddeb
@@ -6,7 +6,16 @@  export ROOT_DIR=$(readlink -e $(dirname $0) | sed 's|/scripts||')
 
 source ${ROOT_DIR}/scripts/common_pkg_build.sh
 
-prepare_tarball
+# debuild default options
+DEB_OPTS="-us -uc"
+
+# Also allow the user to create just the source package (skip build process)
+if [ "$1" == source ]; then
+	prepare_tarball archive
+	DEB_OPTS="-S $DEB_OPTS"
+else
+	prepare_tarball
+fi
 
 pushd ${ROOT_DIR}/${package}-${version}
 cp -r ${ROOT_DIR}/pkg/debian .
@@ -23,6 +32,6 @@  if [ $(egrep "\.([a-z0-9]{8}\>|dirty)" .scmversion |wc -l) -gt 0 ]; then
 	dch --newversion ${version}-1 --urgency low "not a official release!"
 fi
 
-debuild -us -uc
+debuild $DEB_OPTS
 popd
 popd
diff --git a/scripts/common_pkg_build.sh b/scripts/common_pkg_build.sh
index eefc07d..fbb2511 100644
--- a/scripts/common_pkg_build.sh
+++ b/scripts/common_pkg_build.sh
@@ -6,11 +6,9 @@  prepare_tarball() {
 	export package=opendataplane
 
 	pushd ${ROOT_DIR}
-	./bootstrap
-	./configure
-	make dist
 
 	if [[ -d ${ROOT_DIR}/.git ]]; then
+		. scripts/git_hash.sh ${ROOT_DIR}
 		version=$(cat ${ROOT_DIR}/.scmversion)
 	else
 		echo "This script isn't expected to be used without"
@@ -18,6 +16,24 @@  prepare_tarball() {
 		exit 1
 	fi
 
+	if [ "$1" == archive ]; then
+		git archive --format=tar --prefix=${package}-${version}/ HEAD > ${package}-${version}.tar
+
+		# append .scmversion, otherwise bootstrap fails
+		SCMTMP=`mktemp -d`
+		pushd $SCMTMP
+		mkdir ${package}-${version}
+		cp ${ROOT_DIR}/.scmversion ${package}-${version}
+		tar --update -v -f ${ROOT_DIR}/${package}-${version}.tar ${package}-${version}
+		popd
+		rm -rf $SCMTMP
+		gzip ${package}-${version}.tar
+	else
+		./bootstrap
+		./configure
+		make dist
+	fi
+
 	cp ${package}-${version}.tar.gz ${package}_${version}.orig.tar.gz
 	tar xzf ${package}_${version}.orig.tar.gz
 }