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
Show 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 = {
...
@@ -44,20 +44,10 @@ ARCH_MAP = {
'x86_64'
:
'x86-64'
'x86_64'
:
'x86-64'
}
}
OS_MAP
=
{
'darwin'
:
'mac'
,
'linux2'
:
'linux'
#To be continued
}
def
readElfAsDict
(
f
):
def
readElfAsDict
(
f
):
"""Reads ELF information from file"""
"""Reads ELF information from file"""
popen
=
subprocess
.
Popen
([
'readelf'
,
'-d'
,
f
],
result
=
subprocess
.
check_output
((
'readelf'
,
'-d'
,
f
),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
stderr
=
subprocess
.
STDOUT
)[
0
]
result
=
popen
.
communicate
()[
0
]
if
popen
.
returncode
!=
0
:
raise
AssertionError
(
result
)
library_list
=
[]
library_list
=
[]
rpath_list
=
[]
rpath_list
=
[]
runpath_list
=
[]
runpath_list
=
[]
...
@@ -79,49 +69,25 @@ def readElfAsDict(f):
...
@@ -79,49 +69,25 @@ def readElfAsDict(f):
runpath_list
=
sorted
(
runpath_list
)
runpath_list
=
sorted
(
runpath_list
)
)
)
def
call
(
*
args
,
**
kwargs
):
def
call
(
*
args
,
**
kwargs
):
"""Subprocess call with closed file descriptors and stdin"""
"""Subprocess call with closed file descriptors and stdin"""
kwargs
.
update
(
kwargs
.
update
(
stdin
=
subprocess
.
PIPE
,
stdin
=
subprocess
.
PIPE
,
close_fds
=
True
)
close_fds
=
True
)
popen
=
subprocess
.
Popen
(
*
args
,
**
kwargs
)
popen
=
subprocess
.
Popen
(
*
args
,
**
kwargs
)
popen
.
stdin
.
flush
()
popen
.
stdin
.
close
()
popen
.
stdin
.
close
()
popen
.
stdin
=
None
popen
.
stdin
=
None
popen
.
communicate
()
popen
.
communicate
()
if
popen
.
returncode
!=
0
:
if
popen
.
returncode
!=
0
:
raise
subprocess
.
CalledProcessError
(
popen
.
returncode
,
' '
.
join
(
args
[
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
):
def
guessworkdir
(
path
):
if
len
(
os
.
listdir
(
path
))
==
1
:
x
=
os
.
listdir
(
path
)
return
os
.
path
.
join
(
path
,
os
.
listdir
(
path
)[
0
])
return
os
.
path
.
join
(
path
,
*
x
)
if
len
(
x
)
==
1
else
path
return
path
def
guessPlatform
():
def
guessPlatform
():
arch
=
uname
()[
-
2
]
return
ARCH_MAP
[
uname
()[
-
2
]]
target
=
ARCH_MAP
.
get
(
arch
)
assert
target
,
'Unknown architecture'
return
target
def
guessOperatingSystem
():
platform
=
sys
.
platform
target
=
OS_MAP
.
get
(
platform
)
assert
target
,
'Unknown architecture'
return
target
TRUE_LIST
=
(
'y'
,
'on'
,
'yes'
,
'true'
,
'1'
)
TRUE_LIST
=
(
'y'
,
'on'
,
'yes'
,
'true'
,
'1'
)
...
@@ -217,15 +183,13 @@ class Script(EnvironMixin):
...
@@ -217,15 +183,13 @@ class Script(EnvironMixin):
run_list
.
append
(
' '
.
join
(
command_list
))
run_list
.
append
(
' '
.
join
(
command_list
))
previous
=
p
previous
=
p
self
.
logger
.
info
(
'Running: %r'
%
' | '
.
join
(
run_list
))
self
.
logger
.
info
(
'Running: %r'
%
' | '
.
join
(
run_list
))
subprocess_list
.
reverse
()
failed
=
[]
[
q
[
0
].
wait
()
for
q
in
subprocess_list
]
for
q
in
reversed
(
subprocess_list
):
for
q
in
subprocess_list
:
if
q
[
0
].
wait
():
if
q
[
0
].
returncode
!=
0
:
failed
.
append
(
q
[
1
])
raise
zc
.
buildout
.
UserError
(
'Failed while running command %r'
%
q
[
1
])
if
failed
:
raise
zc
.
buildout
.
UserError
(
'Failed while running command:'
def
failIfPathExists
(
self
,
path
):
+
''
.
join
(
'
\
n
'
+
q
for
q
in
failed
))
if
os
.
path
.
lexists
(
path
):
raise
zc
.
buildout
.
UserError
(
'Path %r exists, cannot continue'
%
path
)
def
copyTree
(
self
,
origin
,
destination
,
ignore_dir_list
=
None
):
def
copyTree
(
self
,
origin
,
destination
,
ignore_dir_list
=
None
):
"""Recursively Copy directory.
"""Recursively Copy directory.
...
@@ -258,7 +222,6 @@ class Script(EnvironMixin):
...
@@ -258,7 +222,6 @@ class Script(EnvironMixin):
lambda
self
:
self
.
cleanup_list
)
lambda
self
:
self
.
cleanup_list
)
def
__init__
(
self
,
buildout
,
name
,
options
):
def
__init__
(
self
,
buildout
,
name
,
options
):
self
.
cleanup_list
=
[]
self
.
options
=
options
self
.
options
=
options
self
.
buildout
=
buildout
self
.
buildout
=
buildout
self
.
name
=
name
self
.
name
=
name
...
@@ -296,6 +259,7 @@ class Script(EnvironMixin):
...
@@ -296,6 +259,7 @@ class Script(EnvironMixin):
rmtree
(
location
)
rmtree
(
location
)
# env is used in script exec'ed below
# env is used in script exec'ed below
env
=
self
.
environ
env
=
self
.
environ
self
.
cleanup_list
=
[]
try
:
try
:
exec
(
self
.
script
)
exec
(
self
.
script
)
self
.
_checkPromise
(
'slapos_promise'
,
location
)
self
.
_checkPromise
(
'slapos_promise'
,
location
)
...
@@ -310,7 +274,7 @@ class Script(EnvironMixin):
...
@@ -310,7 +274,7 @@ class Script(EnvironMixin):
else
:
else
:
self
.
logger
.
debug
(
'Removing %r'
,
path
)
self
.
logger
.
debug
(
'Removing %r'
,
path
)
rmtree
(
path
)
rmtree
(
path
)
return
[
location
]
return
location
def
update
(
self
):
def
update
(
self
):
pass
pass
...
@@ -341,6 +305,7 @@ class Script(EnvironMixin):
...
@@ -341,6 +305,7 @@ class Script(EnvironMixin):
if
md5sum
is
not
None
and
' '
in
md5sum
:
if
md5sum
is
not
None
and
' '
in
md5sum
:
md5sum
,
patch_options
=
md5sum
.
split
(
' '
,
1
)
md5sum
,
patch_options
=
md5sum
.
split
(
' '
,
1
)
patch_options
=
patch_options
.
split
(
' '
)
patch_options
=
patch_options
.
split
(
' '
)
kwargs
[
'stdin'
]
=
open
(
self
.
download
(
patch
,
md5sum
))
self
.
logger
.
info
(
'Applying patch %r'
,
patch
)
self
.
logger
.
info
(
'Applying patch %r'
%
patch
)
with
open
(
self
.
download
(
patch
,
md5sum
))
as
stdin
:
calli
([
patch_binary
]
+
patch_options
,
**
kwargs
)
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