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:: ...@@ -222,6 +222,49 @@ Setting `location` option is incompatible::
Initializing section script. Initializing section script.
Error: When shared=true, option 'location' can't be set 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 slapos.recipe.build:download
......
...@@ -263,7 +263,11 @@ class Script(EnvironMixin): ...@@ -263,7 +263,11 @@ class Script(EnvironMixin):
def install(self): def install(self):
if self._install: if self._install:
shared = self._shared
if shared.location:
return self._shared.install(self.__install) return self._shared.install(self.__install)
self._exec(self._install)
else:
self.update() self.update()
return () return ()
......
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