| |
@@ -29,20 +29,58 @@
|
| |
self.specdir = root_dir
|
| |
self.builddir = root_dir
|
| |
self.rpmdir = root_dir
|
| |
+ self.rpmfilename = '%%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'
|
| |
self.srcrpmdir = root_dir
|
| |
self.sources_file_template = sources_file_template
|
| |
|
| |
@classmethod
|
| |
- def from_path(cls, path):
|
| |
+ def from_path(cls, path, hint=None):
|
| |
"""
|
| |
Creates a new object instance from a valid path in the file system.
|
| |
|
| |
Raises exception if path or package structure is invalid.
|
| |
"""
|
| |
- super(DistGitLayout, cls).from_path(path)
|
| |
+ super(DistGitLayout, cls).from_path(path, hint)
|
| |
|
| |
if len([f for f in os.listdir(path) if f.endswith('.spec')]) == 0:
|
| |
raise LayoutError('spec file not found.')
|
| |
+ if (hint == 'resultsdir'):
|
| |
+ raise LayoutError('resultsdir hint given')
|
| |
+ return cls(root_dir=path)
|
| |
+
|
| |
+
|
| |
+ class DistGitResultsDirLayout(BaseLayout):
|
| |
+ """
|
| |
+ This class represents a dist-git package layout using results directory.
|
| |
+ """
|
| |
+ def __init__(self, root_dir=None, sources_file_template='sources'):
|
| |
+ """
|
| |
+ Default class constructor to create a new object instance.
|
| |
+ """
|
| |
+ results_dir = os.path.join(root_dir, 'results')
|
| |
+
|
| |
+ self.root_dir = root_dir
|
| |
+ self.sourcedir = root_dir
|
| |
+ self.specdir = root_dir
|
| |
+ self.builddir = results_dir
|
| |
+ self.rpmdir = results_dir
|
| |
+ self.rpmfilename = '%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'
|
| |
+ self.srcrpmdir = results_dir
|
| |
+ self.sources_file_template = sources_file_template
|
| |
+
|
| |
+ @classmethod
|
| |
+ def from_path(cls, path, hint=None):
|
| |
+ """
|
| |
+ Creates a new object instance from a valid path in the file system.
|
| |
+
|
| |
+ Raises exception if path or package structure is invalid.
|
| |
+ """
|
| |
+ super(DistGitResultsDirLayout, cls).from_path(path, hint)
|
| |
+
|
| |
+ if len([f for f in os.listdir(path) if f.endswith('.spec')]) == 0:
|
| |
+ raise LayoutError('spec file not found.')
|
| |
+ if (hint != 'resultsdir'):
|
| |
+ raise LayoutError('resultsdir hint not given')
|
| |
return cls(root_dir=path)
|
| |
|
| |
|
| |
@@ -59,17 +97,18 @@
|
| |
self.specdir = os.path.join(root_dir, 'SPECS')
|
| |
self.builddir = os.path.join(root_dir, 'BUILD')
|
| |
self.rpmdir = os.path.join(root_dir, 'RPMS')
|
| |
+ self.rpmfilename = '%%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'
|
| |
self.srcrpmdir = os.path.join(root_dir, 'SRPMS')
|
| |
self.sources_file_template = sources_file_template
|
| |
|
| |
@classmethod
|
| |
- def from_path(cls, path):
|
| |
+ def from_path(cls, path, hint=None):
|
| |
"""
|
| |
Creates a new object instance from a valid path in the file system.
|
| |
|
| |
Raises exception if path or package structure is invalid.
|
| |
"""
|
| |
- super(SRPMLayout, cls).from_path(path)
|
| |
+ super(SRPMLayout, cls).from_path(path, hint)
|
| |
|
| |
if not os.path.exists(os.path.join(path, 'SPECS')):
|
| |
raise LayoutError('SPECS dir not found.')
|
| |
@@ -94,13 +133,13 @@
|
| |
self.sources_file_template = sources_file_template
|
| |
|
| |
@classmethod
|
| |
- def from_path(cls, path):
|
| |
+ def from_path(cls, path, hint=None):
|
| |
"""
|
| |
Creates a new object instance from a valid path in the file system.
|
| |
|
| |
Raises exception if package is already retired.
|
| |
"""
|
| |
- super(IncompleteLayout, cls).from_path(path)
|
| |
+ super(IncompleteLayout, cls).from_path(path, hint)
|
| |
|
| |
if cls(root_dir=path).is_retired():
|
| |
raise LayoutError('Retired marker found.')
|
| |
@@ -119,13 +158,13 @@
|
| |
self.root_dir = root_dir
|
| |
|
| |
@classmethod
|
| |
- def from_path(cls, path):
|
| |
+ def from_path(cls, path, hint=None):
|
| |
"""
|
| |
Creates a new object instance from a valid path in the file system.
|
| |
|
| |
Raises exception if no marker is found.
|
| |
"""
|
| |
- super(RetiredLayout, cls).from_path(path)
|
| |
+ super(RetiredLayout, cls).from_path(path, hint)
|
| |
|
| |
if not cls(root_dir=path).is_retired():
|
| |
raise LayoutError('Retired marker not found.')
|
| |
Currently, when using the dist-git layout, build results are written directly to layout root, since all of builddir, srpmdir and rpmdir are set to root. This pattern is unnecessarily difficult to cover in gitignore rules and has led to situation in Fedora where, for many packages, running
fedpkg local
pollutesgit status
.Instead of writing to repository root, it is much cleaner to write to a single subdirectory which is easy to add to ignore rules. To enable this without interfering with current usage, new config option
results_dir
is added. Default value preserving current behavior isroot
, whereas settingsubdir
leads to selecting an alternative dist-git layout that uses subdirectoryresults
instead.This topic has been discussed in Fedora mailing list thread. There, it was proposed that the subdirectory would be the same that the
mockbuild
command uses. Unfortunately, resolving mockbuild results dir name requires parsing the spec file, whereas layout selection happens before. Because of this difficulty, a simpler method of fixed name "results" is used here.Earlier, layout selection was based solely on directory contents. Since build results directory is only created after something is built, that method is not adequate. Thus, additional
hint
input is added to layoutfrom_path
method, allowing selecting the subdir variant from standard dist-git structure.To keep the build result directory as simple as possible, and as similar to mockbuild results, architecture specific subdirectories are not created. This requires adding new member to layouts: rpmfilename. It is passed directly to rpmdefines.
Signed-off-by: Otto Urpelainen oturpe@iki.fi