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.cmmi
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
Xavier Thompson
slapos.recipe.cmmi
Commits
3de46334
Commit
3de46334
authored
Apr 26, 2020
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests
parent
a76ec7be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
98 deletions
+81
-98
slapos/recipe/cmmi/README.rst
slapos/recipe/cmmi/README.rst
+71
-76
slapos/recipe/cmmi/tests.py
slapos/recipe/cmmi/tests.py
+10
-22
No files found.
slapos/recipe/cmmi/README.rst
View file @
3de46334
...
@@ -263,14 +263,17 @@ will add it to environmet variables as the following::
...
@@ -263,14 +263,17 @@ will add it to environmet variables as the following::
Example usage
Example usage
=============
=============
We'
ll
use
a
simple
tarball
to
demonstrate
the
recipe
.
We'
ll
use
a
few
tarballs
to
demonstrate
the
recipe
.
We
'll modify one of them in-place but we don'
t
want
to
alter
the
source
tree
.
>>>
import
os
.
path
>>>
import
os
>>>
src
=
join
(
os
.
path
.
dirname
(
__file__
),
'testdata'
)
>>>
src
=
join
(
os
.
path
.
dirname
(
__file__
),
'testdata'
)
>>>
ls
(
src
)
>>>
ls
(
src
)
-
Foo
-
Bar
-
0.0.0
.
tar
.
gz
-
Foo
-
Bar
-
0.0.0
.
tar
.
gz
-
haproxy
-
1.4.8
-
dummy
.
tar
.
gz
-
haproxy
-
1.4.8
-
dummy
.
tar
.
gz
-
package
-
0.0.0
.
tar
.
gz
-
package
-
0.0.0
.
tar
.
gz
>>>
package_path
=
join
(
tmpdir
(
'testdata'
),
'package-0.0.0.tar.gz'
)
>>>
os
.
symlink
(
join
(
src
,
'package-0.0.0.tar.gz'
),
package_path
)
The
package
contains
a
dummy
``
configure
``
script
that
will
simply
The
package
contains
a
dummy
``
configure
``
script
that
will
simply
echo
the
options
it
was
called
with
and
create
a
``
Makefile
``
that
echo
the
options
it
was
called
with
and
create
a
``
Makefile
``
that
...
@@ -286,8 +289,8 @@ Let's create a buildout to build and install the package.
...
@@ -286,8 +289,8 @@ Let's create a buildout to build and install the package.
...
...
... [package]
... [package]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%s
/package-0.0.0.tar.gz
... url = file://%s
... """ %
src
)
... """ %
package_path
)
This will download, extract and build our demo package with the
This will download, extract and build our demo package with the
default build options.
default build options.
...
@@ -309,9 +312,9 @@ Check option "promises"
...
@@ -309,9 +312,9 @@ Check option "promises"
...
...
... [packagex]
... [packagex]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%s
/package-0.0.0.tar.gz
... url = file://%s
... promises = /usr/bin/myfoo
... promises = /usr/bin/myfoo
... """ %
src
)
... """ %
package_path
)
This will download, extract and build our demo package with the
This will download, extract and build our demo package with the
default build options.
default build options.
...
@@ -414,8 +417,7 @@ and building that.
...
@@ -414,8 +417,7 @@ and building that.
>>>
checkout_dir
=
tmpdir
(
'checkout'
)
>>>
checkout_dir
=
tmpdir
(
'checkout'
)
>>>
import
setuptools
.
archive_util
>>>
import
setuptools
.
archive_util
>>>
setuptools
.
archive_util
.
unpack_archive
(
'%s/package-0.0.0.tar.gz'
%
src
,
>>>
setuptools
.
archive_util
.
unpack_archive
(
package_path
,
checkout_dir
)
...
checkout_dir
)
>>>
ls
(
checkout_dir
)
>>>
ls
(
checkout_dir
)
d
package
-
0.0.0
d
package
-
0.0.0
...
@@ -466,7 +468,7 @@ with a new buildout and provide more options.
...
@@ -466,7 +468,7 @@ with a new buildout and provide more options.
...
...
... [package]
... [package]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%
(src)s/package-0.0.0.tar.gz
... url = file://%
s
... md5sum = 6b94295c042a91ea3203857326bc9209
... md5sum = 6b94295c042a91ea3203857326bc9209
... prefix = /somewhere/else
... prefix = /somewhere/else
... environment-section = build-environment
... environment-section = build-environment
...
@@ -481,7 +483,7 @@ with a new buildout and provide more options.
...
@@ -481,7 +483,7 @@ with a new buildout and provide more options.
... patches =
... patches =
... patches/configure.patch
... patches/configure.patch
... patches/Makefile.dist.patch
... patches/Makefile.dist.patch
... """ %
dict(src=src)
)
... """ %
package_path
)
This configuration uses custom configure options, an environment section,
This configuration uses custom configure options, an environment section,
per-part customization to the environment, custom prefix, multiple make
per-part customization to the environment, custom prefix, multiple make
...
@@ -565,11 +567,12 @@ and a new buildout to try it out
...
@@ -565,11 +567,12 @@ and a new buildout to try it out
...
...
... [package]
... [package]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%(
src)s/package-0.0.0.tar.gz
... url = file://%(
package_path)s
... pre-configure-hook = %(module)s:preconfigure
... pre-configure-hook = %(module)s:preconfigure
... pre-make-hook = %(module)s:premake
... pre-make-hook = %(module)s:premake
... post-make-hook = %(module)s:postmake
... post-make-hook = %(module)s:postmake
... """
%
dict
(
src
=
src
,
module
=
'%s/customhandlers.py'
%
hooks
))
... """
%
dict
(
package_path
=
package_path
,
...
module
=
join
(
hooks
,
'customhandlers.py'
)))
>>>
print
(
system
(
buildout
))
>>>
print
(
system
(
buildout
))
Uninstalling
package
.
Uninstalling
package
.
...
@@ -600,12 +603,12 @@ Let's create a buildout to use these options.
...
@@ -600,12 +603,12 @@ Let's create a buildout to use these options.
...
...
... [package]
... [package]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%s
/package-0.0.0.tar.gz
... url = file://%s
... pre-configure = echo "Configure part: ${:_buildout_section_name_}"
... pre-configure = echo "Configure part: ${:_buildout_section_name_}"
... pre-build = echo "OH OH OH" > a.txt
... pre-build = echo "OH OH OH" > a.txt
... pre-install = cat a.txt
... pre-install = cat a.txt
... post-install = rm -f a.txt && echo "Finished."
... post-install = rm -f a.txt && echo "Finished."
... """ %
src
)
... """ %
package_path
)
This will run pre-configure, pre-build, pre-install, post-install as
This will run pre-configure, pre-build, pre-install, post-install as
shell command in the corresponding stage.
shell command in the corresponding stage.
...
@@ -637,7 +640,7 @@ The recipe can specify build options for each platform. For example,
...
@@ -637,7 +640,7 @@ The recipe can specify build options for each platform. For example,
...
...
... [package]
... [package]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%s
/package-0.0.0.tar.gz
... url = file://%s
... pre-configure = echo "Configure in common platform"
... pre-configure = echo "Configure in common platform"
... post-install = echo "Finished."
... post-install = echo "Finished."
...
...
...
@@ -645,7 +648,7 @@ The recipe can specify build options for each platform. For example,
...
@@ -645,7 +648,7 @@ The recipe can specify build options for each platform. For example,
... pre-configure = echo "Configure in the CYGWIN platform"
... pre-configure = echo "Configure in the CYGWIN platform"
... pre-install = echo "Installing in the CYGWIN"
... pre-install = echo "Installing in the CYGWIN"
... post-install = echo -n "CYGWIN " && ${package:post-install}
... post-install = echo -n "CYGWIN " && ${package:post-install}
... """ %
src
)
... """ %
package_path
)
In the linux, the recipe gets the options from part '
package
', there
In the linux, the recipe gets the options from part '
package
', there
are only ``pre-configure`` and ``post-install``. the output will be
are only ``pre-configure`` and ``post-install``. the output will be
...
@@ -689,9 +692,9 @@ Let's see what happens when set prefix in the buildout section:
...
@@ -689,9 +692,9 @@ Let's see what happens when set prefix in the buildout section:
...
...
... [package]
... [package]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%s
/package-0.0.0.tar.gz
... url = file://%s
... pre-configure = mkdir -p "${buildout:prefix}"
... pre-configure = mkdir -p "${buildout:prefix}"
... """ %
src
)
... """ %
package_path
)
>>> print(system(buildout))
>>> print(system(buildout))
Uninstalling package.
Uninstalling package.
...
@@ -718,10 +721,10 @@ example,
...
@@ -718,10 +721,10 @@ example,
... [package]
... [package]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... prefix = ${buildout:parts-directory}/package
... prefix = ${buildout:parts-directory}/package
... url = file://%s
/package-0.0.0.tar.gz
... url = file://%s
... pre-configure = rm -rf "${buildout:prefix}"
... pre-configure = rm -rf "${buildout:prefix}"
... post-install = test -d "${buildout:prefix}" || echo "None"
... post-install = test -d "${buildout:prefix}" || echo "None"
... """ %
src
)
... """ %
package_path
)
>>> print(system(buildout))
>>> print(system(buildout))
Uninstalling package.
Uninstalling package.
...
@@ -748,13 +751,13 @@ prefix:
...
@@ -748,13 +751,13 @@ prefix:
...
...
... [package]
... [package]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%s
/package-0.0.0.tar.gz
... url = file://%s
... pre-install = sleep 2; mkdir -p "${buildout:prefix}" ; echo x >"${buildout:prefix}/a.txt"
... pre-install = sleep 2; mkdir -p "${buildout:prefix}" ; echo x >"${buildout:prefix}/a.txt"
... [package-2]
... [package-2]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%s
/package-0.0.0.tar.gz
... url = file://%s
... pre-install = sleep 2; mkdir -p "${buildout:prefix}" ; echo x >"${buildout:prefix}/b.txt"; echo
... pre-install = sleep 2; mkdir -p "${buildout:prefix}" ; echo x >"${buildout:prefix}/b.txt"; echo
... """ % (
src, src
))
... """ % (
package_path, package_path
))
>>> print(system(buildout))
>>> print(system(buildout))
Uninstalling package.
Uninstalling package.
...
@@ -787,9 +790,9 @@ as nothing it is removing):
...
@@ -787,9 +790,9 @@ as nothing it is removing):
...
...
... [package]
... [package]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%s
/package-0.0.0.tar.gz
... url = file://%s
... pre-install = sleep 2; mkdir -p "${buildout:prefix}" ; echo x >"${buildout:prefix}/a.txt"
... pre-install = sleep 2; mkdir -p "${buildout:prefix}" ; echo x >"${buildout:prefix}/a.txt"
... """ %
src
)
... """ %
package_path
)
>>> print(system(buildout))
>>> print(system(buildout))
Uninstalling package-2.
Uninstalling package-2.
...
@@ -832,17 +835,17 @@ value in the part section. For example::
...
@@ -832,17 +835,17 @@ value in the part section. For example::
...
...
... [package]
... [package]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%s
/package-0.0.0.tar.gz
... url = file://%s
... configure-command = true
... configure-command = true
... make-binary = true
... make-binary = true
...
...
... [package-2]
... [package-2]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%s
/package-0.0.0.tar.gz
... url = file://%s
... configure-command = true
... configure-command = true
... make-binary = true
... make-binary = true
... post-install = echo package magic prefix is ${package:prefix}
... post-install = echo package magic prefix is ${package:prefix}
... """ % (
src, src
))
... """ % (
package_path, package_path
))
>>> print(system(buildout))
>>> print(system(buildout))
Uninstalling package.
Uninstalling package.
...
@@ -863,10 +866,10 @@ can display "prefix" value in the stdout.
...
@@ -863,10 +866,10 @@ can display "prefix" value in the stdout.
...
...
... [package]
... [package]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%s
/package-0.0.0.tar.gz
... url = file://%s
... configure-command = ./configure
... configure-command = ./configure
... pre-install = sed -i -e "
s
/
installing
package
/
installing
package
at
\\$\\$
prefix
/
g
" Makefile
... pre-install = sed -i -e "
s
/
installing
package
/
installing
package
at
\\$\\$
prefix
/
g
" Makefile
... """
%
src
)
... """
%
package_path
)
>>>
print
(
system
(
buildout
))
>>>
print
(
system
(
buildout
))
Uninstalling
package
-
2.
Uninstalling
package
-
2.
...
@@ -888,11 +891,11 @@ replaced with the recipe final prefix.
...
@@ -888,11 +891,11 @@ replaced with the recipe final prefix.
...
...
... [package]
... [package]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%s
/package-0.0.0.tar.gz
... url = file://%s
... configure-command = ./configure
... configure-command = ./configure
... make-targets = install-lib prefix=%%(prefix)s
... make-targets = install-lib prefix=%%(prefix)s
... pre-install = sed -i -e "
s
/
installing
package
/
installing
package
at
\\$\\$
prefix
/
g
" Makefile
... pre-install = sed -i -e "
s
/
installing
package
/
installing
package
at
\\$\\$
prefix
/
g
" Makefile
... """
%
src
)
... """
%
package_path
)
>>>
print
(
system
(
buildout
))
>>>
print
(
system
(
buildout
))
Uninstalling
package
.
Uninstalling
package
.
...
@@ -906,17 +909,12 @@ Install shared package
...
@@ -906,17 +909,12 @@ Install shared package
======================
======================
Use
option
``
shared
``
to
install
a
shared
package
.
Use
option
``
shared
``
to
install
a
shared
package
.
>>>
import
os
>>>
_
=
system
(
'chmod -R u+w %(path)s && rm -rf %(path)s'
%
dict
(
...
path
=
join
(
os
.
path
.
dirname
(
__file__
),
'shared'
)))
>>>
shared_dir
=
join
(
os
.
path
.
dirname
(
__file__
),
'shared'
)
>>>
os
.
mkdir
(
shared_dir
)
>>>
_
=
system
(
'chmod -R u+w %(path)s && rm -rf %(path)s'
%
dict
(
...
path
=
join
(
os
.
path
.
dirname
(
__file__
),
'another_shared_dir'
)))
>>>
another_shared_dir
=
join
(
...
os
.
path
.
dirname
(
__file__
),
'another_shared_dir'
)
>>>
os
.
mkdir
(
another_shared_dir
)
>>>
import
subprocess
>>>
shared_dir
=
tmpdir
(
'shared'
)
>>>
another_shared_dir
=
tmpdir
(
'another_shared_dir'
)
>>>
__tear_downs
.
insert
(
0
,
lambda
:
subprocess
.
call
(
...
(
'chmod'
,
'-R'
,
'u+w'
,
shared_dir
,
another_shared_dir
)))
If
no
``
shared
-
part
-
list
``
is
set
,
and
``
shared
``
is
True
,
``
shared
``
feature
If
no
``
shared
-
part
-
list
``
is
set
,
and
``
shared
``
is
True
,
``
shared
``
feature
is
not
used
.
is
not
used
.
...
@@ -929,9 +927,9 @@ is not used.
...
@@ -929,9 +927,9 @@ is not used.
...
...
... [package]
... [package]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%s
/package-0.0.0.tar.gz
... url = file://%s
... shared = True
... shared = True
... """
%
src
)
... """
%
package_path
)
>>>
print
(
system
(
buildout
))
#
doctest
:+
ELLIPSIS
>>>
print
(
system
(
buildout
))
#
doctest
:+
ELLIPSIS
Uninstalling
package
.
Uninstalling
package
.
...
@@ -946,12 +944,11 @@ debugging.
...
@@ -946,12 +944,11 @@ debugging.
Also
a
shell
script
with
the
environment
variable
is
created
,
so
that
Also
a
shell
script
with
the
environment
variable
is
created
,
so
that
developer
can
try
same
build
process
as
the
recipe
tried
.
developer
can
try
same
build
process
as
the
recipe
tried
.
>>>
_
=
system
(
'mv %s/package-0.0.0.tar.gz %s/package-0.0.0.tar.gz.bak'
%
(
src
,
src
)
)
>>>
os
.
rename
(
package_path
,
package_path
+
'.bak'
)
>>>
import
tarfile
>>>
import
tarfile
>>>
from
io
import
BytesIO
>>>
from
io
import
BytesIO
>>>
import
sys
>>>
import
sys
>>>
tarpath
=
os
.
path
.
join
(
src
,
'package-0.0.0.tar.gz'
)
>>>
with
tarfile
.
open
(
package_path
,
'w:gz'
)
as
tar
:
>>>
with
tarfile
.
open
(
tarpath
,
'w:gz'
)
as
tar
:
...
configure
=
b
'invalid'
...
configure
=
b
'invalid'
...
info
=
tarfile
.
TarInfo
(
'configure.off'
)
...
info
=
tarfile
.
TarInfo
(
'configure.off'
)
...
info
.
size
=
len
(
configure
)
...
info
.
size
=
len
(
configure
)
...
@@ -966,39 +963,39 @@ developer can try same build process as the recipe tried.
...
@@ -966,39 +963,39 @@ developer can try same build process as the recipe tried.
...
...
... [package]
... [package]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%s
/package-0.0.0.tar.gz
... url = file://%s
... shared = True
... shared = True
... environment =
... environment =
... FOO=bar
... FOO=bar
... """
%
(
shared_dir
,
src
))
... """
%
(
shared_dir
,
package_path
))
>>>
print
(
system
(
buildout
))
#
doctest
:+
ELLIPSIS
>>>
print
(
system
(
buildout
))
#
doctest
:+
ELLIPSIS
package
:
shared
at
/
shared
/
package
/
FIRST_SHARED_PACKAGE_HASH
package
:
shared
at
/
shared
/
package
/
<
MD5SUM
:
0
>
Uninstalling
package
.
Uninstalling
package
.
Installing
package
.
Installing
package
.
package
:
Checking
whether
package
is
installed
at
shared
path
:
/
shared
/
package
/
FIRST_SHARED_PACKAGE_HASH
package
:
Checking
whether
package
is
installed
at
shared
path
:
/
shared
/
package
/
<
MD5SUM
:
0
>
package
:
[
ENV
]
FOO
=
bar
package
:
[
ENV
]
FOO
=
bar
package
:
Command
'set -e;./configure --prefix="/shared/package/
FIRST_SHARED_PACKAGE_HASH
"'
returned
non
-
zero
exit
status
127.
package
:
Command
'set -e;./configure --prefix="/shared/package/
<MD5SUM:0>
"'
returned
non
-
zero
exit
status
127.
package
:
Compilation
error
.
The
package
is
left
as
is
at
/
shared
/
package
/
FIRST_SHARED_PACKAGE_HASH
__compile__
where
you
can
inspect
what
went
wrong
.
package
:
Compilation
error
.
The
package
is
left
as
is
at
/
shared
/
package
/
<
MD5SUM
:
0
>
__compile__
where
you
can
inspect
what
went
wrong
.
A
shell
script
slapos
.
recipe
.
build
.
env
.
sh
has
been
generated
.
You
can
source
it
in
your
shell
to
reproduce
build
environment
.
A
shell
script
slapos
.
recipe
.
build
.
env
.
sh
has
been
generated
.
You
can
source
it
in
your
shell
to
reproduce
build
environment
.
/
bin
/
sh
:
1
:
./
configure
:
not
found
/
bin
/
sh
:
1
:
./
configure
:
not
found
While
:
While
:
Installing
package
.
Installing
package
.
Error
:
System
error
Error
:
System
error
>>>
import
glob
>>>
import
glob
>>>
cat
(
glob
.
glob
(
os
.
path
.
join
(
shared_dir
,
'package/**__compile__/slapos.recipe.build.env.sh'
))[
0
])
>>>
cat
(
glob
.
glob
(
join
(
shared_dir
,
'package/**__compile__/slapos.recipe.build.env.sh'
))[
0
])
export
FOO
=
bar
export
FOO
=
bar
...
...
Next
time
buildout
runs
,
it
detects
that
the
build
failed
,
remove
the
compile
dir
and
retry
.
Next
time
buildout
runs
,
it
detects
that
the
build
failed
,
remove
the
compile
dir
and
retry
.
>>>
print
(
system
(
buildout
))
#
doctest
:+
ELLIPSIS
>>>
print
(
system
(
buildout
))
#
doctest
:+
ELLIPSIS
package
:
shared
at
/
shared
/
package
/
FIRST_SHARED_PACKAGE_HASH
package
:
shared
at
/
shared
/
package
/
<
MD5SUM
:
0
>
Installing
package
.
Installing
package
.
package
:
Checking
whether
package
is
installed
at
shared
path
:
/
shared
/
package
/
FIRST_SHARED_PACKAGE_HASH
package
:
Checking
whether
package
is
installed
at
shared
path
:
/
shared
/
package
/
<
MD5SUM
:
0
>
package
:
[
ENV
]
FOO
=
bar
package
:
[
ENV
]
FOO
=
bar
package
:
Removing
already
existing
directory
/
shared
/
package
/
FIRST_SHARED_PACKAGE_HASH
__compile__
package
:
Removing
already
existing
directory
/
shared
/
package
/
<
MD5SUM
:
0
>
__compile__
package
:
Command
'set -e;./configure --prefix="/shared/package/
FIRST_SHARED_PACKAGE_HASH
"'
returned
non
-
zero
exit
status
127.
package
:
Command
'set -e;./configure --prefix="/shared/package/
<MD5SUM:0>
"'
returned
non
-
zero
exit
status
127.
package
:
Compilation
error
.
The
package
is
left
as
is
at
/
shared
/
package
/
FIRST_SHARED_PACKAGE_HASH
__compile__
where
you
can
inspect
what
went
wrong
.
package
:
Compilation
error
.
The
package
is
left
as
is
at
/
shared
/
package
/
<
MD5SUM
:
0
>
__compile__
where
you
can
inspect
what
went
wrong
.
A
shell
script
slapos
.
recipe
.
build
.
env
.
sh
has
been
generated
.
You
can
source
it
in
your
shell
to
reproduce
build
environment
.
A
shell
script
slapos
.
recipe
.
build
.
env
.
sh
has
been
generated
.
You
can
source
it
in
your
shell
to
reproduce
build
environment
.
/
bin
/
sh
:
1
:
./
configure
:
not
found
/
bin
/
sh
:
1
:
./
configure
:
not
found
While
:
While
:
...
@@ -1012,8 +1009,7 @@ shared part. The shared part was left in an inconsistent state that looked like
...
@@ -1012,8 +1009,7 @@ shared part. The shared part was left in an inconsistent state that looked like
Let
's simulate a scenario where buildout is terminated in the middle of a build.
Let
's simulate a scenario where buildout is terminated in the middle of a build.
For this, we need a package that takes a lot of time to install.
For this, we need a package that takes a lot of time to install.
>>> tarpath = os.path.join(src, '
package
-
0.0.0
.
tar
.
gz
')
>>> with tarfile.open(package_path, '
w
:
gz
') as tar:
>>> with tarfile.open(tarpath, '
w
:
gz
') as tar:
... configure = b'
#
!/bin/sh\necho configure started\nsleep 300;'
... configure = b'
#
!/bin/sh\necho configure started\nsleep 300;'
...
info
=
tarfile
.
TarInfo
(
'configure'
)
...
info
=
tarfile
.
TarInfo
(
'configure'
)
...
info
.
size
=
len
(
configure
)
...
info
.
size
=
len
(
configure
)
...
@@ -1023,7 +1019,6 @@ For this, we need a package that takes a lot of time to install.
...
@@ -1023,7 +1019,6 @@ For this, we need a package that takes a lot of time to install.
We
also
need
a
bit
more
complex
method
to
run
buildout
so
that
we
send
a
termination
signal
in
the
We
also
need
a
bit
more
complex
method
to
run
buildout
so
that
we
send
a
termination
signal
in
the
middle
of
build
process
.
middle
of
build
process
.
>>>
import
subprocess
>>>
import
signal
>>>
import
signal
>>>
import
time
>>>
import
time
>>>
buildout_process
=
subprocess
.
Popen
(
buildout
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
>>>
buildout_process
=
subprocess
.
Popen
(
buildout
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
...
@@ -1048,14 +1043,14 @@ This was not the case in version 0.11 of this recipe. If installation of a share
...
@@ -1048,14 +1043,14 @@ This was not the case in version 0.11 of this recipe. If installation of a share
not
detected
and
the
part
was
considered
as
installed
.
not
detected
and
the
part
was
considered
as
installed
.
>>>
_
=
system
(
'mv %s/package-0.0.0.tar.gz.bak %s/package-0.0.0.tar.gz'
%
(
src
,
src
)
)
>>>
os
.
rename
(
package_path
+
'.bak'
,
package_path
)
>>>
print
(
system
(
buildout
))
#
doctest
:+
ELLIPSIS
>>>
print
(
system
(
buildout
))
#
doctest
:+
ELLIPSIS
package
:
shared
at
/
shared
/
package
/
FIRST_SHARED_PACKAGE_HASH
package
:
shared
at
/
shared
/
package
/
<
MD5SUM
:
0
>
Installing
package
.
Installing
package
.
package
:
Checking
whether
package
is
installed
at
shared
path
:
/
shared
/
package
/
FIRST_SHARED_PACKAGE_HASH
package
:
Checking
whether
package
is
installed
at
shared
path
:
/
shared
/
package
/
<
MD5SUM
:
0
>
package
:
[
ENV
]
FOO
=
bar
package
:
[
ENV
]
FOO
=
bar
package
:
Removing
already
existing
directory
/
shared
/
package
/
FIRST_SHARED_PACKAGE_HASH
__compile__
package
:
Removing
already
existing
directory
/
shared
/
package
/
<
MD5SUM
:
0
>
__compile__
configure
--
prefix
=/
shared
/
package
/
FIRST_SHARED_PACKAGE_HASH
configure
--
prefix
=/
shared
/
package
/
<
MD5SUM
:
0
>
building
package
building
package
installing
package
installing
package
...
@@ -1086,15 +1081,15 @@ used instead of installing if one package has been installed.
...
@@ -1086,15 +1081,15 @@ used instead of installing if one package has been installed.
...
...
... [package]
... [package]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%s
/package-0.0.0.tar.gz
... url = file://%s
... shared = True
... shared = True
... environment =
... environment =
... FOO=bar
... FOO=bar
... """ % (shared_dir, another_shared_dir,
src
))
... """ % (shared_dir, another_shared_dir,
package_path
))
>>> print(system(buildout)) #doctest:+ELLIPSIS
>>> print(system(buildout)) #doctest:+ELLIPSIS
package: shared at /shared/package/
FIRST_SHARED_PACKAGE_HASH
package: shared at /shared/package/
<MD5SUM:0>
Installing package.
Installing package.
package: Checking whether package is installed at shared path: /shared/package/
FIRST_SHARED_PACKAGE_HASH
package: Checking whether package is installed at shared path: /shared/package/
<MD5SUM:0>
package: This shared package has been installed by other package
package: This shared package has been installed by other package
If options change, reinstall in different location:
If options change, reinstall in different location:
...
@@ -1107,17 +1102,17 @@ If options change, reinstall in different location:
...
@@ -1107,17 +1102,17 @@ If options change, reinstall in different location:
...
...
... [package]
... [package]
... recipe = slapos.recipe.cmmi
... recipe = slapos.recipe.cmmi
... url = file://%s
/package-0.0.0.tar.gz
... url = file://%s
... shared =True
... shared =True
... change = True
... change = True
... """ % (shared_dir,
src
))
... """ % (shared_dir,
package_path
))
>>> print(system(buildout)) #doctest:+ELLIPSIS
>>> print(system(buildout)) #doctest:+ELLIPSIS
package: shared at /shared/package/
ANOTHER_SHARED_PACKAGE_HASH
package: shared at /shared/package/
<MD5SUM:1>
Uninstalling package.
Uninstalling package.
Installing package.
Installing package.
package: Checking whether package is installed at shared path: /shared/package/
ANOTHER_SHARED_PACKAGE_HASH
package: Checking whether package is installed at shared path: /shared/package/
<MD5SUM:1>
configure --prefix=/shared/package/
ANOTHER_SHARED_PACKAGE_HASH
configure --prefix=/shared/package/
<MD5SUM:1>
building package
building package
installing package
installing package
...
...
slapos/recipe/cmmi/tests.py
View file @
3de46334
...
@@ -328,24 +328,15 @@ class NonInformativeTests(unittest.TestCase):
...
@@ -328,24 +328,15 @@ class NonInformativeTests(unittest.TestCase):
self
.
assertTrue
(
os
.
path
.
exists
(
build_directory
))
self
.
assertTrue
(
os
.
path
.
exists
(
build_directory
))
def
test_suite
():
def
test_suite
():
# Hash used in the test depend on the file:// url of the package, so
sums
=
[]
# we use re-normalizer to replace SHARED_PACKAGE_HASH with the actual
def
md5sum
(
m
):
# hash for this path.
x
=
m
.
group
(
0
)
package_url
=
'file://%s/package-0.0.0.tar.gz'
%
os
.
path
.
join
(
try
:
os
.
path
.
dirname
(
__file__
),
'testdata'
)
i
=
sums
.
index
(
x
)
except
ValueError
:
signature_FIRST_SHARED_PACKAGE_HASH
=
Signature
(
'.slapos.recipe.cmmi.signature'
)
i
=
len
(
sums
)
signature_FIRST_SHARED_PACKAGE_HASH
.
update
(
'environment'
,
'FOO=bar'
)
sums
.
append
(
x
)
signature_FIRST_SHARED_PACKAGE_HASH
.
update
(
'recipe'
,
'slapos.recipe.cmmi'
)
return
'<MD5SUM:%s>'
%
i
signature_FIRST_SHARED_PACKAGE_HASH
.
update
(
'shared'
,
'True'
)
signature_FIRST_SHARED_PACKAGE_HASH
.
update
(
'url'
,
package_url
)
signature_ANOTHER_SHARED_PACKAGE_HASH
=
Signature
(
'.slapos.recipe.cmmi.signature'
)
signature_ANOTHER_SHARED_PACKAGE_HASH
.
update
(
'change'
,
'True'
)
signature_ANOTHER_SHARED_PACKAGE_HASH
.
update
(
'recipe'
,
'slapos.recipe.cmmi'
)
signature_ANOTHER_SHARED_PACKAGE_HASH
.
update
(
'shared'
,
'True'
)
signature_ANOTHER_SHARED_PACKAGE_HASH
.
update
(
'url'
,
package_url
)
suite
=
unittest
.
TestSuite
((
suite
=
unittest
.
TestSuite
((
doctest
.
DocFileSuite
(
doctest
.
DocFileSuite
(
'README.rst'
,
'README.rst'
,
...
@@ -361,10 +352,7 @@ def test_suite():
...
@@ -361,10 +352,7 @@ def test_suite():
'
--
prefix
=/
shared
/
'),
'
--
prefix
=/
shared
/
'),
(re.compile(r'
\
s
/
\
S
+
\
/
shared
\
/
'),
(re.compile(r'
\
s
/
\
S
+
\
/
shared
\
/
'),
'
/
shared
/
'),
'
/
shared
/
'),
(re.compile('
FIRST_SHARED_PACKAGE_HASH
'),
(re.compile('
[
0
-
9
a
-
f
]{
32
}
'), md5sum),
signature_FIRST_SHARED_PACKAGE_HASH.hexdigest()),
(re.compile('
ANOTHER_SHARED_PACKAGE_HASH
'),
signature_ANOTHER_SHARED_PACKAGE_HASH.hexdigest()),
# Normalize subprocess.CalledProcessError message, on python >= 3.6
# Normalize subprocess.CalledProcessError message, on python >= 3.6
# there'
s
an
extra
.
at
the
end
.
# there'
s
an
extra
.
at
the
end
.
(
re
.
compile
(
r'Command (.*) returned non-zero exit status (\
d+)[
\.]{0,1}'
),
(
re
.
compile
(
r'Command (.*) returned non-zero exit status (\
d+)[
\.]{0,1}'
),
...
...
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