← Back to team overview

curtin-dev team mailing list archive

[Merge] ~mwhudson/curtin:extra-rsync-args into curtin:master

 

Michael Hudson-Doyle has proposed merging ~mwhudson/curtin:extra-rsync-args into curtin:master.

Commit message:
extract: allow config to supply extra arguments to rsync



Requested reviews:
  curtin developers (curtin-dev)

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

I want this for one potential way around issues populating a reset partition.
-- 
Your team curtin developers is requested to review the proposed merge of ~mwhudson/curtin:extra-rsync-args into curtin:master.
diff --git a/curtin/commands/extract.py b/curtin/commands/extract.py
index bfcb076..7df4242 100644
--- a/curtin/commands/extract.py
+++ b/curtin/commands/extract.py
@@ -199,27 +199,31 @@ def get_handler_for_source(source):
         return None
 
 
-def extract_source(source, target):
+def extract_source(install_cfg, source, target):
     handler = get_handler_for_source(source)
     if handler is not None:
         root_dir = handler.setup()
         try:
-            copy_to_target(root_dir, target)
+            copy_to_target(install_cfg, root_dir, target)
         finally:
             handler.cleanup()
     else:
         extract_root_tgz_url(source['uri'], target=target)
 
 
-def copy_to_target(source, target):
+def copy_to_target(install_cfg, source, target):
     if source.startswith("cp://"):
         source = source[5:]
     source = os.path.abspath(source)
 
-    util.subp(args=['sh', '-c',
-                    ('mkdir -p "$2" && cd "$2" && '
-                     'rsync -aXHAS --one-file-system "$1/" .'),
-                    '--', source, target])
+    os.makedirs(target, exist_ok=True)
+
+    util.subp(
+        args=[
+            'rsync', '-aXHAS', '--one-file-system'
+            ] + install_cfg.get('extra-rsync-args', []) + [
+            source + '/', '.'],
+        cwd=target)
 
 
 def _path_from_file_url(url):
@@ -255,7 +259,7 @@ def extract(args):
                 source['uri']):
             if source['type'].startswith('dd-'):
                 continue
-            extract_source(source, target)
+            extract_source(cfg.get('install', {}), source, target)
 
     if cfg.get('write_files'):
         LOG.info("Applying write_files from config.")

Follow ups