Commit a2108d20 authored by Julien Muchembled's avatar Julien Muchembled

default: allow 'install' to install no file/dir

parent 59c48e51
......@@ -222,6 +222,49 @@ Setting `location` option is incompatible::
Initializing section script.
Error: When shared=true, option 'location' can't be set
option: location
----------------
If empty or unset, the value is initialized automatically according to rules
defined above (`shared` option), and before the `init` code is executed.
This way, it's possible to initialize other values of the section depending
on the actual value of location.
If not shared, the value can be customized in `init`. This is actually the
only way to empty location, which is useful if there's nothing file/directory
to track but you need to distinguish install from update::
>>> write(sample_buildout, 'buildout.cfg', """
... [buildout]
... parts = script
...
... [script]
... recipe = slapos.recipe.build
... init =
... options['location'] = ''
... install =
... print("install")
... update =
... print("update")
... """)
>>> print(system(buildout))
Uninstalling script.
Installing script.
install
>>> print(system(buildout))
Updating script.
update
>>> cat('.installed.cfg')
[buildout]
...
[script]
__buildout_installed__ =
__buildout_signature__ = ...
If install & update run the same code, `install` can be unset (or empty)
and you can ignore `location`.
=============================
slapos.recipe.build:download
......
......@@ -263,8 +263,12 @@ class Script(EnvironMixin):
def install(self):
if self._install:
return self._shared.install(self.__install)
self.update()
shared = self._shared
if shared.location:
return self._shared.install(self.__install)
self._exec(self._install)
else:
self.update()
return ()
def __install(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment