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
|
# Copyright (C) 2009, 2010, 2012 Canonical Ltd.
# 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; version 3 of the License.
#
# 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, see <http://www.gnu.org/licenses/>.
"""Compatibility helpers for old-style sync/backport bug requests."""
from __future__ import print_function
import os
import subprocess
def backportpackage(source, extra_env, extra_opts, tty=False):
command = ['backportpackage']
command.extend(extra_opts)
command.append(source)
env = os.environ.copy()
env.update(extra_env)
if 'SYNCLIB_DEBUG' in os.environ:
# Dodgy escaping, but it's only for debugging.
print(' '.join(['%s="%s"' % (k, v) for k, v in extra_env.items()]),
' '.join(command))
return False
# In principle we could use pexpect to answer backportpackage's
# questions automatically. However, that seems like a lot of effort
# given that the archive administrator interface to this feature is
# deprecated (i.e. backporters can simply call backportpackage
# directly).
if tty:
with open("/dev/tty") as tty_file:
return subprocess.call(command, stdin=tty_file, env=env) == 0
else:
return subprocess.call(command, env=env) == 0
# For syncs, we have a proper API, but it needs some work to do all the
# necessary client-side checks and call it properly; syncpackage from
# ubuntu-dev-tools is good at this. This would be neater if more of
# syncpackage were in library code, so that we could call it directly rather
# than using a subprocess.
def syncpackage(source, extra_opts, tty=False):
command = ['syncpackage']
command.extend(extra_opts)
command.append(source)
if 'SYNCLIB_DEBUG' in os.environ:
print(' '.join(command))
return False
# In principle we could use pexpect to answer syncpackage's questions
# automatically. However, that seems like a lot of effort given that
# the archive administrator interface to this feature is deprecated
# (i.e. sponsors can simply call syncpackage directly).
if tty:
with open("/dev/tty") as tty_file:
return subprocess.call(command, stdin=tty_file) == 0
else:
return subprocess.call(command) == 0
|