From 9474b0ab959c4621f96beb627dfb77da552ffd1b Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 26 Feb 2014 15:58:58 -0400 Subject: [PATCH] Support release with fetch builder. --- src/tito/builder/main.py | 68 +++++++++++++++++----------------- src/tito/release.py | 2 +- test/functional/fetch_tests.py | 25 ++++++++----- 3 files changed, 50 insertions(+), 45 deletions(-) diff --git a/src/tito/builder/main.py b/src/tito/builder/main.py index 7950606..756904b 100644 --- a/src/tito/builder/main.py +++ b/src/tito/builder/main.py @@ -170,6 +170,40 @@ class BuilderBase(object): self.rpmbuild_sourcedir, self.rpmbuild_builddir)) self._check_build_dirs_access() + # TODO: reuse_cvs_checkout isn't needed here, should be cleaned up: + def srpm(self, dist=None, reuse_cvs_checkout=False): + """ + Build a source RPM. + """ + self._create_build_dirs() + if not self.ran_tgz: + self.tgz() + + if self.test: + self._setup_test_specfile() + + debug("Creating srpm from spec file: %s" % self.spec_file) + define_dist = "" + if self.dist: + debug("using self.dist: %s" % self.dist) + define_dist = "--define 'dist %s'" % self.dist + elif dist: + debug("using dist: %s" % dist) + define_dist = "--define 'dist %s'" % dist + else: + debug("*NOT* using dist at all") + + rpmbuild_options = self.rpmbuild_options + self._scl_to_rpmbuild_option() + + cmd = ('LC_ALL=C rpmbuild --define "_source_filedigest_algorithm md5" --define' + ' "_binary_filedigest_algorithm md5" %s %s %s --nodeps -bs %s' % ( + rpmbuild_options, self._get_rpmbuild_dir_options(), + define_dist, self.spec_file)) + output = run_command(cmd) + print(output) + self.srpm_location = find_wrote_in_rpmbuild_output(output)[0] + self.artifacts.append(self.srpm_location) + def rpm(self): """ Build an RPM. """ self._create_build_dirs() @@ -378,40 +412,6 @@ class Builder(ConfigObject, BuilderBase): self.artifacts.append(full_path) return full_path - # TODO: reuse_cvs_checkout isn't needed here, should be cleaned up: - def srpm(self, dist=None, reuse_cvs_checkout=False): - """ - Build a source RPM. - """ - self._create_build_dirs() - if not self.ran_tgz: - self.tgz() - - if self.test: - self._setup_test_specfile() - - debug("Creating srpm from spec file: %s" % self.spec_file) - define_dist = "" - if self.dist: - debug("using self.dist: %s" % self.dist) - define_dist = "--define 'dist %s'" % self.dist - elif dist: - debug("using dist: %s" % dist) - define_dist = "--define 'dist %s'" % dist - else: - debug("*NOT* using dist at all") - - rpmbuild_options = self.rpmbuild_options + self._scl_to_rpmbuild_option() - - cmd = ('LC_ALL=C rpmbuild --define "_source_filedigest_algorithm md5" --define' - ' "_binary_filedigest_algorithm md5" %s %s %s --nodeps -bs %s' % ( - rpmbuild_options, self._get_rpmbuild_dir_options(), - define_dist, self.spec_file)) - output = run_command(cmd) - print(output) - self.srpm_location = find_wrote_in_rpmbuild_output(output)[0] - self.artifacts.append(self.srpm_location) - def rpm(self): """ Build an RPM. """ self._create_build_dirs() diff --git a/src/tito/release.py b/src/tito/release.py index 0550ab3..14b479b 100644 --- a/src/tito/release.py +++ b/src/tito/release.py @@ -318,7 +318,7 @@ class RsyncReleaser(Releaser): self.builder.no_cleanup = self.no_cleanup self.builder.tgz() self.builder.srpm() - self.builder._rpm() + self.builder.rpm() self.builder.cleanup() if self.releaser_config.has_option(self.target, 'rsync_args'): diff --git a/test/functional/fetch_tests.py b/test/functional/fetch_tests.py index 40aefae..859ecbf 100644 --- a/test/functional/fetch_tests.py +++ b/test/functional/fetch_tests.py @@ -16,6 +16,7 @@ Functional Tests for the FetchBuilder. """ import ConfigParser +import glob import os import shutil import tempfile @@ -65,10 +66,6 @@ class FetchBuilderTests(TitoGitTestFixture): TitoGitTestFixture.tearDown(self) shutil.rmtree(self.output_dir) - def _setup_fetchbuilder_releaser(self): - self.write_file(join(self.repo_dir, 'rel-eng/releasers.conf'), - RELEASER_CONF) - def test_simple_build_no_tag(self): # We have not tagged here. Build --rpm should just work: self.assertFalse(os.path.exists( @@ -76,20 +73,28 @@ class FetchBuilderTests(TitoGitTestFixture): tito('build --rpm --output=%s --no-cleanup --debug --arg=source=%s ' % (self.output_dir, self.source_filename)) - self.assertTrue(os.path.exists( - join(self.output_dir, 'extsrc-0.0.2-1.fc20.src.rpm'))) - self.assertTrue(os.path.exists( - join(self.output_dir, 'noarch/extsrc-0.0.2-1.fc20.noarch.rpm'))) + self.assertEquals(1, len(glob.glob(join(self.output_dir, + "extsrc-0.0.2-1.*.src.rpm")))) + self.assertEquals(1, len(glob.glob(join(self.output_dir, + "noarch/extsrc-0.0.2-1.*.noarch.rpm")))) def test_tag_rejected(self): self.assertRaises(SystemExit, tito, 'build --tag=extsrc-0.0.1-1 --rpm --output=%s --arg=source=%s ' % (self.output_dir, self.source_filename)) + def _setup_fetchbuilder_releaser(self, yum_repo_dir): + self.write_file(join(self.repo_dir, 'rel-eng/releasers.conf'), + RELEASER_CONF % yum_repo_dir) + def test_with_releaser(self): - self._setup_fetchbuilder_releaser() + yum_repo_dir = os.path.join(self.output_dir, 'yum') + self._setup_fetchbuilder_releaser(yum_repo_dir) tito('release --debug yum-test --arg source=%s' % self.source_filename) - + self.assertEquals(1, len(glob.glob(join(yum_repo_dir, + "extsrc-0.0.2-1.*.noarch.rpm")))) + self.assertEquals(1, len(glob.glob(join(yum_repo_dir, + "repodata/repomd.xml"))))