35
35
from ubuntutools.sponsor_patch.question import ask_for_manual_fixing
36
36
from ubuntutools.sponsor_patch.source_package import SourcePackage
39
def is_command_available(command, check_sbin=False):
40
"Is command in $PATH?"
41
path = os.environ.get('PATH', '/usr/bin:/bin').split(':')
43
path += [directory[:-3] + 'sbin'
44
for directory in path if directory.endswith('/bin')]
45
return any(os.access(os.path.join(directory, command), os.X_OK)
46
for directory in path)
49
def check_dependencies():
50
"Do we have all the commands we need for full functionality?"
52
for cmd in ('patch', 'bzr', 'quilt', 'dput', 'lintian'):
53
if not is_command_available(cmd):
55
if not is_command_available('bzr-buildpackage'):
56
missing.append('bzr-builddeb')
57
if not any(is_command_available(cmd, check_sbin=True)
58
for cmd in ('pbuilder', 'sbuild', 'cowbuilder')):
59
missing.append('pbuilder/cowbuilder/sbuild')
62
Logger.warn("sponsor-patch requires %s to be installed for full "
63
"functionality", ', '.join(missing))
38
66
def get_source_package_name(bug_task):
40
68
if bug_task.bug_target_name != "ubuntu":
152
180
Logger.error("Extraction of %s failed." % (os.path.basename(dsc_file)))
155
def get_open_ubuntu_bug_task(launchpad, bug):
183
def get_open_ubuntu_bug_task(launchpad, bug, branch=None):
156
184
"""Returns an open Ubuntu bug task for a given Launchpad bug.
158
186
The bug task needs to be open (not complete) and target Ubuntu. The user
162
190
bug_tasks = [BugTask(x, launchpad) for x in bug.bug_tasks]
163
191
ubuntu_tasks = [x for x in bug_tasks if x.is_ubuntu_task()]
193
branch = branch.split('/')
164
195
if len(ubuntu_tasks) == 0:
165
196
Logger.error("No Ubuntu bug task found on bug #%i." % (bug.id))
167
198
elif len(ubuntu_tasks) == 1:
168
199
task = ubuntu_tasks[0]
169
if len(ubuntu_tasks) > 1:
200
if len(ubuntu_tasks) > 1 and branch and branch[1] == 'ubuntu':
201
tasks = [task for task in ubuntu_tasks
202
if task.get_series() == branch[2]
203
and task.package == branch[3]]
204
assert len(tasks) == 1
206
elif len(ubuntu_tasks) > 1:
170
207
task_list = [t.get_short_info() for t in ubuntu_tasks]
171
208
Logger.info("%i Ubuntu tasks exist for bug #%i.\n%s", len(ubuntu_tasks),
172
209
bug.id, "\n".join(task_list))
250
287
#pylint: enable=E1101
252
289
(patch, branch) = get_patch_or_branch(bug)
253
task = get_open_ubuntu_bug_task(launchpad, bug)
290
task = get_open_ubuntu_bug_task(launchpad, bug, branch)
255
292
dsc_file = task.download_source()
277
314
previous_version)
280
if source_package.sync(upload, bug_number, bug.owner.name):
317
series = task.get_debian_source_series()
318
if source_package.sync(upload, series, bug_number, bug.owner.name):