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
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
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
Pipeline
#19076
passed with stage
in 0 seconds
Changes
2
Pipelines
1
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
...
@@ -36,7 +36,7 @@ import tempfile
from
setuptools
import
archive_util
from
setuptools
import
archive_util
import
zc.buildout
import
zc.buildout
from
..
import
is_true
,
rmtree
,
EnvironMixin
,
Shared
from
..
import
is_true
,
rmtree
,
EnvironMixin
,
Shared
from
..downloadunpacked
import
extraction_drivers
,
patched_extraction_drivers
from
..downloadunpacked
import
unpack_archive
def
readElfAsDict
(
f
):
def
readElfAsDict
(
f
):
"""Reads ELF information from file"""
"""Reads ELF information from file"""
...
@@ -155,11 +155,7 @@ class Script(EnvironMixin):
...
@@ -155,11 +155,7 @@ class Script(EnvironMixin):
extract_dir
=
tempfile
.
mkdtemp
(
self
.
name
)
extract_dir
=
tempfile
.
mkdtemp
(
self
.
name
)
self
.
cleanup_list
.
append
(
extract_dir
)
self
.
cleanup_list
.
append
(
extract_dir
)
self
.
logger
.
debug
(
'Created working directory: %s'
,
extract_dir
)
self
.
logger
.
debug
(
'Created working directory: %s'
,
extract_dir
)
try
:
unpack_archive
(
self
,
path
,
extract_dir
)
archive_util
.
extraction_drivers
=
patched_extraction_drivers
archive_util
.
unpack_archive
(
path
,
extract_dir
)
finally
:
archive_util
.
extraction_drivers
=
extraction_drivers
return
extract_dir
return
extract_dir
def
pipeCommand
(
self
,
command_list_list
,
*
args
,
**
kwargs
):
def
pipeCommand
(
self
,
command_list_list
,
*
args
,
**
kwargs
):
...
...
slapos/recipe/downloadunpacked.py
View file @
c4362bb8
...
@@ -66,25 +66,10 @@ class Recipe(EnvironMixin):
...
@@ -66,25 +66,10 @@ class Recipe(EnvironMixin):
hash_name
=
True
)(
self
.
_url
,
self
.
options
.
get
(
'md5sum'
)
or
None
,
hash_name
=
True
)(
self
.
_url
,
self
.
options
.
get
(
'md5sum'
)
or
None
,
**
({
'alternate_url'
:
alternate
}
if
alternate
else
{}))
**
({
'alternate_url'
:
alternate
}
if
alternate
else
{}))
try
:
try
:
archive_util
.
extraction_drivers
=
patched_extraction_drivers
unpack_archive
(
self
,
path
,
location
)
# 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
)
finally
:
finally
:
if
is_temp
:
if
is_temp
:
os
.
unlink
(
path
)
os
.
unlink
(
path
)
archive_util
.
extraction_drivers
=
extraction_drivers
strip
=
self
.
_strip
strip
=
self
.
_strip
if
strip
is
None
:
if
strip
is
None
:
...
@@ -108,9 +93,11 @@ class Recipe(EnvironMixin):
...
@@ -108,9 +93,11 @@ class Recipe(EnvironMixin):
def
update
(
self
):
def
update
(
self
):
pass
pass
# Monkey patch to keep symlinks in tarfile
def
unpack_tarfile_patched
(
filename
,
extract_dir
,
def
unpack_archive
(
recipe
,
*
args
):
progress_filter
=
archive_util
.
default_filter
):
# 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`
"""Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined
Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined
...
@@ -120,6 +107,18 @@ def unpack_tarfile_patched(filename, extract_dir,
...
@@ -120,6 +107,18 @@ def unpack_tarfile_patched(filename, extract_dir,
try
:
try
:
tarobj
=
tarfile
.
open
(
filename
)
tarobj
=
tarfile
.
open
(
filename
)
except
tarfile
.
TarError
:
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
(
raise
archive_util
.
UnrecognizedFormat
(
"%s is not a compressed or uncompressed tar file"
%
(
filename
,)
"%s is not a compressed or uncompressed tar file"
%
(
filename
,)
)
)
...
@@ -148,7 +147,5 @@ def unpack_tarfile_patched(filename, extract_dir,
...
@@ -148,7 +147,5 @@ def unpack_tarfile_patched(filename, extract_dir,
pass
pass
return
True
return
True
extraction_drivers
=
archive_util
.
extraction_drivers
return
archive_util
.
unpack_archive
(
*
args
,
patched_extraction_drivers
=
extraction_drivers
[:
2
]
+
(
drivers
=
archive_util
.
extraction_drivers
[:
2
]
+
(
unpack_tarfile_patched
,))
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