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
9ff1a5a3
Commit
9ff1a5a3
authored
Mar 13, 2020
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
default: clean up
parent
d84cd397
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
53 deletions
+18
-53
slapos/recipe/build/__init__.py
slapos/recipe/build/__init__.py
+18
-53
No files found.
slapos/recipe/build/__init__.py
View file @
9ff1a5a3
...
...
@@ -44,20 +44,10 @@ ARCH_MAP = {
'x86_64'
:
'x86-64'
}
OS_MAP
=
{
'darwin'
:
'mac'
,
'linux2'
:
'linux'
#To be continued
}
def
readElfAsDict
(
f
):
"""Reads ELF information from file"""
popen
=
subprocess
.
Popen
([
'readelf'
,
'-d'
,
f
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
result
=
popen
.
communicate
()[
0
]
if
popen
.
returncode
!=
0
:
raise
AssertionError
(
result
)
result
=
subprocess
.
check_output
((
'readelf'
,
'-d'
,
f
),
stderr
=
subprocess
.
STDOUT
)[
0
]
library_list
=
[]
rpath_list
=
[]
runpath_list
=
[]
...
...
@@ -79,49 +69,25 @@ def readElfAsDict(f):
runpath_list
=
sorted
(
runpath_list
)
)
def
call
(
*
args
,
**
kwargs
):
"""Subprocess call with closed file descriptors and stdin"""
kwargs
.
update
(
stdin
=
subprocess
.
PIPE
,
close_fds
=
True
)
popen
=
subprocess
.
Popen
(
*
args
,
**
kwargs
)
popen
.
stdin
.
flush
()
popen
.
stdin
.
close
()
popen
.
stdin
=
None
popen
.
communicate
()
if
popen
.
returncode
!=
0
:
raise
subprocess
.
CalledProcessError
(
popen
.
returncode
,
' '
.
join
(
args
[
0
]))
def
calls
(
call_string
,
**
kwargs
):
"""Subprocesser caller which allows to pass arguments as string"""
call
(
shlex
.
split
(
call_string
),
**
kwargs
)
def
calli
(
*
args
,
**
kwargs
):
"""Subprocesser call wich allow to pass stdin argument"""
popen
=
subprocess
.
Popen
(
*
args
,
**
kwargs
)
popen
.
communicate
()
if
popen
.
returncode
!=
0
:
raise
subprocess
.
CalledProcessError
(
popen
.
returncode
,
' '
.
join
(
args
[
0
]))
def
guessworkdir
(
path
):
if
len
(
os
.
listdir
(
path
))
==
1
:
return
os
.
path
.
join
(
path
,
os
.
listdir
(
path
)[
0
])
return
path
x
=
os
.
listdir
(
path
)
return
os
.
path
.
join
(
path
,
*
x
)
if
len
(
x
)
==
1
else
path
def
guessPlatform
():
arch
=
uname
()[
-
2
]
target
=
ARCH_MAP
.
get
(
arch
)
assert
target
,
'Unknown architecture'
return
target
return
ARCH_MAP
[
uname
()[
-
2
]]
def
guessOperatingSystem
():
platform
=
sys
.
platform
target
=
OS_MAP
.
get
(
platform
)
assert
target
,
'Unknown architecture'
return
target
TRUE_LIST
=
(
'y'
,
'on'
,
'yes'
,
'true'
,
'1'
)
...
...
@@ -217,15 +183,13 @@ class Script(EnvironMixin):
run_list
.
append
(
' '
.
join
(
command_list
))
previous
=
p
self
.
logger
.
info
(
'Running: %r'
%
' | '
.
join
(
run_list
))
subprocess_list
.
reverse
()
[
q
[
0
].
wait
()
for
q
in
subprocess_list
]
for
q
in
subprocess_list
:
if
q
[
0
].
returncode
!=
0
:
raise
zc
.
buildout
.
UserError
(
'Failed while running command %r'
%
q
[
1
])
def
failIfPathExists
(
self
,
path
):
if
os
.
path
.
lexists
(
path
):
raise
zc
.
buildout
.
UserError
(
'Path %r exists, cannot continue'
%
path
)
failed
=
[]
for
q
in
reversed
(
subprocess_list
):
if
q
[
0
].
wait
():
failed
.
append
(
q
[
1
])
if
failed
:
raise
zc
.
buildout
.
UserError
(
'Failed while running command:'
+
''
.
join
(
'
\
n
'
+
q
for
q
in
failed
))
def
copyTree
(
self
,
origin
,
destination
,
ignore_dir_list
=
None
):
"""Recursively Copy directory.
...
...
@@ -258,7 +222,6 @@ class Script(EnvironMixin):
lambda
self
:
self
.
cleanup_list
)
def
__init__
(
self
,
buildout
,
name
,
options
):
self
.
cleanup_list
=
[]
self
.
options
=
options
self
.
buildout
=
buildout
self
.
name
=
name
...
...
@@ -296,6 +259,7 @@ class Script(EnvironMixin):
rmtree
(
location
)
# env is used in script exec'ed below
env
=
self
.
environ
self
.
cleanup_list
=
[]
try
:
exec
(
self
.
script
)
self
.
_checkPromise
(
'slapos_promise'
,
location
)
...
...
@@ -310,7 +274,7 @@ class Script(EnvironMixin):
else
:
self
.
logger
.
debug
(
'Removing %r'
,
path
)
rmtree
(
path
)
return
[
location
]
return
location
def
update
(
self
):
pass
...
...
@@ -341,6 +305,7 @@ class Script(EnvironMixin):
if
md5sum
is
not
None
and
' '
in
md5sum
:
md5sum
,
patch_options
=
md5sum
.
split
(
' '
,
1
)
patch_options
=
patch_options
.
split
(
' '
)
kwargs
[
'stdin'
]
=
open
(
self
.
download
(
patch
,
md5sum
))
self
.
logger
.
info
(
'Applying patch %r'
%
patch
)
calli
([
patch_binary
]
+
patch_options
,
**
kwargs
)
self
.
logger
.
info
(
'Applying patch %r'
,
patch
)
with
open
(
self
.
download
(
patch
,
md5sum
))
as
stdin
:
subprocess
.
check_call
([
patch_binary
]
+
patch_options
,
stdin
=
stdin
,
**
kwargs
)
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