Merge ~smoser/curtin:fix/curtainer-try-harder-for-source into curtin:master

Proposed by Scott Moser
Status: Merged
Approved by: Chad Smith
Approved revision: e33e302b3a92c8be8d32a0b2f5f558184c5a478f
Merge reported by: Chad Smith
Merged at revision: 66c3dc76f9ece9360be24d0d0b814b18f8c79c7e
Proposed branch: ~smoser/curtin:fix/curtainer-try-harder-for-source
Merge into: curtin:master
Diff against target: 89 lines (+44/-14)
1 file modified
tools/curtainer (+44/-14)
Reviewer Review Type Date Requested Status
Chad Smith Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+337388@code.launchpad.net

Commit message

tools/curtainer: Try harder to get source at binary version.

When we test curtin from the daily PPA, sometimes the source version
that is available is newer than the binary version available. That
causes mismatch of vmtest:code.

If 'apt-get source curtin/<version>' fails, then ask apt
what the url to the deb for 'curtin' at 'version' is.
Then replace _all.deb with .dsc and try dget on that url. This
should work because:
a.) curtin is a binary and a source package.
b.) source are generally published along side binaries.
c.) in the ppa case, the files are likely still available but only
    the most current is published in the Sources for the archive.

If this proves to not work, then the next solution is to actually
provide a binary package with the files needed for vmtest.

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)
e33e302... by Scott Moser

better search for directory

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) :
Revision history for this message
Scott Moser (smoser) :
Revision history for this message
Chad Smith (chad.smith) wrote :

Approved, thanks for this fix and the additional thoughts on error content w/ the ls output.

review: Approve

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 6c0628f..ca698c6 100755
3--- a/tools/curtainer
4+++ b/tools/curtainer
5@@ -79,6 +79,39 @@ debug() {
6 error "${@}"
7 }
8
9+get_source() {
10+ local target="$1" pkg="$2" ver="$3"
11+ local tmpd="" x=""
12+ tmpd=$(mktemp -d) || fail "failed to mktemp"
13+ mkdir "$tmpd/extract"
14+ cd "$tmpd/extract"
15+ debug 1 "Inside. getting source for $pkg${ver:+=${ver}}"
16+ if ! apt-get source "${pkg}${ver:+=${ver}}"; then
17+ [ -n "$ver" ] || fail "Failed to get source for $pkg"
18+ # Getting the specific version failed.
19+ # Assume 'pkg' is a binary package and source package.
20+ # Ask apt for the url to the binary, and assume source in same dir.
21+ debug 1 "Failed to apt-get source ${pkg}=$ver. Trying workaround."
22+ url=$(apt-get -qq download --print-uris "$pkg=${ver}" |
23+ awk '{ gsub(/'\''/, ""); print $1}')
24+ local dsc_url="${url%_*.deb}.dsc"
25+ debug 1 "Binary package came from $url."
26+ debug 1 "Trying dsc from $dsc_url"
27+ dget --allow-unauthenticated "$dsc_url" || fail "Failed dget $dsc_url"
28+ fi
29+
30+ # dget or apt-get source of pkg/ver produces pkg-<upstream-ver>/
31+ x="${pkg}-${ver%-*}"
32+ [ -d "$x" ] || {
33+ error "getting source for '$pkg/$ver' did not produce directory '$x'"
34+ error "ls -l:"
35+ ls -l 1>&2
36+ fail
37+ }
38+ cp -a "$x" "$target" || fail "failed copying $x to $target"
39+ rm -Rf "$tmpd"
40+}
41+
42 main() {
43 local short_opts="hv"
44 local long_opts="help,daily,proposed,source:,verbose"
45@@ -158,7 +191,7 @@ main() {
46 inside "$name" sed -i '/^deb-src/s/^/#/' /etc/apt/sources.list ||
47 error "failed to disable deb-src entries"
48 else
49- pkgs="${pkgs} dpkg-dev"
50+ pkgs="${pkgs} dpkg-dev devscripts"
51 fi
52
53 inside "$name" $eatmydata apt-get -q update ||
54@@ -172,18 +205,9 @@ main() {
55 if [ "${getsource}" != "none" ]; then
56 local isrcd="/tmp/curtin-source"
57 debug 1 "getting source for curtin at $pkg_ver to $getsource"
58- inside "$name" $eatmydata sh -ec '
59- target="$1"
60- pkg="$2"
61- ver="$3"
62- d=$(mktemp -d)
63- cd "$d"
64- apt-get source "${pkg}${ver:+=${ver}}"
65- for x in *; do [ -d "$x" ] && break; done
66- [ -d "$x" ] || { echo no source dir found.; exit 1; }
67- cp -a $x "$target"
68- rm -Rf "$d"
69- ' -- "$isrcd" "curtin" "$pkg_ver"
70+ inside "$name" - $eatmydata /bin/bash -s \
71+ get_source "$isrcd" "curtin" "$pkg_ver" < "$0" ||
72+ fail "Failed getting source in $name"
73 mkdir "$getsource" || fail "failed to create dir '$getsource'"
74 inside "$name" tar -C "$isrcd" -cf - . |
75 tar -C "$getsource" -xf - ||
76@@ -202,6 +226,12 @@ main() {
77 CONTAINER=""
78 }
79
80-main "$@"
81+
82+if [ "$1" = "get_source" ]; then
83+ shift
84+ get_source "$@"
85+else
86+ main "$@"
87+fi
88
89 # vi: ts=4 expandtab syntax=sh

Subscribers

People subscribed via source and target branches