From c5010d9665e5d4525177093ca813846e93eba6f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Mon, 31 Mar 2014 02:58:47 +0200 Subject: create_tarball: Add automatic creation of SCM metadata --- create_tarball | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/create_tarball b/create_tarball index 230a944..939f856 100755 --- a/create_tarball +++ b/create_tarball @@ -67,6 +67,23 @@ if [[ -n "$target_tag" ]] && \ exit 1 fi +# Get submodule name +REMOTE_URL=$(git config --get remote.origin.url) +if [ "$REMOTE_URL" = "${REMOTE_URL%/tde}" ]; then + TDEROOT=$( cd `git rev-parse --show-toplevel` && + cd .. && + cd `git rev-parse --show-toplevel` && + pwd ) + SUBROOT=$( cd `git rev-parse --show-toplevel` && + pwd ) +elif [ -f .gitignore ]; then + TDEROOT=$( cd `git rev-parse --show-toplevel` && + pwd ) + SUBROOT=$PWD + METAPACKAGE=true +fi +MODULE=${SUBROOT#$TDEROOT/main/} + # Calculate version tag=`git tag | sort -r | while read t; do \ git branch --contains $t | cut -c 3- | grep -x "$branch" >/dev/null && \ @@ -87,11 +104,14 @@ fi echo "Package name: $package" if [ ! -e $TARBALL_DIR/$package.tar.$TAR_SUFFIX ]; then echo "Creating tarball in $TARBALL_DIR." - trap "rm $TARBALL_DIR/tar-$$; exit 1" INT + echo $MODULE > .tdescmmodule + echo $branch-$(git rev-parse HEAD) > .tdescmrevision + trap "rm $TARBALL_DIR/tar-$$; rm .tdescmmodule .tdescmrevision; exit 1" INT tar c --owner=root --group=users --exclude .git --exclude .gitmodules --transform "s|^\.\(/\|$\)|$package\1|" ./ | \ $COMPRESS -9 >$TARBALL_DIR/tar-$$ && \ mv $TARBALL_DIR/tar-$$ $TARBALL_DIR/$package.tar.$TAR_SUFFIX || \ rm $TARBALL_DIR/tar-$$ + rm .tdescmmodule .tdescmrevision else echo "Unchanged tarball in $TARBALL_DIR." exit 2 -- cgit v1.2.1