From: "sh0127.shin" <[email protected]>
Some tar archives contain directories with restrictive
permissions (e.g. drw-r--r--) that can prevent extraction
or subsequent processing from completing successfully.
Extend FetchMethod.unpack() with a new 'fixperms' SRC_URI
parameter.
When 'fixperms=1' is specified:
1. Add --delay-directory-restore to the tar command to
defer directory permission restoration until all
contents are extracted.
2. Apply chmod -R +X after extraction to ensure
directories remain traversable and executable files
retain appropriate execute permissions.
Usage:
SRC_URI = "https://example.com/foo.tgz;fixperms=1"
Signed-off-by: sh0127.shin <[email protected]>
---
lib/bb/fetch2/__init__.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index 9cb268be5..1c3bab6d7 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -1564,6 +1564,8 @@ class FetchMethod(object):
if unpack:
tar_cmd = ['tar', '--extract', '--no-same-owner']
+ if 'fixperms' in urldata.parm and urldata.parm['fixperms'] == '1':
+ tar_cmd.append('--delay-directory-restore')
if 'striplevel' in urldata.parm:
striplevel = urldata.parm['striplevel']
if not striplevel.isdigit():
@@ -1659,6 +1661,9 @@ class FetchMethod(object):
bb.note("Unpacking %s to %s/" % (file, unpackdir))
_run(cmd)
+ if 'fixperms' in urldata.parm and urldata.parm['fixperms'] == '1':
+ _run(['chmod', '-R', '+X', unpackdir])
+
if iterate is True:
iterate_urldata = urldata
iterate_urldata.localpath = "%s/%s" % (rootdir, iterate_file)
--
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.