This repository has been archived by the owner on Nov 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
maketarball.sh
executable file
·112 lines (86 loc) · 2.01 KB
/
maketarball.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
#######################################################################
# This file is part of steve.
#
# Copyright (C) 2012-2014 Will Kahn-Greene
# Licensed under the Simplified BSD License. See LICENSE for full
# license.
#######################################################################
USAGE="Usage: $0 -h | [-dr] REVISH
Creates a tarball of the repository at rev REVISH. This can be a branch
name, tag, or commit sha.
Options:
-d
Adds date to the directory name.
-h
Shows help and exits.
Examples:
./maketarball v1.5
./maketarball -d master
"
REVISH="none"
PREFIX="none"
NOWDATE=""
while getopts ":dhr" opt;
do
case "$opt" in
h)
echo "$USAGE"
exit 0
;;
d)
NOWDATE=`date "+%Y-%m-%d-"`
shift $((OPTIND-1))
;;
\?)
echo "Invalid option: -$OPTARG" >&2
echo "$USAGE" >&2
;;
esac
done
if [[ -z "$1" ]]; then
echo "$USAGE";
exit 1;
fi
REVISH=$1
PREFIX="$NOWDATE$REVISH"
# convert PREFIX to all lowercase and nix the v from tag names.
PREFIX=`echo "$PREFIX" | tr '[A-Z]' '[a-z]' | sed s/v//`
# build the filename base minus the .tar.gz stuff--this is also
# the directory in the tarball.
FNBASE="pyblosxom-$PREFIX"
STARTDIR=`pwd`
function cleanup {
pushd $STARTDIR
if [[ -e tmp ]]
then
echo "+ cleaning up tmp/"
rm -rf tmp
fi
popd
}
echo "+ Building tarball from: $REVISH"
echo "+ Using prefix: $PREFIX"
echo "+ Release?: $RELEASE"
echo ""
if [[ -e tmp ]]
then
echo "+ there's an existing tmp/. please remove it."
exit 1
fi
mkdir $STARTDIR/tmp
echo "+ generating archive...."
git archive \
--format=tar \
--prefix=$FNBASE/ \
$REVISH > tmp/$FNBASE.tar
if [[ $? -ne 0 ]]
then
echo "+ git archive command failed. See above text for reason."
cleanup
exit 1
fi
echo "+ compressing...."
gzip tmp/$FNBASE.tar
echo "+ archive at tmp/$FNBASE.tar.gz"
echo "+ done."