-
Notifications
You must be signed in to change notification settings - Fork 1
/
makeorig.sh
executable file
·36 lines (28 loc) · 1.03 KB
/
makeorig.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
#!/bin/bash
# Creates a tarball from a Git snapshot.
# This reads Debian package versions in the format majorversion~commithash-debrevision.
set -e
URL="CHANGE THIS TO THE GIT REPO ADDRESS"
PACKAGE="$(dpkg-parsechangelog --show-field Source)"
VERSION="$(dpkg-parsechangelog --show-field Version)"
ORIG_VERSION="$(rev <<< $VERSION | cut -f 2- -d '-' | rev)"
OUTPATH="../../${PACKAGE}_${ORIG_VERSION}.orig.tar.gz"
if [[ "$ORIG_VERSION" == *"~"* ]]; then
COMMIT="$(rev <<< $ORIG_VERSION | cut -f 1 -d '~' | rev)"
else
# If no tilde exists in the orig version, just treat it as the tag.
COMMIT="$VERSION"
fi
echo "Source package name: $PACKAGE"
echo "debian/changelog version: $VERSION"
echo "Upstream part of version: $ORIG_VERSION"
echo "Using Git commit-ish: $COMMIT"
set -x
git clone "$URL" "${PACKAGE}-${ORIG_VERSION}"
echo "# Generating archive from commit."
pushd "${PACKAGE}-${ORIG_VERSION}"
git archive -v "$COMMIT" -o "$OUTPATH"
popd
echo "# Removing temporary Git tree."
rm -rf "${PACKAGE}-${ORIG_VERSION}"
echo "Done - written to $OUTPATH"