summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/__init__.py
diff options
context:
space:
mode:
authorStefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>2021-11-25 13:59:51 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-11-26 17:01:37 +0000
commit8091ad4347ecbf14fcf4d1ee2d47b91670932cf8 (patch)
treedd110b33ab5c4807a31023ed318321178c42c5d6 /bitbake/lib/bb/fetch2/__init__.py
parent11ecd7628c49ec7b7cc44be48c86e4aee0a0d345 (diff)
downloadpoky-8091ad4347ecbf14fcf4d1ee2d47b91670932cf8.tar.gz
bitbake: fetch2: Unify tar command in unpack
The tar command and its arguments are repeated for many archive types in the unpack function. Unify the common parts in a variable to prepare further extension. (Bitbake rev: a08e57c9eaec1d9740a96149bf4843e576da4e5c) Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/__init__.py')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index ded3106173..b0d5508d06 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -1458,30 +1458,31 @@ class FetchMethod(object):
1458 cmd = None 1458 cmd = None
1459 1459
1460 if unpack: 1460 if unpack:
1461 tar_cmd = 'tar --extract --no-same-owner'
1461 if file.endswith('.tar'): 1462 if file.endswith('.tar'):
1462 cmd = 'tar x --no-same-owner -f %s' % file 1463 cmd = '%s -f %s' % (tar_cmd, file)
1463 elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'): 1464 elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'):
1464 cmd = 'tar xz --no-same-owner -f %s' % file 1465 cmd = '%s -z -f %s' % (tar_cmd, file)
1465 elif file.endswith('.tbz') or file.endswith('.tbz2') or file.endswith('.tar.bz2'): 1466 elif file.endswith('.tbz') or file.endswith('.tbz2') or file.endswith('.tar.bz2'):
1466 cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file 1467 cmd = 'bzip2 -dc %s | %s -f -' % (file, tar_cmd)
1467 elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'): 1468 elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
1468 cmd = 'gzip -dc %s > %s' % (file, efile) 1469 cmd = 'gzip -dc %s > %s' % (file, efile)
1469 elif file.endswith('.bz2'): 1470 elif file.endswith('.bz2'):
1470 cmd = 'bzip2 -dc %s > %s' % (file, efile) 1471 cmd = 'bzip2 -dc %s > %s' % (file, efile)
1471 elif file.endswith('.txz') or file.endswith('.tar.xz'): 1472 elif file.endswith('.txz') or file.endswith('.tar.xz'):
1472 cmd = 'xz -dc %s | tar x --no-same-owner -f -' % file 1473 cmd = 'xz -dc %s | %s -f -' % (file, tar_cmd)
1473 elif file.endswith('.xz'): 1474 elif file.endswith('.xz'):
1474 cmd = 'xz -dc %s > %s' % (file, efile) 1475 cmd = 'xz -dc %s > %s' % (file, efile)
1475 elif file.endswith('.tar.lz'): 1476 elif file.endswith('.tar.lz'):
1476 cmd = 'lzip -dc %s | tar x --no-same-owner -f -' % file 1477 cmd = 'lzip -dc %s | %s -f -' % (file, tar_cmd)
1477 elif file.endswith('.lz'): 1478 elif file.endswith('.lz'):
1478 cmd = 'lzip -dc %s > %s' % (file, efile) 1479 cmd = 'lzip -dc %s > %s' % (file, efile)
1479 elif file.endswith('.tar.7z'): 1480 elif file.endswith('.tar.7z'):
1480 cmd = '7z x -so %s | tar x --no-same-owner -f -' % file 1481 cmd = '7z x -so %s | %s -f -' % (file, tar_cmd)
1481 elif file.endswith('.7z'): 1482 elif file.endswith('.7z'):
1482 cmd = '7za x -y %s 1>/dev/null' % file 1483 cmd = '7za x -y %s 1>/dev/null' % file
1483 elif file.endswith('.tzst') or file.endswith('.tar.zst'): 1484 elif file.endswith('.tzst') or file.endswith('.tar.zst'):
1484 cmd = 'zstd --decompress --stdout %s | tar x --no-same-owner -f -' % file 1485 cmd = 'zstd --decompress --stdout %s | %s -f -' % (file, tar_cmd)
1485 elif file.endswith('.zst'): 1486 elif file.endswith('.zst'):
1486 cmd = 'zstd --decompress --stdout %s > %s' % (file, efile) 1487 cmd = 'zstd --decompress --stdout %s > %s' % (file, efile)
1487 elif file.endswith('.zip') or file.endswith('.jar'): 1488 elif file.endswith('.zip') or file.endswith('.jar'):
@@ -1514,7 +1515,7 @@ class FetchMethod(object):
1514 raise UnpackError("Unable to unpack deb/ipk package - does not contain data.tar.* file", urldata.url) 1515 raise UnpackError("Unable to unpack deb/ipk package - does not contain data.tar.* file", urldata.url)
1515 else: 1516 else:
1516 raise UnpackError("Unable to unpack deb/ipk package - could not list contents", urldata.url) 1517 raise UnpackError("Unable to unpack deb/ipk package - could not list contents", urldata.url)
1517 cmd = 'ar x %s %s && tar --no-same-owner -xpf %s && rm %s' % (file, datafile, datafile, datafile) 1518 cmd = 'ar x %s %s && %s -p -f %s && rm %s' % (file, datafile, tar_cmd, datafile, datafile)
1518 1519
1519 # If 'subdir' param exists, create a dir and use it as destination for unpack cmd 1520 # If 'subdir' param exists, create a dir and use it as destination for unpack cmd
1520 if 'subdir' in urldata.parm: 1521 if 'subdir' in urldata.parm: