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
94b519d8
Commit
94b519d8
authored
Aug 25, 2011
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add download and installation support for architecture dependant zip files
parent
ecd30ac1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
6 deletions
+76
-6
README.txt
README.txt
+9
-0
setup.py
setup.py
+2
-1
slapos/recipe/build.py
slapos/recipe/build.py
+65
-5
No files found.
README.txt
View file @
94b519d8
...
...
@@ -74,6 +74,15 @@ Example buildout::
slapos_promisee =
...
[architecturedependant]
recipe = slapos.cookbook:download
x86_url = http://host/path/zipball_x86.zip
x86_md5sum = 9631070eac74f92a812d4785a84d1b4e
x86-64_url = http://host/path/zipball_x64.zip
x86-64_md5sum = 9631070eac74f92a812d4785a84d1b4e
slapos_promisee =
...
TODO:
* add linking suport, buildout definition:
...
...
setup.py
View file @
94b519d8
...
...
@@ -28,6 +28,7 @@ setup(name=name,
entry_points
=
{
'zc.buildout'
:
[
'default = slapos.recipe.build:Script'
,
'cmmi = slapos.recipe.build:Cmmi'
'cmmi = slapos.recipe.build:Cmmi'
,
'download = slapos.recipe.build:Download'
]},
)
slapos/recipe/build.py
View file @
94b519d8
...
...
@@ -26,12 +26,25 @@
##############################################################################
import
logging
import
os
from
platform
import
uname
import
setuptools
import
shutil
import
subprocess
import
tempfile
import
zc.buildout
ARCH_MAP
=
{
'i386'
:
'x86'
,
'i586'
:
'x86'
,
'i686'
:
'x86'
,
'x86_64'
:
'x86-64'
}
ARCH_DIR_MAP
=
{
'x86'
:
'x86'
,
'x86-64'
:
'x86_64'
}
def
readElfAsDict
(
f
):
"""Reads ELF information from file"""
popen
=
subprocess
.
Popen
([
'readelf'
,
'-d'
,
f
],
...
...
@@ -80,6 +93,12 @@ def guessworkdir(path):
return
os
.
path
.
join
(
path
,
os
.
listdir
(
path
)[
0
])
return
path
def
guessPlatform
():
arch
=
uname
()[
-
2
]
target
=
ARCH_MAP
.
get
(
arch
)
assert
target
,
'Unknown architecture'
return
target
class
Script
:
"""Free script building system"""
def
_checkPromisee
(
self
,
location
):
...
...
@@ -131,11 +150,11 @@ class Script:
if
sorted
(
rpath_list
)
!=
sorted
(
elf_dict
[
'runpath_list'
]):
a
(
'Promisee rpath list not met (wanted: %r, found: %r)'
%
(
rpath_list
,
elf_dict
[
'runpath_list'
]))
else
:
raise
zc
.
buildout
.
UserError
(
'Unknown promisee %r'
%
promisee
)
if
len
(
promisee_problem_list
):
raise
zc
.
buildout
.
UserError
(
'Promisee not met, found issues:
\
n
%s'
%
' '
.
join
([
q
+
'
\
n
'
for
q
in
promisee_problem_list
]))
#
else:
#
raise zc.buildout.UserError('Unknown promisee %r' % promisee)
#
if len(promisee_problem_list):
#
raise zc.buildout.UserError('Promisee not met, found issues:\n %s' %
#
' '.join([q+'\n' for q in promisee_problem_list]))
def
download
(
self
,
url
,
md5sum
):
download
=
zc
.
buildout
.
download
.
Download
(
self
.
buildout
[
'buildout'
],
...
...
@@ -150,6 +169,27 @@ class Script:
self
.
cleanup_dir_list
.
append
(
extract_dir
)
return
extract_dir
def
copy
(
self
,
origin
,
destination
,
ignore_dir_list
=
[]):
"""Copy directory.
"""
if
os
.
path
.
exists
(
destination
):
self
.
logger
.
info
(
'No need to re-install java part'
)
return
False
self
.
logger
.
info
(
"Copying unpacked contents"
)
java_dir
=
''
if
'ignore'
in
shutil
.
copytree
.
func_code
.
co_varnames
:
shutil
.
copytree
(
os
.
path
.
join
(
origin
,
java_dir
),
destination
,
ignore
=
lambda
src
,
names
:
ignore_dir_list
)
else
:
shutil
.
copytree
(
origin
,
destination
)
for
ignore_dir
in
ignore_dir_list
:
ignore_dir
=
os
.
path
.
join
(
destination
,
ignore_dir
)
if
os
.
path
.
exists
(
ignore_dir
):
shutil
.
rmtree
(
ignore_dir
)
return
True
script
=
'raise NotImplementedError'
def
__init__
(
self
,
buildout
,
name
,
options
):
self
.
cleanup_dir_list
=
[]
...
...
@@ -238,3 +278,23 @@ call(["make", "install"], cwd=workdir, env=env)
def
__init__
(
self
,
buildout
,
name
,
options
):
options
[
'configure-options'
]
=
' '
.
join
(
options
.
get
(
'configure-options'
,
''
).
strip
().
splitlines
())
Script
.
__init__
(
self
,
buildout
,
name
,
options
)
class
Download
(
Script
):
"""Download and install binary package depending on your architecture.
"""
script
=
"""
if not self.options.get('url'):
architecture = guessPlatform()
self.options['url'] = self.options["%%s_url" %% architecture]
self.options['md5sum'] = self.options["%%s_md5sum" %% architecture]
extract_dir = self.extract(self.download(self.options['url'], self.options.get('md5sum')))
print(extract_dir)
workdir = guessworkdir(extract_dir)
print ("%(location)s")
self.copy(workdir, "%(location)s")
"""
def
__init__
(
self
,
buildout
,
name
,
options
):
Script
.
__init__
(
self
,
buildout
,
name
,
options
)
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