1
# This file is part of Tarmac.
3
# Copyright 2010 Canonical, LTd.
5
# Tarmac is free software: you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License version 3 as
7
# published by the Free Software Foundation.
9
# Tarmac is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with Tarmac. If not, see <http://www.gnu.org/licenses/>.
16
'''Tarmac plug-in for triggering package recipe builds on Launchpad.'''
17
from tarmac.hooks import tarmac_hooks
18
from tarmac.plugins import TarmacPlugin
21
class PackageRecipe(TarmacPlugin):
22
'''Tarmac plug-in for triggering a package recipe build.
24
This plug-in checks for the package_recipe setting on the target branch
25
configuration, and if found, triggers that recipe to build on Launchpad.
28
def run(self, command, branch_url):
29
'''Trigger a package recipe build.'''
31
self.package_recipe = target.config.package_recipe
32
self.series_list = target.config.recipe_series.split(',')
33
except AttributeError:
36
self.logger.debug('Triggering package recipe: %s' % self.package_recipe)
37
(owner, recipe) = self.package_recipe.split('/')
39
for series in self.series_list:
40
lp_recipe = command.launchpad.people[owner].getRecipe(
42
archive = lp_recipe.daily_build_archive
43
distro = self.launchpad.distributions[u'Ubuntu']
44
lp_series = [x for x in distro.series if x.name == series][0]
45
lp_recipe.requestBuild(archive=archive,
46
distroseries=lp_series,
48
except (KeyError, ValueError, AttributeError):
49
self.logger.error('Recipe not found: %s' % self.package_recipe)
53
tarmac_hooks['tarmac_post_merge'].hook(PackageRecipe(),
54
'Package recipe builder plug-in.')