summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/fedpkg.py20
-rw-r--r--src/pyfedpkg/__init__.py23
2 files changed, 27 insertions, 16 deletions
diff --git a/src/fedpkg.py b/src/fedpkg.py
index e3e98a5..cfb0bcc 100755
--- a/src/fedpkg.py
+++ b/src/fedpkg.py
@@ -567,10 +567,7 @@ def local(args):
arch = args.arch
try:
mymodule = pyfedpkg.PackageModule(args.path, args.dist)
- if args.md5:
- return mymodule.local(arch=arch, hashtype='md5')
- else:
- return mymodule.local(arch=arch)
+ return mymodule.local(arch=arch, hashtype=args.hashtype)
except pyfedpkg.FedpkgError, e:
log.error('Could not build locally: %s' % e)
sys.exit(1)
@@ -672,10 +669,8 @@ def srpm(args):
try:
mymodule = pyfedpkg.PackageModule(args.path, args.dist)
pyfedpkg.sources(args.path)
- if args.md5:
- mymodule.srpm('md5')
- else:
- mymodule.srpm()
+ mymodule.srpm(hashtype=args.hashtype,
+ fix_permissions=args.fix_permissions)
except pyfedpkg.FedpkgError, e:
log.error('Could not make an srpm: %s' % e)
sys.exit(1)
@@ -1071,7 +1066,8 @@ packages will be built sequentially.
help = 'Local test rpmbuild binary')
parser_local.add_argument('--arch', help = 'Build for arch')
# optionally define old style hashsums
- parser_local.add_argument('--md5', action = 'store_true',
+ parser_local.add_argument('--md5', action = 'store_const',
+ dest='hashtype', const='md5', default=None,
help = 'Use md5 checksums (for older rpm hosts)')
parser_local.set_defaults(command = local)
@@ -1149,8 +1145,12 @@ packages will be built sequentially.
parser_srpm = subparsers.add_parser('srpm',
help = 'Create a source rpm')
# optionally define old style hashsums
- parser_srpm.add_argument('--md5', action = 'store_true',
+ parser_srpm.add_argument('--md5', action = 'store_const',
+ dest='hashtype', const='md5', default=None,
help = 'Use md5 checksums (for older rpm hosts)')
+ parser_srpm.add_argument('--fix-permissions', action='store_true',
+ default=False,
+ help = 'Fix permissions of files to be put into .src.rpm file')
parser_srpm.set_defaults(command = srpm)
# switch branches
diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py
index f913774..edcbbd8 100644
--- a/src/pyfedpkg/__init__.py
+++ b/src/pyfedpkg/__init__.py
@@ -1070,12 +1070,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
@@ -1523,7 +1523,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.
@@ -1534,6 +1534,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)
@@ -1720,7 +1724,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.
@@ -1738,11 +1742,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,