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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
#!/bin/bash
# Copyright 2010-2024, gregor herrmann <gregoa@debian.org>
# Copyright 2011-2012, Salvatore Bonaccorso <carnil@debian.org>
#
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# wrapper script for building and checking packages
# with [(svn|git)-buildpackage and] pdebuild
# Usage:
# svn-bp: ~/.svn-buildpackage.conf:
# svn-builder=buildpackage-pdebuild
# git-bp: ~/.gbp.conf:
# builder = buildpackage-pdebuild
# or call it directly
BUILDER=
DEBBUILDOPTS=
DEB_BUILD_OPTIONS=
DEB_BUILD_PROFILES=
PDEBUILDOPTS=
PBUILDEROPTS=
VCS=
BUILDDIR=".."
ME="$(basename $0)"
# where are we?
[ -n "$SVN_BUILDPACKAGE" ] && VCS=svn
[ -n "$GBP_BUILD_DIR" ] && VCS=git
# options:
# D foo = distribution foo
# b = binary-arch
# a = binary-indep
# g = --build=source,all
# S = source
# j = -jX
# s = -sa
# i = pdebuild-internal
# w = twice
# v = -vX
# t = notest
# n = noopt
# o = nodoc
# p = nostrip
# h = hardening
# d = DH_VERBOSE
# H = hookdir
# A = host-Arch
# c = -nc # enable by default?
while getopts D:bagScj:siwv:tnophdHA: O; do
case "$O" in
# pbuilder example
#P)
# BUILDER="--pbuilder pbuilder"
# PBUILDEROPTS="$PBUILDEROPTS --basetgz /var/cache/pbuilder/base.tgz"
# ;;
# qemubuilder example
#Q)
# DEBBUILDOPTS="$DEBBUILDOPTS -aarmel"
# BUILDER="--pbuilder qemubuilder"
# PBUILDEROPTS="$PBUILDEROPTS --configfile /var/cache/pbuilder/armel/armel-rc"
# PBUILDEROPTS="$PBUILDEROPTS --basepath /var/cache/pbuilder/${OPTARG}-base.qemu"
# ;;
D)
PBUILDEROPTS="$PBUILDEROPTS --basepath /var/cache/pbuilder/${OPTARG}-base.cow"
;;
b)
PBUILDEROPTS="$PBUILDEROPTS --binary-arch"
;;
a)
PBUILDEROPTS="$PBUILDEROPTS --binary-indep"
;;
g)
# broken. #899224
DEBBUILDOPTS="$DEBBUILDOPTS -g"
;;
S)
# broken. #867822
DEBBUILDOPTS="$DEBBUILDOPTS -S"
;;
c)
DEBBUILDOPTS="$DEBBUILDOPTS -nc"
;;
j)
DEBBUILDOPTS="$DEBBUILDOPTS -j${OPTARG}"
DEB_BUILD_OPTIONS="$DEB_BUILD_OPTIONS parallel=${OPTARG}"
;;
s)
DEBBUILDOPTS="$DEBBUILDOPTS -sa"
;;
i)
PDEBUILDOPTS="$PDEBUILDOPTS --use-pdebuild-internal"
;;
w)
PBUILDEROPTS="$PBUILDEROPTS --twice"
;;
v)
DEBBUILDOPTS="$DEBBUILDOPTS -v${OPTARG}"
;;
t)
DEB_BUILD_OPTIONS="$DEB_BUILD_OPTIONS nocheck"
DEB_BUILD_PROFILES="$DEB_BUILD_PROFILES nocheck"
;;
o)
DEB_BUILD_OPTIONS="$DEB_BUILD_OPTIONS nodoc"
DEB_BUILD_PROFILES="$DEB_BUILD_PROFILES nodoc"
;;
n)
DEB_BUILD_OPTIONS="$DEB_BUILD_OPTIONS noopt"
;;
p)
DEB_BUILD_OPTIONS="$DEB_BUILD_OPTIONS nostrip"
;;
h)
export DEB_BUILD_HARDENING=1
;;
d)
export DH_VERBOSE=1
;;
H)
PBUILDEROPTS="$PBUILDEROPTS --hookdir ${OPTARG}"
;;
A)
PBUILDEROPTS="$PBUILDEROPTS --host-arch ${OPTARG}"
;;
*)
;;
esac
done
shift $((OPTIND - 1))
[ -n "$PBUILDEROPTS" ] && PBUILDEROPTS="-- $PBUILDEROPTS"
[ -n "$DEB_BUILD_OPTIONS" ] && export "DEB_BUILD_OPTIONS=${DEB_BUILD_OPTIONS:1}"
[ -n "$DEB_BUILD_PROFILES" ] && export "DEB_BUILD_PROFILES=${DEB_BUILD_PROFILES:1}"
pdebuild --buildresult $BUILDDIR/ $PDEBUILDOPTS --debbuildopts "$DEBBUILDOPTS" $BUILDER $PBUILDEROPTS "$@"
SUCCESS=$?
case $SUCCESS in
0)
URGENCY=normal
;;
*)
URGENCY=critical
;;
esac
if [ -x /usr/bin/notify-send -a -n "$DISPLAY" ] ; then
notify-send -u $URGENCY -t 5000 "$ME finished" "$(dpkg-parsechangelog | grep -E '^(Source|Version)')"
fi
# unset exported variables to avoid leaking them, e.g. into autopkgtests
unset DEB_BUILD_HARDENING DH_VERBOSE DEB_BUILD_OPTIONS DEB_BUILD_PROFILES
if [ $SUCCESS = 0 -a -e $(dirname $0)/check-build ] ; then
bash $(dirname $0)/check-build
fi
# when called directly ...
if [ -d .pc ] && ! quilt applied >/dev/null 2>&1 ; then
rm -rf .pc
fi
[ -n "$VCS" ] && \
find $BUILDDIR -maxdepth 1 -type d -a -not -wholename "$BUILDDIR" -print0 | xargs -r0 rm -r
exit $SUCCESS
|