builders.py: Simplify publish directory logic to be more reusable

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2018-11-20 23:23:40 +00:00
parent 85fbb6a79c
commit 1d533e410f

View File

@ -31,19 +31,14 @@ def get_sstate_release_number(props):
return '.'.join(release_components).strip('.') return '.'.join(release_components).strip('.')
def get_publish_internal(props, basename=False): def get_publish_internal(props):
""" """
Calculate the location to which artefacts should be published and store it Calculate the location to which artefacts should be published and store it
as a property for use by other workers. as a property for use by other workers.
""" """
dest = "" dest = ""
deploy = props.getProperty("deploy_artefacts", False)
if deploy:
rel_name = ""
dest = props.getProperty("publish_destination", "") dest = props.getProperty("publish_destination", "")
if dest: if dest:
if basename:
return os.path.basename(dest)
return dest return dest
if props.getProperty("is_release", False): if props.getProperty("is_release", False):
@ -92,19 +87,21 @@ def get_publish_internal(props, basename=False):
# all workers in a triggered set publish to the same location # all workers in a triggered set publish to the same location
props.setProperty("publish_destination", dest, props.setProperty("publish_destination", dest,
"get_publish_dest") "get_publish_dest")
if basename:
return os.path.basename(dest)
return dest return dest
else:
return ""
@util.renderer @util.renderer
def get_publish_dest(props): def get_publish_dest(props):
return get_publish_internal(props, basename=False) deploy = props.getProperty("deploy_artefacts", False)
if not deploy:
return ""
return get_publish_internal(props)
@util.renderer @util.renderer
def get_publish_name(props): def get_publish_name(props):
return get_publish_internal(props, basename=True) dest = get_publish_internal(props)
if dest:
return os.path.basename(dest)
return dest
@util.renderer @util.renderer
def ensure_props_set(props): def ensure_props_set(props):