#! /usr/bin/python3 # Copyright (C) 2012 Canonical Ltd. # Author: Colin Watson # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Branch a set of live filesystem configurations for the next release.""" from __future__ import print_function import argparse from launchpadlib.launchpad import Launchpad import lazr.restfulclient.errors def branch_livefses(args, owner): for livefs in list(args.launchpad.livefses): if (livefs.owner == owner and livefs.distro_series == args.source_series): print("Branching %s for %s ..." % ( livefs.web_link, args.dest_series.name)) try: new_livefs = args.launchpad.livefses.getByName( owner=owner, distro_series=args.dest_series, name=livefs.name) except lazr.restfulclient.errors.NotFound: new_livefs = args.launchpad.livefses.new( owner=owner, distro_series=args.dest_series, name=livefs.name, metadata=livefs.metadata) new_livefs.require_virtualized = livefs.require_virtualized new_livefs.relative_build_score = livefs.relative_build_score try: new_livefs.lp_save() except lazr.restfulclient.errors.Unauthorized: print("Could not devirt ppa, ask Launchpad team for support.") pass print(" %s" % new_livefs.web_link) def main(): parser = argparse.ArgumentParser() parser.add_argument( "-l", "--launchpad", dest="launchpad_instance", default="production") parser.add_argument( "-d", "--distribution", default="ubuntu", metavar="DISTRIBUTION", help="branch live filesystems for DISTRIBUTION") parser.add_argument( "--source-series", help="source series (default: current stable release)") parser.add_argument( "--dest-series", help="destination series (default: series in pre-release freeze)") parser.add_argument("owner", help="owner of live filesystems to copy") args = parser.parse_args() args.launchpad = Launchpad.login_with( "branch-livefses", args.launchpad_instance, version="devel") distro = args.launchpad.distributions[args.distribution] if args.source_series is None: args.source_series = [ series for series in distro.series if series.status == "Current Stable Release"][0] else: args.source_series = distro.getSeries( name_or_version=args.source_series) if args.dest_series is None: args.dest_series = [ series for series in distro.series if series.status == "Pre-release Freeze"][0] else: args.dest_series = distro.getSeries( name_or_version=args.dest_series) owner = args.launchpad.people[args.owner] branch_livefses(args, owner) if __name__ == '__main__': main()