Esempio n. 1
0
    def _create_host_os_repo(self):
        LOG.info("Creating Host OS yum repository inside chroot")

        LOG.debug("Creating yum repository directory")
        self.mock.run_command("--shell 'mkdir -p %s'" %
                              CHROOT_HOST_OS_REPO_PATH)

        LOG.debug("Creating package groups metadata file (comps.xml)")
        groups_file_content = packages_groups_xml_creator.create_comps_xml(
            self.config.get('installable_environments'))
        groups_file_path = os.path.join(self.work_dir, GROUPS_FILE_NAME)
        try:
            with open(groups_file_path, 'wt') as groups_file:
                groups_file.write(groups_file_content)
        except IOError:
            LOG.error("Failed to write XML to %s file." % groups_file_path)
            raise
        self.mock.run_command("--copyin %s %s" %
                              (groups_file_path, GROUPS_FILE_CHROOT_PATH))

        LOG.debug("Copying packages to chroot")
        packages_dir = self.config.get('packages_dir')
        rpm_files = utils.recursive_glob(packages_dir, "*.rpm")
        self.mock.run_command("--copyin %s %s" %
                              (" ".join(rpm_files), CHROOT_HOST_OS_REPO_PATH))

        LOG.debug("Creating yum repository")
        create_repo_command = (
            "--shell 'createrepo --verbose --groupfile {groups_file} "
            "{repo_path}'".format(groups_file=GROUPS_FILE_CHROOT_PATH,
                                  repo_path=CHROOT_HOST_OS_REPO_PATH))
        self.mock.run_command(create_repo_command)
Esempio n. 2
0
    def _create_iso_repo(self):
        LOG.info("Creating ISO yum repository inside chroot")

        LOG.debug("Creating ISO yum repository directory")
        mock_iso_repo_dir = self.config.get('mock_iso_repo_dir')
        self._run_mock_command("--shell 'mkdir -p %s'" % mock_iso_repo_dir)

        LOG.debug("Copying rpm packages to ISO yum repo directory")
        packages_dir = self.config.get('packages_dir')
        rpm_files = utils.recursive_glob(packages_dir, "*.rpm")
        self._run_mock_command("--copyin %s %s" %
                               (" ".join(rpm_files), mock_iso_repo_dir))

        LOG.debug("Creating package groups metadata file (comps.xml)")
        comps_xml_str = packages_groups_xml_creator.create_comps_xml(
            self.config.get('hostos_packages_groups'))
        comps_xml_file = "host-os-comps.xml"
        comps_xml_path = os.path.join(self.work_dir, comps_xml_file)
        try:
            with open(comps_xml_path, 'wt') as f:
                f.write(comps_xml_str)
        except IOError:
            LOG.error("Failed to write XML to %s file." % comps_xml_path)
            raise

        comps_xml_chroot_path = os.path.join("/", comps_xml_file)
        self._run_mock_command("--copyin %s %s" %
                               (comps_xml_path, comps_xml_chroot_path))

        LOG.debug("Creating ISO yum repository")
        createrepo_cmd = "createrepo -v -g %s %s" % (comps_xml_chroot_path,
                                                     mock_iso_repo_dir)
        self._run_mock_command("--shell '%s'" % createrepo_cmd)
Esempio n. 3
0
    def _create_host_os_repo(self):
        LOG.info("Creating Host OS yum repository inside chroot")

        LOG.debug("Creating yum repository directory")
        self.mock.run_command(
            "--shell 'mkdir -p %s'" % CHROOT_HOST_OS_REPO_PATH)

        LOG.debug("Creating package groups metadata file (comps.xml)")
        groups_file_content = packages_groups_xml_creator.create_comps_xml(
            self.config.get('installable_environments'))
        groups_file_path = os.path.join(self.work_dir, GROUPS_FILE_NAME)
        try:
            with open(groups_file_path, 'wt') as groups_file:
                groups_file.write(groups_file_content)
        except IOError:
            LOG.error("Failed to write XML to %s file." % groups_file_path)
            raise
        self.mock.run_command("--copyin %s %s" %
                              (groups_file_path, GROUPS_FILE_CHROOT_PATH))

        LOG.debug("Copying packages to chroot")
        packages_dir = self.config.get('packages_dir')
        rpm_files = utils.recursive_glob(packages_dir, "*.rpm")
        self.mock.run_command(
            "--copyin %s %s" % (" ".join(rpm_files), CHROOT_HOST_OS_REPO_PATH))

        LOG.debug("Creating yum repository")
        create_repo_command = (
            "--shell 'createrepo --verbose --groupfile {groups_file} "
            "{repo_path}'".format(groups_file=GROUPS_FILE_CHROOT_PATH,
                                  repo_path=CHROOT_HOST_OS_REPO_PATH))
        self.mock.run_command(create_repo_command)
