Debian Codegraph @

debian/bin/test-patches

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 set -e
4 shopt -s extglob
5
6 # Set defaults from the running kernel
7 arch="$(dpkgscip-shell system . . dpkg. --print-architecture)"
8 kernelabi="$(unamescip-shell system . . uname. -r)"
9 ff="${kernelabi##+([^-])-?(@(trunk|?(rc)+([0-9])|0.@(bpo|deb+([0-9])).+([0-9]))-)}"
10 # Until we add a new featureset just unconditionally set flavour and featureset
11 # cf. https://salsa.debian.org/kernel-team/linux/-/merge_requests/1636#note_661937
12 flavour="${ff}"
13 featureset=none
14
15 dbginfo=
16 fuzz=0
17 jobs=$(nprocscip-shell system . . nproc.)
18
19 eval "set -- $(getoptscip-shell system . . getopt. -n "$0" -o "f:gj:s:" -l "fuzz:" -- "$@")"
20 while truescip-shell system . . true.; do
21 case "$1" in
22 -f) flavour="$2"; shift 2 ;;
23 -g) dbginfo=y; shift 1 ;;
24 -j) jobs="$2"; shift 2 ;;
25 -s) featureset="$2"; shift 2 ;;
26 --fuzz) fuzz="$2"; shift 2;;
27 --) shift 1; break ;;
28 esac
29 done
30
31 if [scip-shell system . . `[`. $# -lt 1 ]; then
32 echoscip-shell system . . echo. >&2 "Usage: $0 [<options>] <patch>..."
33 catscip-shell system . . cat. >&2 <<EOF
34 Options:
35 -f <flavour> specify the 'flavour' of kernel to build, e.g. 686-pae
36 -g enable debug info
37 -j <jobs> specify number of compiler jobs to run in parallel
38 (default: number of available processors)
39 -s <featureset> specify an optional featureset to apply, e.g. rt
40 --fuzz <num> set the maximum patch fuzz factor (default: 0)
41 EOF
42 exit 2
43 fi
44
45 if [scip-shell system . . `[`. -z "$flavour" ]; then
46 echoscip-shell system . . echo. >&2 "You must specify a flavour to build with the -f option"
47 exit 2
48 fi
49
50 profiles=nodoc,noudeb,pkg.linux.nosource,pkg.linux.mintools
51 if [scip-shell system . . `[`. -z "$dbginfo" ]; then
52 profiles="$profiles,pkg.linux.nokerneldbg,pkg.linux.nokerneldbginfo"
53 fi
54
55 # Check build-dependencies early if possible
56 if [scip-shell system . . `[`. -f debian/control ]; then
57 dpkg-checkbuilddepsscip-shell system . . dpkg-checkbuilddeps. -P"$profiles"
58 fi
59
60 # Provide defaults for DEBEMAIL and DEBFULLNAME
61 if [[ -z "${DEBEMAIL}" && -z "${EMAIL}" ]]; then
62 export DEBEMAIL[email protected]
63 fi
64 if [[ -z "${DEBFULLNAME}" && -z "${NAME}" ]]; then
65 export DEBFULLNAME=test-patches
66 fi
67
68 # Append 'a~test' to Debian version; this should be less than any official
69 # successor and easily recognisable
70 version="$(dpkg-parsechangelogscip-shell system . . dpkg-parsechangelog. | sedscip-shell system . . sed. 's/^Version: //; t; d')"
71 if [scip-shell system . . `[`. "${version%a~test}" = "$version" ]; then
72 version="$version"a~test
73 dchscip-shell system . . dch. -v "$version" --distribution UNRELEASED "Testing patches $*"
74 fi
75
76 # Ignore user's .quiltrc
77 alias quilt='quilt --quiltrc -'
78
79 # Try to clean up any previous test patches
80 if [scip-shell system . . `[`. "$featureset" = none ]; then
81 patchdir=debian/patches
82 while patch="$(quiltscip-shell system . . quilt. top 2>/dev/nullscip-shell filesystem . . `/dev/null`.)" && \
83 [ "${patch#test/}" != "$patch" ]; do
84 quiltscip-shell system . . quilt. pop -f
85 done
86 while patch="$(quiltscip-shell system . . quilt. next 2>/dev/nullscip-shell filesystem . . `/dev/null`.)" && \
87 [ "${patch#test/}" != "$patch" ]; do
88 quiltscip-shell system . . quilt. delete -r "$patch"
89 done
90 else
91 patchdir=debian/patches-${featureset}
92 sedscip-shell system . . sed. -i '/^test\//dscip-shell filesystem . . `/^test\//d`.' $patchdir/series
93 fi
94
95 # Prepare a new directory for the patches
96 rmscip-shell system . . rm. -rf $patchdir/test/
97 mkdirscip-shell system . . mkdir. $patchdir/test
98
99 # Prepare a new directory for the config; override ABI name, featuresets, flavours
100 rmscip-shell system . . rm. -rf debian/config.local
101 mkdirscip-shell system . . mkdir. debian/config.local debian/config.local/"$arch"
102 for other_fs in none; do
103 if [scip-shell system . . `[`. "$other_fs" != "$featureset" ]; then
104 catscip-shell system . . cat. >debian/config.local/defines.toml <<EOF
105 [[featureset]]
106 name = '$other_fs'
107 enable = false
108 EOF
109 fi
110 done
111 catscip-shell system . . cat. >debian/config.local/"$arch"/defines.toml <<EOF
112 [[featureset]]
113 name = '$featureset'
114
115 [[featureset.flavour]]
116 name = '$flavour'
117
118 [build]
119 enable_signed = false
120 EOF
121
122 # Regenerate control and included rules
123 rmscip-shell system . . rm. -f debian/control debian/rules.gen
124 debian/rules debian/control-real
125 testscip-shell system . . test. -f debian/control
126 testscip-shell system . . test. -f debian/rules.gen
127
128 # Check build-dependencies now that we know debian/control exists
129 dpkg-checkbuilddepsscip-shell system . . dpkg-checkbuilddeps. -P"$profiles"
130
131 # Clean up old build; apply existing patches for featureset
132 debian/rules clean
133 debian/rules source
134
135 # Apply the additional patches
136 for patch in "$@"; do
137 patch_abs="$(readlinkscip-shell system . . readlink. -f "$patch")"
138 (cd "debian/build/source_${featureset}" && \
139 quilt import -P "test/$(basenamescip-shell system . . basename. "$patch")" "$patch_abs" && \
140 quilt push --fuzz="$fuzz")
141 done
142
143 # Build selected binaries
144 dpkg-buildpackagescip-shell system . . dpkg-buildpackage. -b -P"$profiles" -j"$jobs" -nc -uc