← Back to team overview

curtin-dev team mailing list archive

[Merge] ~mwhudson/curtin:write-local-image-to-disk into curtin:master

 

Michael Hudson-Doyle has proposed merging ~mwhudson/curtin:write-local-image-to-disk into curtin:master.

Commit message:
support dd-raw:file:// urls



Requested reviews:
  curtin developers (curtin-dev)

For more details, see:
https://code.launchpad.net/~mwhudson/curtin/+git/curtin/+merge/446014

I was quite angry when I wrote this, in case you were wondering.
-- 
Your team curtin developers is requested to review the proposed merge of ~mwhudson/curtin:write-local-image-to-disk into curtin:master.
diff --git a/curtin/commands/block_meta.py b/curtin/commands/block_meta.py
index 34acd75..c221ae3 100644
--- a/curtin/commands/block_meta.py
+++ b/curtin/commands/block_meta.py
@@ -155,11 +155,17 @@ def write_image_to_disk(source, dev):
         'dd-xz': '|xzcat',
         'dd-raw': ''
     }
+    uri = source['uri']
+    if uri.startswith('file://'):
+        uri = uri[len('file://'):]
+        fetch = 'cat "$1"'
+    else:
+        fetch = 'wget "$1" --progress=dot:mega -O -'
     (devname, devnode) = block.get_dev_name_entry(dev)
-    util.subp(args=['sh', '-c',
-                    ('wget "$1" --progress=dot:mega -O - ' +
-                     extractor[source['type']] + '| dd bs=4M of="$2"'),
-                    '--', source['uri'], devnode])
+    util.subp(args=[
+        'sh', '-c',
+        fetch + extractor[source['type']] + ' | dd bs=4M of="$2"',
+        '--', source['uri'], devnode])
     util.subp(['partprobe', devnode])
 
     for i in range(3):

Follow ups