summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Ulrich Niedermann <hun@n-dimensional.de>2011-01-21 13:59:34 +0100
committerHans Ulrich Niedermann <hun@n-dimensional.de>2011-01-21 13:59:34 +0100
commitb231f35b52825383c8b8d8f33b8fe651d78489b8 (patch)
treec107ba444ed9ee2e8178b911ec0385d225496435
parent90ed29401b2c6d649cd55f610dd79696fd4300ee (diff)
downloadfedora-packager-b231f35b52825383c8b8d8f33b8fe651d78489b8.tar.gz
fedora-packager-b231f35b52825383c8b8d8f33b8fe651d78489b8.tar.xz
fedora-packager-b231f35b52825383c8b8d8f33b8fe651d78489b8.zip
Unify --md5 parameter handling
Unify handling of the --md5 parameter between the two targets using it: 'fedpkg local' and 'fedpkg srpm'. If no --md5 parameter is given, then the default hashtype is used, as determined in PackageModule.__init__() ('md5' for el5 and el6, and 'sha256' for everything else). If an --md5 parameter is given, then use the 'md5' hashtype.
-rwxr-xr-xsrc/fedpkg.py16
-rw-r--r--src/pyfedpkg/__init__.py11
2 files changed, 14 insertions, 13 deletions
diff --git a/src/fedpkg.py b/src/fedpkg.py
index ebb4c28..5551722 100755
--- a/src/fedpkg.py
+++ b/src/fedpkg.py
@@ -569,10 +569,7 @@ def local(args):
arch = args.arch
try:
mymodule = pyfedpkg.PackageModule(args.path)
- 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)
@@ -668,10 +665,7 @@ def srpm(args):
try:
mymodule = pyfedpkg.PackageModule(args.path)
pyfedpkg.sources(args.path)
- if args.md5:
- mymodule.srpm('md5')
- else:
- mymodule.srpm()
+ mymodule.srpm(hashtype=args.hashtype)
except pyfedpkg.FedpkgError, e:
log.error('Could not make an srpm: %s' % e)
sys.exit(1)
@@ -1079,7 +1073,8 @@ packages will be built sequentially.
"""))
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)
@@ -1157,7 +1152,8 @@ 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.set_defaults(command = srpm)
diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py
index 9c76fc0..4a36ffc 100644
--- a/src/pyfedpkg/__init__.py
+++ b/src/pyfedpkg/__init__.py
@@ -1473,7 +1473,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.
@@ -1484,6 +1484,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)
@@ -1684,11 +1688,12 @@ class PackageModule:
"""
- cmd = ['rpmbuild']
- cmd.extend(self.rpmdefines)
# Figure out which hashtype to use, if not provided one
if not hashtype:
hashtype = self.hashtype
+
+ cmd = ['rpmbuild']
+ cmd.extend(self.rpmdefines)
# 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,