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
diff --git a/tools/curtainer b/tools/curtainer
index 6c0628f..ca698c6 100755
--- a/tools/curtainer
+++ b/tools/curtainer
@@ -79,6 +79,39 @@ debug() {
79 error "${@}"79 error "${@}"
80}80}
8181
82get_source() {
83 local target="$1" pkg="$2" ver="$3"
84 local tmpd="" x=""
85 tmpd=$(mktemp -d) || fail "failed to mktemp"
86 mkdir "$tmpd/extract"
87 cd "$tmpd/extract"
88 debug 1 "Inside. getting source for $pkg${ver:+=${ver}}"
89 if ! apt-get source "${pkg}${ver:+=${ver}}"; then
90 [ -n "$ver" ] || fail "Failed to get source for $pkg"
91 # Getting the specific version failed.
92 # Assume 'pkg' is a binary package and source package.
93 # Ask apt for the url to the binary, and assume source in same dir.
94 debug 1 "Failed to apt-get source ${pkg}=$ver. Trying workaround."
95 url=$(apt-get -qq download --print-uris "$pkg=${ver}" |
96 awk '{ gsub(/'\''/, ""); print $1}')
97 local dsc_url="${url%_*.deb}.dsc"
98 debug 1 "Binary package came from $url."
99 debug 1 "Trying dsc from $dsc_url"
100 dget --allow-unauthenticated "$dsc_url" || fail "Failed dget $dsc_url"
101 fi
102
103 # dget or apt-get source of pkg/ver produces pkg-<upstream-ver>/
104 x="${pkg}-${ver%-*}"
105 [ -d "$x" ] || {
106 error "getting source for '$pkg/$ver' did not produce directory '$x'"
107 error "ls -l:"
108 ls -l 1>&2
109 fail
110 }
111 cp -a "$x" "$target" || fail "failed copying $x to $target"
112 rm -Rf "$tmpd"
113}
114
82main() {115main() {
83 local short_opts="hv"116 local short_opts="hv"
84 local long_opts="help,daily,proposed,source:,verbose"117 local long_opts="help,daily,proposed,source:,verbose"
@@ -158,7 +191,7 @@ main() {
158 inside "$name" sed -i '/^deb-src/s/^/#/' /etc/apt/sources.list ||191 inside "$name" sed -i '/^deb-src/s/^/#/' /etc/apt/sources.list ||
159 error "failed to disable deb-src entries"192 error "failed to disable deb-src entries"
160 else193 else
161 pkgs="${pkgs} dpkg-dev"194 pkgs="${pkgs} dpkg-dev devscripts"
162 fi195 fi
163196
164 inside "$name" $eatmydata apt-get -q update ||197 inside "$name" $eatmydata apt-get -q update ||
@@ -172,18 +205,9 @@ main() {
172 if [ "${getsource}" != "none" ]; then205 if [ "${getsource}" != "none" ]; then
173 local isrcd="/tmp/curtin-source"206 local isrcd="/tmp/curtin-source"
174 debug 1 "getting source for curtin at $pkg_ver to $getsource"207 debug 1 "getting source for curtin at $pkg_ver to $getsource"
175 inside "$name" $eatmydata sh -ec '208 inside "$name" - $eatmydata /bin/bash -s \
176 target="$1"209 get_source "$isrcd" "curtin" "$pkg_ver" < "$0" ||
177 pkg="$2"210 fail "Failed getting source in $name"
178 ver="$3"
179 d=$(mktemp -d)
180 cd "$d"
181 apt-get source "${pkg}${ver:+=${ver}}"
182 for x in *; do [ -d "$x" ] && break; done
183 [ -d "$x" ] || { echo no source dir found.; exit 1; }
184 cp -a $x "$target"
185 rm -Rf "$d"
186 ' -- "$isrcd" "curtin" "$pkg_ver"
187 mkdir "$getsource" || fail "failed to create dir '$getsource'"211 mkdir "$getsource" || fail "failed to create dir '$getsource'"
188 inside "$name" tar -C "$isrcd" -cf - . |212 inside "$name" tar -C "$isrcd" -cf - . |
189 tar -C "$getsource" -xf - ||213 tar -C "$getsource" -xf - ||
@@ -202,6 +226,12 @@ main() {
202 CONTAINER=""226 CONTAINER=""
203}227}
204228
205main "$@"229
230if [ "$1" = "get_source" ]; then
231 shift
232 get_source "$@"
233else
234 main "$@"
235fi
206236
207# vi: ts=4 expandtab syntax=sh237# vi: ts=4 expandtab syntax=sh

Subscribers

People subscribed via source and target branches