diff options
author | Bogdano Arendartchuk <bogdano@mandriva.org> | 2006-02-13 18:09:13 +0000 |
---|---|---|
committer | Bogdano Arendartchuk <bogdano@mandriva.org> | 2006-02-13 18:09:13 +0000 |
commit | a82183a6b78b934dc1be25a2722bfc271385b4f7 (patch) | |
tree | 3fad9f27de8a1fbef2a4bfcd3be8579a7493938e | |
parent | 476d25ef622e0797b3413031030be8de6076b0e3 (diff) | |
download | mgarepo-a82183a6b78b934dc1be25a2722bfc271385b4f7.tar mgarepo-a82183a6b78b934dc1be25a2722bfc271385b4f7.tar.gz mgarepo-a82183a6b78b934dc1be25a2722bfc271385b4f7.tar.bz2 mgarepo-a82183a6b78b934dc1be25a2722bfc271385b4f7.tar.xz mgarepo-a82183a6b78b934dc1be25a2722bfc271385b4f7.zip |
- the package url is now mapped using mapurl
- parse options using OptionParser
- added options -r and -t to improve readability
-rwxr-xr-x | create-srpm | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/create-srpm b/create-srpm index cdf8e26..000afd2 100755 --- a/create-srpm +++ b/create-srpm @@ -3,9 +3,11 @@ from RepSys import Error, config from RepSys.rpmutil import get_srpm from RepSys.cgiutil import get_targets +from RepSys.util import mapurl import sys import os import pwd +import optparse class CmdError(Error): pass @@ -13,7 +15,8 @@ class CmdIface: def author_email(self, author): return config.get("users", author) - def submit_package(self, packageurl, packagerev, targetname): + def submit_package(self, packageurl, packagerev, targetname, + dontmapurl_=0): pw = pwd.getpwuid(os.getuid()) username = pw[0] packager = config.get("users", username) or pw[4] @@ -40,7 +43,10 @@ class CmdIface: else: raise CmdError, "%s is not allowed for this target" \ % packageurl - get_srpm(packageurl, + newurl = packageurl + if not dontmapurl_: + newurl = mapurl(packageurl) + get_srpm(newurl, revision=packagerev, targetdirs=target.target, packager=packager, @@ -53,19 +59,29 @@ class CmdIface: return [x.name for x in get_targets()] -def main(): +def parse_options(): + usage = "create-srpm <packageurl> -t <target> [-r <revision>]" + parser = optparse.OptionParser(usage=usage) + parser.add_option("-r", "--revision", dest="revision", type="string", + help="the revision number") + parser.add_option("-t", "--target", type="string", dest="target", + help="target name") + parser.add_option("-M", "--nomapping", action="store_true", + dest="urlmap", default=False, + help="disable url mapping") + opts, args = parser.parse_args() + if not args: + parser.error("you must supply a package url") + return opts, args + +def main(): iface = CmdIface() + opts, args = parse_options() + iface.submit_package(args[0], opts.revision, opts.target, opts.urlmap) + - print sys.argv +if __name__ == "__main__": + main() - if len(sys.argv) == 3: - rev = None - target = sys.argv[2] - else: - rev = sys.argv[2] - target = sys.argv[3] - - iface.submit_package(sys.argv[1], rev, target) - -main() +# vim:ts=4:sw=4:et |