blob: 4828a622d0bdda5eafbfda1079380d676d0edd7b (
plain)
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
|
#!/bin/sh
set -e
rev=${1:-HEAD}
revname=$(git describe $rev)
# revname could be 0.7.5 or 0.7.5-NNN-gHASH
# turn that into 0.7.5 or 0.7.5+NNN.gHASH
case "$revname" in
*-*) revname=$(echo "$revname" | sed -e 's/-/+/' -e 's/-/./')
esac
archive_base="cloud-init-$revname"
# when building an archiving from HEAD, ensure that there aren't any
# uncomitted changes in the working directory (because these would not
# end up in the archive).
if [ "$rev" = HEAD ] && ! git diff-index --quiet HEAD --; then
if [ -z "$SKIP_UNCOMITTED_CHANGES_CHECK" ]; then
echo "ERROR: There are uncommitted changes in your working directory." >&2
exit 1
else
echo "WARNING: There are uncommitted changes in your working directory." >&2
echo " This changes will not be included in the archive." >&2
fi
fi
git archive \
--format=tar.gz \
--prefix="$archive_base/" "$rev" \
"--output=$archive_base.tar.gz"
echo "${archive_base}.tar.gz"
|