summaryrefslogtreecommitdiffstats
path: root/src/fedpkg.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/fedpkg.py')
-rwxr-xr-xsrc/fedpkg.py49
1 files changed, 34 insertions, 15 deletions
diff --git a/src/fedpkg.py b/src/fedpkg.py
index 75770f5..fd16f49 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, 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)
@@ -674,10 +671,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)
@@ -848,8 +843,10 @@ def verrel(args):
sys.exit(1)
print('%s-%s-%s' % (mymodule.module, mymodule.ver, mymodule.rel))
-# THe main code goes here
-if __name__ == '__main__':
+
+def parse_cmdline(generate_manpage = False):
+ """Parse the command line"""
+
# Create the parser object
parser = argparse.ArgumentParser(description = 'Fedora Packaging utility',
prog = 'fedpkg',
@@ -861,7 +858,8 @@ if __name__ == '__main__':
parser.add_argument('--dist', default=None,
help='Override the distribution, eg f15 or el6')
# Let somebody override the username found in fedora cert
- parser.add_argument('-u', '--user')
+ parser.add_argument('-u', '--user',
+ help = "Override the username found in the fedora cert")
# Let the user define which path to look at instead of pwd
parser.add_argument('--path', default = os.getcwd(),
help='Directory to interact with instead of current dir')
@@ -1079,7 +1077,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)
@@ -1157,8 +1156,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
@@ -1238,8 +1241,24 @@ packages will be built sequentially.
' name-version-release')
parser_verrel.set_defaults(command = verrel)
- # Parse the args
- args = parser.parse_args()
+ if not generate_manpage:
+ # Parse the args
+ return parser.parse_args()
+ else:
+ # Generate the man page
+
+ # Use the "as man_page" part to avoid overwriting the pyfedpkg
+ # namespace, which would break all usage of pyfedpkg.* outside
+ # of this else branch.
+ import pyfedpkg.man_page as man_page
+ man_page.generate(parser, subparsers)
+ sys.exit(0)
+ # no return possible
+
+
+# The main code goes here
+if __name__ == '__main__':
+ args = parse_cmdline()
# setup the logger -- This logger will take things of INFO or DEBUG and
# log it to stdout. Anything above that (WARN, ERROR, CRITICAL) will go