diff options
Diffstat (limited to 'lib/swupd/path.py')
-rw-r--r-- | lib/swupd/path.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/swupd/path.py b/lib/swupd/path.py index 580d0b6..61e979e 100644 --- a/lib/swupd/path.py +++ b/lib/swupd/path.py @@ -9,7 +9,7 @@ def copyxattrtree(src, dst): dst -- the destination to copy to """ import subprocess - cmd = "tar --xattrs --xattrs-include='*' -cf - -C %s -p . | tar -p --xattrs --xattrs-include='*' -xf - -C %s" % (src, dst) + cmd = "bsdtar -cf - -C %s . | bsdtar -xf - -C %s" % (src, dst) subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) @@ -19,8 +19,8 @@ def copyxattrfiles(d, filelist, src, dst, archive=False): d -- the bitbake data store filelist -- a list of file paths - src -- where to copy the files from - dst -- where to copy the files to + src -- where to copy the files from (directory or archive, auto-detected) + dst -- where to copy the files to (directory or archive, depending on archive parameter) archive -- create archive at dst instead of writing into that directory """ import subprocess @@ -29,19 +29,27 @@ def copyxattrfiles(d, filelist, src, dst, archive=False): bb.utils.mkdirhier(os.path.dirname(dst) if archive else dst) files = sorted(filelist) + fromdir = os.path.isdir(src) workdir = d.getVar('WORKDIR', True) fd, copyfile = tempfile.mkstemp(dir=workdir) os.close(fd) with open(copyfile, 'w') as fdest: - fdest.write('-C%s\n' % src) for f in files: fdest.write('%s\n' % f) - if archive: - cmd = "tar --xattrs --xattrs-include='*' --no-recursion -zcf %s -T %s -p" % (dst, copyfile) + if fromdir: + if archive: + cmd = "bsdtar --no-recursion -C %s -zcf %s -T %s -p" % (src, dst, copyfile) + else: + cmd = "bsdtar --no-recursion -C %s -cf - -T %s -p | bsdtar -p -xf - -C %s" % (src, copyfile, dst) else: - cmd = "tar --xattrs --xattrs-include='*' --no-recursion -cf - -T %s -p | tar -p --xattrs --xattrs-include='*' -xf - -C %s" % (copyfile, dst) - subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) + if archive: + # archive->archive not needed at the moment and cannot be done easily, + # because although bsdtar supports reading from an archive with @<archive>, + # filtering entries isn't supported in that mode. + bb.fatal('Extracting files from an archive and writing into an archive not implemented yet.') + else: + cmd = "bsdtar --no-recursion -C %s -xf %s -T %s" % (dst, src, copyfile) output = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT) if output: bb.fatal('Unexpected output from the following command:\n%s\n%s' % (cmd, output)) |