Filter out components not listed in origins file
If component is not mentioned in origins file (like oslo-messaging in havana-1) this means it is not needed for this origins and it should be ignored. Change-Id: I8ce113bd823d6a3d3f1c743b30585af79966720e
This commit is contained in:
parent
bb679fe3ea
commit
d10a5db610
@ -102,7 +102,7 @@ def run(args):
|
|||||||
# Load + verify the person
|
# Load + verify the person
|
||||||
try:
|
try:
|
||||||
persona_obj = persona.load(persona_fn)
|
persona_obj = persona.load(persona_fn)
|
||||||
persona_obj.verify(dist)
|
persona_obj.verify(dist, args['origins_fn'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise excp.OptionException("Error loading persona file: %s due to %s" % (persona_fn, e))
|
raise excp.OptionException("Error loading persona file: %s due to %s" % (persona_fn, e))
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ from anvil import settings
|
|||||||
from anvil import shell as sh
|
from anvil import shell as sh
|
||||||
from anvil import trace as tr
|
from anvil import trace as tr
|
||||||
from anvil import utils
|
from anvil import utils
|
||||||
import yaml
|
|
||||||
|
|
||||||
from anvil.packaging.helpers import pip_helper
|
from anvil.packaging.helpers import pip_helper
|
||||||
|
|
||||||
@ -144,8 +143,7 @@ class PythonInstallComponent(PkgInstallComponent):
|
|||||||
def download(self):
|
def download(self):
|
||||||
"""Download sources needed to build the component, if any."""
|
"""Download sources needed to build the component, if any."""
|
||||||
target_dir = self.get_option('app_dir')
|
target_dir = self.get_option('app_dir')
|
||||||
with open(self._origins_fn, 'r') as fh:
|
download_cfg = utils.load_yaml(self._origins_fn).get(self.name, {})
|
||||||
download_cfg = yaml.safe_load(fh.read()).get(self.name, {})
|
|
||||||
if not target_dir or not download_cfg:
|
if not target_dir or not download_cfg:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -22,13 +22,12 @@ import platform
|
|||||||
import re
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
|
|
||||||
import yaml
|
|
||||||
|
|
||||||
from anvil import colorizer
|
from anvil import colorizer
|
||||||
from anvil import exceptions as excp
|
from anvil import exceptions as excp
|
||||||
from anvil import importer
|
from anvil import importer
|
||||||
from anvil import log as logging
|
from anvil import log as logging
|
||||||
from anvil import shell as sh
|
from anvil import shell as sh
|
||||||
|
from anvil import utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -145,12 +144,8 @@ def load(path):
|
|||||||
for fn in input_files:
|
for fn in input_files:
|
||||||
LOG.debug("Attempting to load distro definition from %r", fn)
|
LOG.debug("Attempting to load distro definition from %r", fn)
|
||||||
try:
|
try:
|
||||||
# Don't use sh here so that we always
|
cls_kvs = utils.load_yaml(fn)
|
||||||
# read this (even if dry-run)
|
except Exception as err:
|
||||||
with open(fn, 'r') as fh:
|
|
||||||
contents = fh.read()
|
|
||||||
cls_kvs = yaml.safe_load(contents)
|
|
||||||
distro_possibles.append(Distro(**cls_kvs))
|
|
||||||
except (IOError, yaml.YAMLError) as err:
|
|
||||||
LOG.warning('Could not load distro definition from %r: %s', fn, err)
|
LOG.warning('Could not load distro definition from %r: %s', fn, err)
|
||||||
|
distro_possibles.append(Distro(**cls_kvs))
|
||||||
return _match_distro(distro_possibles)
|
return _match_distro(distro_possibles)
|
||||||
|
@ -14,9 +14,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import yaml
|
|
||||||
|
|
||||||
from anvil import log as logging
|
from anvil import log as logging
|
||||||
|
from anvil import utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -25,12 +24,18 @@ class Persona(object):
|
|||||||
|
|
||||||
def __init__(self, supports, components, **kargs):
|
def __init__(self, supports, components, **kargs):
|
||||||
self.distro_support = supports or []
|
self.distro_support = supports or []
|
||||||
self.wanted_components = components or []
|
|
||||||
self.source = kargs.get('source')
|
self.source = kargs.get('source')
|
||||||
|
self.wanted_components = components or []
|
||||||
self.wanted_subsystems = kargs.get('subsystems') or {}
|
self.wanted_subsystems = kargs.get('subsystems') or {}
|
||||||
self.component_options = kargs.get('options') or {}
|
self.component_options = kargs.get('options') or {}
|
||||||
|
|
||||||
def verify(self, distro):
|
def verify(self, distro, origins_fn):
|
||||||
|
# Filter components out that are not in origins file
|
||||||
|
available_components = set(utils.load_yaml(origins_fn).iterkeys())
|
||||||
|
available_components.add('general')
|
||||||
|
self.wanted_components = [c for c in self.wanted_components
|
||||||
|
if c in available_components]
|
||||||
|
|
||||||
# Some sanity checks against the given distro/persona
|
# Some sanity checks against the given distro/persona
|
||||||
d_name = distro.name
|
d_name = distro.name
|
||||||
if d_name not in self.distro_support:
|
if d_name not in self.distro_support:
|
||||||
@ -41,11 +46,7 @@ class Persona(object):
|
|||||||
|
|
||||||
|
|
||||||
def load(fn):
|
def load(fn):
|
||||||
# Don't use sh here so that we always
|
cls_kvs = utils.load_yaml(fn)
|
||||||
# read this (even if dry-run)
|
|
||||||
with open(fn, 'r') as fh:
|
|
||||||
contents = fh.read()
|
|
||||||
cls_kvs = yaml.safe_load(contents)
|
|
||||||
cls_kvs['source'] = fn
|
cls_kvs['source'] = fn
|
||||||
instance = Persona(**cls_kvs)
|
instance = Persona(**cls_kvs)
|
||||||
return instance
|
return instance
|
||||||
|
Loading…
Reference in New Issue
Block a user