From cd80781178ed32b406eb6f460e9f713ef4a39cc4 Mon Sep 17 00:00:00 2001 From: Brian Stinson Date: Jul 05 2014 09:59:13 +0000 Subject: Customize the srpm method, this lets us accommodate the CentOS directory structure The vanilla rpkg instance dumps all the sources in the toplevel of the package checkout (everything is flat). CentOS uses the SOURCES,SPECS,SRPMS directory structure. --- diff --git a/src/centpkg/__init__.py b/src/centpkg/__init__.py index 72d5e9d..adfd309 100644 --- a/src/centpkg/__init__.py +++ b/src/centpkg/__init__.py @@ -145,6 +145,37 @@ class Commands(pyrpkg.Commands): return + def srpm(self, hashtype=None): + """Create an srpm using hashtype from content in the module + + Requires sources already downloaded. + """ + + # This line is what changed for centpkg, in Fedora the directory + # structure is flat, in CentOS we use the proper SRPMS/ directory for + # our source RPMs + self.srpmname = os.path.join(self.path, 'SRPMS', + "{0}-{1}-{2}.src.rpm".format(self.module_name, + self.ver, self.rel)) + # See if we need to build the srpm + if os.path.exists(self.srpmname): + self.log.debug('Srpm found, rewriting it.') + + cmd = ['rpmbuild'] + cmd.extend(self.rpmdefines) + if self.quiet: + cmd.append('--quiet') + # Figure out which hashtype to use, if not provided one + if not hashtype: + # Try to determine the dist + hashtype = self._guess_hashtype() + # This may need to get updated if we ever change our checksum default + if not hashtype == 'sha256': + cmd.extend(["--define '_source_filedigest_algorithm %s'" % hashtype, + "--define '_binary_filedigest_algorithm %s'" % hashtype]) + cmd.extend(['--nodeps', '-bs', os.path.join(self.path, self.spec)]) + self._run_command(cmd, shell=True) + # These are the commands defined in the base pyrpkg.Commands class # and have not been implemented here, yet @@ -202,9 +233,6 @@ class Commands(pyrpkg.Commands): def prep(self, *args, **kwargs): raise NotImplementedError("This command is not yet implemented in centpkg") - def srpm(self, *args, **kwargs): - raise NotImplementedError("This command is not yet implemented in centpkg") - def unused_patches(self, *args, **kwargs): raise NotImplementedError("This command is not yet implemented in centpkg")