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
a2172850
Commit
a2172850
authored
Sep 27, 2021
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
default: clean up copyTree/extract and preserve symlinks
parent
30e20b79
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
17 deletions
+14
-17
slapos/recipe/build/__init__.py
slapos/recipe/build/__init__.py
+14
-17
No files found.
slapos/recipe/build/__init__.py
View file @
a2172850
...
...
@@ -29,14 +29,15 @@ import linecache
import
logging
import
os
from
platform
import
uname
import
setuptools
import
shlex
import
shutil
import
subprocess
import
sys
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
ARCH_MAP
=
{
'i386'
:
'x86'
,
...
...
@@ -161,9 +162,13 @@ class Script(EnvironMixin):
def
extract
(
self
,
path
):
extract_dir
=
tempfile
.
mkdtemp
(
self
.
name
)
self
.
logger
.
debug
(
'Created working directory %r'
%
extract_dir
)
setuptools
.
archive_util
.
unpack_archive
(
path
,
extract_dir
)
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
return
extract_dir
def
pipeCommand
(
self
,
command_list_list
,
*
args
,
**
kwargs
):
...
...
@@ -190,7 +195,7 @@ class Script(EnvironMixin):
raise
zc
.
buildout
.
UserError
(
'Failed while running:
\
n
'
+
'
\
n
'
.
join
(
failed
))
def
copyTree
(
self
,
origin
,
destination
,
ignore_dir_list
=
None
):
def
copyTree
(
self
,
origin
,
destination
,
ignore_dir_list
=
()
):
"""Recursively Copy directory.
ignore_dir_list is a list of relative directories you want to exclude.
...
...
@@ -201,21 +206,13 @@ class Script(EnvironMixin):
# that does not belong to us.
if
os
.
path
.
exists
(
destination
):
raise
shutil
.
Error
(
'Destination already exists: %s'
%
destination
)
self
.
logger
.
info
(
"Copying %s to %s"
%
(
origin
,
destination
))
if
ignore_dir_list
is
None
:
ignore_dir_list
=
[]
self
.
logger
.
info
(
"Copying %r to %r"
,
origin
,
destination
)
try
:
shutil
.
copytree
(
origin
,
destination
,
shutil
.
copytree
(
origin
,
destination
,
symlinks
=
True
,
ignore
=
lambda
src
,
names
:
ignore_dir_list
)
except
(
shutil
.
Error
,
OSError
)
as
error
:
# Cleanup in case of failure
try
:
shutil
.
rmtree
(
destination
,
ignore_errors
=
True
)
except
(
shutil
.
Error
,
OSError
)
as
strerror
:
self
.
logger
.
error
(
"Error occurred when cleaning after error: %s"
,
strerror
)
raise
error
return
True
except
:
self
.
cleanup_list
.
append
(
destination
)
raise
cleanup_dir_list
=
cleanup_file_list
=
property
(
lambda
self
:
self
.
cleanup_list
)
...
...
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