Merge ~smoser/curtin:ubuntu/artful into curtin:ubuntu/artful

Proposed by Scott Moser
Status: Merged
Merged at revision: bf5efeaee588d64c32c106e864fd3f8fcb539581
Proposed branch: ~smoser/curtin:ubuntu/artful
Merge into: curtin:ubuntu/artful
Diff against target: 281 lines (+155/-88)
1 file modified
debian/new-upstream-snapshot (+155/-88)
Reviewer Review Type Date Requested Status
Ryan Harper (community) Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+336168@code.launchpad.net

Commit message

packaging: Update new-upstream-snapshot to work with git.

After the move to git, we need to update new-upstream-snapshot.
This version comes from cloud-init, with an extra hunk in it to
handle the transition from bzr.

Commit new-upstream-snapshot to master, where it previously
only lived on ubuntu branches. Then, commit it also to the branches
so that it does not cause conflict.

Description of the change

see commit message

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ryan Harper (raharper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/new-upstream-snapshot b/debian/new-upstream-snapshot
2index 093329d..54802e5 100755
3--- a/debian/new-upstream-snapshot
4+++ b/debian/new-upstream-snapshot
5@@ -1,55 +1,48 @@
6 #!/bin/sh
7
8+TEMP_D=""
9+CR='
10+'
11+error() { echo "$@" 1>&2; }
12+fail() { [ $# -eq 0 ] || error "$@"; exit 1; }
13 Usage() {
14- cat <<EOF
15-Usage: ${0##*/} trunk-dir [next-upstream-version]
16-
17- pull in new upstream snapshot from trunk-dir
18-
19- Leaves file 'new-changes.log'
20-
21- Example:
22- $ ${0##*/} ../trunk
23- # prepare bzr dir in . with new snapshot from ../trunk
24- $ dch --edit
25- # read changes in new-changes.log and write changelog
26- $ debcommit
27- $ dch --release
28- $ debcommit --release
29+cat <<EOF
30+${0##*/} [branch]
31+ update current branch with trunk branch.
32+ branch defaults to 'master'
33 EOF
34 }
35-fail() { echo "$@" 1>&2; exit 1; }
36
37 print_commit() {
38- local subject="$1" author="$2" bugs="$3" aname=""
39+ local subject="$1" author="$2" bugs="$3" aname="" buf="" abugs=""
40+ local indent=" - " indent2=" " ll=79
41 aname=${author% <*}
42- echo " - $subject${aname:+ [${aname}]}${bugs:+ (LP: ${bugs})}"
43+ [ "${aname}" = "Scott Moser" ] && aname=""
44+ abugs="${aname:+ [${aname}]}${bugs:+ (LP: ${bugs})}"
45+ if [ $((${#subject}+${#abugs})) -le $(($ll-${#indent})) ]; then
46+ echo "${indent}${subject}${abugs}"
47+ elif [ ${#subject} -ge $(($ll-${#indent})) ]; then
48+ echo "${subject}${abugs}" |
49+ fmt --width=$(($ll-${#indent})) |
50+ sed -e "1s/^/${indent}/; 1n;" \
51+ -e 's/^[ ]*//' \
52+ -e '/^[ ]*$/d' -e "s/^/$indent2/" -e 's/[ ]\+$//'
53+
54+ else
55+ ( echo "${subject}"; echo "${abugs}" ) |
56+ fmt --width=$(($ll-${#indent})) |
57+ sed -e "1s/^/${indent}/; 1n;" \
58+ -e 's/^[ ]*//' \
59+ -e '/^[ ]*$/d' -e "s/^/$indent2/" -e 's/[ ]\+$//'
60+ fi
61 }
62
63-# unfortunately seems like no easy way to get 'Author' unless
64-# the committer sets it on the commit. And since curtin is doing
65-# bzr merge and letting committer merge it, then author doesn't
66-# end up correct on most commits.
67-#
68-# log messages look like:
69-#revno: 424 [merge]
70-#fixes bug: https://launchpad.net/bugs/1618429
71-#committer: Ryan Harper <ryan.harper@canonical.com>
72-#branch nick: merge-wesley-lp1618429
73-#timestamp: Thu 2016-09-15 08:48:13 -0500
74-#message:
75-# block/mdadm: add option to ignore mdadm_assemble errors
76-#
77-# When wiping disks with mdadm partitions we may encounter unexpected
78-# return codes. In the case of wiping disks, we don't care if we
79-# observe any error so allow wipe to ignore the errors by explicitly
80-# passing in ignore errors.
81-bzr_log_to_dch() {
82- local line="" commit="" lcommit="" bugs="" bug=""
83+git_log_to_dch() {
84+ local line="" commit="" lcommit="" bugs=""
85 while :; do
86 read line || break
87 case "$line" in
88- revno:\ *)
89+ commit\ *)
90 if [ -n "$commit" ]; then
91 print_commit "$subject" "$author" "$bugs"
92 fi
93@@ -59,65 +52,139 @@ bzr_log_to_dch() {
94 subject=""
95 ;;
96 Author:*) author="${line#Author: }";;
97- fixes\ bug:*)
98- # fixes bug: https://launchpad.net/bugs/1618429
99- bug="#${line##*/}"
100- bugs="${bugs:+${bugs}, }${bug}";;
101- message:)
102- read subject;;
103+ LP:*) bugs="${bugs:+${bugs}, }${line#*: }";;
104+ "") [ -z "$subject" ] && read subject;;
105 esac
106 done
107 if [ -n "$commit" ]; then
108 print_commit "$subject" "$author" "$bugs"
109 fi
110 }
111+cleanup() {
112+ [ ! -d "${TEMP_D}" ] || rm -Rf "${TEMP_D}"
113+}
114+
115+from_ref=${1:-"master"}
116+cur_branch=$(git rev-parse --abbrev-ref HEAD) ||
117+ fail "failed to get current branch"
118+
119+case "$cur_branch" in
120+ ubuntu/*) :;;
121+ *) fail "You are on branch '$cur_branch', expect to be on ubuntu/*";;
122+esac
123+
124+TEMP_D=$(mktemp -d) || fail "failed mktemp"
125+trap cleanup EXIT
126+
127+prev_pkg_ver=$(dpkg-parsechangelog --show-field Version) ||
128+ fail "failed reading package version"
129+pkg_name=$(dpkg-parsechangelog --show-field Source) ||
130+ fail "failed to read Source from changelog"
131+
132+# turn 0.7.7-10-gbc2c326-0ubuntu1 into 'bc2c326'
133+t=${prev_pkg_ver%-*}
134+prev_pkg_hash=${t##*-g}
135+case "${prev_pkg_ver}" in
136+ *-*-g[a-z]*-*)
137+ # use the hash.
138+ t=${prev_pkg_ver%-*}
139+ prev_pkg_hash=${t##*-g};;
140+ *)
141+ prev_tag=ubuntu/$(echo "${prev_pkg_ver}" | sed 's,~,_,g')
142+ echo "prev_tag=$prev_tag"
143+ out=$(git tag --list "${prev_tag}") ||
144+ fail "failed to look for a tag $prev_tag"
145+ if [ -z "$out" ]; then
146+ fail "no way to figure out merge-base between " \
147+ "${prev_pkg_ver} and ${from_ref}"
148+ fi
149+ prev_pkg_hash=$(git merge-base "${from_ref}" "$prev_tag") ||
150+ fail "failed git merge-base \"${from_ref}\" \"${prev_tag}\""
151+ [ -n "${prev_pkg_hash}" ] ||
152+ fail "cannot find merge base for ${prev_pkg_ver} and ${from_ref}"
153+ ;;
154+esac
155
156-[ $# -eq 0 ] && { Usage 1>&2; exit 1; }
157-[ "$1" = "-h" -o "$1" = "--help" ] && { Usage; exit 0; }
158-trunk=$1
159-revno=${2:-tip}
160-uver=${3:-0.1.0} # the *next* upstream version
161-
162-[ -d "$trunk" ] ||
163- fail "trunk dir '$trunk' not a dir"
164-if [ "$revno" = "tip" ]; then
165- revno=$(cd "$trunk" && bzr revno) ||
166- fail "failed getting bzr revno from $trunk"
167+new_pkg_debian="0ubuntu1"
168+new_upstream_ver=$(git describe --abbrev=8 "${from_ref}")
169+new_pkg_ver="${new_upstream_ver}-${new_pkg_debian}"
170+
171+prev_upstream_ver=${prev_pkg_ver%-*}
172+if [ "${prev_upstream_ver}" = "${new_upstream_ver}" ]; then
173+ echo "nothing to commit. '$from_ref' is at ${new_upstream_ver}."
174+ exit 0
175 fi
176-pversion=$(dpkg-parsechangelog --show-field Version) ||
177- fail "failed to read previous version with dpkg-parsechangelog"
178-prevno=$(echo "$pversion" | sed 's,.*bzr\([0-9]\+\)-.*,\1,') ||
179- fail "fail reading previous bzr revision from previous version '$pversion'"
180-version=${uver}~bzr${revno}
181-tarball=curtin-${version}.tar.gz
182-t=../curtin_${version}.orig.tar.gz
183-if [ -f "$t" ]; then
184- echo "using '$t' as tarball" 1>&2
185- tarball="$t"
186-else
187- echo "creating $tarball with bzr export" 1>&2
188- bzr export --format=tgz "--revision=${revno}" "$tarball" "${trunk}" ||
189- fail "failed exporting bzr in $trunk to $tarball"
190+
191+dpseries="debian/patches/series"
192+if [ -e $dpseries ]; then
193+ drops=""
194+ while read bname extra; do
195+ case "$bname" in
196+ cpick-*)
197+ commit=${bname#cpick-}
198+ commit=${commit%%-*}
199+ echo "bname=$bname commit=${commit}" 1>&2
200+ if git merge-base --is-ancestor "$commit" "$from_ref"; then
201+ drops="${drops} debian/patches/$bname"
202+ fi
203+ ;;
204+ *) echo "$bname${extra:+ ${extra}}";;
205+ esac
206+ done < $dpseries > "${TEMP_D}/series"
207+ drops=${drops# }
208+ if [ -n "$drops" ]; then
209+ cp "${TEMP_D}/series" "$dpseries" ||
210+ fail "failed copying to $dpseries"
211+ if [ ! -s $dpseries ]; then
212+ git rm --force "$dpseries" ||
213+ fail "failed removing empty $dpseries: git rm $dpseries"
214+ fi
215+ msg="drop cherry picks before merge from ${from_ref} at $new_upstream_ver"
216+ msg="$msg${CR}${CR}drop the following cherry picks:"
217+ for file in $drops; do
218+ git rm "$file" || fail "failed to git rm $file"
219+ msg="${msg}$CR $file"
220+ done
221+ git commit -m "$msg" "$dpseries" $drops
222+ fi
223 fi
224-bzr merge-upstream "$tarball" "--version=${version}" ||
225- fail "failed merge-upstream of $tarball at version=$version"
226
227-oldrev=$(($prevno+1))
228-( cd "$trunk" && bzr log -r "${oldrev}..${revno}" ) > new-changes.log ||
229- fail "failed to get changes from ${oldrev}..$revno"
230-bzr_log_to_dch < new-changes.log > new-dch.log
231+git merge "${from_ref}" -m "merge from $from_ref at $new_upstream_ver" ||
232+ fail "failed: git merge ${from_ref} -m 'merge from $from_ref ..'"
233+clog="${TEMP_D}/changelog"
234+gitlog="${TEMP_D}/gitlog"
235+
236+git log --first-parent --no-decorate --format=full \
237+ "${prev_pkg_hash}..${from_ref}" > "$gitlog" ||
238+ fail "failed git log ${prev_pkg_hash}..${from_ref}"
239+
240+cat >> "$clog" <<EOF
241+$pkg_name ($new_pkg_ver) UNRELEASED; urgency=medium
242+
243+ * New upstream snapshot.
244+EOF
245+git_log_to_dch < "$gitlog" >> "$clog" ||
246+ fail "failed git_log_to_dch"
247+cat >> "$clog" <<EOF
248+
249+ -- ${DEBFULLNAME} <$DEBEMAIL> $(date -R)
250
251-cat <<EOF
252-====
253-Now see ./new-changes.log for changes between $oldrev and $revno
254-
255-then:
256- $ dch --edit
257- # read changes in new-dch.log or full changes in new-changes.log
258- # and write changelog
259- $ debcommit
260- $ dch --release
261- $ debcommit --release
262- $ debuild -S
263 EOF
264
265+cat "$clog" "debian/changelog" > "$TEMP_D/newlog" &&
266+ cp "$TEMP_D/newlog" "debian/changelog" ||
267+ fail "failed replacing debian/changelog"
268+
269+dch -e || fail "dch -e exited $?"
270+
271+git diff
272+
273+echo -n "Commit this change? (Y/n): "
274+read answer || fail "failed to read answer"
275+case "$answer" in
276+ n|[Nn][oO]) exit 1;;
277+esac
278+
279+msg="update changelog (new upstream snapshot $new_upstream_ver)."
280+git commit -m "$msg" debian/changelog ||
281+ fail "failed to commit '$msg'"

Subscribers

People subscribed via source and target branches