]> git.proxmox.com Git - debcargo-conf.git/blame - vars.sh.frag
Add cargo-outdated
[debcargo-conf.git] / vars.sh.frag
CommitLineData
9cfc4370 1# -*- mode: sh -*-
931eabc0
XL
2set -e
3
999f9269 4abort() { local x=$1; shift; for i in "$@"; do echo >&2 "$0: abort: $i"; done; exit "$x"; }
88f8e3e6 5
cfc28aec 6mkdir -p "$(dirname "$0")/.git/hooks"
b6a1d240
XL
7HOOK_COMMIT="$(dirname "$0")/.git/hooks/pre-commit"
8if [ ! -x "$HOOK_COMMIT" ]; then
9cat <<'eof' >"$HOOK_COMMIT"
10#!/bin/sh
11if git rev-parse -q --verify MERGE_HEAD; then exit; fi
12case $(git rev-parse --abbrev-ref HEAD) in
13pending-*) true;;
14*) if git diff --cached --name-only | \
15 grep '^src/.*/debian/changelog$' | \
f830d4fb 16 while read x; do if ! [ -f "$x" ]; then continue; fi; echo "$x: $(head -n1 $x)"; done | \
b6a1d240
XL
17 grep -v UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then
18 echo >&2 "please don't finalise changelogs directly on the master branch, use ./release.sh instead"; exit 1;
19 fi;;
20esac
21eof
22chmod +x "$HOOK_COMMIT"
23fi
24
23db3623
XL
25if [ -n "$DEBCARGO" ]; then
26 true
27elif which debcargo >/dev/null; then
28 DEBCARGO=$(which debcargo)
29elif [ -f "$HOME/.cargo/bin/debcargo" ]; then
30 DEBCARGO="$HOME/.cargo/bin/debcargo"
31else
32 abort 1 "debcargo not found, run \`cargo install debcargo\` or set DEBCARGO to point to it"
33fi
34
35test -x "$DEBCARGO" || abort 1 "debcargo found but not executable: $DEBCARGO"
34c68b28
XL
36dcver=$($DEBCARGO --version | sed -ne 's/debcargo //p')
37case $dcver in
4333698e 382.0.*|2.1.*|2.2.[0123456789]|2.2.[0123456789]-*) abort 1 "unsupported debcargo version $dcver. try reinstalling with \`cargo install debcargo --force\`";;
c452f0f4 392.2.*) true;;
4b576729 402.3.*) true;;
5f4657b0 412.4.*) true;;
34c68b28
XL
42*) abort 1 "unsupported debcargo version: $dcver";;
43esac
23db3623 44
32fc064c
XL
45if [ $# -ne 1 -a $# -ne 2 ]; then
46 echo >&2 "Usage: $0 <rust-crate-name>"
47 echo >&2 " $0 <rust-crate-name> <old-version>"
48 echo >&2 "See README.rst for more details on usage."
49 exit 2
50fi
51
999f9269 52CRATE="$1"
ea9f59b2 53VER="$2"
931eabc0 54
e81e375b 55PKGNAME=${PKGNAME:-$($DEBCARGO deb-src-name "$CRATE" $VER || abort 1 "couldn't find crate $CRATE")}
999f9269 56PKGBASE=$($DEBCARGO deb-src-name "$CRATE" || abort 1 "couldn't find crate $CRATE")
931eabc0
XL
57PKGDIR_REL="src/$PKGNAME"
58PKGDIR="$PWD/$PKGDIR_REL"
59BUILDDIR="$PWD/build/$PKGNAME"
60PKGCFG="$PKGDIR/debian/debcargo.toml"
1230b71f
XL
61
62mkdir -p "$(dirname $BUILDDIR)"
1057693c
XL
63cp "$PWD/build.sh" "$PWD/build/build.sh"
64chmod +x "$PWD/build/build.sh"
1230b71f 65
999f9269
XL
66if [ -z "$CRATE" ]; then
67 abort 2 "Usage: $0 <crate> [<version>]"
1230b71f 68fi
cc003c95
XL
69
70run_debcargo() {
f3600938 71 rm -rf "$BUILDDIR" "$(dirname "$BUILDDIR")/rust-${PKGNAME}_${REALVER:-$VER}"*.orig.tar.*
ba393157 72 $DEBCARGO package --config "$PKGCFG" --directory "$BUILDDIR" "$@" "$CRATE" "${REALVER:-$VER}"
cc003c95 73}
b4e5b9dc
XL
74
75shouldbuild() {
76 local dst="$1"
77 local src="$2"
78 test ! -e "$dst" -o "$src" -nt "$dst"
79}