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
92dfe439
Commit
92dfe439
authored
6 years ago
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
downliadunpacked: add shared feature
parent
b0a8d3fd
master
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
4 deletions
+35
-4
slapos/recipe/downloadunpacked.py
slapos/recipe/downloadunpacked.py
+35
-4
No files found.
slapos/recipe/downloadunpacked.py
View file @
92dfe439
...
...
@@ -32,6 +32,7 @@ import tarfile
import
zc.buildout
import
tempfile
import
setuptools.archive_util
from
hashlib
import
md5
is_true
=
(
'false'
,
'true'
).
index
...
...
@@ -47,13 +48,34 @@ class Recipe:
'exclusive.'
)
self
.
parts
=
None
self
.
destination
=
self
.
options
.
get
(
'destination'
,
None
)
self
.
shared
=
shared
=
options
.
get
(
'shared'
,
''
)
if
self
.
destination
is
None
:
self
.
parts
=
os
.
path
.
join
(
self
.
buildout
[
'buildout'
][
'parts-directory'
],
self
.
name
)
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
=
shared
self
.
logger
.
info
(
'shared directory %s set for %s'
%
(
shared
,
name
))
else
:
self
.
parts
=
os
.
path
.
join
(
self
.
buildout
[
'buildout'
][
'parts-directory'
],
self
.
name
)
self
.
destination
=
self
.
parts
# backward compatibility with other recipes -- expose location
options
[
'location'
]
=
os
.
path
.
join
(
self
.
buildout
[
'buildout'
][
'parts-directory'
],
self
.
name
)
options
[
'location'
]
=
self
.
parts
options
[
'target'
]
=
self
.
destination
options
.
setdefault
(
'extract-directory'
,
''
)
...
...
@@ -76,6 +98,11 @@ class Recipe:
self
.
environ
[
key
]
=
self
.
environ
[
key
]
%
os
.
environ
def
install
(
self
):
if
self
.
shared
:
self
.
logger
.
info
(
'Checking whether package is installed at shared path : %s'
%
self
.
destination
)
if
os
.
path
.
exists
(
self
.
destination
):
self
.
logger
.
info
(
'This shared package has been installed by other package'
)
return
[]
if
self
.
parts
is
not
None
:
if
not
os
.
path
.
isdir
(
self
.
parts
):
os
.
mkdir
(
self
.
parts
)
...
...
@@ -132,6 +159,10 @@ class Recipe:
shutil
.
rmtree
(
extract_dir
)
self
.
logger
.
debug
(
'Downloaded %r and saved to %r.'
,
self
.
options
[
'url'
],
self
.
destination
)
if
self
.
shared
:
with
open
(
os
.
path
.
join
(
self
.
parts
,
".slapos.recipe.build.signature"
),
'w'
)
as
f
:
f
.
write
(
'
\
n
'
.
join
(
self
.
_debug_signature_text
))
if
self
.
parts
is
not
None
:
return
[
self
.
parts
]
else
:
...
...
This diff is collapsed.
Click to expand it.
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