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
|
#!/bin/sh
. "${DPT__SCRIPTS:-/usr/share/pkg-perl-tools}/lib/dpt-lib.sh"
set -e
set -u
not_is_dirty() {
git diff --quiet
}
# defaults for configuration variable(s)
DPT_FIXUP_DOUBLECHECK=${DPT_FIXUP_DOUBLECHECK:-''}
# check at the beginning
not_is_dirty || die "Your Git repo is dirty. Please fix."
# reformat before actual changes
header "Reformat debian/control"
cme modify dpkg-control -save
not_is_dirty || git commit -a -m 'Reformat debian/control with cme' -m 'Gbp-Dch: ignore' || true
# autopkgtest
header "Testsuite: autopkgtest-pkg-perl"
if is_pkg_perl && ! grep -qF "Testsuite: autopkgtest-pkg-perl" debian/control; then
cme modify dpkg-control source 'Testsuite="autopkgtest-pkg-perl"'
not_is_dirty || git commit -a -m 'Mark package as autopkgtest-able.' || true
fi
# Standards-Version
header "Standards-Version"
if ! grep -qF "Standards-Version: 4.7.2" debian/control; then
cme modify dpkg-control source 'Standards-Version="4.7.2"'
not_is_dirty || git commit -a -m 'Declare compliance with Debian Policy 4.7.2.' || true
fi
# R³
header "Rules-Requires-Root"
if ! grep -qF chown debian/rules && ! grep -qF Rules-Requires-Root debian/control; then
cme modify dpkg-control source 'Rules-Requires-Root="no"'
not_is_dirty || git commit -a -m 'Set Rules-Requires-Root: no.' || true
fi
#debhelper
header "debhelper"
if ! grep -E -q "debhelper-compat.*(13|14)" debian/control; then
rm -f debian/compat
perl -pi -e 's/debhelper\s*?(,|$)/debhelper-compat (= 13)$1/;' \
-e 's/debhelper[^)]+/debhelper-compat (= 13/' debian/control
not_is_dirty || git commit -a -m 'Bump debhelper-compat to 13.' || true
fi
# other fixes, mostly versioned dependencies.
if [ -n "$DPT_FIXUP_DOUBLECHECK" ]; then
header "cme fix dpkg-control" $(colored "MAGENTA" "(!)")
cme fix dpkg-control
not_is_dirty || git commit -a -m 'Drop unneeded version constraints from (build) dependencies.' || true
fi
# cross builds
if is_pkg_perl && grep -qF "Architecture: any" debian/control; then
grep -qF perl-xs-dev debian/control || cme modify dpkg-control 'source Build-Depends:.insort(perl-xs-dev)'
if ! grep -qF perl:native debian/control; then
cme modify dpkg-control 'source Build-Depends:=~s/^perl$/perl:native/'
cme modify dpkg-control 'source Build-Depends:=~"s/^perl \(>/perl:native (>/"'
cme modify dpkg-control 'source Build-Depends:.insort(perl:native)'
fi
not_is_dirty || git commit -a -m "Update Build-Depends for cross builds." || true
fi
# hardening
header "Hardening flags"
if grep -q "DEB_BUILD_MAINT_OPTIONS.*bindnow" debian/rules; then
perl -pi -e 's/hardening=\+bindnow/hardening=+all/' debian/rules
not_is_dirty || git commit -a -m "Update 'DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow' to '=+all'." || true
fi
if grep -qF "Architecture: any" debian/control && ! grep -Lq "DEB_BUILD_MAINT_OPTIONS.*hardening" debian/rules; then
perl -pi -e 's/%:/export DEB_BUILD_MAINT_OPTIONS = hardening=+all\n\n%:/' debian/rules
not_is_dirty || git commit -a -m "Enable all hardening flags." || true
fi
# <!nocheck>
if [ -n "$DPT_FIXUP_DOUBLECHECK" ]; then
header "<!nocheck> annotations" $(colored "MAGENTA" "(!)")
if is_pkg_perl; then
PERL5LIB="$DPT__SCRIPTS/../lib" "$DPT__SCRIPTS/lib/guess-nocheck.pl" && \
cme modify dpkg-control -save
not_is_dirty || git commit -a -m 'Annotate test-only build dependencies with <!nocheck>.' || true
fi
fi
# "3.0 (quilt)"
header "Source format"
if [ ! -f debian/source/format ]; then
mkdir -p debian/source
echo '3.0 (quilt)' > debian/source/format
git add debian/source
not_is_dirty || git commit -m 'Switch to source format "3.0 (quilt)".'
fi
# Module::Build
header "libmodule-build-perl"
if [ -f Build.PL ] && ! grep -q libmodule-build debian/control; then
cme modify dpkg-control 'source Build-Depends:.insort(libmodule-build-perl)'
not_is_dirty || git commit -a -m "Add explicit build dependency on libmodule-build-perl." || true
fi
# sort
header "Sort dependencies"
cme modify dpkg-control 'source Build-Depends:.sort Build-Depends-Indep:.sort Build-Conflicts:.sort'
cme modify dpkg-control "binary:~/./ Depends:.sort Recommends:.sort Suggests:.sort Breaks:.sort Replaces:.sort Conflicts:.sort Provides:.sort"
not_is_dirty || git commit -a -m '(Re-)sort dependencies' -m 'Gbp-Dch: ignore' || true
# d/watch
header "debian/watch"
if [ -f debian/watch ] && grep -qF 'version=3' debian/watch; then
sed -i -e 's/version=3/version=4/' debian/watch
perl -pi -e 's,/(\S+)-v.+$,/$1-v?\@ANY_VERSION\@\@ARCHIVE_EXT\@\$,g' debian/watch
not_is_dirty || git commit -a -m 'debian/watch: use uscan version 4.' || true
fi
# d/copyright
header "Packaging copyright years"
cme run update-my-copyright-year --commit="Update years of packaging copyright." || true
# whitespace
header "Trailing whitespace"
for f in $(find debian -maxdepth 1 -type f) debian/source/* debian/upstream/* ; do
[ ! -f "$f" ] || sed -i -e :a -e '/^\n*$/{$d;N;};/\n$/ba' -e 's@[[:space:]]*$@@g' "$f"
done
not_is_dirty || git commit -a -m 'Remove trailing whitespace from debian/*.' -m 'Gbp-Dch: ignore' || true
# lintian-brush
if [ -n "$DPT_FIXUP_DOUBLECHECK" ]; then
header "lintian-brush" $(colored "MAGENTA" "(!)")
if is_command lintian-brush; then
[ -d .pc ] && ! quilt applied >/dev/null 2>&1 && rm -rf .pc || true
lintian-brush --modern --no-update-changelog --opinionated --uncertain
fi
fi
POD=<<'EOF'
=head1 NAME
dpt-fixup - apply some automatic fixes to packaging
=head1 SYNOPSIS
B<dpt fixup>
=head1 DESCRIPTION
B<dpt fixup> does some automatic cleanups and fixups for the packaging, with
a focus on but not limited to Debian Perl Group packages. It is basically a
wrapper around L<cme(1)> and other tools.
=head1 CONFIGURATION
Some of the changes done by tools called by B<dpt fixup> need human
double-checking. These fixes are only run if the C<DPT_FIXUP_DOUBLECHECK>
environment variable is set.
If you set this variable, please do double-check the changes made in the
steps denoted by '(!)' in the output.
See L<dpt-config(5)> for details.
=head1 COPYRIGHT & LICENSE
=over
=item Copyright 2022-2025 gregor herrmann L<gregoa@debian.org>
=back
This program is free software, licensed under the same terms as perl.
=cut
EOF
|