diff -Nru sbuild-launchpad-chroot-0.7/bin/sbuild-launchpad-chroot sbuild-launchpad-chroot-0.8/bin/sbuild-launchpad-chroot --- sbuild-launchpad-chroot-0.7/bin/sbuild-launchpad-chroot 2014-07-12 00:22:21.000000000 +1000 +++ sbuild-launchpad-chroot-0.8/bin/sbuild-launchpad-chroot 2015-01-09 12:32:43.000000000 +1100 @@ -117,6 +117,46 @@ percent = size_read/total_size*100 print("%.0f %%" % (percent), end='\r') +def update_ppa(args): + chroot = args.name + + print("[%s] Processing config" % chroot) + config_path = os.path.join("/etc/schroot/chroot.d/", chroot) + + # Parse the existing configuration + config = ConfigParser() + config.read(config_path) + + aliases = config.get(chroot, 'aliases') + series = config.get(chroot, 'launchpad.series') + pocket = "proposed" + ppa=args.ppa.replace('/','~') + + + new_aliases = [] + + if args.remove: + for a in aliases.split(','): + if not ppa in a: + new_aliases.append(a) + else: + new_aliases = aliases.split(',') + for component in ("main", "universe"): + a = args.name.replace(series, "%s-%s+%s+%s" % + (series, pocket, ppa,component)) + if a not in new_aliases: + new_aliases.append(a) + print ('[%s] Adding alias %s'%(chroot, a)) + + config.set(args.name, "aliases", ",".join(new_aliases)) + with open(config_path, "w+") as fd: + config.write(fd) + + fd.seek(0) + content = fd.read() + fd.truncate(0) + fd.seek(0) + fd.write(content.replace(" = ", "=")) def update_chroot(args): chroot = args.name @@ -287,6 +327,14 @@ parser_remove.add_argument("-n", "--name", required=True) parser_remove.set_defaults(func=remove_chroot) + # ppa + parser_ppa = subparsers.add_parser( + 'ppa', help="Update ppa sources for Launchpad-based chroot") + parser_ppa.add_argument("-n", "--name", required=True) + parser_ppa.add_argument("-p", "--ppa", required=True, help='ppa to add aliases for i.e. gnome3-team/gnome3') + parser_ppa.add_argument("-r", "--remove", required=False, action='store_true', help='remove aliases for given ppa') + parser_ppa.set_defaults(func=update_ppa) + args = parser.parse_args() # Some checks diff -Nru sbuild-launchpad-chroot-0.7/debian/changelog sbuild-launchpad-chroot-0.8/debian/changelog --- sbuild-launchpad-chroot-0.7/debian/changelog 2014-07-12 03:00:01.000000000 +1000 +++ sbuild-launchpad-chroot-0.8/debian/changelog 2015-01-09 12:48:40.000000000 +1100 @@ -1,3 +1,9 @@ +sbuild-launchpad-chroot (0.8) vivid; urgency=medium + + * Add support for adding ppa's via aliases with a new ppa command (LP: #1408853) + + -- Tim Lunn Fri, 09 Jan 2015 12:34:16 +1100 + sbuild-launchpad-chroot (0.7) utopic; urgency=medium * Add missing ubuntu-dev-tools to Build-Depends, as required by diff -Nru sbuild-launchpad-chroot-0.7/etc/schroot/setup.d/90apt-sources sbuild-launchpad-chroot-0.8/etc/schroot/setup.d/90apt-sources --- sbuild-launchpad-chroot-0.7/etc/schroot/setup.d/90apt-sources 2014-07-12 00:21:51.000000000 +1000 +++ sbuild-launchpad-chroot-0.8/etc/schroot/setup.d/90apt-sources 2015-01-09 12:33:57.000000000 +1100 @@ -82,6 +82,11 @@ case "$suite_comp" in '') ;; + *+*+*) + suite=`echo "$suite_comp" | sed -e 's/\+.*//'` + comp=`echo "$suite_comp" | sed -e 's/[^\+]*+[^\+]*+//'` + ppa=`echo "$suite_comp" | sed -e 's/[^\+]*+//' -e 's/\+.*//'` + ;; *+*) suite=`echo "$suite_comp" | sed -e 's/\+.*//'` comp=`echo "$suite_comp" | sed -e 's/[^\+]*+//'` @@ -106,7 +111,10 @@ '') ;; *) echo "unknown component $comp" 1>&2; exit 1 ;; esac - + + if [ -n "$ppa" ]; then + APT_PPA=`echo "$ppa" | sed -e 's/~/\//'` + fi APT_POCKETS="$suites" APT_COMPONENTS="$comps" fi @@ -142,6 +150,14 @@ changed=true fi + if [ -n "$APT_PPA" ]; then + echo "setting PPA '$APT_PPA' in sources.list" + cat /etc/schroot/ppa/gnome3.list + series=`echo $CHROOT_NAME | sed 's/\-.*//'` + echo "deb http://ppa.launchpad.net/$APT_PPA/ubuntu $series main" >> "$sources" + changed=true + fi + if [ "$VERBOSE" = 'verbose' -a "$changed" = 'true' ]; then echo "Resulting sources.list" cat "$sources"