Merge ubuntu-qa-tools:dl-ubuntu-test-iso-snap into ubuntu-qa-tools:master

Proposed by Jean-Baptiste Lallement
Status: Merged
Merged at revision: a1efbf61330007328aa8d8caa8c362589b032436
Proposed branch: ubuntu-qa-tools:dl-ubuntu-test-iso-snap
Merge into: ubuntu-qa-tools:master
Diff against target: 100 lines (+51/-4)
2 files modified
dl-ubuntu-test-iso/dl-ubuntu-test-iso (+10/-4)
dl-ubuntu-test-iso/snapcraft.yaml (+41/-0)
Reviewer Review Type Date Requested Status
Steve Beattie Approve
Review via email: mp+382314@code.launchpad.net

Commit message

This PR packages dl-ubuntu-test-iso as a snap (published https://snapcraft.io/dl-ubuntu-test-iso)
It required some changes to the code to find the path of zsync and rsync.

The snap package runs in strict confined mode and support storage of downloaded file on local filesystem and removable media.

To post a comment you must log in.
Revision history for this message
Steve Beattie (sbeattie) wrote :

LGTM, merged.

One issue I have with running it out of a snap is that I have the script configured to store the isos in a location where I can serve them up in apache. I'm not sure of the best way to cope with that via snap.

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/dl-ubuntu-test-iso/dl-ubuntu-test-iso b/dl-ubuntu-test-iso/dl-ubuntu-test-iso
2index 3e21aa6..fc34eab 100755
3--- a/dl-ubuntu-test-iso/dl-ubuntu-test-iso
4+++ b/dl-ubuntu-test-iso/dl-ubuntu-test-iso
5@@ -19,6 +19,7 @@ import subprocess
6 import stat
7 import signal
8 import sys
9+import shutil
10
11 try:
12 import distro_info
13@@ -72,7 +73,8 @@ except ImportError:
14 print("Unable to import launchpadlib")
15 default["do_release_check"] = False
16
17-zsync_binary = "/usr/bin/zsync"
18+zsync_binary = shutil.which("zsync")
19+rsync_binary = shutil.which("rsync")
20
21
22 class Flavor(object):
23@@ -420,7 +422,11 @@ def do_zsync(config, destination, uri, isoname):
24
25
26 def _do_rsync(config, source, target):
27- command = ["/usr/bin/rsync", "-zthLP", "rsync://%s/cdimage%s" % (config.host, source), target]
28+ if not rsync_binary or not os.path.exists(rsync_binary):
29+ config._log("Warning! rsync is not installed. Aborting.")
30+ sys.exit(1)
31+
32+ command = [rsync_binary, "-zthLP", "rsync://%s/cdimage%s" % (config.host, source), target]
33 if len(config.bwlimit) > 0:
34 command.insert(2, "--bwlimit=" + config.bwlimit)
35 if config.quiet:
36@@ -470,7 +476,7 @@ def do_verify(config, destination, hashsuffix, path, iso):
37 with open(local) as f:
38 for line in f:
39 if iso in line:
40- digest = re.split("\s+", line)[0]
41+ digest = re.split(r"\s+", line)[0]
42 break
43
44 if not digest:
45@@ -819,7 +825,7 @@ def main():
46 else:
47 config._log = my_log
48
49- if config.use_zsync and not os.path.exists(zsync_binary):
50+ if config.use_zsync and (not zsync_binary or not os.path.exists(zsync_binary)):
51 config._log("Warning! zsync is not installed, falling back to rsync")
52 config.use_zsync = False
53
54diff --git a/dl-ubuntu-test-iso/snapcraft.yaml b/dl-ubuntu-test-iso/snapcraft.yaml
55new file mode 100644
56index 0000000..284b1b7
57--- /dev/null
58+++ b/dl-ubuntu-test-iso/snapcraft.yaml
59@@ -0,0 +1,41 @@
60+name: dl-ubuntu-test-iso
61+grade: stable
62+summary: Easily download daily Ubuntu and flavours ISOs
63+description: |
64+ dl-ubuntu-test-iso is a command line tool to download daily images of
65+ Ubuntu and its flavors from cdimage.ubuntu.com. It is highly configurable
66+ from the command line or its configution file.
67+
68+ NOTE THAT RUNNING THIS SCRIPT WILL DOWNLOAD A LOT OF DATA BY DEFAULT. More
69+ specifically, it will download every ISO by default, for a total of several
70+ tens of gigabytes of data.
71+base: core18
72+confinement: strict
73+adopt-info: dl-ubuntu-test-iso
74+
75+parts:
76+ dl-ubuntu-test-iso:
77+ plugin: nil
78+ source: .
79+ stage-packages:
80+ - python3
81+ - python3-distro-info
82+ - python3-launchpadlib
83+ - rsync
84+ - zsync
85+ override-build: |
86+ cp dl-ubuntu-test-iso ${SNAPCRAFT_PART_INSTALL}/usr/bin
87+ DOCDIR="${SNAPCRAFT_PART_INSTALL}/usr/share/doc/dl-ubuntu-test-iso"
88+ mkdir -p ${DOCDIR}
89+ cp README ${DOCDIR}/dl-ubuntu-test-iso.README
90+ snapcraftctl set-version "$(date +%Y%m%d)"
91+
92+apps:
93+ dl-ubuntu-test-iso:
94+ command: dl-ubuntu-test-iso
95+ plugs:
96+ - home
97+ - network
98+ - removable-media
99+ environment:
100+ ISOROOT: ${SNAP_USER_COMMON}/iso

Subscribers

People subscribed via source and target branches