def test_rpmbuild_which_ended_with_error_is_described_with_the_analyzed_line(self, mock_error): output = "some error output from rpmbuild\n" \ "next error line" find_wrote_in_rpmbuild_output(output) mock_error.assert_called_once_with("Unable to locate 'Wrote: ' lines in rpmbuild output: '%s'" % output)
def test_rpmbuild_claims_to_be_successful(self): succeeded_result = "success" output = "Wrote: %s" % succeeded_result success_line = find_wrote_in_rpmbuild_output(output) self.assertEquals(succeeded_result, success_line[0])
def srpm(self, dist=None): """ 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 = ('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_print(cmd) 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() if not self.ran_tgz: self.tgz() define_dist = "" if self.dist: define_dist = "--define 'dist %s'" % self.dist rpmbuild_options = self.rpmbuild_options + self._scl_to_rpmbuild_option() cmd = ('rpmbuild --define "_source_filedigest_algorithm md5" ' '--define "_binary_filedigest_algorithm md5" %s %s %s --clean ' '-ba %s' % (rpmbuild_options, self._get_rpmbuild_dir_options(), define_dist, self.spec_file)) debug(cmd) try: output = run_command_print(cmd) except (KeyboardInterrupt, SystemExit): print("") exit(1) except RunCommandException: err = sys.exc_info()[1] msg = str(err) if re.search('Failed build dependencies', err.output): cmd = "dnf builddep %s" if package_manager() == "dnf" else "yum-builddep %s" msg = "Please run '%s' as root." % \ cmd % find_spec_file(self.relative_project_dir) error_out('%s' % msg) except Exception: err = sys.exc_info()[1] error_out('%s' % str(err)) files_written = find_wrote_in_rpmbuild_output(output) if len(files_written) < 2: error_out("Error parsing rpmbuild output") self.srpm_location = files_written[0] self.artifacts.extend(files_written) print info_out("Successfully built: %s" % ' '.join(files_written))
def rpm(self): """ Build an RPM. """ self._create_build_dirs() if not self.ran_tgz: self.tgz() define_dist = "" if self.dist: define_dist = "--define 'dist %s'" % self.dist rpmbuild_options = self.rpmbuild_options + self._scl_to_rpmbuild_option( ) cmd = ('rpmbuild --define "_source_filedigest_algorithm md5" ' '--define "_binary_filedigest_algorithm md5" %s %s %s --clean ' '-ba %s' % (rpmbuild_options, self._get_rpmbuild_dir_options(), define_dist, self.spec_file)) debug(cmd) try: output = getoutput(cmd) except (KeyboardInterrupt, SystemExit): print("") exit(1) except RunCommandException: err = sys.exc_info()[1] msg = str(err) if (re.search('Failed build dependencies', err.output)): msg = "Please run 'yum-builddep %s' as root." % \ find_spec_file(self.relative_project_dir) error_out('%s' % msg) except Exception: err = sys.exc_info()[1] error_out('%s' % str(err)) files_written = find_wrote_in_rpmbuild_output(output) if len(files_written) < 2: error_out("Error parsing rpmbuild output") self.srpm_location = files_written[0] self.artifacts.extend(files_written) print print("Successfully built: %s" % ' '.join(files_written))