Skip to content

Commit 8804a98

Browse files
committed
we can now use clean tarball archives directly from git
1 parent 8d3f7a9 commit 8804a98

File tree

1 file changed

+32
-45
lines changed

1 file changed

+32
-45
lines changed

dist.sh

+32-45
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,58 @@
11
#!/bin/sh -e
22

3-
# Simple shell script to create a tarball source distribution of NAV
3+
show_help() {
4+
cat <<EOF
5+
$0 [-r revision]
46
5-
USAGE="dist.sh [-r revision]
7+
Simple shell script to create and sign tarball source distribution of NAV
68
7-
Invokation with no arguments will create a tarball from the HEAD of the
8-
current repository."
9+
Invocation with no arguments will create a tarball from the HEAD of the
10+
current repository.
11+
EOF
12+
}
913

1014
REVISION=$(git describe)
1115

1216
# Parse arguments
13-
ARG_PREV=""
14-
for ARG in $@
15-
do
16-
if [ "$ARG_PREV" ]; then
17-
18-
case $ARG_PREV in
19-
-r) REVISION="$ARG" ;;
20-
*) ARG_PREV=$ARG ;;
21-
esac
22-
23-
ARG_PREV=""
24-
25-
else
26-
27-
case $ARG in
28-
-r)
29-
ARG_PREV=$ARG
30-
;;
31-
*)
32-
echo " $USAGE"
33-
exit 1
34-
;;
17+
OPTIND=1
18+
while getopts "hr:" opt; do
19+
case $opt in
20+
h) show_help
21+
exit 0;
22+
;;
23+
r) REVISION="$OPTARG"
24+
;;
25+
*)
26+
show_help >&2
27+
exit 1
28+
;;
3529
esac
36-
fi
3730
done
3831

3932
DIST_NAME="nav-$REVISION"
4033
TARBALL="${DIST_NAME}.tar.gz"
4134

35+
archive() {
36+
umask 0022
37+
git rev-parse "$REVISION" >/dev/null || return 1
38+
git archive --format=tar --prefix="$DIST_NAME/" "$REVISION" \
39+
| gzip - > "$TARBALL"
40+
}
41+
4242
if [ -f $TARBALL ]; then
4343
echo "Tarball already exists: $TARBALL"
4444
echo "Please remove it."
4545
exit 1
4646
fi
4747

48-
echo "Exporting archive of NAV revision $REVISION ..."
49-
if git archive --format=tar --prefix="$DIST_NAME/" "$REVISION" | tar x; then
50-
# Do the magic dance required to get a few generated files into the
51-
# archive
52-
./autogen.sh
53-
cp version.m4 "$DIST_NAME/"
54-
( cd "$DIST_NAME" && ./autogen.sh )
55-
56-
echo "Creating tarball ($TARBALL) ..."
57-
tar czf "$TARBALL" "$DIST_NAME"
58-
59-
rm -rf "$DIST_NAME"
60-
61-
echo "md5sum:"
62-
md5sum "$TARBALL"
63-
echo "sha1sum:"
64-
sha1sum "$TARBALL"
48+
echo "Exporting archive of NAV revision $REVISION ..."
49+
if archive; then
50+
echo "MD5SUM:"; md5sum "$TARBALL"
51+
echo "SHA1SUM:"; sha1sum "$TARBALL"
6552

6653
echo "Please sign the tarball"
6754
gpg --armor --detach-sign "$TARBALL"
68-
55+
6956
echo "All done. Enjoy your tarball:."
7057
ls -la "$TARBALL"*
7158
fi

0 commit comments

Comments
 (0)