def import_repositories_marked_as_imageinclude(self): """ Those <repository> sections which are marked with the imageinclude attribute should be permanently added to the image repository configuration """ repository_sections = \ self.xml_state.get_repository_sections_used_in_image() root = RootInit(root_dir=self.root_dir, allow_existing=True) repo = Repository(RootBind(root), self.xml_state.get_package_manager()) repo.use_default_location() for xml_repo in repository_sections: repo_type = xml_repo.get_type() repo_source = xml_repo.get_source().get_path() repo_user = xml_repo.get_username() repo_secret = xml_repo.get_password() repo_alias = xml_repo.get_alias() repo_priority = xml_repo.get_priority() repo_dist = xml_repo.get_distribution() repo_components = xml_repo.get_components() repo_repository_gpgcheck = xml_repo.get_repository_gpgcheck() repo_package_gpgcheck = xml_repo.get_package_gpgcheck() uri = Uri(repo_source, repo_type) repo_source_translated = uri.translate( check_build_environment=False) if not repo_alias: repo_alias = uri.alias() log.info('Setting up image repository %s', repo_source) log.info('--> Type: %s', repo_type) log.info('--> Translated: %s', repo_source_translated) log.info('--> Alias: %s', repo_alias) repo.add_repo(repo_alias, repo_source_translated, repo_type, repo_priority, repo_dist, repo_components, repo_user, repo_secret, uri.credentials_file_name(), repo_repository_gpgcheck, repo_package_gpgcheck)
def __init__(self, xml_state, root_dir, allow_existing=False): """ Setup and host bind new root system at given root_dir directory """ log.info('Setup root directory: %s', root_dir) root = RootInit(root_dir, allow_existing) root.create() image_uri = xml_state.get_derived_from_image_uri() if image_uri: root_import = RootImport(root_dir, image_uri, xml_state.build_type.get_image()) root_import.sync_data() root_bind = RootBind(root) root_bind.setup_intermediate_config() root_bind.mount_kernel_file_systems() root_bind.mount_shared_directory() self.xml_state = xml_state self.profiles = xml_state.profiles self.root_bind = root_bind # A list of Uri references is stored inside of the System instance # in order to delay the Uri destructors until the System instance # dies. This is needed to keep bind mounted Uri locations alive # for System operations self.uri_list = []
def setup(self): root = mock.Mock() root.root_dir = 'root-dir' self.bind_root = RootBind(root) # stub config files and bind locations self.bind_root.config_files = ['/foo'] self.bind_root.bind_locations = ['/proc'] # stub files/dirs and mountpoints to cleanup self.mount_manager = mock.Mock() self.bind_root.cleanup_files = ['/foo.kiwi'] self.bind_root.mount_stack = [self.mount_manager] self.bind_root.dir_stack = ['/mountpoint']
def __init__( self, xml_state, root_dir, allow_existing=False ): """ Setup and host bind new root system at given root_dir directory """ log.info('Setup root directory: %s', root_dir) if not log.getLogLevel() == logging.DEBUG and not log.get_logfile(): self.issue_message = dedent(''' {headline}: {reason} Further details to clarify the error might have been reported earlier in the package manager log information and did not get exposed to the caller. Thus if the above message is not clear on the error please call kiwi with the --debug or --logfile option. ''') else: self.issue_message = '{headline}: {reason}' root = RootInit( root_dir, allow_existing ) root.create() image_uri = xml_state.get_derived_from_image_uri() if image_uri: root_import = RootImport.new( root_dir, image_uri, xml_state.build_type.get_image() ) root_import.sync_data() root_bind = RootBind( root ) root_bind.setup_intermediate_config() root_bind.mount_kernel_file_systems() root_bind.mount_shared_directory() self.xml_state = xml_state self.profiles = xml_state.profiles self.root_bind = root_bind # A list of Uri references is stored inside of the System instance # in order to delay the Uri destructors until the System instance # dies. This is needed to keep bind mounted Uri locations alive # for System operations self.uri_list = []