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
|
#!/bin/sh
Usage() {
cat <<EOF
Usage: ${0##*/} trunk-dir [next-upstream-version]
pull in new upstream snapshot from trunk-dir
Leaves file 'new-changes.log'
Example:
$ ${0##*/} ../trunk
# prepare bzr dir in . with new snapshot from ../trunk
$ dch --edit
# read changes in new-changes.log and write changelog
$ debcommit
$ dch --release
$ debcommit --release
EOF
}
fail() { echo "$@" 1>&2; exit 1; }
print_commit() {
local subject="$1" author="$2" bugs="$3" aname=""
aname=${author% <*}
echo " - $subject ${aname:+[${aname}]}${bugs:+ (LP: ${bugs})}"
}
# unfortunately seems like no easy way to get 'Author' unless
# the committer sets it on the commit. And since curtin is doing
# bzr merge and letting committer merge it, then author doesn't
# end up correct on most commits.
#
# log messages look like:
#revno: 424 [merge]
#fixes bug: https://launchpad.net/bugs/1618429
#committer: Ryan Harper <ryan.harper@canonical.com>
#branch nick: merge-wesley-lp1618429
#timestamp: Thu 2016-09-15 08:48:13 -0500
#message:
# block/mdadm: add option to ignore mdadm_assemble errors
#
# When wiping disks with mdadm partitions we may encounter unexpected
# return codes. In the case of wiping disks, we don't care if we
# observe any error so allow wipe to ignore the errors by explicitly
# passing in ignore errors.
bzr_log_to_dch() {
local line="" commit="" lcommit="" bugs="" bug=""
while :; do
read line || break
case "$line" in
revno:\ *)
if [ -n "$commit" ]; then
print_commit "$subject" "$author" "$bugs"
fi
commit=${line#*: }
bugs=""
author=""
subject=""
;;
Author:*) author="${line#Author: }";;
fixes\ bug:*)
# fixes bug: https://launchpad.net/bugs/1618429
bug="#${line##*/}"
bugs="${bugs:+${bugs}, }${bug}";;
message:)
read subject;;
esac
done
if [ -n "$commit" ]; then
print_commit "$subject" "$author" "$bugs"
fi
}
[ $# -eq 0 ] && { Usage 1>&2; exit 1; }
[ "$1" = "-h" -o "$1" = "--help" ] && { Usage; exit 0; }
trunk=$1
revno=${2:-tip}
uver=${3:-0.1.0} # the *next* upstream version
[ -d "$trunk" ] ||
fail "trunk dir '$trunk' not a dir"
if [ "$revno" = "tip" ]; then
revno=$(cd "$trunk" && bzr revno) ||
fail "failed getting bzr revno from $trunk"
fi
pversion=$(dpkg-parsechangelog --show-field Version) ||
fail "failed to read previous version with dpkg-parsechangelog"
prevno=$(echo "$pversion" | sed 's,.*bzr\([0-9]\+\)-.*,\1,') ||
fail "fail reading previous bzr revision from previous version '$pversion'"
version=${uver}~bzr${revno}
tarball=curtin-${version}.tar.gz
t=../curtin_${version}.orig.tar.gz
if [ -f "$t" ]; then
echo "using '$t' as tarball" 1>&2
tarball="$t"
else
echo "creating $tarball with bzr export" 1>&2
bzr export --format=tgz "--revision=${revno}" "$tarball" "${trunk}" ||
fail "failed exporting bzr in $trunk to $tarball"
fi
bzr merge-upstream "$tarball" "--version=${version}" ||
fail "failed merge-upstream of $tarball at version=$version"
oldrev=$(($prevno+1))
( cd "$trunk" && bzr log -r "${oldrev}..${revno}" ) > new-changes.log ||
fail "failed to get changes from ${oldrev}..$revno"
bzr_log_to_dch < new-changes.log > new-dch.log
cat <<EOF
====
Now see ./new-changes.log for changes between $oldrev and $revno
then:
$ dch --edit
# read changes in new-dch.log or full changes in new-changes.log
# and write changelog
$ debcommit
$ dch --release
$ debcommit --release
$ debuild -S
EOF
|