~jelmer/parsnip/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/python
# Copyright (C) 2011 Canonical Ltd
# Authors: Jelmer Vernooij <jelmer@ubuntu.com>
#
# 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; either version 3 of the License, or
# (at your option) any later version.
#
# 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

import optparse
import os
import sys

sys.path.insert(0, os.path.dirname(__file__))

from bzrlib.plugin import load_plugins
load_plugins() # for lp:

from bzrlib import initialize as bzrlib_initialize
import atexit
context = bzrlib_initialize()
if context is not None:
    atexit.register(context.__enter__().__exit__, None, None, None)


from launchpadlib.launchpad import Launchpad

from parsnip.meal import create_meal

parser = optparse.OptionParser("[options] <project>...")
parser.add_option("--archive", help="Archive to build into", type=str, default="test")
parser.add_option("--all", help="Process all projects", action="store_true")
parser.add_option("--list", help="List projects rather than creating recipes",
                  action="store_true")

(opts, args) = parser.parse_args()

lp = Launchpad.login_with("parsnip-recipe", 'production')
person = lp.people["parsnip"]
ubuntu = lp.distributions["ubuntu"]
natty = ubuntu.series[2]
archive = person.getPPAByName(name=opts.archive)
ubuntu_desktop = lp.people["ubuntu-desktop"]

if opts.all:
    projects = (b.project.name for b in ubuntu_desktop.getBranches() if b.project is not None)
else:
    projects = args

for project in projects:
    if opts.list:
        print project
    else:
        print "Project: %s" % project
        target_dir = "daily-%s" % project
        upstream_url = "lp:%s" % project
        packaging_branch_url = "lp:~ubuntu-desktop/%s/ubuntu" % project
        create_meal(project, upstream_url, packaging_branch_url, target_dir,
                    person, archive, natty)