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
8312e7b3
Commit
8312e7b3
authored
Dec 09, 2021
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
default, download-unpacked: improve multiarch support
parent
5ad49b57
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
22 deletions
+64
-22
README.rst
README.rst
+22
-3
slapos/recipe/__init__.py
slapos/recipe/__init__.py
+17
-1
slapos/recipe/build/__init__.py
slapos/recipe/build/__init__.py
+2
-13
slapos/recipe/downloadunpacked.py
slapos/recipe/downloadunpacked.py
+23
-5
No files found.
README.rst
View file @
8312e7b3
...
...
@@ -24,16 +24,18 @@ Example that installs software::
statlib:lib/libfoo.a
statlib:lib/libfoo.la
dynlib:bin/foo linked:libbar.so.1,libc.so.6,libfoo.so.1 rpath:${bar:location}/lib,!/lib
x86 = http://host/path/x86.zip
[md5sum]
x86
-64 = http://host/path/x64.zip
[md5sum]
i386-linux-gnu = http://host/path/i386.tar.gz
[md5sum]
x86
_64-linux-gnu = http://host/path/amd64.tar.gz
[md5sum]
install =
url, md5sum = options[
guessPlatform
()].split()
url, md5sum = options[
multiarch
()].split()
extract_dir = self.extract(self.download(url, md5sum))
self.copyTree(guessworkdir(extract_dir), location)
${:update}
update =
...
See also the ``download-unpacked`` recipe, which has options to install multiarch specific archives.
Using the init option::
[section-one]
...
...
@@ -507,6 +509,23 @@ Example::
Uninstalling download.
Installing download.
multiarch
---------
`url` (optionally combined with `md5sum` and `alternate-url`) is actually a
default option to specify what to download. It can be overridden with machine
specific value, like in the example of the default recipe::
[buildout]
parts =
download
[download]
recipe = slapos.recipe.build:download-unpacked
i386-linux-gnu = http://host/path/i386.tar.gz [alternate-url] md5sum]
x86_64-linux-gnu = http://host/path/amd64.tar.gz [[alternate-url] md5sum]
Values can be separated with newlines.
==============================
slapos.recipe.build:gitclone
...
...
slapos/recipe/__init__.py
View file @
8312e7b3
...
...
@@ -5,7 +5,7 @@ except ImportError:
from
pkgutil
import
extend_path
__path__
=
extend_path
(
__path__
,
__name__
)
import
errno
,
json
,
logging
,
os
,
shutil
,
stat
import
errno
,
json
,
logging
,
os
,
shutil
,
stat
,
subprocess
from
hashlib
import
md5
from
zc.buildout
import
UserError
from
zc.buildout.rmtree
import
rmtree
as
buildout_rmtree
...
...
@@ -31,6 +31,22 @@ def make_read_only_recursively(path):
for
file_
in
file_list
:
make_read_only
(
os
.
path
.
join
(
root
,
file_
))
def
multiarch
():
try
:
m
=
multiarch
.
cache
except
AttributeError
:
try
:
m
=
subprocess
.
check_output
(
(
'gcc'
,
'-dumpmachine'
),
universal_newlines
=
True
).
rstrip
()
except
Exception
as
e
:
m
=
e
multiarch
.
cache
=
m
if
type
(
m
)
is
str
:
if
m
:
return
m
raise
Exception
(
"empty multiarch value"
)
raise
m
def
rmtree
(
path
):
try
:
buildout_rmtree
(
path
)
...
...
slapos/recipe/build/__init__.py
View file @
8312e7b3
...
...
@@ -28,7 +28,6 @@ import errno
import
linecache
import
logging
import
os
from
platform
import
uname
import
shlex
import
shutil
import
subprocess
...
...
@@ -36,16 +35,9 @@ import sys
import
tempfile
from
setuptools
import
archive_util
import
zc.buildout
from
..
import
is_true
,
rmtree
,
EnvironMixin
,
Shared
from
..
import
is_true
,
multiarch
,
rmtree
,
EnvironMixin
,
Shared
from
..downloadunpacked
import
extraction_drivers
,
patched_extraction_drivers
ARCH_MAP
=
{
'i386'
:
'x86'
,
'i586'
:
'x86'
,
'i686'
:
'x86'
,
'x86_64'
:
'x86-64'
}
def
readElfAsDict
(
f
):
"""Reads ELF information from file"""
result
=
subprocess
.
check_output
((
'readelf'
,
'-d'
,
f
),
...
...
@@ -87,11 +79,8 @@ def guessworkdir(path):
x
=
os
.
listdir
(
path
)
return
os
.
path
.
join
(
path
,
*
x
)
if
len
(
x
)
==
1
else
path
def
guessPlatform
():
return
ARCH_MAP
[
uname
()[
-
2
]]
GLOBALS
=
(
lambda
*
x
:
{
x
.
__name__
:
x
for
x
in
x
})(
call
,
guess
Platform
,
guessworkdir
,
is_true
)
call
,
guess
workdir
,
is_true
,
multiarch
)
class
Script
(
EnvironMixin
):
"""Free script building system"""
...
...
slapos/recipe/downloadunpacked.py
View file @
8312e7b3
...
...
@@ -31,7 +31,8 @@ import tarfile
import
tempfile
from
hashlib
import
md5
from
setuptools
import
archive_util
from
.
import
is_true
,
EnvironMixin
,
Shared
from
zc.buildout
import
UserError
from
.
import
is_true
,
multiarch
,
EnvironMixin
,
Shared
from
.
import
make_read_only_recursively
# for slapos.recipe.cmmi
class
Recipe
(
EnvironMixin
):
...
...
@@ -41,8 +42,25 @@ class Recipe(EnvironMixin):
self
.
name
=
name
self
.
options
=
options
self
.
_strip
=
is_true
(
options
.
get
(
'strip-top-level-dir'
),
None
)
self
.
_url
=
options
[
'url'
]
self
.
_alternate
=
options
.
get
(
'alternate-url'
)
self
.
_md5sum
=
options
.
get
(
'md5sum'
)
url
=
options
.
get
(
'url'
)
try
:
m
=
multiarch
()
except
Exception
as
e
:
if
not
url
:
raise
UserError
(
"option 'url' missing; could not fallback on multiarch (%s)"
%
e
)
else
:
x
=
options
.
get
(
m
)
if
x
:
x
=
x
.
split
()
url
=
x
.
pop
(
0
)
self
.
_md5sum
=
x
.
pop
()
if
x
else
None
self
.
_alternate
,
=
x
or
(
None
,)
elif
not
url
:
raise
UserError
(
"missing option: 'url' or %r"
%
m
)
self
.
_url
=
url
shared
=
Shared
(
buildout
,
name
,
options
)
destination
=
options
.
get
(
'destination'
)
if
destination
:
...
...
@@ -63,9 +81,9 @@ class Recipe(EnvironMixin):
# inside slapos.buildout (see networkcache support)
from
zc.buildout
import
download
location
=
self
.
_shared
.
location
alternate
=
self
.
options
.
get
(
'alternate-url'
)
alternate
=
self
.
_alternate
path
,
is_temp
=
download
.
Download
(
self
.
buildout
[
'buildout'
],
hash_name
=
True
)(
self
.
_url
,
self
.
options
.
get
(
'md5sum'
)
or
None
,
hash_name
=
True
)(
self
.
_url
,
self
.
_md5sum
or
None
,
**
({
'alternate_url'
:
alternate
}
if
alternate
else
{}))
try
:
archive_util
.
extraction_drivers
=
patched_extraction_drivers
...
...
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