[Openfirst-cvscommit] www/htdocs/nightly package.py,NONE,1.1
Brought to you by:
xtimg
From: Jamie <ast...@us...> - 2005-11-19 17:26:45
|
Update of /cvsroot/openfirst/www/htdocs/nightly In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12476/www/htdocs/nightly Added Files: package.py Log Message: A file to package openFIRST modules. Should work on Unix systems --- NEW FILE: package.py --- #!python """A script to package an openFIRST module""" from sys import argv, stdout, exit from os import * ## Use one of the following lines for the CVSROOT. ## The former is for external, the other for internal. CVSROOT = ":pserver:ano...@cv...:/cvsroot/openfirst" #CVSROOT = ":pserver:anonymous@cvs1:/cvsroot/openfirst" if len(argv) < 3 or "--help" in argv: stdout.write("""Packages openFIRST modules. Syntax: %s <package> <module> [<module> ...] Note that if you specify more than one module, then only the zip file will be correct.""" % argv[0]) exit(1) def getCVSModuleName(id): if id[:10] == "openfirst.": ## we can handle this module, it's one of ours return id[10:] else: ## someone else's module! Who knows!! return False def checkOutCVS(module, target=None): command = "cvs -d%s export -rHEAD -R " % CVSROOT if target is not None: command += "-d %s " % (target) command += "%s" % (module) print "Exporting CVS module %s..." % module retval = system(command) return retval == 0 # cvs = popen(command, 'r') # print cvs # print cvs.readlines() def system2(command): print "> "+command return system(command) def packageDirectory(directory, target): print "Creating gzip..." if path.exists(target+".tar.gz"): action = 'r' else: action = 'c' system2("tar -%szf %r %r" % (action, target+".tar.gz", directory)) print "Creating bzip..." if path.exists(target+".tar.bz"): action = 'r' else: action = 'c' system("tar -%sjf %r %r" % (action, target+".tar.bz", directory)) print "Creating zip..." system("zip -r %r %r" % (target+".zip", directory)) def packageBaseDirectory(directory, target): rtar = path.join(pardir, target) rtar2 = rtar ## Hack: Change \ to / #rtar2 = rtar.replace('\\', '/') chdir(directory) print "Creating gzip %s.tar.gz" % target if path.exists(target+".tar.gz"): action = 'r' else: action = 'c' system2("tar -%szf %s *" % (action, rtar2+".tar.gz")) print "Creating bzip %s.tar.bz" % target if path.exists(target+".tar.bz"): action = 'r' else: action = 'c' system("tar -%sjf %s *" % (action, rtar2+".tar.bz")) print "Creating zip %s.zip" % target system("zip -r %s %s" % (rtar+".zip", '*')) chdir(pardir) def cleanPackage(target): if path.exists(target+".tar.gz"): remove(target+".tar.gz") if path.exists(target+".tar.bz"): remove(target+".tar.bz") if path.exists(target+".zip"): remove(target+".zip") def cleanCVSExport(directory): if not path.exists(directory): return for f in listdir(directory): pf = path.join(directory, f) if path.isdir(pf): cleanCVSExport(pf) else: remove(pf) try: rmdir(directory) except: pass package = "pkg/openfirst-" + argv[1] cleanPackage(package) modules = argv[2:] for mod in modules: directory = mod cleanCVSExport(directory) checkOutCVS(mod) if mod == "base": packageBaseDirectory(directory, package) else: packageDirectory(directory, package) ## Don't allow web access to CVS cleanCVSExport(directory) |