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
aa0bf7e0
Commit
aa0bf7e0
authored
Mar 08, 2017
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
downloadunpacked: support .xz and .lz archives.
parent
e3e15b9f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
1 deletion
+33
-1
slapos/recipe/downloadunpacked.py
slapos/recipe/downloadunpacked.py
+33
-1
No files found.
slapos/recipe/downloadunpacked.py
View file @
aa0bf7e0
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
import
os
import
os
import
logging
import
logging
import
shutil
import
shutil
import
subprocess
import
tarfile
import
tarfile
import
zc.buildout
import
zc.buildout
import
tempfile
import
tempfile
...
@@ -70,6 +71,24 @@ class Recipe:
...
@@ -70,6 +71,24 @@ class Recipe:
options
[
'target'
]
=
self
.
destination
options
[
'target'
]
=
self
.
destination
options
.
setdefault
(
'extract-directory'
,
''
)
options
.
setdefault
(
'extract-directory'
,
''
)
self
.
environ
=
{}
self
.
original_environment
=
os
.
environ
.
copy
()
environment_section
=
self
.
options
.
get
(
'environment-section'
,
''
).
strip
()
if
environment_section
and
environment_section
in
buildout
:
# Use environment variables from the designated config section.
self
.
environ
.
update
(
buildout
[
environment_section
])
for
variable
in
self
.
options
.
get
(
'environment'
,
''
).
splitlines
():
if
variable
.
strip
():
try
:
key
,
value
=
variable
.
split
(
'='
,
1
)
self
.
environ
[
key
.
strip
()]
=
value
except
ValueError
:
raise
zc
.
buildout
.
UserError
(
'Invalid environment variable definition: %s'
,
variable
)
# Extrapolate the environment variables using values from the current
# environment.
for
key
in
self
.
environ
:
self
.
environ
[
key
]
=
self
.
environ
[
key
]
%
os
.
environ
def
install
(
self
):
def
install
(
self
):
if
self
.
parts
is
not
None
:
if
self
.
parts
is
not
None
:
if
not
os
.
path
.
isdir
(
self
.
parts
):
if
not
os
.
path
.
isdir
(
self
.
parts
):
...
@@ -83,6 +102,19 @@ class Recipe:
...
@@ -83,6 +102,19 @@ class Recipe:
self
.
logger
.
debug
(
'Created working directory %r'
%
extract_dir
)
self
.
logger
.
debug
(
'Created working directory %r'
%
extract_dir
)
try
:
try
:
patch_archive_util
()
patch_archive_util
()
# ad-hoc support for .xz and .lz archive
hdr
=
file
(
path
).
read
(
6
)
if
hdr
==
'
\
xfd
7zXZ
\
x00
'
:
new_path
=
os
.
path
.
join
(
extract_dir
,
os
.
path
.
basename
(
path
))
file
(
new_path
,
'w'
).
write
(
subprocess
.
check_output
([
'xzcat'
,
path
],
env
=
self
.
environ
))
setuptools
.
archive_util
.
unpack_archive
(
new_path
,
extract_dir
)
os
.
unlink
(
new_path
)
elif
hdr
.
startswith
(
'LZIP'
):
new_path
=
os
.
path
.
join
(
extract_dir
,
os
.
path
.
basename
(
path
))
file
(
new_path
,
'w'
).
write
(
subprocess
.
check_output
([
'lunzip'
,
'-c'
,
path
],
env
=
self
.
environ
))
setuptools
.
archive_util
.
unpack_archive
(
new_path
,
extract_dir
)
os
.
unlink
(
new_path
)
else
:
setuptools
.
archive_util
.
unpack_archive
(
path
,
extract_dir
)
setuptools
.
archive_util
.
unpack_archive
(
path
,
extract_dir
)
finally
:
finally
:
unpatch_archive_util
()
unpatch_archive_util
()
...
...
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