~ubuntu-branches/ubuntu/precise/ubuntu-dev-tools/precise-proposed

« back to all changes in this revision

Viewing changes to ubuntutools/sponsor_patch/sponsor_patch.py

  • Committer: Package Import Robot
  • Author(s): Stefano Rivera, Stefano Rivera, Evan Broder
  • Date: 2012-02-15 17:21:39 UTC
  • Revision ID: package-import@ubuntu.com-20120215172139-0v53nju5kopdsku2
Tags: 0.139
[ Stefano Rivera ]
* syncpackage, backportpackage, sponsor-patch: Use -nc when building source
  packages. Avoids needing build-deps on the build machine.
* sponsor-patch:
  - Determine the task from the UDD branch.
  - Support syncs of new packages.
  - Support syncs from a non-default series (LP: #931644)
  - Check for dependencies that the package doesn't Depend on. Recommend
    dput, lintian, patch, quilt. (LP: #846385)
* Re-add dgetlp. Still needed for downloading source packages from +queue.
  (LP: #919805)
* pbuilder-dist:
  - Export DISTRIBUTION and ARCHITECTURE as well as DIST and ARCH. Thanks
    Alessio Treglia. (Closes: #659060, LP: #423609)
  - Pass DEB_BUILD_OPTIONS through (LP: #685786)
* reverse-depends: Now that Debian is supported server-side:
  - Convert Debian release aliases to codenames.
  - Default to the devel release of the vendor distribution.
  - Provide transitional reverse-build-depends wrapper to help users
    discover reverse-depends. (LP: #910420)
* backportpackage: Map Debian release aliases to codenames (LP: #918231)

[ Evan Broder]
* sponsor-patch, requestsync, syncpackage: Add a config variable for -k
  arguments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
from ubuntutools.sponsor_patch.question import ask_for_manual_fixing
36
36
from ubuntutools.sponsor_patch.source_package import SourcePackage
37
37
 
 
38
 
 
39
def is_command_available(command, check_sbin=False):
 
40
    "Is command in $PATH?"
 
41
    path = os.environ.get('PATH', '/usr/bin:/bin').split(':')
 
42
    if check_sbin:
 
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)
 
47
 
 
48
 
 
49
def check_dependencies():
 
50
    "Do we have all the commands we need for full functionality?"
 
51
    missing = []
 
52
    for cmd in ('patch', 'bzr', 'quilt', 'dput', 'lintian'):
 
53
        if not is_command_available(cmd):
 
54
            missing.append(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')
 
60
 
 
61
    if missing:
 
62
        Logger.warn("sponsor-patch requires %s to be installed for full "
 
63
                    "functionality", ', '.join(missing))
 
64
 
 
65
 
38
66
def get_source_package_name(bug_task):
39
67
    package = None
40
68
    if bug_task.bug_target_name != "ubuntu":
152
180
        Logger.error("Extraction of %s failed." % (os.path.basename(dsc_file)))
153
181
        sys.exit(1)
154
182
 
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.
157
185
 
158
186
    The bug task needs to be open (not complete) and target Ubuntu. The user
161
189
    """
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()]
 
192
    if branch:
 
193
        branch = branch.split('/')
 
194
 
164
195
    if len(ubuntu_tasks) == 0:
165
196
        Logger.error("No Ubuntu bug task found on bug #%i." % (bug.id))
166
197
        sys.exit(1)
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
 
205
        task = tasks[0]
 
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
251
288
 
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)
254
291
 
255
292
    dsc_file = task.download_source()
256
293
 
277
314
                                                         previous_version)
278
315
 
279
316
        if successful:
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):
281
319
                return
282
320
            else:
283
321
                edit = True