return sum.hexdigest()
except:
- raise MDError, 'Error opening file for checksum'
+ raise MDError, 'Error opening file for checksum: %s' % file
def utf8String(string):
(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))
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))
-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 <filename> 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
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']:
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)
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)
errorprint(_('Error was %s') % e)
os.chdir(curdir)
sys.exit(1)
+
try:
os.rmdir(cmds['olddir'])
except OSError, e: