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
|
# gitpkg hook script to build packages locally after export
#
# To enable this hook, use:
# git config gitpkg.exit-hook /usr/share/gitpkg/hooks/dpkg-buildpackage-exit-hook
# We're out of the repo tree, but want to check git-config
. /usr/share/gitpkg/hooks/repo-config-helper
# See dpkg-buildpackage(1) for what's valid to set in this one
extract_values_for_option dpkg-bp "${GITPKG_IOPTS[@]}"
# Command line options override the git config
if [ ${#EXTRACTED_OPTS[@]} -gt 0 ]; then
DPKG_BUILDPACKAGE_OPTS=( "${EXTRACTED_OPTS[@]}" )
else
while read opt; do DPKG_BUILDPACKAGE_OPTS+=("$opt")
done < <(repo_config --get-all gitpkg-dpkg-buildpackage-exit-hook.options)
# Having a veto can be handy sometimes
if [ "$(repo_config --get --bool gitpkg-dpkg-buildpackage-exit-hook.ask-first)" = "true" ]
then
printf "Build binary packages from $DEB_DSC now (Y/n)? "
read -e yesno
case "$yesno" in
N* | n*)
echo "Ok, you're the boss. If you change your mind, just run:"
echo "cd $DEB_DIR/$DEB_SOURCE/$DEB_PACKAGE &&" \
"dpkg-buildpackage ${DPKG_BUILDPACKAGE_OPTS[@]}"
echo
exit 0
;;
*) ;;
esac
fi
fi
# But you don't always need to log everything
if [ "$(repo_config --get --bool gitpkg-dpkg-buildpackage-exit-hook.build-log)" = "false" ]
then
echo "cd $DEB_PACKAGE && dpkg-buildpackage ${DPKG_BUILDPACKAGE_OPTS[@]}"
( cd "$DEB_PACKAGE" && dpkg-buildpackage "${DPKG_BUILDPACKAGE_OPTS[@]}" ) || exit 1
else
DATE="$(date +%Y%m%d+%H.%M 2>/dev/null)"
echo "cd $DEB_PACKAGE && dpkg-buildpackage" "${DPKG_BUILDPACKAGE_OPTS[@]}" \
"> ../build-${DEB_SOURCE}_${DEB_VERSION}_${DATE}.log"
( cd "$DEB_PACKAGE" &&
dpkg-buildpackage "${DPKG_BUILDPACKAGE_OPTS[@]}" 2>&1 |
tee ../build-${DEB_SOURCE}_${DEB_VERSION}_${DATE}.log
) || exit 1
fi
# vi:sts=4:sw=4:noet:foldmethod=marker
|