]> code.ossystems Code Review - openembedded-core.git/commitdiff
scripts/lib/wic/engine: Fix cp's target path for ext* filesystems
authorLeonardo Augusto <leobsd@gmail.com>
Fri, 8 Feb 2019 16:35:12 +0000 (08:35 -0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 14 Feb 2019 11:20:06 +0000 (11:20 +0000)
Python subprocess' shell=True defaults to /bin/sh[1][2], which
often refers to a POSIX-compliant shell. As the -e flag is
not defined in the POSIX standard[3], some shells may
interpret "-e" as the first argument to the echo command,
causing the rest of the command line to fail.

In this particular case, "echo -e 'cd {}'" is interpreted
as "-e cd {}", which causes the first line of the command
to fail, and causing cp to always place the source file
in the filesystem's root.

Replacing "echo -e" for a printf command makes this
more portable.

This issue only affects "wic cp" for ext* filesystems.

[1] https://docs.python.org/2/library/subprocess.html
[2] https://docs.python.org/3/library/subprocess.html
[3] http://pubs.opengroup.org/onlinepubs/9699919799

Signed-off-by: Leonardo Augusto <leobsd@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/lib/wic/engine.py

index 4662c665c0ef704b2e6410734eefb24a6e48595f..97f5e848cc4d58afeeed3ee4b56db5346300be0e 100644 (file)
@@ -331,7 +331,7 @@ class Disk:
     def copy(self, src, pnum, path):
         """Copy partition image into wic image."""
         if self.partitions[pnum].fstype.startswith('ext'):
-            cmd = "echo -e 'cd {}\nwrite {} {}' | {} -w {}".\
+            cmd = "printf 'cd {}\nwrite {} {}' | {} -w {}".\
                       format(path, src, os.path.basename(src),
                              self.debugfs, self._get_part_image(pnum))
         else: # fat