Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.recipe.build
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Leymonerie
slapos.recipe.build
Commits
c4362bb8
Commit
c4362bb8
authored
Dec 26, 2021
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
default: add support for xz/lz archives to 'self.extract'
parent
1046b48f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
29 deletions
+22
-29
slapos/recipe/build/__init__.py
slapos/recipe/build/__init__.py
+2
-6
slapos/recipe/downloadunpacked.py
slapos/recipe/downloadunpacked.py
+20
-23
No files found.
slapos/recipe/build/__init__.py
View file @
c4362bb8
...
...
@@ -36,7 +36,7 @@ import tempfile
from
setuptools
import
archive_util
import
zc.buildout
from
..
import
is_true
,
rmtree
,
EnvironMixin
,
Shared
from
..downloadunpacked
import
extraction_drivers
,
patched_extraction_drivers
from
..downloadunpacked
import
unpack_archive
def
readElfAsDict
(
f
):
"""Reads ELF information from file"""
...
...
@@ -155,11 +155,7 @@ class Script(EnvironMixin):
extract_dir
=
tempfile
.
mkdtemp
(
self
.
name
)
self
.
cleanup_list
.
append
(
extract_dir
)
self
.
logger
.
debug
(
'Created working directory: %s'
,
extract_dir
)
try
:
archive_util
.
extraction_drivers
=
patched_extraction_drivers
archive_util
.
unpack_archive
(
path
,
extract_dir
)
finally
:
archive_util
.
extraction_drivers
=
extraction_drivers
unpack_archive
(
self
,
path
,
extract_dir
)
return
extract_dir
def
pipeCommand
(
self
,
command_list_list
,
*
args
,
**
kwargs
):
...
...
slapos/recipe/downloadunpacked.py
View file @
c4362bb8
...
...
@@ -66,25 +66,10 @@ class Recipe(EnvironMixin):
hash_name
=
True
)(
self
.
_url
,
self
.
options
.
get
(
'md5sum'
)
or
None
,
**
({
'alternate_url'
:
alternate
}
if
alternate
else
{}))
try
:
archive_util
.
extraction_drivers
=
patched_extraction_drivers
# ad-hoc support for .xz and .lz archive
with
open
(
path
,
'rb'
)
as
f
:
hdr
=
f
.
read
(
6
)
for
magic
,
cmd
in
((
b'
\
xfd
7zXZ
\
x00
'
,
(
'xzcat'
,)),
(
b'LZIP'
,
(
'lunzip'
,
'-c'
))):
if
hdr
.
startswith
(
magic
):
with
tempfile
.
NamedTemporaryFile
()
as
uncompressed_archive
:
subprocess
.
check_call
(
cmd
+
(
path
,),
stdout
=
uncompressed_archive
,
env
=
self
.
environ
)
archive_util
.
unpack_archive
(
uncompressed_archive
.
name
,
location
)
break
else
:
archive_util
.
unpack_archive
(
path
,
location
)
unpack_archive
(
self
,
path
,
location
)
finally
:
if
is_temp
:
os
.
unlink
(
path
)
archive_util
.
extraction_drivers
=
extraction_drivers
strip
=
self
.
_strip
if
strip
is
None
:
...
...
@@ -108,9 +93,11 @@ class Recipe(EnvironMixin):
def
update
(
self
):
pass
# Monkey patch to keep symlinks in tarfile
def
unpack_tarfile_patched
(
filename
,
extract_dir
,
progress_filter
=
archive_util
.
default_filter
):
def
unpack_archive
(
recipe
,
*
args
):
# Monkey patch to keep symlinks in tarfile
def
unpack_tarfile_patched
(
filename
,
extract_dir
,
progress_filter
=
archive_util
.
default_filter
):
"""Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined
...
...
@@ -120,6 +107,18 @@ def unpack_tarfile_patched(filename, extract_dir,
try
:
tarobj
=
tarfile
.
open
(
filename
)
except
tarfile
.
TarError
:
# ad-hoc support for .xz and .lz archive
with
open
(
filename
,
'rb'
)
as
f
:
hdr
=
f
.
read
(
6
)
for
magic
,
cmd
in
((
b'
\
xfd
7zXZ
\
x00
'
,
(
'xzcat'
,)),
(
b'LZIP'
,
(
'lunzip'
,
'-c'
))):
if
hdr
.
startswith
(
magic
):
with
tempfile
.
NamedTemporaryFile
()
as
uncompressed_archive
:
subprocess
.
check_call
(
cmd
+
(
filename
,),
stdout
=
uncompressed_archive
,
env
=
recipe
.
environ
)
archive_util
.
unpack_archive
(
uncompressed_archive
.
name
,
extract_dir
,
progress_filter
)
return
True
raise
archive_util
.
UnrecognizedFormat
(
"%s is not a compressed or uncompressed tar file"
%
(
filename
,)
)
...
...
@@ -148,7 +147,5 @@ def unpack_tarfile_patched(filename, extract_dir,
pass
return
True
extraction_drivers
=
archive_util
.
extraction_drivers
patched_extraction_drivers
=
extraction_drivers
[:
2
]
+
(
unpack_tarfile_patched
,
)
return
archive_util
.
unpack_archive
(
*
args
,
drivers
=
archive_util
.
extraction_drivers
[:
2
]
+
(
unpack_tarfile_patched
,))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment