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
Xiaowu Zhang
slapos.recipe.build
Commits
b0a8d3fd
Commit
b0a8d3fd
authored
Jul 03, 2018
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
download: add shared feature
parent
06b80033
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
2 deletions
+43
-2
slapos/recipe/download.py
slapos/recipe/download.py
+43
-2
No files found.
slapos/recipe/download.py
View file @
b0a8d3fd
...
...
@@ -28,6 +28,8 @@ import errno
import
os
import
shutil
import
zc.buildout
import
logging
from
hashlib
import
md5
class
Recipe
(
object
):
_parts
=
None
...
...
@@ -38,17 +40,45 @@ class Recipe(object):
hash_name
=
True
)
self
.
_url
=
options
[
'url'
]
self
.
_md5sum
=
options
.
get
(
'md5sum'
)
self
.
_name
=
name
mode
=
options
.
get
(
'mode'
)
log
=
logging
.
getLogger
(
name
)
if
mode
is
not
None
:
mode
=
int
(
mode
,
8
)
self
.
_mode
=
mode
if
'filename'
in
options
and
'destination'
in
options
:
raise
zc
.
buildout
.
UserError
(
'Parameters filename and destination are '
'exclusive.'
)
destination
=
options
.
get
(
'destination'
,
None
)
if
destination
is
None
:
shared
=
options
.
get
(
'shared'
)
self
.
_shared
=
shared
if
shared
:
shared_part
=
buildout
[
'buildout'
].
get
(
'shared-part'
,
None
)
if
not
shared_part
:
raise
ValueError
(
" Set ${buildout:shared-part} for shared feature"
)
shared
=
os
.
path
.
join
(
shared_part
.
strip
().
rstrip
(
'/'
),
name
)
if
not
os
.
path
.
exists
(
shared
):
os
.
makedirs
(
shared
)
self
.
_debug_signature_text
=
[]
m
=
md5
()
profile_base_location
=
options
.
get
(
'_profile_base_location_'
,
''
)
for
k
,
v
in
sorted
(
options
.
items
()):
if
profile_base_location
:
v
=
v
.
replace
(
profile_base_location
,
'${:_profile_base_location_}'
)
option_signature
=
(
'%r: %r'
%
(
k
,
v
)).
encode
()
self
.
_debug_signature_text
.
append
(
option_signature
)
m
.
update
(
option_signature
)
shared
=
os
.
path
.
join
(
shared
,
m
.
hexdigest
())
self
.
_parts
=
parts
=
shared
log
.
info
(
'shared directory %s set for %s'
%
(
shared
,
name
))
else
:
self
.
_parts
=
parts
=
os
.
path
.
join
(
buildout_section
[
'parts-directory'
],
name
)
destination
=
os
.
path
.
join
(
parts
,
options
.
get
(
'filename'
,
name
))
# Compatibility with other recipes: expose location
options
[
'location'
]
=
parts
...
...
@@ -58,6 +88,13 @@ class Recipe(object):
destination
=
self
.
_destination
result
=
[
destination
]
parts
=
self
.
_parts
log
=
logging
.
getLogger
(
self
.
_name
)
if
self
.
_shared
:
log
.
info
(
'Checking whether package is installed at shared path: %s'
%
destination
)
if
os
.
path
.
exists
(
destination
):
log
.
info
(
'This shared package has been installed by other package'
)
return
[]
if
parts
is
not
None
and
not
os
.
path
.
isdir
(
parts
):
os
.
mkdir
(
parts
)
result
.
append
(
parts
)
...
...
@@ -74,6 +111,10 @@ class Recipe(object):
if
self
.
_mode
is
not
None
:
os
.
fchmod
(
fdst
.
fileno
(),
self
.
_mode
)
shutil
.
copyfileobj
(
fsrc
,
fdst
)
if
self
.
_shared
:
with
open
(
os
.
path
.
join
(
parts
,
".slapos.recipe.build.signature"
),
'w'
)
as
f
:
f
.
write
(
'
\
n
'
.
join
(
self
.
_debug_signature_text
))
return
result
def
update
(
self
):
...
...
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