← Back to team overview

ubuntu-bugcontrol team mailing list archive

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

 

Jean-Baptiste Lallement has proposed merging ubuntu-qa-tools:dl-ubuntu-test-iso-snap into ubuntu-qa-tools:master.

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.

Requested reviews:
  Ubuntu Bug Control (ubuntu-bugcontrol)

For more details, see:
https://code.launchpad.net/~ubuntu-bugcontrol/ubuntu-qa-tools/+git/ubuntu-qa-tools/+merge/382314
-- 
Your team Ubuntu Bug Control is requested to review the proposed merge of ubuntu-qa-tools:dl-ubuntu-test-iso-snap into ubuntu-qa-tools:master.
diff --git a/dl-ubuntu-test-iso/dl-ubuntu-test-iso b/dl-ubuntu-test-iso/dl-ubuntu-test-iso
index 3e21aa6..fc34eab 100755
--- a/dl-ubuntu-test-iso/dl-ubuntu-test-iso
+++ b/dl-ubuntu-test-iso/dl-ubuntu-test-iso
@@ -19,6 +19,7 @@ import subprocess
 import stat
 import signal
 import sys
+import shutil
 
 try:
     import distro_info
@@ -72,7 +73,8 @@ except ImportError:
     print("Unable to import launchpadlib")
     default["do_release_check"] = False
 
-zsync_binary = "/usr/bin/zsync"
+zsync_binary = shutil.which("zsync")
+rsync_binary = shutil.which("rsync")
 
 
 class Flavor(object):
@@ -420,7 +422,11 @@ def do_zsync(config, destination, uri, isoname):
 
 
 def _do_rsync(config, source, target):
-    command = ["/usr/bin/rsync", "-zthLP", "rsync://%s/cdimage%s" % (config.host, source), target]
+    if not rsync_binary or not os.path.exists(rsync_binary):
+        config._log("Warning! rsync is not installed. Aborting.")
+        sys.exit(1)
+
+    command = [rsync_binary, "-zthLP", "rsync://%s/cdimage%s" % (config.host, source), target]
     if len(config.bwlimit) > 0:
         command.insert(2, "--bwlimit=" + config.bwlimit)
     if config.quiet:
@@ -470,7 +476,7 @@ def do_verify(config, destination, hashsuffix, path, iso):
     with open(local) as f:
         for line in f:
             if iso in line:
-                digest = re.split("\s+", line)[0]
+                digest = re.split(r"\s+", line)[0]
                 break
 
     if not digest:
@@ -819,7 +825,7 @@ def main():
     else:
         config._log = my_log
 
-    if config.use_zsync and not os.path.exists(zsync_binary):
+    if config.use_zsync and (not zsync_binary or not os.path.exists(zsync_binary)):
         config._log("Warning! zsync is not installed, falling back to rsync")
         config.use_zsync = False
 
diff --git a/dl-ubuntu-test-iso/snapcraft.yaml b/dl-ubuntu-test-iso/snapcraft.yaml
new file mode 100644
index 0000000..284b1b7
--- /dev/null
+++ b/dl-ubuntu-test-iso/snapcraft.yaml
@@ -0,0 +1,41 @@
+name: dl-ubuntu-test-iso
+grade: stable
+summary: Easily download daily Ubuntu and flavours ISOs
+description: |
+  dl-ubuntu-test-iso is a command line tool to download daily images of
+  Ubuntu and its flavors from cdimage.ubuntu.com. It is highly configurable
+  from the command line or its configution file.
+
+  NOTE THAT RUNNING THIS SCRIPT WILL DOWNLOAD A LOT OF DATA BY DEFAULT. More
+  specifically, it will download every ISO by default, for a total of several
+  tens of gigabytes of data.
+base: core18
+confinement: strict
+adopt-info: dl-ubuntu-test-iso
+
+parts:
+  dl-ubuntu-test-iso:
+    plugin: nil
+    source: .
+    stage-packages:
+      - python3
+      - python3-distro-info
+      - python3-launchpadlib
+      - rsync
+      - zsync
+    override-build: |
+      cp dl-ubuntu-test-iso ${SNAPCRAFT_PART_INSTALL}/usr/bin
+      DOCDIR="${SNAPCRAFT_PART_INSTALL}/usr/share/doc/dl-ubuntu-test-iso"
+      mkdir -p ${DOCDIR}
+      cp README ${DOCDIR}/dl-ubuntu-test-iso.README
+      snapcraftctl set-version "$(date +%Y%m%d)"
+
+apps:
+  dl-ubuntu-test-iso:
+    command: dl-ubuntu-test-iso
+    plugs:
+      - home
+      - network
+      - removable-media
+    environment:
+      ISOROOT: ${SNAP_USER_COMMON}/iso

Follow ups