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
|
# gitpkg hook script to extract an .orig.tar.gz using pristine-tar.
# Originally from David Bremner.
#
# To enable this hook, use:
# git config gitpkg.pre-export-hook /usr/share/gitpkg/hooks/pristine-tar-pre-export-hook
pt_hook_fail() {
cat 1>&2 <<-EOF
pristine-tar-pre-export-hook:
$*
Use: git config gitpkg.pre-export-hook ''
to disable this hook for this repo, else fix the real problem and try again
EOF
exit 1
}
if [ -n "$DEB_ORIG" ]; then
pt_ref=$(git show-ref pristine-tar | cut -f1 -d' ')
if [ -z "$pt_ref" ]; then
pt_hook_fail "No pristine-tar branch found in this repo."
fi
# try the local branch first
pt_tree=$(git show pristine-tar:"$DEB_ORIG".id)
if [ -z "$pt_tree" ]; then
pt_tree=$(git show $pt_ref:"$DEB_ORIG".id)
fi
if [ -z "$pt_tree" ]; then
pt_hook_fail "Unable to find pristine-tar data for $DEB_ORIG"
fi
commit=""
while read -r hash tree; do
if [ "$tree" == "$pt_tree" ]; then
if [ "$hash" == "commit" ]; then
# pre-1.22 pristine-tar used commits in id files
commit=$tree
else
commit=$hash
fi
continue
fi
done < <(git rev-list --pretty="%H %T" $GITPKG_TREEISH --)
mkdir -p "$DEB_DIR/$DEB_SOURCE"
if [ -n "$commit" ]; then
echo "$commit" > "$DEB_DIR/$DEB_SOURCE/$DEB_ORIG".commit
else
echo "pristine-tar-pre-export-hook: " 1>&2
echo " Warning: Unable to find original commit for $DEB_ORIG" 1>&2
fi
echo "pristine-tar checkout $DEB_DIR/$DEB_SOURCE/$DEB_ORIG"
pristine-tar checkout "$DEB_DIR/$DEB_SOURCE/$DEB_ORIG"
fi
|