38
def tar_xattr_opts(cmd=None):
39
# if tar cmd supports xattrs, return the required flags to extract them.
43
if isinstance(cmd, str):
46
(out, _err) = curtin.util.subp(cmd + ['--help'], capture=True)
49
return ['--xattrs', '--xattrs-include=*', '--acls']
38
53
def extract_root_tgz_url(source, target):
39
curtin.util.subp(args=['sh', '-c',
54
curtin.util.subp(args=['sh', '-cf',
40
55
('wget "$1" --progress=dot:mega -O - |'
41
'tar -C "$2" -Sxpzf - --numeric-owner'),
56
'tar -C "$2" ' + ' '.join(tar_xattr_opts()) +
57
' ' + '-Sxpzf - --numeric-owner'),
42
58
'--', source, target])
45
61
def extract_root_tgz_file(source, target):
46
curtin.util.subp(args=['tar', '-C', target, '-Sxpzf', source,
62
curtin.util.subp(args=['tar', '-C', target] +
63
tar_xattr_opts() + ['-Sxpzf', source, '--numeric-owner'])
50
66
def copy_to_target(source, target):
80
96
LOG.debug("Installing sources: %s to target at %s" % (sources, target))
82
98
for source in sources:
83
if source.startswith("cp://"):
84
copy_to_target(source, target)
85
elif os.path.isfile(source):
86
extract_root_tgz_file(source, target)
87
elif source.startswith("file://"):
88
extract_root_tgz_file(source[len("file://"):], target)
89
elif source.startswith("http://") or source.startswith("https://"):
90
extract_root_tgz_url(source, target)
99
if source['type'].startswith('dd-'):
101
if source['uri'].startswith("cp://"):
102
copy_to_target(source['uri'], target)
103
elif os.path.isfile(source['uri']):
104
extract_root_tgz_file(source['uri'], target)
105
elif source['uri'].startswith("file://"):
106
extract_root_tgz_file(
107
source['uri'][len("file://"):],
109
elif (source['uri'].startswith("http://") or
110
source['uri'].startswith("https://")):
111
extract_root_tgz_url(source['uri'], target)
92
raise TypeError("do not know how to extract '%s'", source)
114
"do not know how to extract '%s'" %
95
118
def POPULATE_SUBCMD(parser):