Esempio n. 4
0
def validate_rpm_specs(base_dir):
    """
    Validate specification files of rpm packages in a base directory

    Args:
        base_dir (str): base directory path

    Returns:
        bool: if RPM specification files are valid
    """

    files = recursive_glob(base_dir, "*.spec")
    valid = True
    for _file in files:
        if not validate_rpm_spec(_file):
            valid = False

    return valid
Esempio n. 5
0
def validate_yamls(base_dir):
    """
    Validate yaml files

    Args:
        base_dir (str): base directory path

    Returns:
        bool: if YAML files are valid
    """

    files = recursive_glob(base_dir, "*.yaml")
    valid = True
    for _file in files:
        if not validate_yaml(_file):
            valid = False

    return valid
def validate_yamls(base_dir):
    """
    Validate yaml files

    Args:
        base_dir (str): base directory path

    Returns:
        bool: if YAML files are valid
    """

    files = recursive_glob(base_dir, "*.yaml")
    valid = True
    for _file in files:
        if not validate_yaml(_file):
            valid = False

    if valid:
         LOG.info("Validation completed successfully.")
    else:
         LOG.info("Validation failed.")

    return valid
def validate_rpm_specs(base_dir):
    """
    Validate specification files of rpm packages in a base directory

    Args:
        base_dir (str): base directory path

    Returns:
        bool: if RPM specification files are valid
    """

    files = recursive_glob(base_dir, "*.spec")
    valid = True
    for _file in files:
        if not validate_rpm_spec(_file):
            valid = False

    if valid:
        LOG.info("Validation completed successfully.")
    else:
        LOG.info("Validation failed.")

    return valid
Esempio n. 8
0
def validate_rpm_specs(base_dir):
    """
    Validate specification files of rpm packages in a base directory

    Args:
        base_dir (str): base directory path

    Returns:
        bool: if RPM specification files are valid
    """

    files = recursive_glob(base_dir, "*.spec")
    valid = True
    for _file in files:
        if not validate_rpm_spec(_file):
            valid = False

    if valid:
        LOG.info("Validation completed successfully.")
    else:
        LOG.info("Validation failed.")

    return valid
def validate_yamls(base_dir):
    """
    Validate yaml files

    Args:
        base_dir (str): base directory path

    Returns:
        bool: if YAML files are valid
    """

    files = recursive_glob(base_dir, "*.yaml")
    valid = True
    for _file in files:
        if not validate_yaml(_file):
            valid = False

    if valid:
        LOG.info("Validation completed successfully.")
    else:
        LOG.info("Validation failed.")

    return valid
Esempio n. 10
0
    def needs_rebuild(self):
        """
        Check if the package needs to be rebuild.
        Compare the modification time of the package source and metadata
        files with the latest build results files and check if the build
        dependencies were updated.

        Returns:
            bool: whether the package needs to be rebuilt
        """
        # Check if there are any cached build results
        if not self.cached_build_results:
            LOG.debug("%s: No previous build results found." % self.name)
            return True

        latest_source_time_stamp = None
        for file_path in utils.recursive_glob(self.package_dir, "*"):
            file_time_stamp = os.stat(file_path).st_mtime
            latest_source_time_stamp = max(
                latest_source_time_stamp, file_time_stamp)
        latest_build_results_time_stamp = self._latest_build_results_time_stamp

        # Check if sources are older than build results
        if latest_build_results_time_stamp < latest_source_time_stamp:
            LOG.debug("%s: Build results are outdated." % self.name)
            return True

        # Check if build dependencies were rebuilt since last build
        for dependency in self.build_dependencies:
            if (latest_build_results_time_stamp
                    < dependency._latest_build_results_time_stamp):
                LOG.debug("%s: Build dependency %s has been rebuilt."
                          % (self.name, dependency.name))
                return True

        LOG.debug("%s: Up-to-date build results found." % self.name)
        return False
Esempio n. 11
0
    def needs_rebuild(self):
        """
        Check if the package needs to be rebuild.
        Compare the modification time of the package source and metadata
        files with the latest build results files and check if the build
        dependencies were updated.

        Returns:
            bool: whether the package needs to be rebuilt
        """
        # Check if there are any cached build results
        if not self.cached_build_results:
            LOG.debug("%s: No previous build results found." % self.name)
            return True

        latest_source_time_stamp = None
        for file_path in utils.recursive_glob(self.package_dir, "*"):
            file_time_stamp = os.stat(file_path).st_mtime
            latest_source_time_stamp = max(latest_source_time_stamp,
                                           file_time_stamp)
        latest_build_results_time_stamp = self._latest_build_results_time_stamp

        # Check if sources are older than build results
        if latest_build_results_time_stamp < latest_source_time_stamp:
            LOG.debug("%s: Build results are outdated." % self.name)
            return True

        # Check if build dependencies were rebuilt since last build
        for dependency in self.build_dependencies:
            if (latest_build_results_time_stamp <
                    dependency._latest_build_results_time_stamp):
                LOG.debug("%s: Build dependency %s has been rebuilt." %
                          (self.name, dependency.name))
                return True

        LOG.debug("%s: Up-to-date build results found." % self.name)
        return False