Re: [PATCH] Fix handling for relative absolute paths
Paul Nasrat <[email protected]>
| Newsgroups | gmane.linux.rpm.metadata |
|---|---|
| Organization | Red Hat, Inc. |
| Message-ID | <[email protected]> |
On Thu, 2005-11-17 at 12:36 -0500, Paul Nasrat wrote: > Ugly but works, expect a clean up of the option parsing/setting sometime > after fc5t1 is out. > > This fixes cachedir/groupfile handling with basedir and using paths not > relative to cwd without basedir. Without stupid typo/indent error. Paul _______________________________________________ Rpm-metadata mailing list [email protected] https://lists.dulug.duke.edu/mailman/listinfo/rpm-metadata
createrepo-relative.patch
(text/x-patch, 2.4 KB)
Index: generate/genpkgmetadata.py
===================================================================
--- generate.orig/genpkgmetadata.py
+++ generate/genpkgmetadata.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python -t
+#!/usr/bin/python -t:
# primary functions and glue for generating the repository metadata
#
@@ -397,11 +397,7 @@ def parseArgs(args):
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()
+ cmds['groupfile'] = a
elif arg in ['-x', '--exclude']:
cmds['excludes'].append(a)
elif arg in ['-p', '--pretty']:
@@ -412,12 +408,7 @@ def parseArgs(args):
errorprint(_('This option is deprecated'))
elif arg in ['-c', '--cachedir']:
cmds['cache'] = True
- if not os.path.isabs(a):
- a = os.path.join(os.getcwd(), a)
cmds['cachedir'] = a
- if not checkAndMakeDir(a):
- errorprint(_('Error: cannot open/write to cache dir %s' % a))
- usage()
elif arg == '--basedir':
cmds['basedir'] = a
@@ -431,6 +422,27 @@ def parseArgs(args):
def main(args):
cmds, directories = parseArgs(args)
directory = directories[0]
+# Fix paths
+ if os.path.isabs(directory):
+ cmds['basedir'] = directory
+ directory = '.'
+ else:
+ cmds['basedir'] = os.path.realpath(os.path.join(cmds['basedir'], directory))
+ directory = '.'
+ if cmds['groupfile']:
+ a = cmds['groupfile']
+ if not os.path.isabs(cmds['groupfile']):
+ a = os.path.join(cmds['basedir'], cmds['groupfile'])
+ if not os.path.exists(a):
+ errorprint(_('Error: groupfile %s cannot be found.' % a))
+ usage()
+ if cmds['cachedir']:
+ a = cmds ['cachedir']
+ if not os.path.isabs(a):
+ a = os.path.join(cmds['basedir'] ,a)
+ if not checkAndMakeDir(a):
+ errorprint(_('Error: cannot open/write to cache dir %s' % a))
+ usage()
#setup some defaults
cmds['primaryfile'] = 'primary.xml.gz'