From: Paul Nasrat Date: Thu, 8 Dec 2005 19:25:39 +0000 (+0000) Subject: Fix cachedir/groupfile handling with --basedir and using paths not X-Git-Tag: upstream/0.9.9~254 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=61096cd7c6cffaffa32313cea357eaaa29d2cc91;p=tools%2Fcreaterepo.git Fix cachedir/groupfile handling with --basedir and using paths not relative to cwd when run without --basedir. --- diff --git a/genpkgmetadata.py b/genpkgmetadata.py index 28b458e..a7973c1 100755 --- a/genpkgmetadata.py +++ b/genpkgmetadata.py @@ -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,34 @@ def parseArgs(args): def main(args): cmds, directories = parseArgs(args) directory = directories[0] +# Fix paths + directory = os.path.normpath(directory) + if cmds['split']: + pass + elif 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 cmds['split']: + a = os.path.join(cmds['basedir'], directory, cmds['groupfile']) + elif not os.path.isabs(a): + a = os.path.join(cmds['basedir'], cmds['groupfile']) + if not os.path.exists(a): + errorprint(_('Error: groupfile %s cannot be found.' % a)) + usage() + cmds['groupfile'] = a + 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() + cmds['cachdir'] = a #setup some defaults cmds['primaryfile'] = 'primary.xml.gz'