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 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
|
#!/bin/bash
# Copyright: 2010-2024, gregor herrmann <gregoa@debian.org>
# 2014-2015, Salvatore Bonaccorso <carnil@debian.org>
# 2015-2023, intrigeri <intrigeri@debian.org>
# 2019, Clément Hermann <nodens@nodens.org>
# Licensed under the same terms as Perl (Artistic | GPL-1+)
# to be run from source directory
# environment:
# - BUILDDIR, defaults to ".."
# - ARCH, defaults to arch of .changes file
# initialize begin
for f in ~/.dpt.conf ~/.config/dpt.conf; do
if [ -r "$f" ]; then
. "$f"
fi
done
# shellcheck source=../scripts/lib/dpt-lib.sh
OOT=1 . "${DPT__SCRIPTS:-/usr/share/pkg-perl-tools}/lib/dpt-lib.sh"
# initialize end
# functions #
notify() {
local command=$1
local urgency=${2:-normal}
if [ -x /usr/bin/notify-send ] && [ -n "$DISPLAY" ] && [ -n "$command" ] ; then
notify-send -u "$urgency" -t 5000 "$command finished" "$(dpkg-parsechangelog | grep -E '^(Source|Version)')"
fi
}
# main #
BUILDDIR=${BUILDDIR:-".."}
if [ ! -d "$BUILDDIR" ] ; then
die "Build directory \"$BUILDDIR\" does not exist.\n" \
" Maybe you forgot to set the BUILDDIR variable?\n" \
" Exiting ..."
fi
rm -rf "$BUILDDIR"/*obsolete*
rm -f "$BUILDDIR"/*.dsc.asc
PACKAGE=$(dpkg-parsechangelog -S Source)
VERSION=$(dpkg-parsechangelog -S Version | perl -pe 's|^\d+:||')
if [ -z "$ARCH" ] ; then
# Since we use a ls sorting option, implementing this without ls|grep
# would require quite some efforts.
# shellcheck disable=SC2010
CHANGES=$(ls -1rt "$BUILDDIR/${PACKAGE}_${VERSION}"_*.changes \
| grep -v -E '_source\.changes$' \
| tail -n 1)
ARCH=$(basename "${CHANGES##"$BUILDDIR/${PACKAGE}_${VERSION}"_}" .changes)
else
CHANGES="$BUILDDIR/${PACKAGE}_${VERSION}_${ARCH}.changes"
fi
BUILD="$BUILDDIR/${PACKAGE}_${VERSION}_${ARCH}.build"
DSC="$BUILDDIR/${PACKAGE}_${VERSION}.dsc"
if [ ! -r "$CHANGES" ] || ! [ -r "$DSC" ] ; then
die "Can't read \"$CHANGES\" or \"$DSC\".\n" \
" Is BUILDDIR set correctly: \"$BUILDDIR\"?\n" \
" Exiting ..."
fi
if is_command lintian; then
header "lintian"
#lintian -i -I --show-overrides --pedantic --color auto --no-tag-display-limit "$CHANGES"
#~/.lintianrc, lintian 2.5.1;
#--output-width since 2.105.0
LINTIANVERSION=$(dpkg-query -f '${Version}\n' -W lintian)
if dpkg --compare-versions "$LINTIANVERSION" ge 2.105.0 ; then
lintian --output-width 80 "$CHANGES"
else
lintian "$CHANGES"
fi
fi
if [ -r "$BUILD" ] && ! grep -E -q "^Architecture: all$" "$DSC" ; then
if is_command blhc; then
header "blhc"
blhc --buildd "$BUILD"
fi
fi
if is_command duck; then
header "duck"
timeout 30s duck
fi
echo
if promptyesno "debc?"; then
debc -a "$ARCH" "$CHANGES" | less
fi
echo
if promptyesno "piuparts?"; then
PIUPARTSLOG="${CHANGES%.changes}_piuparts.log"
CHROOT=
# default is --no-minimize; add --minimize for pbuilder/cowbuilder, not for schroot
[ -f /var/cache/pbuilder/base.tar.gz ] && CHROOT="--pbuilder --minimize"
[ -f /var/cache/pbuilder/base.tgz ] && CHROOT="--pbuilder --minimize"
[ -d /var/cache/pbuilder/base.cow ] && CHROOT="--existing-chroot /var/cache/pbuilder/base.cow --minimize"
# no eatmydata in chroot; proxy not resolvable
if [ -x /usr/bin/schroot ] && schroot -l | grep -q default; then
CHROOT="--schroot default --no-eatmydata --proxy=DIRECT"
fi
CHANGESPIU="${CHANGES%.changes}_piuparts.changes"
if grep -qE "^Binary: .+-dbgsym.*$" "$CHANGES" ; then
grep -vE '\-dbgsym_.+\.deb$' "$CHANGES" > "$CHANGESPIU"
else
cp "$CHANGES" "$CHANGESPIU"
fi
echo
# since 1.5.0 /usr/sbin/piuparts -> /usr/bin/piuparts
PIUPARTSVERSION=$(dpkg-query -f '${Version}\n' -W piuparts)
if dpkg --compare-versions "$PIUPARTSVERSION" ge 1.5.0 ; then
PIUPARTSBIN=/usr/bin/piuparts
else
PIUPARTSBIN=/usr/sbin/piuparts
fi
# log-level: error < info < debug < dump
# Deliberately word splitting CHROOT
# shellcheck disable=SC2086
sudo $PIUPARTSBIN \
$CHROOT -t "${TMPDIR:-/tmp}" \
--warn-on-others --warn-on-debsums-errors --skip-logrotatefiles-test \
--log-level=debug --log-file="$PIUPARTSLOG" \
"$CHANGESPIU"
rm "$CHANGESPIU"
notify piuparts
fi
echo
if promptyesno "reprotest?"; then
REPROTESTLOG="${CHANGES%.changes}_reprotest.log"
if [ -x /usr/bin/schroot ] && schroot -l | grep -q default; then
REPROTEST_VIRT_SERVER=schroot
REPROTEST_VIRT_SERVER_ARGS=default
fi
if [ -n "$REPROTEST_VIRT_SERVER" ]; then
REPROTESTPARAMS=("--variations=+all,-user_group,-domain_host,-fileordering,-time" "--vary=environment.variables+=SHELL=/bin/dash" "--verbosity 1" . )
echo
# Deliberately word splitting variables
# shellcheck disable=SC2086
# Deliberately word splitting array
# shellcheck disable=SC2068
env -u TMPDIR CCACHE_DIR=/tmp/.ccache reprotest ${REPROTESTPARAMS[@]} -- $REPROTEST_VIRT_SERVER $REPROTEST_VIRT_SERVER_ARGS 2>&1 | \
tee $REPROTESTLOG
notify reprotest
else
warn "Could not find reprotest virtualization server."
fi
fi
echo
if grep -q 'Testsuite: autopkgtest' debian/control || [ -f debian/tests/control ]; then
if promptyesno "autopkgtest?"; then
AUTOPKGTESTLOG="${CHANGES%.changes}_autopkgtest.log"
if ! [ -v AUTOPKGTEST_VIRT_SERVER ]; then
if [ -x /usr/bin/schroot ] && schroot -l | grep -q default; then
AUTOPKGTEST_VIRT_SERVER=schroot
AUTOPKGTEST_VIRT_SERVER_ARGS=default
fi
fi
if [ -n "$AUTOPKGTEST_VIRT_SERVER" ]; then
echo
# Deliberately word splitting variables
# shellcheck disable=SC2086
autopkgtest "$CHANGES" --log-file="$AUTOPKGTESTLOG" --shell-fail $AUTOPKGTEST_ARGS -- \
$AUTOPKGTEST_VIRT_SERVER $AUTOPKGTEST_VIRT_SERVER_ARGS
SUCCESS=$?
case $SUCCESS in
0)
URGENCY=normal
;;
2)
warn "autopkgtest: at least one test was skipped (or at least one flaky test failed)."
URGENCY=normal
;;
8)
warn "autopkgtest: no tests in this package, or all non-superficial tests were skipped."
URGENCY=normal
;;
*)
colored "RED" "autopkgtest: failed ($SUCCESS)."
URGENCY=critical
;;
esac
exec 0</dev/tty
notify autopkgtest $URGENCY
else
warn "Could find no autopkgtest virtualization server."
fi
# TODO:
# since 3.7 we get colours but only without --log-file=. and on STDERR.
# See https://git-tails.immerda.ch/tails/tree/run_test_suite?h=testing
# for an example of how to get colours on the terminal,
# while still creating a log file without control chars.
fi
fi
echo
PKGVER=$(echo "${PACKAGE}-${VERSION}" | perl -pe 's;^(.+)(?:-.+)$;$1;')
AUTOPATCH="debian/patches/debian-changes-${VERSION}"
DIFFGZ="$BUILDDIR/${PACKAGE}_${VERSION}.diff.gz"
DEBGZ="$BUILDDIR/${PACKAGE}_${VERSION}.debian.tar.gz"
DEBBZ2="$BUILDDIR/${PACKAGE}_${VERSION}.debian.tar.bz2"
DEBXZ="$BUILDDIR/${PACKAGE}_${VERSION}.debian.tar.xz"
[ -e "$DEBGZ" ] || DEBGZ="$DEBBZ2"
[ -e "$DEBGZ" ] || DEBGZ="$DEBXZ"
FORMAT=$(grep ^Format: "$DSC" | cut -f2 -d" ")
if [ "$FORMAT" = "1.0" ] && [ -e "$DIFFGZ" ] && zgrep -E "^\+\+\+ " "$DIFFGZ" | grep -q -v "$PKGVER/debian"; then
echo
warn "Changes in .diff.gz outside debian/!"
if promptyesno "View .diff.gz? y/N"; then
filterdiff -z -x "$PKGVER/debian/*" "$DIFFGZ" | colordiff | /usr/bin/less -R
fi
echo
info "Maybe: mkdir -p debian/patches && diff2patches $DIFFGZ"
echo
elif [ "$FORMAT" = "3.0" ] && [ -e "$DEBGZ" ] && tar tvf "$DEBGZ" | grep -q "$AUTOPATCH"; then
echo
warn "Automatically created patch in .debian.tar.gz/.bz2/.xz!"
if promptyesno "View .debian.tar.gz/.bz2/.xz? y/N"; then
tar xf "$DEBGZ" "$AUTOPATCH" --to-stdout | colordiff | /usr/bin/less -R
fi
echo
info "Maybe: tar xf $DEBGZ $AUTOPATCH"
echo
else
if promptyesno "Ready for upload?"; then
echo
cat "$CHANGES"
echo
BUILDINFO="${CHANGES%%.changes}".buildinfo
if grep -q "\.u\?deb" "$CHANGES"; then
if promptyesno "Strip binary .(u)debs?"; then
SOURCEONLYCHANGES="${CHANGES%%_"$ARCH".changes}_sourceonly.changes"
mergechanges --source "$CHANGES" "$CHANGES" > "$SOURCEONLYCHANGES"
if [ -f "$BUILDINFO" ]; then
if [ -x /usr/bin/changestool ]; then
SOURCEONLYBUILDINFO="${BUILDINFO%%_"$ARCH".buildinfo}_sourceonly.buildinfo"
cp "$BUILDINFO" "$SOURCEONLYBUILDINFO"
changestool "$SOURCEONLYCHANGES" add "$SOURCEONLYBUILDINFO"
else
echo
warn "Can't find changestool (from reprepro package)."
fi
fi
echo
cat "$SOURCEONLYCHANGES"
CHANGES="$SOURCEONLYCHANGES"
else
echo
# Fallback to question if only want to strip arch:any (u)debs
if promptyesno "Strip arch:any .(u)debs"; then
ALLONLYCHANGES="${CHANGES%%_"$ARCH".changes}_allonly.changes"
mergechanges --indep "$CHANGES" "$CHANGES" > "$ALLONLYCHANGES"
if [ -f "$BUILDINFO" ]; then
if [ -x /usr/bin/changestool ]; then
ALLONLYBUILDINFO="${BUILDINFO%%_"$ARCH".buildinfo}_allonly.buildinfo"
cp "$BUILDINFO" "$ALLONLYBUILDINFO"
changestool "$ALLONLYCHANGES" add "$ALLONLYBUILDINFO"
else
echo
warn "Can't find changestool (from reprepro package)."
fi
fi
echo
cat "$ALLONLYCHANGES"
CHANGES="$ALLONLYCHANGES"
fi
fi
echo
fi
debsign "$CHANGES"
echo
echo dput "$(readlink -f "$CHANGES")"
fi
echo
fi
|