[PATCH] output dir option

Dennis Gregorovic <[email protected]>
Newsgroups gmane.linux.rpm.metadata
Message-ID <[email protected]>
The attached patch creates a new configuration option "outputdir" which
specifies the directory where the "repodata" dir will be created.  By
default, the outputdir is the same as the basedir.  

A user specifying the outputdir can create repodata somewhere other than
the package source.  This can be useful, for example, when the package
source is on a read-only filesystem.  

Along these lines, I'm also working on a separate patch for yum that
will use the xml:base attribute of the location tag when it is set.
Then, by using a command like

 $ createrepo --baseurl file:///mnt/loop --outputdir . /mnt/loop

we can create a local yum repository against read-only package
directories.

One more note about the patch.  I moved the "# Fix paths" section of
code from main() to parseArgs().  Like my previous patch, this helps to
consolidate the configuration settings so that code using
genpkgmetadata.py as a library works more smoothly.

Thoughts?

-- Dennis

_______________________________________________
Rpm-metadata mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/rpm-metadata
outputdir.patch (text/x-patch, 6.1 KB)
Index: dumpMetadata.py
===================================================================
RCS file: /cvsroot/metadata/cvs-root/generate/dumpMetadata.py,v
retrieving revision 1.35
diff -w -r1.35 dumpMetadata.py
744c744
<         zfo = _gzipOpen(os.path.join(cmds['basedir'], cmds['tempdir'], file))
---
>         zfo = _gzipOpen(os.path.join(cmds['outputdir'], cmds['tempdir'], file))
747,748c747,748
<         csum = getChecksum(sumtype, os.path.join(cmds['basedir'], cmds['tempdir'], file))
<         timestamp = os.stat(os.path.join(cmds['basedir'], cmds['tempdir'], file))[8]
---
>         csum = getChecksum(sumtype, os.path.join(cmds['outputdir'], cmds['tempdir'], file))
>         timestamp = os.stat(os.path.join(cmds['outputdir'], cmds['tempdir'], file))[8]
767c767
<         output = open(os.path.join(cmds['basedir'], cmds['tempdir'], sfile), 'w')
---
>         output = open(os.path.join(cmds['outputdir'], cmds['tempdir'], sfile), 'w')
Index: genpkgmetadata.py
===================================================================
RCS file: /cvsroot/metadata/cvs-root/generate/genpkgmetadata.py,v
retrieving revision 1.48
diff -w -r1.48 genpkgmetadata.py
132c132
<         basefilepath = os.path.join(self.cmds['basedir'], self.cmds['tempdir'], self.cmds['primaryfile'])
---
>         basefilepath = os.path.join(self.cmds['outputdir'], self.cmds['tempdir'], self.cmds['primaryfile'])
144c144
<         filelistpath = os.path.join(self.cmds['basedir'], self.cmds['tempdir'], self.cmds['filelistsfile'])
---
>         filelistpath = os.path.join(self.cmds['outputdir'], self.cmds['tempdir'], self.cmds['filelistsfile'])
156c156
<         otherfilepath = os.path.join(self.cmds['basedir'], self.cmds['tempdir'], self.cmds['otherfile'])
---
>         otherfilepath = os.path.join(self.cmds['outputdir'], self.cmds['tempdir'], self.cmds['otherfile'])
248c248
<         repofilepath = os.path.join(self.cmds['basedir'], self.cmds['tempdir'], self.cmds['repomdfile'])
---
>         repofilepath = os.path.join(self.cmds['outputdir'], self.cmds['tempdir'], self.cmds['repomdfile'])
346a347
>     cmds['outputdir'] = ""
354c355
<                                                                   'version', 'pretty', 'split'])
---
>                                                                   'version', 'pretty', 'split', 'outputdir='])
413a415,416
>             elif arg == '--outputdir':
>                 cmds['outputdir'] = a
419,431d421
<     #setup some defaults
<     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'
<     cmds['olddir'] = '.olddata'
< 
<     return cmds, directories
< 
< def main(args):
<     cmds, directories = parseArgs(args)
442a433,435
>     directories[0] = directory
>     if not cmds['outputdir']:
>         cmds['outputdir'] = cmds['basedir']
461a455,471
>     #setup some defaults
>     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'
>     cmds['olddir'] = '.olddata'
> 
>     return cmds, directories
> 
> def main(args):
>     cmds, directories = parseArgs(args)
>     print cmds
>     print directories
>     directory = directories[0]
> 
471c481
<     if not os.access(cmds['basedir'], os.W_OK):
---
>     if not os.access(cmds['outputdir'], os.W_OK):
478c488
<     if not checkAndMakeDir(os.path.join(cmds['basedir'], cmds['tempdir'])):
---
>     if not checkAndMakeDir(os.path.join(cmds['outputdir'], cmds['tempdir'])):
481c491
<     if not checkAndMakeDir(os.path.join(cmds['basedir'], cmds['finaldir'])):
---
>     if not checkAndMakeDir(os.path.join(cmds['outputdir'], cmds['finaldir'])):
484c494
<     if os.path.exists(os.path.join(cmds['basedir'], cmds['olddir'])):
---
>     if os.path.exists(os.path.join(cmds['outputdir'], cmds['olddir'])):
491c501
<             filepath = os.path.join(cmds['basedir'], cmds[direc], cmds[file])
---
>             filepath = os.path.join(cmds['outputdir'], cmds[direc], cmds[file])
506c516
<     if os.path.exists(os.path.join(cmds['basedir'], cmds['finaldir'])):
---
>     if os.path.exists(os.path.join(cmds['outputdir'], cmds['finaldir'])):
508,509c518,519
<             os.rename(os.path.join(cmds['basedir'], cmds['finaldir']),
<                       os.path.join(cmds['basedir'], cmds['olddir']))
---
>             os.rename(os.path.join(cmds['outputdir'], cmds['finaldir']),
>                       os.path.join(cmds['outputdir'], cmds['olddir']))
511,512c521,522
<             errorprint(_('Error moving final %s to old dir %s' % (os.path.join(cmds['basedir'], cmds['finaldir']),
<                                                                   os.path.join(cmds['basedir'], cmds['olddir']))))
---
>             errorprint(_('Error moving final %s to old dir %s' % (os.path.join(cmds['outputdir'], cmds['finaldir']),
>                                                                   os.path.join(cmds['outputdir'], cmds['olddir']))))
516,517c526,527
<         os.rename(os.path.join(cmds['basedir'], cmds['tempdir']),
<                   os.path.join(cmds['basedir'], cmds['finaldir']))
---
>         os.rename(os.path.join(cmds['outputdir'], cmds['tempdir']),
>                   os.path.join(cmds['outputdir'], cmds['finaldir']))
521,522c531,532
<         os.rename(os.path.join(cmds['basedir'], cmds['olddir']),
<                   os.path.join(cmds['basedir'], cmds['finaldir']))
---
>         os.rename(os.path.join(cmds['outputdir'], cmds['olddir']),
>                   os.path.join(cmds['outputdir'], cmds['finaldir']))
530c540
<         oldfile = os.path.join(cmds['basedir'], cmds['olddir'], fn)
---
>         oldfile = os.path.join(cmds['outputdir'], cmds['olddir'], fn)
539c549
< #XXX: fix to remove tree as we mung basedir
---
> #XXX: fix to remove tree as we mung outputdir
541c551
<         os.rmdir(os.path.join(cmds['basedir'], cmds['olddir']))
---
>         os.rmdir(os.path.join(cmds['outputdir'], cmds['olddir']))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.