summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorkylev@kylev-dt.sfo.ironport.com <kylev@kylev-dt.sfo.ironport.com>2008-06-10 16:05:39 -0700
committerkylev@kylev-dt.sfo.ironport.com <kylev@kylev-dt.sfo.ironport.com>2008-06-10 16:05:39 -0700
commitc8fc7e922add5d33b32b17069dd11818b7aa579d (patch)
tree7abf44db3bed5ab4f669bed0f28ae82bc7c37b69 /src
parent6b58cccbc0a8a48541d38e525f0fd597a23b8d3f (diff)
downloadfedpkg-c8fc7e922add5d33b32b17069dd11818b7aa579d.tar.gz
fedpkg-c8fc7e922add5d33b32b17069dd11818b7aa579d.tar.xz
fedpkg-c8fc7e922add5d33b32b17069dd11818b7aa579d.zip
Add in anonymous capability for aspiring but unsponsored contributors,
big clean-up.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/fedora-cvs.py99
1 files changed, 59 insertions, 40 deletions
diff --git a/src/fedora-cvs.py b/src/fedora-cvs.py
index 7a40ced..06214de 100755
--- a/src/fedora-cvs.py
+++ b/src/fedora-cvs.py
@@ -1,57 +1,76 @@
#!/usr/bin/python
+import commands
+import optparse
import os
-import string
import sys
-import commands
+
from OpenSSL import crypto
-def readUser():
- ''' sample line "Subject: C=US, ST=North Carolina, O=Fedora Project, OU=Dennis Gilmore, CN=ausil/emailAddress=dennis@ausil.us" '''
- userCert = ""
- if os.access(os.path.join(os.path.expanduser('~'),".fedora.cert"), os.R_OK):
- userCert = open(os.path.join(os.path.expanduser('~'),".fedora.cert"), "r").read()
- else:
+PKG_ROOT = 'cvs.fedoraproject.org:/cvs/pkgs'
+
+
+def read_cert_user():
+ """Figure out the Fedora user name from ~/.fedora.cert. Sample line:
+
+ Subject: C=US, ST=North Carolina, O=Fedora Project, OU=Dennis Gilmore, CN=ausil/emailAddress=dennis@ausil.us
+ """
+
+ # Mak sure we can even read the thing.
+ cert_file = os.path.join(os.path.expanduser('~'), ".fedora.cert")
+ if not os.access(cert_file, os.R_OK):
print "!!! cannot read your ~/.fedora.cert file !!!"
print "!!! Ensure the file is readable and try again !!!"
sys.exit(1)
- myCert = crypto.load_certificate(1, userCert)
- if myCert.has_expired():
- print "Certificate expired please get a new one"
+
+ user_cert = open(cert_file, "r").read()
+ my_cert = crypto.load_certificate(crypto.FILETYPE_PEM, user_cert)
+
+ if my_cert.has_expired():
+ print "Certificate expired; please get a new one."
sys.exit(1)
- subject = str(myCert.get_subject())
- subjectLine = subject.split("CN=")
- name = subjectLine[1].split("/")
- return name[0]
-
-
-def cvsco(user, module):
- '''CVSROOT=:ext:ausil@cvs.fedoraproject.org:/cvs/extras/'''
- print "Checking out %s from fedora cvs:" % module
- (s, o) = commands.getstatusoutput("CVSROOT=:ext:%s@cvs.fedoraproject.org:/cvs/pkgs/ CVS_RSH=ssh cvs co %s" % (user, module))
- if s != 0:
- print "Error: %s" % o
+
+ subject = str(my_cert.get_subject())
+ subject_line = subject.split("CN=")
+ cn_parts = subject_line[1].split("/")
+
+ return cn_parts[0]
+
+
+def main(user, pkg_list):
+ if user is not None:
+ cvs_env = "CVSROOT=:ext:%s@%s CVS_RSH=ssh" % (user, PKG_ROOT)
else:
- print o
+ cvs_env = "CVSROOT=:pserver:anonymous@" + PKG_ROOT
-def usage():
- print """
- add the modules you wish to check out from cvs
- example fedora-cvs konversation mysql cvs mercurial
- """
+ for module in pkg_list:
+ print "Checking out %s from fedora CVS as %s:" % \
+ (module, user or "anonymous")
+
+ retcode, output = commands.getstatusoutput("%s cvs co %s" %
+ (cvs_env, module))
+
+ if retcode != 0:
+ print "Error: %s" % (output,)
+ else:
+ print output
-def main(pkg):
- userName = readUser()
- for Item in pkg:
- cvsco(userName, Item)
if __name__ == '__main__':
- if len(sys.argv) < 2:
- usage()
- sys.exit(1)
- #the package we want to pull from cvs
- pkg = sys.argv
- pkg.remove(sys.argv[0])
+ opt_p = optparse.OptionParser(usage="%prog [OPTIONS] module ...")
+
+ opt_p.add_option('-a', '--anonymous', action='store_true', dest='anon',
+ help="Use anonymous CVS.")
+
+ opts, pkgs = opt_p.parse_args()
- main(pkg)
+ if len(pkgs) < 1:
+ opt_p.error("You must specify at least one module to check out.")
+
+ # Determine user name, if any
+ if opts.anon:
+ user = None
+ else:
+ user = read_cert_user()
+ main(user, pkgs)