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
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
Pipeline
#17532
failed with stage
in 0 seconds
Changes
1
Pipelines
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
...
@@ -29,14 +29,15 @@ import linecache
import
logging
import
logging
import
os
import
os
from
platform
import
uname
from
platform
import
uname
import
setuptools
import
shlex
import
shlex
import
shutil
import
shutil
import
subprocess
import
subprocess
import
sys
import
sys
import
tempfile
import
tempfile
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
ARCH_MAP
=
{
ARCH_MAP
=
{
'i386'
:
'x86'
,
'i386'
:
'x86'
,
...
@@ -161,9 +162,13 @@ class Script(EnvironMixin):
...
@@ -161,9 +162,13 @@ class Script(EnvironMixin):
def
extract
(
self
,
path
):
def
extract
(
self
,
path
):
extract_dir
=
tempfile
.
mkdtemp
(
self
.
name
)
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
.
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
return
extract_dir
def
pipeCommand
(
self
,
command_list_list
,
*
args
,
**
kwargs
):
def
pipeCommand
(
self
,
command_list_list
,
*
args
,
**
kwargs
):
...
@@ -190,7 +195,7 @@ class Script(EnvironMixin):
...
@@ -190,7 +195,7 @@ class Script(EnvironMixin):
raise
zc
.
buildout
.
UserError
(
'Failed while running:
\
n
'
raise
zc
.
buildout
.
UserError
(
'Failed while running:
\
n
'
+
'
\
n
'
.
join
(
failed
))
+
'
\
n
'
.
join
(
failed
))
def
copyTree
(
self
,
origin
,
destination
,
ignore_dir_list
=
None
):
def
copyTree
(
self
,
origin
,
destination
,
ignore_dir_list
=
()
):
"""Recursively Copy directory.
"""Recursively Copy directory.
ignore_dir_list is a list of relative directories you want to exclude.
ignore_dir_list is a list of relative directories you want to exclude.
...
@@ -201,21 +206,13 @@ class Script(EnvironMixin):
...
@@ -201,21 +206,13 @@ class Script(EnvironMixin):
# that does not belong to us.
# that does not belong to us.
if
os
.
path
.
exists
(
destination
):
if
os
.
path
.
exists
(
destination
):
raise
shutil
.
Error
(
'Destination already exists: %s'
%
destination
)
raise
shutil
.
Error
(
'Destination already exists: %s'
%
destination
)
self
.
logger
.
info
(
"Copying %s to %s"
%
(
origin
,
destination
))
self
.
logger
.
info
(
"Copying %r to %r"
,
origin
,
destination
)
if
ignore_dir_list
is
None
:
ignore_dir_list
=
[]
try
:
try
:
shutil
.
copytree
(
origin
,
destination
,
shutil
.
copytree
(
origin
,
destination
,
symlinks
=
True
,
ignore
=
lambda
src
,
names
:
ignore_dir_list
)
ignore
=
lambda
src
,
names
:
ignore_dir_list
)
except
(
shutil
.
Error
,
OSError
)
as
error
:
except
:
# Cleanup in case of failure
self
.
cleanup_list
.
append
(
destination
)
try
:
raise
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
cleanup_dir_list
=
cleanup_file_list
=
property
(
cleanup_dir_list
=
cleanup_file_list
=
property
(
lambda
self
:
self
.
cleanup_list
)
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