1
# -*- coding: utf-8 -*-
2
# Copyright 2009 Canonical Ltd.
3
# Author 2009 Didier Roche
5
# This file is part of Quickly ubuntu-project-template
7
#This program is free software: you can redistribute it and/or modify it
8
#under the terms of the GNU General Public License version 3, as published
9
#by the Free Software Foundation.
11
#This program is distributed in the hope that it will be useful, but
12
#WITHOUT ANY WARRANTY; without even the implied warranties of
13
#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14
#PURPOSE. See the GNU General Public License for more details.
16
#You should have received a copy of the GNU General Public License along
17
#with this program. If not, see <http://www.gnu.org/licenses/>.
24
from quickly import launchpadaccess
27
from gettext import gettext as _
30
gettext.textdomain('quickly')
32
def updatepackaging():
33
"""create or update a package using python-mkdebian.
35
Commit after the first packaging creation"""
37
return_code = subprocess.call(["python-mkdebian"])
39
print _("Ubuntu packaging created in debian/")
41
print _("An error has occurred")
44
# check if first python-mkdebian (debian/ creation) to commit it
45
# that means debian/ under unknown
46
bzr_instance = subprocess.Popen(["bzr", "status"], stdout=subprocess.PIPE)
47
bzr_status, err = bzr_instance.communicate()
48
if bzr_instance.returncode != 0:
49
return(bzr_instance.returncode)
51
if re.match('(.|\n)*unknown:\n.*debian/(.|\n)*', bzr_status):
52
return_code = subprocess.call(["bzr", "add"])
54
return_code = subprocess.call(["bzr", "commit", "-m 'Creating ubuntu package'"])
58
def push_to_ppa(ppa_user, changes_file):
59
""" Push some code to a ppa """
61
# creation/update debian packaging
62
return_code = updatepackaging()
64
print _("ERROR: can't create or update ubuntu package")
67
# creating local binary package
68
return_code = subprocess.call(["dpkg-buildpackage", "-S", "-I.bzr"])
70
print _("ERROR: an error occurred during source package creation")
73
if launchpadaccess.lp_server == "staging":
74
ppa_targeted = "ppa:%s/%s" % (ppa_user, "staging")
76
ppa_targeted = "ppa:%s/%s" % (ppa_user, "ppa")
78
# now, pushing it to launchpad personal ppa (or team later)
79
return_code = subprocess.call(["dput", ppa_targeted, changes_file])
81
print _("ERROR: an error occurred during source upload to launchpad")
87
def check_for_ppa(launchpad, lp_team_or_user):
88
""" check if ppa exist """
90
# check that the owner really has an ppa:
91
if launchpadaccess.lp_server == "staging":
92
ppa_name_dest = 'staging'
97
for ppa in lp_team_or_user.ppas:
98
if ppa.name == ppa_name_dest: