stable-update: Rewrite stable-update.sh in Python
This fixes some of the problems dch was causing: - Putting the stable log in the wrong place - Updating the date unnecessarily Change stable-update.sh to be a wrapper for stable-update. Delete ckt-stable-update.sh; if we need it again in future, it can be implemented more cleanly as part of the new script.
This commit is contained in:
parent
d25555f798
commit
12fe9efbc6
|
@ -75,10 +75,9 @@ Aside from those general rules:
|
||||||
list all changes that are relevant to our package and that fix bugs
|
list all changes that are relevant to our package and that fix bugs
|
||||||
that we would consider 'important' or higher severity
|
that we would consider 'important' or higher severity
|
||||||
|
|
||||||
- The script debian/bin/stable-update.sh updates the changelog
|
- The script debian/bin/stable-update updates the changelog
|
||||||
version and inserts the list of changes (but it doesn't always
|
version and inserts the list of changes. It doesn't attempt to
|
||||||
put it in the right place!). It doesn't attempt to filter out
|
filter out irrelevant or unimportant changes.
|
||||||
irrelevant or unimportant changes.
|
|
||||||
|
|
||||||
- The script debian/bin/ckt-stable-update.sh does the same for
|
- The script debian/bin/ckt-stable-update.sh does the same for
|
||||||
stable updates by the Canonical Kernel Team.
|
stable updates by the Canonical Kernel Team.
|
||||||
|
|
|
@ -1,76 +0,0 @@
|
||||||
#!/bin/bash -eu
|
|
||||||
|
|
||||||
if [ $# -ne 2 ]; then
|
|
||||||
echo >&2 "Usage: $0 REPO VERSION"
|
|
||||||
echo >&2 "REPO is the git repository to generate a changelog from"
|
|
||||||
echo >&2 "VERSION is the stable version (without leading v)"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get base version, i.e. the stable release that a branch started from
|
|
||||||
base_version() {
|
|
||||||
local ver
|
|
||||||
ver="${1%-rc*}"
|
|
||||||
case "$ver" in
|
|
||||||
*-ckt*)
|
|
||||||
ver="${ver%-*}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
echo "$ver"
|
|
||||||
}
|
|
||||||
|
|
||||||
add_update() {
|
|
||||||
local base update
|
|
||||||
base="$(base_version "$1")"
|
|
||||||
update="${1#$base-ckt}"
|
|
||||||
if [ "$update" = "$1" ]; then
|
|
||||||
update=0
|
|
||||||
fi
|
|
||||||
update="$((update + $2))"
|
|
||||||
if [ $update = 0 ]; then
|
|
||||||
echo "$base"
|
|
||||||
else
|
|
||||||
echo "$base-ckt$update"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get next stable update version
|
|
||||||
next_update() {
|
|
||||||
add_update "$1" 1
|
|
||||||
}
|
|
||||||
|
|
||||||
export GIT_DIR="$1/.git"
|
|
||||||
|
|
||||||
new_ver="$2"
|
|
||||||
cur_pkg_ver="$(dpkg-parsechangelog | sed -n 's/^Version: //p')"
|
|
||||||
cur_ver="${cur_pkg_ver%-*}"
|
|
||||||
|
|
||||||
if [ "$(base_version "$new_ver")" != "$(base_version "$cur_ver")" ]; then
|
|
||||||
echo >&2 "$new_ver is not on the same stable series as $cur_ver"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$cur_pkg_ver" in
|
|
||||||
*~exp*)
|
|
||||||
new_pkg_ver="$new_ver-1~exp1"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
new_pkg_ver="$new_ver-1"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# dch insists on word-wrapping everything, so just add the first line initially
|
|
||||||
dch -v "$new_pkg_ver" --preserve --multimaint-merge -D UNRELEASED \
|
|
||||||
--release-heuristic=changelog 'New upstream stable update:'
|
|
||||||
|
|
||||||
# Then append the shortlogs with sed
|
|
||||||
sed -i '1,/^ --/ { /New upstream stable update:/ { a\
|
|
||||||
'"$(
|
|
||||||
while [ "v$cur_ver" != "v$new_ver" ]; do
|
|
||||||
next_ver="$(next_update "$cur_ver")"
|
|
||||||
echo " http://kernel.ubuntu.com/stable/ChangeLog-$next_ver\\"
|
|
||||||
git log --reverse --pretty=' - %s\' "v$cur_ver..v$next_ver^"
|
|
||||||
cur_ver="$next_ver"
|
|
||||||
done)"'
|
|
||||||
|
|
||||||
} }' debian/changelog
|
|
|
@ -0,0 +1,126 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append(sys.path[0] + "/../lib/python")
|
||||||
|
|
||||||
|
import os, re, subprocess
|
||||||
|
|
||||||
|
from debian_linux.debian import Changelog, VersionLinux
|
||||||
|
|
||||||
|
def base_version(ver):
|
||||||
|
# Assume base version is at least 3.0, thus only 2 components wanted
|
||||||
|
match = re.match(r'^(\d+\.\d+)', ver)
|
||||||
|
assert match
|
||||||
|
return match.group(1)
|
||||||
|
|
||||||
|
def add_update(ver, inc):
|
||||||
|
base = base_version(ver)
|
||||||
|
if base == ver:
|
||||||
|
update = 0
|
||||||
|
else:
|
||||||
|
update = int(ver[len(base)+1:])
|
||||||
|
update += inc
|
||||||
|
if update == 0:
|
||||||
|
return base
|
||||||
|
else:
|
||||||
|
return '{}.{}'.format(base, update)
|
||||||
|
|
||||||
|
def next_update(ver):
|
||||||
|
return add_update(ver, 1)
|
||||||
|
|
||||||
|
def print_stable_log(log, cur_ver, new_ver):
|
||||||
|
major_ver = re.sub(r'^(\d+)\..*', r'\1', cur_ver)
|
||||||
|
while cur_ver != new_ver:
|
||||||
|
next_ver = next_update(cur_ver)
|
||||||
|
print(' https://www.kernel.org/pub/linux/kernel/v{}.x/ChangeLog-{}'
|
||||||
|
.format(major_ver, next_ver),
|
||||||
|
file=log)
|
||||||
|
log.flush() # serialise our output with git's
|
||||||
|
subprocess.check_call(['git', 'log', '--reverse',
|
||||||
|
'--pretty= - %s',
|
||||||
|
'v{}..v{}^'.format(cur_ver, next_ver)],
|
||||||
|
stdout=log)
|
||||||
|
cur_ver = next_ver
|
||||||
|
|
||||||
|
def main(repo, new_ver):
|
||||||
|
os.environ['GIT_DIR'] = repo + '/.git'
|
||||||
|
|
||||||
|
changelog = Changelog(version=VersionLinux)
|
||||||
|
cur_pkg_ver = changelog[0].version
|
||||||
|
cur_ver = cur_pkg_ver.linux_upstream_full
|
||||||
|
|
||||||
|
if base_version(new_ver) != base_version(cur_ver):
|
||||||
|
print('{} is not on the same stable series as {}'
|
||||||
|
.format(new_ver, cur_ver),
|
||||||
|
file=sys.stderr)
|
||||||
|
sys.exit(2)
|
||||||
|
|
||||||
|
new_pkg_ver = new_ver + '-1'
|
||||||
|
if cur_pkg_ver.linux_revision_experimental:
|
||||||
|
new_pkg_ver += '~exp1'
|
||||||
|
|
||||||
|
# Three possible cases:
|
||||||
|
# 1. The current version has been released so we need to add a new
|
||||||
|
# version to the changelog.
|
||||||
|
# 2. The current version has not been released so we're changing its
|
||||||
|
# version string.
|
||||||
|
# (a) There are no stable updates included in the current version,
|
||||||
|
# so we need to insert an introductory line, the URL(s) and
|
||||||
|
# git log(s) and a blank line at the top.
|
||||||
|
# (b) One or more stable updates are already included in the current
|
||||||
|
# version, so we need to insert the URL(s) and git log(s) after
|
||||||
|
# them.
|
||||||
|
|
||||||
|
changelog_intro = 'New upstream stable update:'
|
||||||
|
|
||||||
|
# Case 1
|
||||||
|
if changelog[0].distribution != 'UNRELEASED':
|
||||||
|
subprocess.check_call(['dch', '-v', new_pkg_ver, '-D', 'UNRELEASED',
|
||||||
|
changelog_intro])
|
||||||
|
|
||||||
|
with open('debian/changelog', 'r') as old_log:
|
||||||
|
with open('debian/changelog.new', 'w') as new_log:
|
||||||
|
line_no = 0
|
||||||
|
inserted = False
|
||||||
|
intro_line = ' * {}\n'.format(changelog_intro)
|
||||||
|
|
||||||
|
for line in old_log:
|
||||||
|
line_no += 1
|
||||||
|
|
||||||
|
# Case 2
|
||||||
|
if changelog[0].distribution == 'UNRELEASED' and line_no == 1:
|
||||||
|
print('{} ({}) UNRELEASED; urgency={}'
|
||||||
|
.format(changelog[0].source, new_pkg_ver,
|
||||||
|
changelog[0].urgency),
|
||||||
|
file=new_log)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not inserted:
|
||||||
|
# Case 2(a)
|
||||||
|
if line_no == 3 and line != intro_line:
|
||||||
|
new_log.write(intro_line)
|
||||||
|
print_stable_log(new_log, cur_ver, new_ver)
|
||||||
|
new_log.write('\n')
|
||||||
|
inserted = True
|
||||||
|
# Case 1 or 2(b)
|
||||||
|
elif line_no > 3 and line == '\n':
|
||||||
|
print_stable_log(new_log, cur_ver, new_ver)
|
||||||
|
inserted = True
|
||||||
|
|
||||||
|
# Check that we inserted before hitting the end of the
|
||||||
|
# first version entry
|
||||||
|
assert not (line.startswith(' -- ') and not inserted)
|
||||||
|
|
||||||
|
new_log.write(line)
|
||||||
|
|
||||||
|
os.rename('debian/changelog.new', 'debian/changelog')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
print('''\
|
||||||
|
Usage: {} REPO VERSION"
|
||||||
|
REPO is the git repository to generate a changelog from
|
||||||
|
VERSION is the stable version (without leading v)'''.format(sys.argv[0]),
|
||||||
|
file=sys.stderr)
|
||||||
|
sys.exit(2)
|
||||||
|
main(*sys.argv[1:])
|
|
@ -1,78 +1,2 @@
|
||||||
#!/bin/bash -eu
|
#!/bin/sh -e
|
||||||
|
exec "$(dirname "$0")/stable-update" "$@"
|
||||||
if [ $# -ne 2 ]; then
|
|
||||||
echo >&2 "Usage: $0 REPO VERSION"
|
|
||||||
echo >&2 "REPO is the git repository to generate a changelog from"
|
|
||||||
echo >&2 "VERSION is the stable version (without leading v)"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get base version, i.e. the Linus stable release that a version is based on
|
|
||||||
base_version() {
|
|
||||||
local ver
|
|
||||||
ver="${1%-rc*}"
|
|
||||||
case "$ver" in
|
|
||||||
2.6.*.* | [3-9].*.* | ??.*.*)
|
|
||||||
ver="${ver%.*}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
echo "$ver"
|
|
||||||
}
|
|
||||||
|
|
||||||
add_update() {
|
|
||||||
local base update
|
|
||||||
base="$(base_version "$1")"
|
|
||||||
update="${1#$base.}"
|
|
||||||
if [ "$update" = "$1" ]; then
|
|
||||||
update=0
|
|
||||||
fi
|
|
||||||
update="$((update + $2))"
|
|
||||||
if [ $update = 0 ]; then
|
|
||||||
echo "$base"
|
|
||||||
else
|
|
||||||
echo "$base.$update"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get next stable update version
|
|
||||||
next_update() {
|
|
||||||
add_update "$1" 1
|
|
||||||
}
|
|
||||||
|
|
||||||
export GIT_DIR="$1/.git"
|
|
||||||
|
|
||||||
new_ver="$2"
|
|
||||||
cur_pkg_ver="$(dpkg-parsechangelog | sed -n 's/^Version: //p')"
|
|
||||||
cur_ver="${cur_pkg_ver%-*}"
|
|
||||||
|
|
||||||
if [ "$(base_version "$new_ver")" != "$(base_version "$cur_ver")" ]; then
|
|
||||||
echo >&2 "$new_ver is not on the same stable series as $cur_ver"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$cur_pkg_ver" in
|
|
||||||
*~exp*)
|
|
||||||
new_pkg_ver="$new_ver-1~exp1"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
new_pkg_ver="$new_ver-1"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# dch insists on word-wrapping everything, so just add the URLs initially
|
|
||||||
dch -v "$new_pkg_ver" --preserve --multimaint-merge -D UNRELEASED \
|
|
||||||
--release-heuristic=changelog "$(
|
|
||||||
echo "New upstream stable update: "
|
|
||||||
while [ "v$cur_ver" != "v$new_ver" ]; do
|
|
||||||
cur_ver="$(next_update "$cur_ver")"
|
|
||||||
echo "https://www.kernel.org/pub/linux/kernel/v${cur_ver%%.*}.x/ChangeLog-$cur_ver"
|
|
||||||
done)"
|
|
||||||
|
|
||||||
# Then insert the shortlogs with sed
|
|
||||||
while [ "v$cur_ver" != "v$new_ver" ]; do
|
|
||||||
next_ver="$(next_update "$cur_ver")"
|
|
||||||
sed -i '/ChangeLog-'"${next_ver//./\\.}"'/a\
|
|
||||||
'"$(git log --reverse --pretty=' - %s\' "v$cur_ver..v$next_ver^")"'
|
|
||||||
' debian/changelog
|
|
||||||
cur_ver="$next_ver"
|
|
||||||
done
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ linux (4.5.2-2) UNRELEASED; urgency=medium
|
||||||
(Closes: #823603)
|
(Closes: #823603)
|
||||||
* bpf: fix refcnt overflow (CVE-2016-4558)
|
* bpf: fix refcnt overflow (CVE-2016-4558)
|
||||||
* bpf: fix check_map_func_compatibility logic (CVE-2016-XXXX)
|
* bpf: fix check_map_func_compatibility logic (CVE-2016-XXXX)
|
||||||
|
* stable-update: Rewrite stable-update.sh in Python
|
||||||
|
|
||||||
-- Uwe Kleine-König <ukleinek@debian.org> Sun, 01 May 2016 16:13:04 +0200
|
-- Uwe Kleine-König <ukleinek@debian.org> Sun, 01 May 2016 16:13:04 +0200
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue