teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame make-git-snapshot.sh

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