From 1451c4938aea157c2bf743483d524aebbf9c5a69 Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Sat, 5 Jun 2004 18:31:31 +0000 Subject: [PATCH] revert some changes --- dumpMetadata.py | 19 +++++++--------- genpkgmetadata.py | 58 +++++++++-------------------------------------- 2 files changed, 19 insertions(+), 58 deletions(-) diff --git a/dumpMetadata.py b/dumpMetadata.py index 80046ca..122a000 100644 --- a/dumpMetadata.py +++ b/dumpMetadata.py @@ -587,17 +587,16 @@ def otherXML(doc, node, rpmObj): def repoXML(node, cmds): """generate the repomd.xml file that stores the info on the other files""" sumtype = cmds['sumtype'] - workfiles = [(cmds['zotherfile'], 'other', cmds['otherfile']), - (cmds['zfilelistsfile'], 'filelists', cmds['filelistsfile']), - (cmds['zprimaryfile'], 'primary', cmds['primaryfile'])] - - if cmds['zgroupfile'] is not None: - workfiles.append((cmds['zgroupfile'], 'group', cmds['groupfile'])) + workfiles = [(cmds['otherfile'], 'other',), + (cmds['filelistsfile'], 'filelists'), + (cmds['primaryfile'], 'primary')] + + if cmds['groupfile'] is not None: + workfiles.append((cmds['groupfile'], 'group')) - for (file, ftype, un) in workfiles: + for (file, ftype) in workfiles: csum = getChecksum(sumtype, os.path.join(cmds['tempdir'], file)) timestamp = os.stat(os.path.join(cmds['tempdir'], file))[8] - uncsum = getChecksum(sumtype, os.path.join(cmds['tempdir'], un)) data = node.newChild(None, 'data', None) data.newProp('type', ftype) location = data.newChild(None, 'location', None) @@ -607,6 +606,4 @@ def repoXML(node, cmds): checksum = data.newChild(None, 'checksum', csum) checksum.newProp('type', sumtype) timestamp = data.newChild(None, 'timestamp', str(timestamp)) - unchecksum = data.newChild(None, 'uncompressed-checksum', uncsum) - unchecksum.newProp('type', sumtype) - + diff --git a/genpkgmetadata.py b/genpkgmetadata.py index 42e3ca9..f63170d 100755 --- a/genpkgmetadata.py +++ b/genpkgmetadata.py @@ -33,7 +33,7 @@ from zlib import error as zlibError from gzip import write32u, FNAME import dumpMetadata -__version__ = '0.3.2' +__version__ = '0.1' def errorprint(stuff): print >> sys.stderr, stuff @@ -157,8 +157,7 @@ def parseArgs(args): cmds['verbose'] = 0 cmds['excludes'] = [] cmds['baseurl'] = None - cmds['zgroupfile'] = None - cmds['groupfile'] = None + cmds['groupfile'] = None cmds['sumtype'] = 'md5' cmds['pretty'] = 0 @@ -228,7 +227,7 @@ def doPkgMetadata(cmds, ts): basens = baseroot.newNs('http://linux.duke.edu/metadata/common', None) baseroot.setNs(basens) basefilepath = os.path.join(cmds['tempdir'], cmds['primaryfile']) - basefile = open(basefilepath, 'w') + basefile = _gzipOpen(basefilepath, 'w') basefile.write('\n') basefile.write('\n') @@ -238,7 +237,7 @@ def doPkgMetadata(cmds, ts): filesns = filesroot.newNs('http://linux.duke.edu/metadata/filelists', None) filesroot.setNs(filesns) filelistpath = os.path.join(cmds['tempdir'], cmds['filelistsfile']) - flfile = open(filelistpath, 'w') + flfile = _gzipOpen(filelistpath, 'w') flfile.write('\n') flfile.write('\n') @@ -249,7 +248,7 @@ def doPkgMetadata(cmds, ts): otherns = otherroot.newNs('http://linux.duke.edu/metadata/other', None) otherroot.setNs(otherns) otherfilepath = os.path.join(cmds['tempdir'], cmds['otherfile']) - otherfile = open(otherfilepath, 'w') + otherfile = _gzipOpen(otherfilepath, 'w') otherfile.write('\n') otherfile.write('\n') @@ -357,33 +356,14 @@ def doRepoMetadata(cmds): del repodoc - -def compressMetadata(cmds): - """gzip compress the metadata files""" - compresslist = [('primaryfile', 'zprimaryfile'), - ('filelistsfile', 'zfilelistsfile'), - ('otherfile', 'zotherfile')] - - for (un, com) in compresslist: - fn = os.path.join(cmds['tempdir'], cmds[un]) - zfn = os.path.join(cmds['tempdir'], cmds[com]) - zfo = _gzipOpen(zfn, mode='wb') - fo = open(fn, 'r') - zfo.write(fo.read()) - fo.close() - zfo.close() - - + def main(args): cmds, directory = parseArgs(args) #setup some defaults - cmds['primaryfile'] = 'primary.xml' - cmds['filelistsfile'] = 'filelists.xml' - cmds['otherfile'] = 'other.xml' - cmds['zprimaryfile'] = 'primary.xml.gz' - cmds['zfilelistsfile'] = 'filelists.xml.gz' - cmds['zotherfile'] = 'other.xml.gz' + cmds['primaryfile'] = 'primary.xml.gz' + cmds['filelistsfile'] = 'filelists.xml.gz' + cmds['otherfile'] = 'other.xml.gz' cmds['repomdfile'] = 'repomd.xml' cmds['tempdir'] = '.repodata' cmds['finaldir'] = 'repodata' @@ -442,9 +422,6 @@ def main(args): # always clean up your messes os.chdir(curdir) raise - - # compress it - compressMetadata(cmds) try: doRepoMetadata(cmds) @@ -470,8 +447,7 @@ def main(args): sys.exit(1) - for file in ['primaryfile', 'filelistsfile', 'otherfile', 'repomdfile', - 'zprimaryfile', 'zfilelistsfile', 'zotherfile']: + for file in ['primaryfile', 'filelistsfile', 'otherfile', 'repomdfile']: oldfile = os.path.join(cmds['olddir'], cmds[file]) if os.path.exists(oldfile): try: @@ -488,19 +464,7 @@ def main(args): errorprint(_('Error was %s') % e) os.chdir(curdir) sys.exit(1) - - # get rid of the uncompressed files - for file in ['primaryfile', 'filelistsfile', 'otherfile']: - unfile = os.path.join(cmds['finaldir'], cmds[file]) - if os.path.exists(unfile): - try: - os.remove(unfile) - except OSError, e: - errorprint(_('Could not remove uncompressed metadata file: %s') % unfile) - errorprint(_('Error was %s') % e) - os.chdir(curdir) - sys.exit(1) - + # take us home mr. data -- 2.34.1