Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
slapos
Commits
bc48619b
Commit
bc48619b
authored
Aug 14, 2012
by
Antoine Catton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use archived rootfs
parent
3282889c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
20 deletions
+59
-20
slapos/recipe/downloader.py
slapos/recipe/downloader.py
+55
-17
software/lxc/instance-lxc.cfg
software/lxc/instance-lxc.cfg
+2
-1
software/lxc/software.cfg
software/lxc/software.cfg
+2
-2
No files found.
slapos/recipe/downloader.py
View file @
bc48619b
...
@@ -28,17 +28,26 @@
...
@@ -28,17 +28,26 @@
import
os
import
os
import
urllib
import
urllib
import
hashlib
import
hashlib
import
tempfile
import
shutil
import
subprocess
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe
import
GenericBaseRecipe
BUFFER_SIZE
=
1024
BUFFER_SIZE
=
1024
def
service
(
args
):
def
service
(
args
):
environ
=
os
.
environ
.
copy
()
environ
.
update
(
PATH
=
args
[
'path'
])
if
not
os
.
path
.
exists
(
args
[
'confirm'
]):
if
not
os
.
path
.
exists
(
args
[
'confirm'
]):
urllib
.
urlretrieve
(
args
[
'url'
],
args
[
'output'
])
tmpdir
=
tempfile
.
mkdtemp
()
try
:
# XXX: Hardcoded path
tmpoutput
=
os
.
path
.
join
(
tmpdir
,
'downloaded'
)
urllib
.
urlretrieve
(
args
[
'url'
],
tmpoutput
)
if
args
[
'md5'
]
is
not
None
:
if
args
[
'md5'
]
is
not
None
:
# XXX: F
ind a better way to do a md5sum
# XXX: we need to f
ind a better way to do a md5sum
md5sum
=
hashlib
.
md5
()
md5sum
=
hashlib
.
md5
()
with
open
(
args
[
'output'
],
'r'
)
as
output
:
with
open
(
args
[
'output'
],
'r'
)
as
output
:
file_buffer
=
output
.
read
(
BUFFER_SIZE
)
file_buffer
=
output
.
read
(
BUFFER_SIZE
)
...
@@ -49,6 +58,31 @@ def service(args):
...
@@ -49,6 +58,31 @@ def service(args):
if
args
[
'md5'
]
!=
md5sum
.
hexdigest
():
if
args
[
'md5'
]
!=
md5sum
.
hexdigest
():
return
127
# Not-null return code
return
127
# Not-null return code
if
not
args
[
'archive'
]:
os
.
rename
(
tmpoutput
,
args
[
'output'
])
else
:
# XXX: hardcoding path
extract_dir
=
os
.
path
.
join
(
tmpdir
,
'extract'
)
os
.
mkdir
(
extract_dir
)
subprocess
.
check_call
(
[
'tar'
,
'-x'
,
'-f'
,
tmpoutput
,
'-C'
,
extract_dir
,
],
env
=
environ
,
)
archive_content
=
os
.
listdir
(
extract_dir
)
if
len
(
archive_content
)
==
1
and
\
os
.
path
.
isfile
(
os
.
path
.
join
(
extract_dir
,
archive_content
[
0
])):
os
.
rename
(
os
.
path
.
join
(
extract_dir
,
archive_content
[
0
]),
args
[
'output'
])
else
:
return
127
# Not-null return code
finally
:
shutil
.
rmtree
(
tmpdir
)
# Just a touch on args['confirm'] file
# Just a touch on args['confirm'] file
open
(
args
[
'confirm'
],
'w'
).
close
()
open
(
args
[
'confirm'
],
'w'
).
close
()
...
@@ -65,16 +99,20 @@ class Recipe(GenericBaseRecipe):
...
@@ -65,16 +99,20 @@ class Recipe(GenericBaseRecipe):
if
len
(
md5sum
)
==
0
:
if
len
(
md5sum
)
==
0
:
md5sum
=
None
md5sum
=
None
path_list
.
append
(
keywords
=
{
self
.
createPythonScript
(
self
.
options
[
'binary'
],
'slapos.recipe.downloader.service'
,
{
'url'
:
self
.
options
[
'url'
],
'url'
:
self
.
options
[
'url'
],
'md5'
:
md5sum
,
'md5'
:
md5sum
,
'output'
:
self
.
options
[
'downloaded-file'
],
'output'
:
self
.
options
[
'downloaded-file'
],
'confirm'
:
self
.
options
[
'downloaded-file-complete'
]
'confirm'
:
self
.
options
[
'downloaded-file-complete'
],
'archive'
:
self
.
optionIsTrue
(
'archive'
,
False
),
}
}
if
keywords
[
'archive'
]:
keywords
[
'path'
]
=
self
.
options
[
'path'
]
path_list
.
append
(
self
.
createPythonScript
(
self
.
options
[
'binary'
],
'slapos.recipe.downloader.service'
,
keywords
,
)
)
)
)
...
...
software/lxc/instance-lxc.cfg
View file @
bc48619b
...
@@ -53,7 +53,8 @@ md5sum = $${slap-parameter:rootfs-md5sum}
...
@@ -53,7 +53,8 @@ md5sum = $${slap-parameter:rootfs-md5sum}
downloaded-file = $${rootdirectory:srv}/rootfs.img
downloaded-file = $${rootdirectory:srv}/rootfs.img
downloaded-file-complete = $${:downloaded-file}.complete
downloaded-file-complete = $${:downloaded-file}.complete
binary = $${basedirectory:services}/rootfsdownload
binary = $${basedirectory:services}/rootfsdownload
wget-binary = ${wget:location}/bin/wget
path = ${tar:location}/bin/:${gzip:location}/bin/:${bzip2:location}/bin/:${xz-utils:location}/bin/
archive = true
[lxc-conf]
[lxc-conf]
recipe = slapos.cookbook:template
recipe = slapos.cookbook:template
...
...
software/lxc/software.cfg
View file @
bc48619b
...
@@ -5,10 +5,10 @@ extends =
...
@@ -5,10 +5,10 @@ extends =
../../component/lxc/buildout.cfg
../../component/lxc/buildout.cfg
../../component/lxml-python/buildout.cfg
../../component/lxml-python/buildout.cfg
../../component/curl/buildout.cfg
../../component/curl/buildout.cfg
../../component/wget/buildout.cfg
../../component/gzip/buildout.cfg
../../component/gzip/buildout.cfg
../../component/bzip2/buildout.cfg
../../component/bzip2/buildout.cfg
../../component/xz-utils/buildout.cfg
../../component/xz-utils/buildout.cfg
../../component/tar/buildout.cfg
../../component/shellinabox/buildout.cfg
../../component/shellinabox/buildout.cfg
../../component/pwgen/buildout.cfg
../../component/pwgen/buildout.cfg
...
@@ -33,7 +33,7 @@ mode = 0644
...
@@ -33,7 +33,7 @@ mode = 0644
[template-lxc]
[template-lxc]
recipe = slapos.recipe.template
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-lxc.cfg
url = ${:_profile_base_location_}/instance-lxc.cfg
md5sum =
2d0975e08aa402a9aec325cfc03229d2
md5sum =
93791cb9eb71236c94273167d9b7df33
output = ${buildout:directory}/template-lxc.cfg
output = ${buildout:directory}/template-lxc.cfg
mode = 0644
mode = 0644
...
...
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