6 Usage: ${P:-$(basename "$0")} [-h|--help] [-d|--dry-run] [-c|--include-config] [-s|--skip-master]
8 Prepare the closing release commit. Include all the changelog entries
9 in the current release, including the changes from the base
10 kernel. Also close the changelog entry and check for config changes.
13 -d, --dry-run Perform a trial run with no changes made
14 printing the commands instead.
15 -c, --include-config Include config changes in the closing commit.
16 -s, --skip-master Skip master kernel changelog entries (used when
17 bootstraping new kernels).
18 -h, --help Show this help message and exit.
21 Simply close a release:
24 Also include any config changes to the closing commit:
33 while [ "$#" -gt 0 ]; do
56 hl
() { echo -e "\e[1m$*\e[0m"; }
59 # Quote args for echo or eval
62 quoted
+=( "$(printf '%q' "$token")" )
65 if [ "$dry_run" -eq 1 ]; then
66 hl
"DRY RUN: ${quoted[*]}"
74 # Trick shellcheck so it doesn't complain every time it's necessary to
75 # use `run $CHROOT`. Use `chroot_run` instead.
76 shopt -s expand_aliases
77 alias chroot_run
='run ${CHROOT:-}'
80 # shellcheck disable=SC1091
83 # Check if the "debian.<branch>/" directory exists.
84 if [ ! -d "$DEBIAN" ]; then
85 echo "You must run this script from the top directory of this repository."
90 # Check if changelog is open
91 series
=$
(dpkg-parsechangelog
-l"$DEBIAN/changelog" -SDistribution)
92 if [ "$series" != 'UNRELEASED' ]; then
93 echo "The last entry of the changelog is already released."
98 chroot_run fakeroot debian
/rules clean updateconfigs
99 changes
=$
(git
diff HEAD
-- "./$DEBIAN/config/")
100 if [ "$commit_configs" -eq 0 ] && [ -n "$changes" ]; then
101 echo "Config has changed! please, review it and commit."
105 # Derivatives have at least one base kernel.
106 if [ "$branch" != 'master' ]; then
107 # For backports, insert the changes from the base derivative.
108 # Straight derivatives and backports such as hwe and hwe-edge, should
109 # skip that step and fetch the entries directly from the master kernel.
110 version
=$
(dpkg-parsechangelog
-l"$DEBIAN/changelog" -SVersion)
111 if [[ $version == *~
* ]]; then
112 base_version
=$
(dpkg-parsechangelog
-l"$DEBIAN/changelog" -SVersion -c1 -o1)
113 base_changelog
="${DEBIAN%-*}/changelog"
114 if [ -f "$base_changelog" ] && [ "$DEBIAN" != "${DEBIAN%-*}" ]; then
115 run .
/debian
/scripts
/misc
/insert-ubuntu-changes
"$DEBIAN/changelog" "${base_version%%~*}" "${version%%~*}" "$base_changelog"
116 skip_master_entries
=1
120 if [ "$skip_master_entries" -eq 0 ]; then
122 # Loop through each entry of the current changelog, searching for an
123 # entry that refers to the master version used as base (ie a line
124 # containing "[ Ubuntu: 4.15.0-39.42 ]"):
126 changes
=$
(dpkg-parsechangelog
-l"$DEBIAN/changelog" -SChanges -c1 -o"$offset")
127 if ! [ "$changes" ]; then
128 echo "Failed to retrieve base master version from changelog file: $DEBIAN/changelog"
131 base_master_version
=$
(echo "$changes" |
sed -n -r -e '/^\s.*\[ Ubuntu: ([0-9.-]*) \]$/{s//\1/p;q}')
132 [ "$base_master_version" ] && break
133 offset
=$
(( offset
+ 1 ))
135 master_version
=$
(dpkg-parsechangelog
-ldebian.master
/changelog
-SVersion)
136 if ! [ "$master_version" ]; then
137 echo "Failed to retrieve current master version from changelog: $DEBIAN/changelog"
140 run .
/debian
/scripts
/misc
/insert-ubuntu-changes
"$DEBIAN/changelog" "$base_master_version" "$master_version"
144 # Insert local changes
145 run fakeroot debian
/rules insertchanges
147 # This should be the last step. If there were no changes to the
148 # changelog, there is nothing to release, so nothing to commit.
149 changes
=$
(git
diff HEAD
)
150 if [ -z "$changes" ] && [ "$dry_run" -eq 0 ]; then
151 hl
"No changes to commit."
155 # Find the current series from previous changelog entries:
159 series
=$
(dpkg-parsechangelog
-l"$DEBIAN/changelog" -SDistribution -c1 -o"$offset")
160 if [ "$series" ] && [ "$series" != 'UNRELEASED' ]; then
163 offset
=$
(( offset
+ 1 ))
165 if ! [ "$series" ]; then
166 echo "Failed to retrieve the package series from changelog: $DEBIAN/changelog"
169 # Close the changelog
170 run dch
--nomultimaint -c "$DEBIAN/changelog" -r -D "$series" ''
173 package
=$
(dpkg-parsechangelog
-l"$DEBIAN/changelog" -SSource)
174 prefix
="Ubuntu$(echo "$package" | sed -r -e 's/linux(-?)/\1/')-"
175 version
=$
(dpkg-parsechangelog
-l"$DEBIAN/changelog" -SVersion)
176 run git commit
-sam "UBUNTU: $prefix$version"