systemd/make-git-snapshot.sh
Michal Schmidt 5911067120 add easy building of git snapshots
add make-git-snapshot.sh to make a tarball from upstream git.
if %global gitcommit is defined on the top, a snapshot is being built.
don't BuildRequire auto-tools to build from release tarballs.
2012-01-22 20:46:35 +01:00

29 lines
777 B
Bash
Executable File

#!/bin/bash
set -e
NAME=systemd
UPSTREAM=git://anongit.freedesktop.org/systemd/systemd
REFDIR="$HOME/git/systemd" # for faster cloning, if available
[ -n "$1" ] && HEAD="$1" || HEAD="HEAD"
WORKDIR="$(mktemp -d --tmpdir "$NAME.XXXXXXXXXX")"
trap 'rm -rf $WORKDIR' exit
[ -d "$REFDIR" ] && REFERENCE="--reference $REFDIR"
git clone $REFERENCE "$UPSTREAM" "$WORKDIR"
pushd "$WORKDIR" > /dev/null
read COMMIT_ID COMMIT_SHORTID COMMIT_TITLE <<EOGIT
$(git log ${HEAD}^..${HEAD} --pretty='format:%H %h %s')
EOGIT
popd > /dev/null
echo "Making git snapshot using commit: $COMMIT_SHORTID $COMMIT_TITLE"
DIRNAME="$NAME-git$COMMIT_SHORTID"
git archive --remote="$WORKDIR" --format=tar --prefix="$DIRNAME/" "$COMMIT_ID" | xz -9 > "$DIRNAME.tar.xz"
echo "Written $DIRNAME.tar.xz"