aboutsummaryrefslogtreecommitdiff
path: root/mktarball
diff options
context:
space:
mode:
authorAndy Whitcroft <apw@shadowen.org>2007-06-04 18:04:05 +0100
committerNishanth Aravamudan <nacc@us.ibm.com>2007-06-05 16:00:37 -0700
commit3bb7409f05d65f7a7615019ad6844af4dd49d5a8 (patch)
tree932d7af4f5dd0749052d151adb6f97f87d0b7fef /mktarball
parent8f0231dfbb06017bfd109fa2fce411ee75c22af5 (diff)
downloadlibhugetlbfs-3bb7409f05d65f7a7615019ad6844af4dd49d5a8.tar.gz
mktarball: make valid tarballs from any commit
Allow the generation of a correctly versioned tarball from any commitish from with the git repo. The version is taken from the nearest tag and inserted into the tarball. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Diffstat (limited to 'mktarball')
-rwxr-xr-xmktarball32
1 files changed, 32 insertions, 0 deletions
diff --git a/mktarball b/mktarball
new file mode 100755
index 0000000..8855204
--- /dev/null
+++ b/mktarball
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+#
+P='mktarball'
+
+if [ "$#" -ne 1 ]; then
+ echo 1>&2 "Usage: $P <commitish>"
+ exit 1
+fi
+commit="$1"
+
+if [ ! .git ]; then
+ echo 1>&2 "$P: not in the source tree"
+ exit 1
+fi
+
+# Get the official name for this commit.
+name=`git describe --tags "$commit"`
+
+# Build a version file to add to the tarball, we know it is not
+# modified as we just took a commit which is unmodified by definition.
+tmp="/tmp/tarball-$$"
+mkdir -p "$tmp/libhugetlbfs-$name"
+echo "$name" >"$tmp/libhugetlbfs-$name/version"
+
+git archive --format=tar --prefix="libhugetlbfs-$name/" "$commit" \
+ >"libhugetlbfs-$name.tar"
+tar -C "$tmp" -rf "libhugetlbfs-$name.tar" "libhugetlbfs-$name/version"
+gzip -9 "libhugetlbfs-$name.tar"
+
+# Clean up the version.
+[ -d "$tmp/libhugetlbfs-$name" ] && rm -rf "$tmp"