mirror of
https://git.proxmox.com/git/debcargo-conf
synced 2025-04-28 13:24:24 +00:00
68 lines
2.1 KiB
JavaScript
68 lines
2.1 KiB
JavaScript
set -e
|
|
|
|
abort() { local x=$1; shift; for i in "$@"; do echo >&2 "$0: abort: $i"; done; exit "$x"; }
|
|
|
|
HOOK_COMMIT="$(dirname "$0")/.git/hooks/pre-commit"
|
|
if [ ! -x "$HOOK_COMMIT" ]; then
|
|
cat <<'eof' >"$HOOK_COMMIT"
|
|
#!/bin/sh
|
|
if git rev-parse -q --verify MERGE_HEAD; then exit; fi
|
|
case $(git rev-parse --abbrev-ref HEAD) in
|
|
pending-*) true;;
|
|
*) if git diff --cached --name-only | \
|
|
grep '^src/.*/debian/changelog$' | \
|
|
while read x; do echo "$x: $(head -n1 $x)"; done | \
|
|
grep -v UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then
|
|
echo >&2 "please don't finalise changelogs directly on the master branch, use ./release.sh instead"; exit 1;
|
|
fi;;
|
|
esac
|
|
eof
|
|
chmod +x "$HOOK_COMMIT"
|
|
fi
|
|
|
|
if [ -n "$DEBCARGO" ]; then
|
|
true
|
|
elif which debcargo >/dev/null; then
|
|
DEBCARGO=$(which debcargo)
|
|
elif [ -f "$HOME/.cargo/bin/debcargo" ]; then
|
|
DEBCARGO="$HOME/.cargo/bin/debcargo"
|
|
else
|
|
abort 1 "debcargo not found, run \`cargo install debcargo\` or set DEBCARGO to point to it"
|
|
fi
|
|
|
|
test -x "$DEBCARGO" || abort 1 "debcargo found but not executable: $DEBCARGO"
|
|
dcver=$($DEBCARGO --version | sed -ne 's/debcargo //p')
|
|
case $dcver in
|
|
2.0.*|2.1.*|2.2.[012]|2.2.[012]-*) abort 1 "unsupported debcargo version $dcver. try reinstalling with \`cargo install debcargo --force\`";;
|
|
2.2.*) true;;
|
|
*) abort 1 "unsupported debcargo version: $dcver";;
|
|
esac
|
|
|
|
if [ $# -ne 1 -a $# -ne 2 ]; then
|
|
echo >&2 "Usage: $0 <rust-crate-name>"
|
|
echo >&2 " $0 <rust-crate-name> <old-version>"
|
|
echo >&2 "See README.rst for more details on usage."
|
|
exit 2
|
|
fi
|
|
|
|
CRATE="$1"
|
|
VER="$2"
|
|
|
|
PKGNAME=$($DEBCARGO deb-src-name "$CRATE" $VER || abort 1 "couldn't find crate $CRATE")
|
|
PKGBASE=$($DEBCARGO deb-src-name "$CRATE" || abort 1 "couldn't find crate $CRATE")
|
|
PKGDIR_REL="src/$PKGNAME"
|
|
PKGDIR="$PWD/$PKGDIR_REL"
|
|
BUILDDIR="$PWD/build/$PKGNAME"
|
|
PKGCFG="$PKGDIR/debian/debcargo.toml"
|
|
|
|
mkdir -p "$(dirname $BUILDDIR)"
|
|
|
|
if [ -z "$CRATE" ]; then
|
|
abort 2 "Usage: $0 <crate> [<version>]"
|
|
fi
|
|
|
|
run_debcargo() {
|
|
rm -rf "$BUILDDIR" "$(dirname "$BUILDDIR")/rust-${PKGNAME}_$VER"*.orig.tar.*
|
|
$DEBCARGO package --config "$PKGCFG" --directory "$BUILDDIR" "$@" "$CRATE" "$VER"
|
|
}
|