6 Usage: ${P:-$(basename "$0")} [-h|--help] [-d|--dry-run] [-r|--reuse-abi]
8 Create a "start new release" commit. The new commit will contain ABI
9 changes and any customization required by backport kernels.
12 -d, --dry-run Perform a trial run with no changes made
13 printing the commands instead.
14 -r, --reuse-abi Do not download the previous release ABI files
15 for the new release and just rename the
16 current ABI directory. This might cause the
17 build to fail if the module list or the
18 retpoline information has changed.
19 -h, --help Show this help message and exit.
22 CRANKY_MAILENFORCE Regular expression used to validate \$DEBEMAIL. If not
23 set, it defaults to "@canonical.com$".
26 Simply start a new release (that will fetch the ABI files from the
27 archieve repositories):
30 Start a new release re-using the ABI files already present in the
32 \$ cranky open --reuse-abi
39 while [ "$#" -gt 0 ]; do
59 hl
() { echo -e "\e[1m$*\e[0m"; }
62 # Quote args for echo or eval
65 quoted
+=("$(printf '%q' "$token")")
68 if [ "$dry_run" -eq 1 ]; then
69 hl
"DRY RUN: ${quoted[*]}"
77 # Trick shellcheck so it doesn't complain every time it's necessary to
78 # use `run $CHROOT`. Use `chroot_run` instead.
79 shopt -s expand_aliases
80 alias chroot_run
='run ${CHROOT:-}'
82 # Check DEBEMAIL (used to create the new changelog stanza):
83 DEBEMAIL
="${DEBEMAIL:-}"
84 CRANKY_MAILENFORCE
="${CRANKY_MAILENFORCE:-@canonical.com\$}"
85 if [ -z "$DEBEMAIL" ] ||
! echo "$DEBEMAIL" |
grep -qE "$CRANKY_MAILENFORCE"; then
86 echo "DEBEMAIL is unset, or does not contain \"$CRANKY_MAILENFORCE\": $DEBEMAIL" >&2
91 if [ ! -e .git
]; then
92 echo "Not a git repository!" >&2
96 # Check the debian directory
97 if [ ! -e debian
/debian.env
]; then
98 echo "Cannot find debian/debian.env!" >&2
102 # shellcheck disable=SC1091
104 if [ -z "$DEBIAN" ] ||
[ ! -d "$DEBIAN" ]; then
105 echo "Invalid DEBIAN directory: $DEBIAN" >&2
109 # Abort if changes or untracked files are found in the debian
110 # directory (ie, in "debian.master/"). cranky-open is expected to
111 # change and commit files in this directory.
112 if ! git diff-index
--quiet HEAD
-- "$DEBIAN/" || \
113 [ -n "$(git ls-files --others -- "$DEBIAN/")" ]; then
114 echo "\"$DEBIAN/\" is not clean!" >&2
119 series
=$
(dpkg-parsechangelog
-l"$DEBIAN/changelog" -SDistribution)
120 if [ "$series" == 'UNRELEASED' ]; then
121 echo "$DEBIAN/changelog is not closed!" >&2
125 # Load the info about derivative
127 derivative_conf
="$DEBIAN/etc/update.conf"
128 if [ -f "$derivative_conf" ]; then
129 # shellcheck disable=SC1090
133 # Run the update script used for backport kernels
134 if [ -n "$BACKPORT_SUFFIX" ]; then
135 update_from_master_script
="$DEBIAN/scripts/helpers/copy-files"
136 if [ ! -x "$update_from_master_script" ]; then
137 echo "Backport kernel is missing the"\
138 "\"$update_from_master_script\" script!";
141 # The tree should be clean at this point, since that is enforced at
142 # the beginning of the script. Because of that, it's safe to git add
144 run env CHROOT
="$CHROOT" "$update_from_master_script"
145 run git add
"$DEBIAN"
146 # Update configs after the necessary files were copied from
147 # the base kernel. It's not expected that `fdr updateconfigs`
148 # will fail at this point, because the base kernel's
149 # configuration and annotations file are expected to be in a
150 # correct state. `fdr updateconfigs` should only change a few
151 # configuration options that depend on the userspace tooling
152 # version, such as gcc.
153 if ! chroot_run fakeroot debian
/rules clean updateconfigs
; then
154 echo "Failed to update configs. Please review the previous" \
155 "rebase operation and \"$update_from_master_script\"";
158 run git add
"$DEBIAN/config"
161 # fdr clean should be called after copy-files, that way we can git add
162 # any changes in "debian.<branch>/" (`fdr clean` in trusty will
163 # usually generate changes in "debian.<branch>/). Also, fdr clean
164 # removes an ABI that matches the current version in the
165 # changelog. Since `fdr startnewrelease` requires `fdr clean`, we need
166 # to call it before getabis.
167 chroot_run fakeroot debian
/rules clean
170 if [ -d "$DEBIAN/abi" ]; then
171 # The new ABI directory should use the current version in the
172 # changelog since `fdr startnewrelease` was't called at this
174 new
=$
(dpkg-parsechangelog
-l"$DEBIAN/changelog" -SVersion)
176 if [ "$reuse_abi" -ne 0 ]; then
177 # Get the old ABI directory:
178 old
=$
(find "$DEBIAN/abi/" -mindepth 1 -maxdepth 1 -type d
-a -name "${new%%-*}*")
179 if [ "$(echo "$old" | wc -l)" -gt 1 ]; then
180 echo "Failed to rename the current ABI directory." \
181 "Multiple directories found. Please check \"$DEBIAN/abi/\"!" >&2
184 new
="$DEBIAN/abi/$new"
185 # Rename the ABI directory
186 run git
mv "$old" "$new"
188 # Call in-tree getabis:
189 # Use the single argument form since getabis is now
190 # updated by cranky fix.
191 run debian
/scripts
/misc
/getabis
"${new}"
192 # getabis already handles the necessary git add/rm calls.
196 # Create the new changelog entry:
197 run fakeroot debian
/rules startnewrelease
198 run git add
"$DEBIAN/changelog"
201 run git commit
-s -F debian
/commit-templates
/newrelease
203 # Perform a basic ABI check
204 if [ "$dry_run" -eq 0 ]; then
205 version
=$
(dpkg-parsechangelog
-l"$DEBIAN/changelog" -SVersion -c1 -o1)
206 abi_dir
="$DEBIAN/abi/$version"
207 [ ! -d "$abi_dir" ] && hl
"Warning: ABI directory is missing: $abi_dir"
210 # Mimic maint-startnewrelease
211 [ "$dry_run" -eq 0 ] && \
212 hl
"\n***** Now please inspect the commit before pushing *****"