2 # This program is free software; you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation; either version 2 of the License, or
5 # (at your option) any later version.
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU Library General Public License for more details.
12 # You should have received a copy of the GNU General Public License
13 # along with this program; if not, write to the Free Software
14 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 # Copyright 2008 Red Hat, Inc - written by skvidal at fedoraproject.org
17 # merge repos from arbitrary repo urls
20 import createrepo.merge
21 from optparse import OptionParser
25 # handle content/distro tags
30 """Parse our opts/args"""
32 mergerepo: take 2 or more repositories and merge their metadata into a new repo
34 mergerepo --repo=url --repo=url --outputdir=/some/path"""
36 parser = OptionParser(version = "mergerepo 0.1", usage=usage)
38 parser.add_option("-r", "--repo", dest='repos', default=[], action="append",
40 parser.add_option("-a", "--archlist", default=[], action="append",
41 help="Defaults to all arches - otherwise specify arches")
42 parser.add_option("-d", "--database", default=True, action="store_true")
43 parser.add_option( "--no-database", default=False, action="store_true", dest="nodatabase")
44 parser.add_option("-o", "--outputdir", default=None,
45 help="Location to create the repository")
46 parser.add_option("", "--nogroups", default=False, action="store_true",
47 help="Do not merge group(comps) metadata")
48 parser.add_option("", "--noupdateinfo", default=False, action="store_true",
49 help="Do not merge updateinfo metadata")
50 (opts, argsleft) = parser.parse_args(args)
52 if len(opts.repos) < 2:
56 # sort out the comma-separated crap we somehow inherited.
58 for archs in opts.archlist:
59 for arch in archs.split(','):
62 opts.archlist = archlist
68 opts = parse_args(args)
69 rmbase = createrepo.merge.RepoMergeBase(opts.repos)
71 rmbase.archlist = opts.archlist
73 rmbase.outputdir = opts.outputdir
75 rmbase.mdconf.database = False
79 rmbase.updateinfo = False
82 rmbase.write_metadata()
84 if __name__ == "__main__":