Exemplo n.º 1
0
    def update_package(self, fedpkg_root, branch, new_release):
        """
        Pulls in new source, patches spec file, commits,
        pushes and builds new version on specified branch

        :param fedpkg_root: The root of dist-git repository
        :param branch: What Fedora branch is this
        :param new_release: an array containing info about new release, see main() for definition
        :return: True on success, False on failure
        """
        is_master = branch.lower() == "master"

        # retrieve sources
        if not self.fedpkg_sources(fedpkg_root, branch, fail=is_master):
            return False

        # update spec file
        spec_path = os.path.join(fedpkg_root,
                                 f"{self.conf.repository_name}.spec")
        update_spec(spec_path, new_release)

        # check if spec file is valid
        if not self.fedpkg_lint(fedpkg_root, branch, fail=is_master):
            return False

        dir_listing = os.listdir(fedpkg_root)

        # get new source
        if not self.fedpkg_spectool(fedpkg_root, branch, fail=is_master):
            return False

        # find new sources
        dir_new_listing = os.listdir(fedpkg_root)
        sources = " ".join((set(dir_new_listing) - set(dir_listing)))

        # if there are no new sources, abort update
        if not sources.strip():
            self.logger.warning(
                "There are no new sources, won't continue releasing to fedora")
            return False

        # add new sources
        if not self.fedpkg_new_sources(
                fedpkg_root, branch, sources, fail=is_master):
            return False

        # commit this change, push it and start a build
        if not self.fedpkg_commit(fedpkg_root,
                                  branch,
                                  f"Update to {new_release['version']}",
                                  fail=is_master):
            return False
        if not self.fedpkg_push(fedpkg_root, branch, fail=is_master):
            return False
        if not self.fedpkg_build(
                fedpkg_root, branch, scratch=False, fail=is_master):
            return False

        return True
Exemplo n.º 2
0
 def test_valid_conf_changelog(self, valid_spec, valid_new_release,
                               spec_updated_changelog, patch_datetime_now):
     valid_new_release['changelog'] = [
         'Changelog entry 1', 'Changelog entry 2'
     ]
     update_spec(valid_spec, valid_new_release)
     with open(valid_spec) as spec, open(
             spec_updated_changelog) as original:
         assert spec.read() == original.read()
Exemplo n.º 3
0
 def test_missing_spec(self, valid_new_release):
     with pytest.raises(ReleaseException):
         update_spec("", valid_new_release)
Exemplo n.º 4
0
 def test_valid_conf(self, valid_spec, valid_new_release, spec_updated, patch_datetime_now):
     update_spec(valid_spec, valid_new_release)
     with open(valid_spec) as spec, open(spec_updated) as original:
         assert spec.read() == original.read()