| |
@@ -47,6 +47,7 @@
|
| |
from pyrpkg.lookaside import CGILookasideCache
|
| |
from pyrpkg.sources import SourcesFile
|
| |
from pyrpkg.utils import cached_property, log_result, find_me
|
| |
+ from pyrpkg.layout import Layout
|
| |
|
| |
PY26 = sys.version_info < (2, 7, 0)
|
| |
|
| |
@@ -241,6 +242,10 @@
|
| |
self._path = value
|
| |
|
| |
@property
|
| |
+ def layout(self):
|
| |
+ return Layout.load(self.path)
|
| |
+
|
| |
+ @property
|
| |
def kojisession(self):
|
| |
"""This property ensures the kojisession attribute"""
|
| |
|
| |
@@ -821,16 +826,17 @@
|
| |
self._distvar, self._distval = osver.split('-')
|
| |
self._distval = self._distval.replace('.', '_')
|
| |
self._disttag = 'el%s' % self._distval
|
| |
- self._rpmdefines = ["--define '_sourcedir %s'" % self.path,
|
| |
- "--define '_specdir %s'" % self.path,
|
| |
- "--define '_builddir %s'" % self.path,
|
| |
- "--define '_srcrpmdir %s'" % self.path,
|
| |
- "--define '_rpmdir %s'" % self.path,
|
| |
+ self._rpmdefines = ["--define '_sourcedir %s'" % self.layout.sourcedir,
|
| |
+ "--define '_specdir %s'" % self.layout.specdir,
|
| |
+ "--define '_builddir %s'" % self.layout.builddir,
|
| |
+ "--define '_srcrpmdir %s'" % self.layout.srcrpmdir,
|
| |
+ "--define '_rpmdir %s'" % self.layout.rpmdir,
|
| |
"--define 'dist .%s'" % self._disttag,
|
| |
"--define '%s %s'" % (self._distvar,
|
| |
self._distval.split('_')[0]),
|
| |
# int and float this to remove the decimal
|
| |
"--define '%s 1'" % self._disttag]
|
| |
+ self.log.debug("RPMDefines: %s" % self._rpmdefines)
|
| |
|
| |
@property
|
| |
def spec(self):
|
| |
@@ -843,19 +849,19 @@
|
| |
def load_spec(self):
|
| |
"""This sets the spec attribute"""
|
| |
|
| |
- deadpackage = False
|
| |
+ # For all layouts, check for dead.pkg in the root of the package dir
|
| |
+ files = os.listdir(self.path)
|
| |
+ for f in files:
|
| |
+ if f == 'dead.package':
|
| |
+ raise rpkgError('No spec file found. This package is retired')
|
| |
|
| |
# Get a list of files in the path we're looking at
|
| |
- files = os.listdir(self.path)
|
| |
+ files = os.listdir(self.layout.specdir)
|
| |
# 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 = f
|
| |
+ self._spec = os.path.join(self.layout.specdir, f)
|
| |
return
|
| |
- if f == 'dead.package':
|
| |
- deadpackage = True
|
| |
- if deadpackage:
|
| |
- raise rpkgError('No spec file found. This package is retired')
|
| |
else:
|
| |
raise rpkgError('No spec file found.')
|
| |
|
| |
@@ -1067,7 +1073,7 @@
|
| |
|
| |
@property
|
| |
def sources_filename(self):
|
| |
- return os.path.join(self.path, 'sources')
|
| |
+ return os.path.join(self.path, self.layout.sources_file_template.format(self))
|
| |
|
| |
@property
|
| |
def osbs_config_filename(self):
|
| |
@@ -2750,7 +2756,7 @@
|
| |
for f in files:
|
| |
# TODO: Skip empty file needed?
|
| |
file_hash = self.lookasidecache.hash_file(f)
|
| |
- file_basename = os.path.basename(f)
|
| |
+ file_basename = f.replace(self.path + '/', '')
|
| |
|
| |
try:
|
| |
sourcesf.add_entry(self.lookasidehash, file_basename,
|
| |
@@ -2777,7 +2783,7 @@
|
| |
sourcesf.write()
|
| |
gitignore.write()
|
| |
|
| |
- self.repo.index.add(['sources', '.gitignore'])
|
| |
+ self.repo.index.add([sourcesf.sourcesfile, '.gitignore'])
|
| |
|
| |
def prep(self, arch=None, builddir=None, buildrootdir=None):
|
| |
"""Run ``rpmbuild -bp``
|
| |
@@ -2818,7 +2824,7 @@
|
| |
digests.
|
| |
"""
|
| |
|
| |
- self.srpmname = os.path.join(self.path,
|
| |
+ self.srpmname = os.path.join(self.layout.srcrpmdir,
|
| |
"%s-%s-%s.src.rpm"
|
| |
% (self.repo_name, self.ver, self.rel))
|
| |
|
| |
Background
The Fedora and CentOS infrastructure teams are working on synchronizing branches between src.fedoraproject.org and git.centos.org this means that CentOS developers will see Fedora branches when they work on things, and Fedora developers will see the branches pushed from Red Hat into CentOS. Consider an example package a2ps
Fedora follows the dist-git layout:
CentOS uses the exploded SRPM layout:
Proposal
We should define a layout object that contains configuration for all of the information about where the files go in a package directory. This would eventually allow us to use the same tool to work across Fedora and CentOS branches, and to translate between the two formats. Sometimes packagers might want to take a package branched for Fedora, and bring it into a Special Interest Group in CentOS (for example).
New layouts can be registered, we differentiate the layouts by specifying a file to look for in the root of the package directory to signify which layout to use. For the 2 existing layouts we search for the lookaside metadata file:
@Layout.subclass('sources')
, for example, looks for the 'sources' file in a standard dist-git directory and registers the layout with the handler.I've tested this current PR with centpkg and fedpkg, and it seems to support functionality as it exists (that is to say, no harm was done).
What's needed to remove the
[WIP]
tag?