From ca61eb86f9170a63622baaee4faa7dae9fa5e3d5 Mon Sep 17 00:00:00 2001 From: Brian Stinson Date: Jun 14 2014 04:17:24 +0000 Subject: override some loaders to work with the CentOS file structure and release numbering --- diff --git a/src/centpkg/__init__.py b/src/centpkg/__init__.py index f60209a..17e8edb 100644 --- a/src/centpkg/__init__.py +++ b/src/centpkg/__init__.py @@ -1,4 +1,6 @@ import pyrpkg +import os +import re from . import cli @@ -15,6 +17,48 @@ class Commands(pyrpkg.Commands): quiet) + # redefined loaders + def load_rpmdefines(self): + try: + osver = re.search(r'\d.*$', self.branch_merge).group() + except AttributeError: + raise pyrpkg.rpkgError('Could not find the base OS ver from branch name' + ' %s' % self.branch_merge) + self._distval = osver + self._distval = self._distval.replace('.', '_') + self._disttag = 'el%s' % self._distval + self._rpmdefines = ["--define '_sourcedir %s'" % os.path.join(self.path,'SOURCES'), + "--define '_specdir %s'" % os.path.join(self.path,'SPECS'), + "--define '_builddir %s'" % os.path.join(self.path,'BUILD'), + "--define '_srcrpmdir %s'" % os.path.join(self.path,'SRPMS'), + "--define '_rpmdir %s'" % os.path.join(self.path, 'RPMS'), + "--define 'dist .%s'" % self._disttag, + # int and float this to remove the decimal + "--define '%s 1'" % self._disttag] + + def load_spec(self): + """This sets the spec attribute""" + + # We are not using the upstream load_spec because the file structure is + # hard-coded + + deadpackage = False + + # Get a list of files in the path we're looking at + files = os.listdir(os.path.join(self.path,'SPECS')) + # Search the files for the first one that ends with ".spec" + for f in files: + if f.endswith('.spec') and not f.startswith('.'): + self._spec = os.path.join('SPECS',f) + return + if f == 'dead.package': + deadpackage = True + if deadpackage: + raise pyrpkg.rpkgError('No spec file found. This package is retired') + else: + raise pyrpkg.rpkgError('No spec file found.') + + # These are the commands defined in the base pyrpkg.Commands class def load_kojisession(self, *args, **kwargs): raise NotImplementedError("This command is not yet implemented in centpkg")