| |
@@ -20,6 +20,7 @@
|
| |
import re
|
| |
import shutil
|
| |
import subprocess
|
| |
+ import tempfile
|
| |
|
| |
from .check import CheckTrigger, CheckSourceFile, CheckPayloadFile
|
| |
from .samples import hello_world, simple_library_source, sample_man_page, \
|
| |
@@ -49,13 +50,15 @@
|
| |
"""
|
| |
Wrapper for an invocation of rpmbuild
|
| |
"""
|
| |
- def __init__(self, buildArchs=None):
|
| |
+ def __init__(self, buildArchs=None, tmpdir=True):
|
| |
"""
|
| |
buildArchs:
|
| |
if None, the build will happen on the current arch
|
| |
if non-None, should be a list of strings: the archs to build on
|
| |
"""
|
| |
self.buildArchs = buildArchs
|
| |
+ self.tmpdir = tmpdir
|
| |
+ self.tmpdir_location = None
|
| |
|
| |
def is_up_to_date(self):
|
| |
# FIXME: crude check for now: does the build dir exist?
|
| |
@@ -69,6 +72,8 @@
|
| |
|
| |
def clean(self):
|
| |
shutil.rmtree(self.get_base_dir(), ignore_errors=True)
|
| |
+ if self.tmpdir and self.tmpdir_location:
|
| |
+ shutil.rmtree(self.tmpdir_location, ignore_errors=True)
|
| |
|
| |
def sanitize_string(self, name):
|
| |
"""Strip what can be dangerous for filenames"""
|
| |
@@ -76,6 +81,8 @@
|
| |
|
| |
def __create_directories(self):
|
| |
"""Sets up the directory hierarchy for the build"""
|
| |
+ if self.tmpdir and not (self.tmpdir_location and os.path.isdir(self.tmpdir_location)):
|
| |
+ self.tmpdir_location = tempfile.mkdtemp(prefix="rpmfluff-")
|
| |
os.mkdir(self.get_base_dir())
|
| |
|
| |
# Make fake rpmbuild directories
|
| |
@@ -168,8 +175,8 @@
|
| |
class SimpleRpmBuild(RpmBuild):
|
| |
"""A wrapper for rpmbuild that also provides a canned way of generating a
|
| |
specfile and the source files."""
|
| |
- def __init__(self, name, version, release, buildArchs=None):
|
| |
- RpmBuild.__init__(self, buildArchs)
|
| |
+ def __init__(self, name, version, release, buildArchs=None, tmpdir=True):
|
| |
+ RpmBuild.__init__(self, buildArchs=buildArchs, tmpdir=tmpdir)
|
| |
|
| |
self.specfileEncoding = 'utf-8'
|
| |
|
| |
@@ -211,7 +218,11 @@
|
| |
self.specbasename = None
|
| |
|
| |
def get_base_dir(self):
|
| |
- return "test-rpmbuild-%s-%s-%s" % (self.name, self.version, expand_macros(self.release))
|
| |
+ if self.tmpdir_location:
|
| |
+ return "%s/test-rpmbuild-%s-%s-%s" % (self.tmpdir_location, self.name, self.version,
|
| |
+ expand_macros(self.release))
|
| |
+ else:
|
| |
+ return "test-rpmbuild-%s-%s-%s" % (self.name, self.version, expand_macros(self.release))
|
| |
|
| |
def get_subpackage_names(self):
|
| |
"""
|
| |
But you can change the behaviour by tmpdir param.
Resolves https://pagure.io/rpmfluff/issue/30