From: Seth Vidal Date: Tue, 20 Jul 2004 01:23:57 +0000 (+0000) Subject: re-enabled group files X-Git-Tag: upstream/0.9.9~301 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=46dc83cd8129b8e06e5718a582be5622da79a671;p=tools%2Fcreaterepo.git re-enabled group files documented it --- diff --git a/dumpMetadata.py b/dumpMetadata.py index 31c9967..f892a0c 100644 --- a/dumpMetadata.py +++ b/dumpMetadata.py @@ -81,7 +81,7 @@ def getChecksum(sumtype, file, CHUNK=2**16): return sum.hexdigest() except: - raise MDError, 'Error opening file for checksum' + raise MDError, 'Error opening file for checksum: %s' % file def utf8String(string): @@ -639,8 +639,6 @@ def repoXML(node, cmds): (cmds['filelistsfile'], 'filelists'), (cmds['primaryfile'], 'primary')] - if cmds['groupfile'] is not None: - workfiles.append((cmds['groupfile'], 'group')) for (file, ftype) in workfiles: zfo = _gzipOpen(os.path.join(cmds['tempdir'], file)) @@ -657,6 +655,27 @@ def repoXML(node, cmds): checksum = data.newChild(None, 'checksum', csum) checksum.newProp('type', sumtype) timestamp = data.newChild(None, 'timestamp', str(timestamp)) - unchecksum = unchecksum = data.newChild(None, 'open-checksum', uncsum) + unchecksum = data.newChild(None, 'open-checksum', uncsum) unchecksum.newProp('type', sumtype) - + + # if we've got a group file then checksum it once and be done + if cmds['groupfile'] is not None: + grpfile = cmds['groupfile'] + timestamp = os.stat(grpfile)[8] + sfile = os.path.basename(grpfile) + fo = open(grpfile, 'r') + output = open(os.path.join(cmds['tempdir'], sfile), 'w') + output.write(fo.read()) + output.close() + csum = getChecksum(sumtype, fo) + fo.close() + + data = node.newChild(None, 'data', None) + data.newProp('type', 'group') + location = data.newChild(None, 'location', None) + if cmds['baseurl'] is not None: + location.newProp('xml:base', cmds['baseurl']) + location.newProp('href', os.path.join(cmds['finaldir'], grpfile)) + checksum = data.newChild(None, 'checksum', csum) + checksum.newProp('type', sumtype) + timestamp = data.newChild(None, 'timestamp', str(timestamp)) diff --git a/genpkgmetadata.py b/genpkgmetadata.py index cc847fa..85a32d0 100755 --- a/genpkgmetadata.py +++ b/genpkgmetadata.py @@ -50,6 +50,7 @@ def usage(): -u, --baseurl = optional base url location for all files -x, --exclude = files globs to exclude, can be specified multiple times -q, --quiet = run quietly + -g, --groupfile to point to for group information (precreated) -v, --verbose = run verbosely -s, --checksum = md5 or sha - select type of checksum to use (default: md5) -h, --help = show this help @@ -188,13 +189,16 @@ def parseArgs(args): usage() else: cmds['baseurl'] = a -# elif arg in ['-g', '--groupfile']: -# if cmds['groupfile'] is not None: -# errorprint(_('Error: Only one groupfile allowed.')) -# usage() -# else: -# cmds['groupfile'] = a - + elif arg in ['-g', '--groupfile']: + if cmds['groupfile'] is not None: + errorprint(_('Error: Only one groupfile allowed.')) + usage() + else: + if os.path.exists(a): + cmds['groupfile'] = a + else: + errorprint(_('Error: groupfile %s cannot be found.' % a)) + usage() elif arg in ['-x', '--exclude']: cmds['excludes'].append(a) elif arg in ['-p', '--pretty']: @@ -402,13 +406,6 @@ def main(args): errorprint(_('Old data directory exists, please remove: %s') % cmds['olddir']) sys.exit(1) - # check out the group file if specified -# if cmds['groupfile'] is not None: -# grpfile = os.path.join(directory, cmds['groupfile']) -# if not os.access(grpfile, os.R_OK): -# errorprint(_('Groupfile %s must exist and be readable') % grpfile) -# usage() - # change to the basedir to work from w/i the path - for relative url paths os.chdir(directory) @@ -453,9 +450,12 @@ def main(args): os.chdir(curdir) sys.exit(1) - - for file in ['primaryfile', 'filelistsfile', 'otherfile', 'repomdfile']: - oldfile = os.path.join(cmds['olddir'], cmds[file]) + for file in ['primaryfile', 'filelistsfile', 'otherfile', 'repomdfile', 'groupfile']: + if cmds[file]: + fn = os.path.basename(cmds[file]) + else: + continue + oldfile = os.path.join(cmds['olddir'], fn) if os.path.exists(oldfile): try: os.remove(oldfile) @@ -464,6 +464,7 @@ def main(args): errorprint(_('Error was %s') % e) os.chdir(curdir) sys.exit(1) + try: os.rmdir(cmds['olddir']) except OSError, e: