Merge ~smoser/curtin:cleanup/curtainer-patch-version into curtin:master

Proposed by Scott Moser
Status: Merged
Approved by: Scott Moser
Approved revision: 1af5e654857c70bc762ced0e968b605b077cb99e
Merge reported by: Scott Moser
Merged at revision: 50c0007c083564e82e359f86f34e05dcd436b078
Proposed branch: ~smoser/curtin:cleanup/curtainer-patch-version
Merge into: curtin:master
Diff against target: 72 lines (+21/-6)
1 file modified
tools/curtainer (+21/-6)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Needs Fixing
Ryan Harper (community) Approve
Review via email: mp+346651@code.launchpad.net

Commit message

curtainer: patch source version from --source.

After adding 'CURTIN_EXE_VERSION' and 'CURTIN_VERSION' in output
we now see nice output for runs from trunk. But when running from
a package via curtainer, we see:
  CURTIN_VMTEST_CURTIN_EXE=.. curtin-vmtest-proposed-a-29 curtin
  CURTIN_VMTEST_CURTIN_EXE_VERSION=18.1-17-gae48e86f-0ubuntu1~17.10.1
  CURTIN_VMTEST_CURTIN_VERSION=18.1

That is confusing as it appears our vmtest version is different
from our exe version.

That is because the patching of the version that we do in debian/rules
only applies to the built binaries, the source still has the un-modified
@@PACKAGED_VERSION@@ in tact.

The change here is patch the source code output by --source
by default, so that running 'curtin version' from that source will
provide the correct output. Jenkins is the only known consumer of this
ouput so it was easier to change the default behavior than have the caller
become aware. To disable this behavior pass '--no-patch-version'

Note that curtin has verified that it downloaded the
version of the source that it is patching in, so this is
known-to-be-correct.

Description of the change

Note, we will have to have the jenkins job start passing '--patch-version' to curtainer.

and we will also probably want to first check if curtainer *has* that option.

./tools/curtainer --help | grep -q -- --patch-version &&
   pverarg="--patch-version" || pverarg=""

./tools/curtainer ubuntu-daily:xenial $pverarg ....

To post a comment you must log in.
b91e519... by Scott Moser

better identify where that .dist file came from

Revision history for this message
Ryan Harper (raharper) :
Revision history for this message
Scott Moser (smoser) :
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ryan Harper (raharper) :
review: Approve
Revision history for this message
Scott Moser (smoser) wrote :

since our only consumer to my knowledge of '--source' is jenkins...
i thjink its probably sane to just switch the default behavior
and add a '--no-patch-version' option for future consumer.

then we dont need any changes to jenkins jobs.

9ca81ae... by Scott Moser

flip the logic.

patch the source by default.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

Yes, that's a great idea.

Revision history for this message
Ryan Harper (raharper) wrote :

That works even when we want to run by hand; generally we always want to do that unless we have a specific reason to try cross versions.

Revision history for this message
Ryan Harper (raharper) wrote :

This looks fine, the commit description is now incorrect as you inverted the logic.

review: Approve
Revision history for this message
Scott Moser (smoser) wrote :

commit description was updated. i'll hit rebuild and with c-i vote, land.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

An upstream commit landed for this bug.

To view that commit see the following URL:
https://git.launchpad.net/curtin/commit/?id=50c0007c

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tools/curtainer b/tools/curtainer
2index ca698c6..466d719 100755
3--- a/tools/curtainer
4+++ b/tools/curtainer
5@@ -17,10 +17,13 @@ Usage: ${0##*/} [ options ] <image> name
6 start a container of image (ubuntu-daily:xenial) and install curtin.
7
8 options:
9- --proposed enable proposed
10- --daily enable daily curtin archive
11- --source D grab the source deb, unpack inside, and copy unpacked
12- source out to 'D'
13+ --no-patch-version do not patch source dir/curtin/version.py
14+ by default, --source will have version.py updated
15+ with dpkg's version.
16+ --proposed enable proposed
17+ --daily enable daily curtin archive
18+ --source D grab the source deb, unpack inside, and copy unpacked
19+ source out to 'D'
20 EOF
21 }
22
23@@ -114,7 +117,7 @@ get_source() {
24
25 main() {
26 local short_opts="hv"
27- local long_opts="help,daily,proposed,source:,verbose"
28+ local long_opts="help,daily,no-patch-version,proposed,source:,verbose"
29 local getopt_out=""
30 getopt_out=$(getopt --name "${0##*/}" \
31 --options "${short_opts}" --long "${long_opts}" -- "$@") &&
32@@ -123,13 +126,14 @@ main() {
33
34 local cur="" next=""
35 local proposed=false daily=false src="" name="" maxwait=30
36- local eatmydata="eatmydata" getsource="none"
37+ local eatmydata="eatmydata" getsource="none" patch_version=true
38
39 while [ $# -ne 0 ]; do
40 cur="$1"; next="$2";
41 case "$cur" in
42 -h|--help) Usage ; exit 0;;
43 --source) getsource="$next"; shift;;
44+ --no-patch-version) patch_version=false;;
45 --proposed) proposed=true;;
46 --daily) daily=true;;
47 -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));;
48@@ -147,6 +151,7 @@ main() {
49 if [ "$getsource" != "none" ]; then
50 [ ! -e "$getsource" ] || fail "source output '$getsource' exists."
51 fi
52+ getsource="${getsource%/}"
53
54 lxc launch "$src" "$name" || fail "failed lxc launch $src $name"
55 CONTAINER=$name
56@@ -218,6 +223,16 @@ main() {
57 if [ "$src_ver" != "$pkg_ver" ]; then
58 fail "source version ($src_ver) != package version ($pkg_ver)"
59 fi
60+ if "${patch_version}"; then
61+ local verfile="$getsource/curtin/version.py"
62+ grep -q "@@PACKAGED_VERSION@@" "$verfile" ||
63+ fail "failed patching version: " \
64+ "@@PACKAGED_VERSION@@ not found in $verfile"
65+ sed -i.curtainer-dist \
66+ "s,@@PACKAGED_VERSION@@,${pkg_ver}," "$verfile" ||
67+ fail "failed modifying $verfile"
68+ debug 1 "patched $verfile pkg version to $pkg_ver."
69+ fi
70 inside "$name" rm -Rf "$isrcd" ||
71 fail "failed removal of extract dir"
72 debug 1 "put source for curtin at $src_ver in $getsource"

Subscribers

People subscribed via source and target branches