Can we just remove _tgz_ from the method name,
and add the squashfs handling in there? Something like
extract_root_from_file
extract_root_from_url
Then we could push some of the logic for source and format hanlding into those two functions.
Something like this:
if source['type'].startswith('dd-'):
continue
if source['uri'].startswith("cp://"): copy_to_target(source['uri'], target)
elif os.path.isfile(source['uri']) or source['uri'].startswith("file://"): extract_root_from_file(source['uri'], fmt=source['type'], target=target)
elif (source['uri'].startswith("http://") or source['uri'].startswith("https://")): extract_root_from_url(source['uri'], fmt=source['type'], target=target)
else:
raise TypeError("do not know how to extract '%s'" % source['uri'])
The extract logic currently is like:
dd-
continue
cp://
copy_to_target
isfile: root_tgz_ file
extract_
file:// root_tgz_ file
extract_
http[s]:// root_tgz_ url
extract_
Can we just remove _tgz_ from the method name,
and add the squashfs handling in there? Something like
extract_ root_from_ file root_from_ url
extract_
Then we could push some of the logic for source and format hanlding into those two functions.
Something like this:
if source[ 'type'] .startswith( 'dd-'): 'uri']. startswith( "cp://" ):
copy_to_ target( source[ 'uri'], target) isfile( source[ 'uri']) or source[ 'uri']. startswith( "file:/ /"):
extract_ root_from_ file(source[ 'uri'], fmt=source['type'],
target= target) 'uri']. startswith( "http://") or
source[ 'uri']. startswith( "https://")):
extract_ root_from_ url(source[ 'uri'], fmt=source['type'],
target= target)
continue
if source[
elif os.path.
elif (source[
else:
raise TypeError("do not know how to extract '%s'" % source['uri'])
def extract_ root_from_ file(source, fmt=None, target=None): startswith( 'file:/ /'): len('file: //'):] root_fsimage( source, target)
curtin. util.subp( args=[' tar', '-C', target] +
tar_ xattr_opts( ) +
['- Sxpzf', source, '--numeric-owner'])
if source.
source = source[
if fmt == "fsimage":
return extract_
else:
def extract_ root_from_ url(source, fmt=None, target=None): root_fsimage_ url(source, target)
curtin. util.subp( args=[' sh', '-cf',
( 'wget "$1" --progress=dot:mega -O - |'
'smtar -C "$2" ' + ' '.join( tar_xattr_ opts()) +
' ' + '-Sxpf - --numeric-owner'),
' --', source, target])
if fmt == "fsimage":
return extract_
else: