Debian Codegraph @

tools/build-deb

raw
1 #!/bin/sh
2
3 set -e
4
5 sourcename="cloud-utils"
6 RELEASE=${RELEASE:-UNRELEASED}
7 TEMP_D=""
8
9 fail() { echo "$@" 1>&2; exit 1; }
10 cleanup() {
11 [ -z "$TEMP_D" ] || rm -Rf "$TEMP_D"
12 }
13
14 if [ "$1" = "-h" -o "$1" = "--help" ]; then
15 cat <<EOF
16 Usage: ${0##*/}
17 build a deb of from trunk directory
18 any options are passed straight through to debuild
19
20 Example:
21 * ${0##*/} -us -uc
22
23 Its not significantly different than what you'd get by modifying
24 the debian/changelog to have the current HEAD, and then running
25 debuild --no-tgz-check
26 EOF
27 exit
28 fi
29
30 bname=${0##*/}
31
32 [ -n "$DEBEMAIL" ] || DEBEMAIL=$(git config user.email)
33 [ -n "$DEBFULLNAME" ] || DEBFULLNAME=$(git config user.name)
34
35 if [ -z "$DEBEMAIL" -o -z "$DEBFULLNAME" ]; then
36 echo "Must have DEBEMAIL and DEBFULLNAME in environment"
37 echo "or set git user.email and user.name."
38 fi
39
40 start_d=$PWD
41 top_d=$(cd "$(dirname "${0}")"/.. && pwd)
42
43 # git describe will output something either like '0.1.0' (a tag)
44 # or TAG-N-gHASH where N is number of commits since TAG
45 uver=$(git describe --abbrev=8) ||
46 fail "failed to get upstream version with 'git describe'"
47 clogver_debian=${CLOGVER_DEBIAN:-0ubuntu1}
48
49 clogver_new="${uver}-${clogver_debian}"
50
51 TEMP_D=$(mktemp -d "${TMPDIR:-/tmp}/${bname}.XXXXXX")
52
53 trap cleanup EXIT
54
55 echo "building upstream version ${uver}, debian ver=${clogver_debian}"
56
57 dir="${sourcename}-$uver"
58 tarball="${sourcename}_$uver.orig.tar.gz"
59
60 myd=$(dirname "$0")
61 "$myd/make-tarball" "--output=${TEMP_D}/$tarball" HEAD
62 echo "created ${tarball}"
63
64 cd "${TEMP_D}"
65 tar xzf "$tarball" || fail "failed extract tarball"
66 cd "$dir" || fail "failed cd $dir"
67
68 cat > debian/changelog <<EOF
69 $sourcename ($uver-${clogver_debian}) $RELEASE; urgency=low
70
71 * Upstream Build
72
73 -- $DEBFULLNAME <$DEBEMAIL> $(date -R)
74 EOF
75
76 debuild "$@" || fail "debuild failed"
77
78 cd "$TEMP_D"
79 for f in *; do
80 [ -f "$f" ] || continue
81 cp "$f" "$start_d" || fail "failed copy $f"
82 echo "wrote $f"
83 done
84 exit