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
Ayush Tiwari
slapos.recipe.build
Commits
f84536b8
Commit
f84536b8
authored
Oct 10, 2018
by
Bryton Lacquement
🚪
Committed by
Julien Muchembled
Oct 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More Py3 fixes
parent
9c49c425
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
48 deletions
+38
-48
README.rst
README.rst
+25
-25
slapos/recipe/build/tests.py
slapos/recipe/build/tests.py
+9
-19
slapos/recipe/downloadunpacked.py
slapos/recipe/downloadunpacked.py
+4
-4
No files found.
README.rst
View file @
f84536b8
...
...
@@ -69,7 +69,7 @@ For example::
recipe = slapos.recipe.build
example = foobar's one
script =
print
'%%s' %% self.options['example']
print
('%%s' %% self.options['example'])
# will print “foobar's one”
[no-escaping]
...
...
@@ -78,9 +78,9 @@ For example::
foo = bar
format = no
script =
print
'%s' % self.options['example']
print
('%s' % self.options['example'])
# will print “foobar's one”
print
'%(foo)s'
print
('%(foo)s')
# will print “%(foo)s”
Pure download
...
...
@@ -150,7 +150,7 @@ the recipe will pick up the latest commit on the remote master branch::
This will clone the git repository in `parts/git-clone` directory.
Then let's run the buildout::
>>> print
system(buildout
)
>>> print
(system(buildout)
)
Installing git-clone.
Cloning into '/sample-buildout/parts/git-clone'...
...
...
@@ -161,7 +161,7 @@ Let's take a look at the buildout parts directory now::
When updating, it will do a "git fetch; git reset @{upstream}"::
>>> print
system(buildout
)
>>> print
(system(buildout)
)
Updating git-clone.
Fetching origin
HEAD is now at ...
...
...
@@ -185,7 +185,7 @@ run it will take the latest commit on this remote branch::
Then let's run the buildout::
>>> print
system(buildout
)
>>> print
(system(buildout)
)
Uninstalling git-clone.
Running uninstall recipe.
Installing git-clone.
...
...
@@ -200,13 +200,13 @@ And let's see that current branch is "build"::
>>> import subprocess
>>> cd('parts', 'git-clone')
>>> print
subprocess.check_output(['git', 'branch']
)
>>> print
(subprocess.check_output(['git', 'branch'], universal_newlines=True)
)
* build
When updating, it will do a "git fetch; git reset build"::
>>> cd(sample_buildout)
>>> print
system(buildout
)
>>> print
(system(buildout)
)
Updating git-clone.
Fetching origin
HEAD is now at ...
...
...
@@ -231,7 +231,7 @@ This option has priority over the "branch" option::
Then let's run the buildout::
>>> print
system(buildout
)
>>> print
(system(buildout)
)
Uninstalling git-clone.
Running uninstall recipe.
Installing git-clone.
...
...
@@ -246,13 +246,13 @@ And let's see that current revision is "2566127"::
>>> import subprocess
>>> cd(sample_buildout, 'parts', 'git-clone')
>>> print
subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']
)
>>> print
(subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'], universal_newlines=True)
)
2566127
When updating, it will do a "git fetch; git reset revision"::
>>> cd(sample_buildout)
>>> print
system(buildout
)
>>> print
(system(buildout)
)
Updating git-clone.
...
HEAD is now at 2566127 ...
...
...
@@ -283,14 +283,14 @@ extend an existing section specifying a branch)::
... branch = master
... """)
>>> print
system(buildout
)
>>> print
(system(buildout)
)
Uninstalling git-clone.
Running uninstall recipe.
Installing git-clone.
Cloning into '/sample-buildout/parts/git-clone'...
>>> cd(sample_buildout, 'parts', 'git-clone')
>>> print
system('git branch'
)
>>> print
(system('git branch')
)
* master
Revision/branch priority
...
...
@@ -312,7 +312,7 @@ and branch parameter is ignored::
... revision = 2566127
... """)
>>> print
system(buildout
)
>>> print
(system(buildout)
)
Uninstalling git-clone.
Running uninstall recipe.
Installing git-clone.
...
...
@@ -321,7 +321,7 @@ and branch parameter is ignored::
HEAD is now at 2566127 ...
>>> cd(sample_buildout, 'parts', 'git-clone')
>>> print
system('git branch'
)
>>> print
(system('git branch')
)
* master
Setup a "develop" repository
...
...
@@ -351,7 +351,7 @@ erase your local modifications by specifying the "develop" flag::
... develop = true
... """)
>>> print
system(buildout
)
>>> print
(system(buildout)
)
Uninstalling git-clone.
Running uninstall recipe.
Installing git-clone.
...
...
@@ -361,10 +361,10 @@ Buildout will then keep local modifications, instead of resetting the
repository::
>>> cd(sample_buildout, 'parts', 'git-clone')
>>> print
system('echo foo > setup.py'
)
>>> print
(system('echo foo > setup.py')
)
>>> cd(sample_buildout)
>>> print
system(buildout
)
>>> print
(system(buildout)
)
Updating git-clone.
Fetching origin
...
...
...
@@ -372,26 +372,26 @@ repository::
>>> cd(sample_buildout, 'parts', 'git-clone')
>>> print
system('cat setup.py'
)
>>> print
(system('cat setup.py')
)
foo
Then, when update occurs, nothing is done::
>>> cd(sample_buildout, 'parts', 'git-clone')
>>> print
system('echo kept > local_change'
)
>>> print
(system('echo kept > local_change')
)
>>> print
system('git remote add broken http://git.erp5.org/repos/nowhere'
)
>>> print
(system('git remote add broken http://git.erp5.org/repos/nowhere')
)
...
>>> cd(sample_buildout)
>>> print
system(buildout
)
>>> print
(system(buildout)
)
Updating git-clone.
Fetching origin
Fetching broken
Unable to update:
Traceback (most recent call last):
...
CalledProcessError: Command '['git', 'fetch', '--all']' returned non-zero exit status 1
...
CalledProcessError: Command '['git', 'fetch', '--all']' returned non-zero exit status 1
<BLANKLINE>
...
fatal: unable to access 'http://git.erp5.org/repos/nowhere/': The requested URL returned error: 500
...
...
@@ -399,7 +399,7 @@ Then, when update occurs, nothing is done::
<BLANKLINE>
>>> cd(sample_buildout, 'parts', 'git-clone')
>>> print
system('cat local_change'
)
>>> print
(system('cat local_change')
)
kept
In case of uninstall, buildout will keep the repository directory::
...
...
@@ -418,7 +418,7 @@ In case of uninstall, buildout will keep the repository directory::
... foo = bar
... """)
>>> print
system(buildout
)
>>> print
(system(buildout)
)
Uninstalling git-clone.
Running uninstall recipe.
You have uncommited changes in /sample-buildout/parts/git-clone. This folder will be left as is.
...
...
slapos/recipe/build/tests.py
View file @
f84536b8
...
...
@@ -64,22 +64,16 @@ class GitCloneNonInformativeTests(unittest.TestCase):
recipe
=
self
.
makeGitCloneRecipe
({
"use-cache"
:
"true"
,
"repository"
:
BAD_GIT_REPOSITORY
})
os
.
chdir
(
self
.
dir
)
try
:
with
self
.
assertRaises
(
zc
.
buildout
.
UserError
)
as
cm
:
recipe
.
install
()
# Should have raised before.
self
.
assertTrue
(
False
)
except
zc
.
buildout
.
UserError
as
e
:
self
.
assertEqual
(
e
.
message
,
GIT_CLONE_CACHE_ERROR_MESSAGE
)
self
.
assertEqual
(
str
(
cm
.
exception
),
GIT_CLONE_CACHE_ERROR_MESSAGE
)
def
test_not_using_download_cache_if_forbidden
(
self
):
recipe
=
self
.
makeGitCloneRecipe
({
"repository"
:
BAD_GIT_REPOSITORY
})
os
.
chdir
(
self
.
dir
)
try
:
with
self
.
assertRaises
(
zc
.
buildout
.
UserError
)
as
cm
:
recipe
.
install
()
# Should have raised before.
self
.
assertTrue
(
False
)
except
zc
.
buildout
.
UserError
as
e
:
self
.
assertEqual
(
e
.
message
,
GIT_CLONE_ERROR_MESSAGE
)
self
.
assertEqual
(
str
(
cm
.
exception
),
GIT_CLONE_ERROR_MESSAGE
)
def
test_cleanup_of_pyc_files
(
self
):
recipe
=
self
.
makeGitCloneRecipe
({})
...
...
@@ -101,9 +95,9 @@ class GitCloneNonInformativeTests(unittest.TestCase):
# Monkey patch check_call
original_check_call
=
slapos
.
recipe
.
gitclone
.
check_call
check_call_param
a
ter_list
=
[]
check_call_param
e
ter_list
=
[]
def
patch_check_call
(
*
args
,
**
kw
):
check_call_param
ater_list
.
extend
([
args
,
kw
]
)
check_call_param
eter_list
.
extend
((
args
,
kw
)
)
original_check_call
(
args
[
0
])
slapos
.
recipe
.
gitclone
.
check_call
=
patch_check_call
...
...
@@ -116,19 +110,15 @@ class GitCloneNonInformativeTests(unittest.TestCase):
options
=
{
'repository'
:
GIT_REPOSITORY
,
"ignore-ssl-certificate"
:
str
(
ignore_ssl_certificate
).
lower
(),
"repository"
:
GIT_REPOSITORY
}
recipe
=
slapos
.
recipe
.
gitclone
.
Recipe
(
bo
,
'test'
,
options
)
recipe
.
install
()
# Check git clone parameters
if
ignore_ssl_certificate
:
self
.
assertTrue
(
"--config"
in
check_call_paramater_list
[
0
][
0
])
self
.
assertTrue
(
"http.sslVerify=false"
in
check_call_paramater_list
[
0
][
0
])
else
:
self
.
assertTrue
(
not
"--config"
in
check_call_paramater_list
[
0
][
0
])
self
.
assertTrue
(
not
"http.sslVerify=false"
in
check_call_paramater_list
[
0
][
0
])
_
=
self
.
assertIn
if
ignore_ssl_certificate
else
self
.
assertNotIn
_
(
"--config"
,
check_call_parameter_list
[
0
][
0
])
_
(
"http.sslVerify=false"
,
check_call_parameter_list
[
0
][
0
])
# Restore original check_call method
slapos
.
recipe
.
gitclone
.
check_call
=
original_check_call
...
...
slapos/recipe/downloadunpacked.py
View file @
f84536b8
...
...
@@ -250,16 +250,16 @@ class Signature:
return
m
.
hexdigest
()
def
dumps
(
self
):
return
'
\
n
'
.
join
(
self
.
item_list
)
return
b
'
\
n
'
.
join
(
self
.
item_list
)
def
test
(
self
,
folder_path
):
digest
=
self
.
hexdigest
()
if
os
.
path
.
basename
(
folder_path
)
==
digest
:
if
os
.
path
.
basename
(
folder_path
)
.
encode
(
'utf-8'
)
==
digest
:
target_path
=
os
.
path
.
join
(
folder_path
,
self
.
filename
)
if
os
.
path
.
exists
(
target_path
)
and
open
(
target_path
).
read
()
==
self
.
dumps
():
if
os
.
path
.
exists
(
target_path
)
and
open
(
target_path
,
'rb'
).
read
()
==
self
.
dumps
():
return
True
return
False
def
save
(
self
,
folder_path
):
with
open
(
os
.
path
.
join
(
folder_path
,
self
.
filename
),
'w'
)
as
f
:
with
open
(
os
.
path
.
join
(
folder_path
,
self
.
filename
),
'w
b
'
)
as
f
:
f
.
write
(
self
.
dumps
())
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