Codebase list rust-libslirp / 9cc53ba vars.sh.frag
9cc53ba

Tree @9cc53ba (Download .tar.gz)

vars.sh.frag @9cc53ba

9cfc437
931eabc
 
999f926
88f8e3e
cfc28ae
b6a1d24
 
 
 
 
 
 
 
 
f830d4f
b6a1d24
 
 
 
 
 
 
 
23db362
 
 
 
 
 
 
 
 
 
 
34c68b2
 
86d55e8
5f4657b
34c68b2
 
23db362
32fc064
 
 
 
 
 
 
999f926
ea9f59b
931eabc
e81e375
999f926
931eabc
 
 
 
1230b71
 
9cc53ba
1057693
1230b71
999f926
 
1230b71
cc003c9
 
f360093
ba39315
cc003c9
b4e5b9d
 
 
 
 
 
# -*- mode: sh -*-
set -e

abort() { local x=$1; shift; for i in "$@"; do echo >&2 "$0: abort: $i"; done; exit "$x"; }

mkdir -p "$(dirname "$0")/.git/hooks"
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 if ! [ -f "$x" ]; then continue; fi; 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.*|2.3.*)	abort 1 "unsupported debcargo version $dcver. try reinstalling with \`cargo install debcargo --force\`";;
2.4.*)	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=${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)"
ln -srf "$PWD/build.sh" "$PWD/build/build.sh"
chmod +x "$PWD/build/build.sh"

if [ -z "$CRATE" ]; then
	abort 2 "Usage: $0 <crate> [<version>]"
fi

run_debcargo() {
	rm -rf "$BUILDDIR" "$(dirname "$BUILDDIR")/rust-${PKGNAME}_${REALVER:-$VER}"*.orig.tar.*
	$DEBCARGO package --config "$PKGCFG" --directory "$BUILDDIR" "$@" "$CRATE" "${REALVER:-$VER}"
}

shouldbuild() {
	local dst="$1"
	local src="$2"
	test ! -e "$dst" -o "$src" -nt "$dst"
}