bricks@344: #! /usr/bin/python
bricks@344: # Copyright (C) 2007, 2008, 2009 by Intevation GmbH
bricks@344: # Authors:
bricks@344: # Bernhard Herzog <bh@intevation.de>
bricks@344: #
bricks@344: # This program is free software under the GPL (>=v2)
bricks@344: # Read the file COPYING coming with the software for details.
bricks@344: 
bricks@344: """Script to initialize the builder environment for the tree packager
bricks@344: 
bricks@344: The script assumes that the config file for the tree packager already
bricks@344: contains the builder settings.  Also, this script assumes that there is
bricks@344: only one builder setting for all packagers.
bricks@344: """
bricks@344: 
bricks@344: import sys
bricks@344: 
bricks@344: import treepkgcmd
bricks@344: from treepkg.options import create_parser
bricks@344: from treepkg.packager import create_package_track, PackagerGroup
bricks@344: from treepkg.readconfig import read_config
bricks@344: 
bricks@344: 
bricks@344: def parse_commandline():
bricks@344:     parser = create_parser()
bricks@344:     parser.set_defaults(distribution="etch")
bricks@344:     parser.add_option("--mirrorsite",
bricks@344:                       help=("The debian mirror site"
bricks@344:                             " (pbuilder MIRRORSITE setting).  Required."))
bricks@344:     parser.add_option("--othermirror",
bricks@344:                       help=("Extra contents of the OTHERMIRROR setting."
bricks@344:                             " See the pbuilder documentation for the format."))
bricks@344:     parser.add_option("--distribution",
bricks@344:                       help=("The debian distribution for the pbuilder chroot."
bricks@344:                             " Default is etch."))
bricks@344:     return parser.parse_args()
bricks@344: 
bricks@344: 
bricks@344: def main():
bricks@344:     options, args = parse_commandline()
bricks@344: 
bricks@344:     if options.mirrorsite is None:
bricks@344:         print >>sys.stderr, "Missing required option --mirrorsite"
bricks@344:         sys.exit(1)
bricks@344: 
bricks@344:     treepkg_opts, packager_opts = read_config(options.config_file)
bricks@344:     group = PackagerGroup([create_package_track(**opts)
bricks@344:                            for opts in packager_opts],
bricks@344:                           **treepkg_opts)
bricks@344:     track = group.get_package_tracks()[0]
bricks@344:     track.builder.init_builder(distribution=options.distribution,
bricks@344:                                 mirrorsite=options.mirrorsite,
bricks@344:                                 extramirrors=options.othermirror)
bricks@344: 
bricks@344: main()