summaryrefslogtreecommitdiffstats
path: root/src/pyfedpkg/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/pyfedpkg/__init__.py')
-rw-r--r--src/pyfedpkg/__init__.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py
index 401f738..6b9682e 100644
--- a/src/pyfedpkg/__init__.py
+++ b/src/pyfedpkg/__init__.py
@@ -136,7 +136,7 @@ def _run_command(cmd, shell=False, env=None, pipe=[], cwd=None):
"""
- # Process any environment vairables.
+ # Process any environment variables.
environ = os.environ
if env:
for item in env.keys():
@@ -1075,12 +1075,12 @@ class PackageModule:
return subprocess.Popen(['rpm --eval %{_arch}'], shell=True,
stdout=subprocess.PIPE).communicate()[0].strip('\n')
- def __init__(self, path=None, dist=None):
+ def __init__(self, path, dist=None):
# Initiate a PackageModule object in a given path
# Set some global variables used throughout
- if not path:
- path = os.getcwd()
log.debug('Creating module object from %s' % path)
+ if not os.path.isdir(path):
+ raise FedpkgError('Module directory not found: %s' % path)
self.path = path
self.lookaside = LOOKASIDE
self.lookasidehash = LOOKASIDEHASH
@@ -1528,7 +1528,7 @@ class PackageModule:
_run_command(cmd, shell=True)
return
- def local(self, arch=None, hashtype='sha256'):
+ def local(self, arch=None, hashtype=None):
"""rpmbuild locally for given arch.
Takes arch to build for, and hashtype to build with.
@@ -1539,6 +1539,10 @@ class PackageModule:
"""
+ # Figure out which hashtype to use, if not provided one
+ if not hashtype:
+ hashtype = self.hashtype
+
# This could really use a list of arches to build for and loop over
# Get the sources
sources(self.path)
@@ -1725,7 +1729,7 @@ class PackageModule:
_run_command(cmd, shell=True)
return
- def srpm(self, hashtype=None):
+ def srpm(self, hashtype=None, fix_permissions=False):
"""Create an srpm using hashtype from content in the module
Requires sources already downloaded.
@@ -1743,11 +1747,18 @@ class PackageModule:
# srpm is newer, don't redo it
return
- cmd = ['rpmbuild']
+ if fix_permissions:
+ _run_command(cmd=['git', 'ls-files', '-z'],
+ pipe= ['xargs', '-0', 'chmod', 'a+r'],
+ shell=False)
+
+ cmd = ['fakeroot', 'rpmbuild']
cmd.extend(self.rpmdefines)
+
# Figure out which hashtype to use, if not provided one
if not hashtype:
hashtype = self.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,