* check-mir, check-symbols, grep-merges, pbuilder-dist-simple,

setup-packaging-environment, submittodebian, ubuntu-iso:
  Do enough argument parsing to handle --help (LP: #988009)
* dgetlp: Require a UTF-8 locale, or it'll crash when displaying errors
  (LP: #979117)
* pbuilder-dist: Don't try to enable -updates for Debian testing
  (LP: #993006)
* pbuilder-dist, pull-debian-source, pull-lp-source, requestsync,
  reverse-depends, submittodebian, syncpackage:
  Handle outdated distro-info data. Fall back to sane defaults where
  possible.
* backportpackage: Avoid uploading orig tarballs if they are already present
  in the destination PPA (LP: #691897)
* Allow mk-sbuild to be run by root if a configuration file exists
  (LP: #888736)
* backportpackage: Allow unsigned backports (LP: #992739)
* update-maintainer: Add a function to restore the original maintainer.
* submittodebian: Revert Ubuntu Maintainer mangling, and re-build the source
  package before diffing. (LP: #902233)
This commit is contained in:
Stefano Rivera 2012-05-11 18:13:04 -07:00
commit 0f5ab96310
22 changed files with 397 additions and 110 deletions

View File

@ -18,6 +18,7 @@
# #
# ################################################################## # ##################################################################
import glob
import optparse import optparse
import os import os
import shutil import shutil
@ -25,8 +26,8 @@ import sys
import tempfile import tempfile
import lsb_release import lsb_release
from devscripts.logger import Logger from devscripts.logger import Logger
from httplib2 import Http, HttpLib2Error
from ubuntutools.archive import (SourcePackage, DebianSourcePackage, from ubuntutools.archive import (SourcePackage, DebianSourcePackage,
UbuntuSourcePackage, DownloadError) UbuntuSourcePackage, DownloadError)
@ -85,6 +86,11 @@ def parse(args):
parser.add_option('-u', '--upload', parser.add_option('-u', '--upload',
metavar='UPLOAD', metavar='UPLOAD',
help='Specify an upload destination') help='Specify an upload destination')
parser.add_option("-k", "--key",
help="Specify the key ID to be used for signing.")
parser.add_option('--dont-sign',
dest='key', action='store_false',
help='Do not sign the upload.')
parser.add_option('-y', '--yes', parser.add_option('-y', '--yes',
dest='prompt', dest='prompt',
default=True, default=True,
@ -132,6 +138,8 @@ def parse(args):
opts.lpinstance = config.get_value('LPINSTANCE') opts.lpinstance = config.get_value('LPINSTANCE')
if opts.upload is None: if opts.upload is None:
opts.upload = config.get_value('UPLOAD') opts.upload = config.get_value('UPLOAD')
if opts.keyid is None:
opts.keyid = config.get_value('KEYID')
if not opts.upload and not opts.workdir: if not opts.upload and not opts.workdir:
parser.error('Please specify either a working dir or an upload target!') parser.error('Please specify either a working dir or an upload target!')
if opts.upload and opts.upload.startswith('ppa:'): if opts.upload and opts.upload.startswith('ppa:'):
@ -235,8 +243,33 @@ def do_upload(workdir, package, bp_version, changes, upload, prompt):
check_call(['dput', upload, changes], cwd=workdir) check_call(['dput', upload, changes], cwd=workdir)
def orig_needed(upload, workdir, pkg):
'''Avoid a -sa if possible'''
if not upload or not upload.startswith('ppa:'):
return True
ppa = upload.split(':', 1)[1]
user, ppa = ppa.split('/', 1)
version = pkg.version.full_version
if pkg.version.epoch:
version = version.split(pkg.version.epoch, 1)[1]
h = Http()
for filename in glob.glob(os.path.join(workdir,
'%s_%s.orig*' % (pkg.source, version))):
url = ('https://launchpad.net/~%s/+archive/%s/+files/%s'
% (user, ppa, filename))
try:
headers, body = h.request(url, 'HEAD')
if headers.status != 200:
return True
except HttpLib2Error, e:
Logger.info(e)
return True
return False
def do_backport(workdir, pkg, suffix, close, release, release_pocket, build, def do_backport(workdir, pkg, suffix, close, release, release_pocket, build,
builder, update, upload, prompt): builder, update, upload, keyid, prompt):
dirname = '%s-%s' % (pkg.source, release) dirname = '%s-%s' % (pkg.source, release)
srcdir = os.path.join(workdir, dirname) srcdir = os.path.join(workdir, dirname)
@ -263,16 +296,28 @@ def do_backport(workdir, pkg, suffix, close, release, release_pocket, build,
'--distribution', bp_dist, '--distribution', bp_dist,
changelog], changelog],
cwd=srcdir) cwd=srcdir)
check_call(['debuild', '--no-lintian', '-S', '-nc', '-sa'], cwd=srcdir)
cmd = ['debuild', '--no-lintian', '-S', '-nc', '-uc', '-us']
if orig_needed(upload, workdir, pkg):
cmd.append('-sa')
else:
cmd.append('-sd')
check_call(cmd, cwd=srcdir)
fn_base = pkg.source + '_' + bp_version.split(':', 1)[-1] fn_base = pkg.source + '_' + bp_version.split(':', 1)[-1]
changes = fn_base + '_source.changes'
if build: if build:
if 0 != do_build(workdir, fn_base + '.dsc', release, builder, update): if 0 != do_build(workdir, fn_base + '.dsc', release, builder, update):
sys.exit(1) sys.exit(1)
if keyid != False:
cmd = ['debsign']
if keyid:
cmd.append('-k' + keyid)
cmd.append(changes)
check_call(cmd, cwd=workdir)
if upload: if upload:
do_upload(workdir, pkg.source, bp_version, fn_base + '_source.changes', do_upload(workdir, pkg.source, bp_version, changes, upload, prompt)
upload, prompt)
shutil.rmtree(srcdir) shutil.rmtree(srcdir)
@ -318,6 +363,7 @@ def main(args):
opts.builder, opts.builder,
opts.update, opts.update,
opts.upload, opts.upload,
opts.key,
opts.prompt) opts.prompt)
except DownloadError, e: except DownloadError, e:
error(str(e)) error(str(e))

View File

@ -21,10 +21,13 @@
# this program; if not, write to the Free Software Foundation, Inc., # this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import apt
import sys import sys
import optparse
import os.path import os.path
import apt
def check_support(apt_cache, pkgname, alt=False): def check_support(apt_cache, pkgname, alt=False):
'''Check if pkgname is in main or restricted. '''Check if pkgname is in main or restricted.
@ -118,6 +121,11 @@ def check_binary_dependencies(apt_cache, control):
return any_unsupported return any_unsupported
def main(): def main():
parser = optparse.OptionParser(
description="Check if any of a package's build or binary "
"dependencies are in universe or multiverse. "
"Run this inside an unpacked source package")
parser.parse_args()
apt_cache = apt.Cache() apt_cache = apt.Cache()
if not os.path.exists('debian/control'): if not os.path.exists('debian/control'):

View File

@ -29,21 +29,55 @@
# * nm (from binutils) # * nm (from binutils)
DISTRO=$(lsb_release -c -s) DISTRO=$(lsb_release -c -s)
VERSION=$(apt-cache madison "$1" | grep -- "$DISTRO"'/.*Sources$' | awk '{print $3}')
PACKAGES=$(apt-cache showsrc "$1" | grep-dctrl -s Binary -F Version "$VERSION" | sed 's/Binary\:\ //g;s/\,//g' | sort -u)
DEBLINE="" DEBLINE=""
DEBUG=False DEBUG=False
if [[ -z $1 ]]; then usage() {
echo "Missing argument: source package name." prog=$(basename $0)
exit 1 cat <<EOF
Usage: $prog [options] source-package [DEBDIR]
Get a diff of the exported symbols of all .so files in every binary package of
package the source package. The source package will be found in DEBDIR, defaulting to /var/cache/pbuilder/result.
Options:
-h, --help show this help message and exit
EOF
exit $1
}
PACKAGE=""
DEBDIR="/var/cache/pbuilder/result"
POSITION=0
while [ $# -gt 0 ]; do
case "$1" in
-h|--help)
usage 0
;;
-*)
usage 1
;;
*)
if [ $POSITION -eq 0 ]; then
PACKAGE="$1"
elif [ $POSITION -eq 1 ]; then
DEBDIR="$1"
else
echo "Too many arguments." >&2
usage 1
fi
POSITION=$(($POSITION+1))
esac
shift
done
if [ $POSITION -eq 0 ]; then
echo "Missing argument: source package name." >&2
usage 1
fi fi
if [[ -z $2 ]]; then VERSION=$(apt-cache madison "$PACKAGE" | grep -- "$DISTRO"'/.*Sources$' | awk '{print $3}')
DEBDIR="/var/cache/pbuilder/result" PACKAGES=$(apt-cache showsrc "$PACKAGE" | grep-dctrl -s Binary -F Version "$VERSION" | sed 's/Binary\:\ //g;s/\,//g' | sort -u)
else
DEBDIR="$2"
fi
if [ `id -u` != "0" ] if [ `id -u` != "0" ]
then then
@ -67,7 +101,7 @@ do
done done
if [[ -z $DEBLINE ]]; then if [[ -z $DEBLINE ]]; then
echo "Package doesn't exist: $1." echo "Package doesn't exist: $PACKAGE."
exit 1 exit 1
fi fi

19
debian/changelog vendored
View File

@ -4,6 +4,25 @@ ubuntu-dev-tools (0.142) UNRELEASED; urgency=low
* mk-sbuild: Support kmod, when checking for overlayfs availability. * mk-sbuild: Support kmod, when checking for overlayfs availability.
* pbuilder-dist: improve bash_completion for *.dsc files. Thanks Maarten * pbuilder-dist: improve bash_completion for *.dsc files. Thanks Maarten
Bezemer. (Closes: #670924, LP: #770529) Bezemer. (Closes: #670924, LP: #770529)
* check-mir, check-symbols, grep-merges, pbuilder-dist-simple,
setup-packaging-environment, submittodebian, ubuntu-iso:
Do enough argument parsing to handle --help (LP: #988009)
* dgetlp: Require a UTF-8 locale, or it'll crash when displaying errors
(LP: #979117)
* pbuilder-dist: Don't try to enable -updates for Debian testing
(LP: #993006)
* pbuilder-dist, pull-debian-source, pull-lp-source, requestsync,
reverse-depends, submittodebian, syncpackage:
Handle outdated distro-info data. Fall back to sane defaults where
possible.
* backportpackage: Avoid uploading orig tarballs if they are already present
in the destination PPA (LP: #691897)
* Allow mk-sbuild to be run by root if a configuration file exists
(LP: #888736)
* backportpackage: Allow unsigned backports (LP: #992739)
* update-maintainer: Add a function to restore the original maintainer.
* submittodebian: Revert Ubuntu Maintainer mangling, and re-build the source
package before diffing. (LP: #902233)
[ Evan Broder ] [ Evan Broder ]
* backportpackage: Add -c, --close flag to include a changelog closer. * backportpackage: Add -c, --close flag to include a changelog closer.

3
dgetlp
View File

@ -43,6 +43,7 @@ except ImportError:
sys.exit(1) sys.exit(1)
from ubuntutools import subprocess from ubuntutools import subprocess
import ubuntutools.misc
USAGE = u"""Usage: %prog [-d|(-v|-q)] <Launchpad URL> USAGE = u"""Usage: %prog [-d|(-v|-q)] <Launchpad URL>
@ -253,6 +254,8 @@ def main():
default=False, help="Never print any output") default=False, help="Never print any output")
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
ubuntutools.misc.require_utf8()
if len(args) != 1: if len(args) != 1:
parser.error("Missing URL") parser.error("Missing URL")
Debug = options.debug Debug = options.debug

View File

@ -19,6 +19,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import optparse
import sys import sys
import json import json
@ -28,12 +29,19 @@ import ubuntutools.misc
def main(): def main():
ubuntutools.misc.require_utf8() parser = optparse.OptionParser(usage='%prog [options] [string]',
if len(sys.argv) > 1: description='List pending merges from Debian matching string')
match = sys.argv[1] args = parser.parse_args()[1]
if len(args) > 1:
parser.error('Too many arguments')
elif len(args) == 1:
match = args[0]
else: else:
match = None match = None
ubuntutools.misc.require_utf8()
for component in ('main', 'main-manual', for component in ('main', 'main-manual',
'restricted', 'restricted-manual', 'restricted', 'restricted-manual',
'universe', 'universe-manual', 'universe', 'universe-manual',

View File

@ -175,9 +175,15 @@ done
# will not exist in the chroot. # will not exist in the chroot.
cd / cd /
# Make sure we've got a regular user if [ -w /etc/passwd -a ! -e ~/.sbuildrc -a ! -e ~/.mk-sbuild.rc ]; then
if [ -w /etc/passwd ]; then cat >&2 <<EOF
echo "Please run this script as a regular user, not root." >&2 It's recommended to run this script as a regular user, not root, so that it
uses the configuration files in your home directory.
It will use sudo to escalate to root as necessary.
If you really do want to use it as root, create a .sbuildrc or .mk-sbuild.rc
in root's home.
EOF
exit 1 exit 1
fi fi

View File

@ -33,7 +33,7 @@ import os
import sys import sys
from devscripts.logger import Logger from devscripts.logger import Logger
from distro_info import DebianDistroInfo, UbuntuDistroInfo from distro_info import DebianDistroInfo, UbuntuDistroInfo, DistroDataOutdated
import ubuntutools.misc import ubuntutools.misc
from ubuntutools.config import UDTConfig from ubuntutools.config import UDTConfig
@ -266,11 +266,17 @@ class PbuilderDist:
othermirrors = [] othermirrors = []
if self.target_distro in self._debian_distros: if self.target_distro in self._debian_distros:
debian_info = DebianDistroInfo() debian_info = DebianDistroInfo()
if (debian_info.codename(self.target_distro) or self.target_distro try:
in (debian_info.devel(), 'experimental')): codename = debian_info.codename(self.target_distro,
default=self.target_distro)
except DistroDataOutdated, e:
Logger.warn(e)
if codename in (debian_info.devel(), 'experimental'):
self.enable_security = False self.enable_security = False
self.enable_updates = False self.enable_updates = False
self.enable_proposed = False self.enable_proposed = False
elif codename == 'testing':
self.enable_updates = False
if self.enable_security: if self.enable_security:
othermirrors.append('deb %s %s/updates %s' othermirrors.append('deb %s %s/updates %s'
@ -283,7 +289,13 @@ class PbuilderDist:
othermirrors.append('deb %s %s-proposed-updates %s' othermirrors.append('deb %s %s-proposed-updates %s'
% (mirror, self.target_distro, components)) % (mirror, self.target_distro, components))
else: else:
if self.target_distro == UbuntuDistroInfo().devel(): try:
dev_release = self.target_distro == UbuntuDistroInfo().devel()
except DistroDataOutdated, e:
Logger.warn(e)
dev_release = True
if dev_release:
self.enable_security = False self.enable_security = False
self.enable_updates = False self.enable_updates = False
self.enable_proposed = False self.enable_proposed = False

View File

@ -30,29 +30,44 @@ OPERATION=$1
DISTRIBUTION=`basename $0 | cut -f2 -d '-'` DISTRIBUTION=`basename $0 | cut -f2 -d '-'`
PROCEED=false PROCEED=false
BASE_DIR="$HOME/pbuilder" BASE_DIR="$HOME/pbuilder"
usage() {
prog=$(basename $0)
cat <<EOF
Usage: $prog command [pbuilder-options...]
A simple multi-release pbuilder wrapper
Valid commands are:
create
update
build
clean
login
execute
Options:
-h, --help show this help message and exit
EOF
exit $1
}
case $OPERATION in case $OPERATION in
create|update|build|clean|login|execute) create|update|build|clean|login|execute)
PROCEED=true ;;
-h|--help)
usage 0
;;
*)
usage 1
;; ;;
esac esac
if [ $PROCEED = true ]; then
shift shift
if [ ! -d $BASE_DIR/${DISTRIBUTION}_result ] if [ ! -d $BASE_DIR/${DISTRIBUTION}_result ]; then
then mkdir -p $BASE_DIR/${DISTRIBUTION}_result/ mkdir -p $BASE_DIR/${DISTRIBUTION}_result/
fi fi
sudo pbuilder $OPERATION \ sudo pbuilder $OPERATION \
--basetgz $BASE_DIR/$DISTRIBUTION-base.tgz \ --basetgz $BASE_DIR/$DISTRIBUTION-base.tgz \
--distribution $DISTRIBUTION \ --distribution $DISTRIBUTION \
--buildresult $BASE_DIR/$DISTRIBUTION_result \ --buildresult $BASE_DIR/$DISTRIBUTION_result \
--othermirror "deb http://archive.ubuntu.com/ubuntu $DISTRIBUTION universe multiverse" $@ --othermirror "deb http://archive.ubuntu.com/ubuntu $DISTRIBUTION universe multiverse" "$@"
else
echo "Invalid command..."
echo "Valid commands are:"
echo " create"
echo " update"
echo " build"
echo " clean"
echo " login"
echo " execute"
exit 1
fi

View File

@ -22,7 +22,7 @@ import sys
import urllib2 import urllib2
from devscripts.logger import Logger from devscripts.logger import Logger
from distro_info import DebianDistroInfo from distro_info import DebianDistroInfo, DistroDataOutdated
from ubuntutools.archive import DebianSourcePackage, DownloadError, rmadison from ubuntutools.archive import DebianSourcePackage, DownloadError, rmadison
from ubuntutools.config import UDTConfig from ubuntutools.config import UDTConfig
@ -52,7 +52,10 @@ def is_suite(version):
def source_package_for(binary, release): def source_package_for(binary, release):
"""Query DDE to find the source package for a particular binary""" """Query DDE to find the source package for a particular binary"""
try:
release = DebianDistroInfo().codename(release, default=release) release = DebianDistroInfo().codename(release, default=release)
except DistroDataOutdated, e:
Logger.warn(e)
url = ('http://dde.debian.net/dde/q/udd/dist/d:debian/r:%s/p:%s/?t=json' url = ('http://dde.debian.net/dde/q/udd/dist/d:debian/r:%s/p:%s/?t=json'
% (release, binary)) % (release, binary))
try: try:

View File

@ -30,7 +30,7 @@ import urllib2
from optparse import OptionParser from optparse import OptionParser
from devscripts.logger import Logger from devscripts.logger import Logger
from distro_info import UbuntuDistroInfo from distro_info import UbuntuDistroInfo, DistroDataOutdated
from ubuntutools.archive import UbuntuSourcePackage, DownloadError from ubuntutools.archive import UbuntuSourcePackage, DownloadError
from ubuntutools.config import UDTConfig from ubuntutools.config import UDTConfig
@ -89,7 +89,11 @@ def main():
if len(args) > 1: # Custom distribution specified. if len(args) > 1: # Custom distribution specified.
version = str(args[1]) version = str(args[1])
else: else:
try:
version = os.getenv('DIST') or ubuntu_info.devel() version = os.getenv('DIST') or ubuntu_info.devel()
except DistroDataOutdated, e:
Logger.warn("%s\nOr specify a distribution.", e)
sys.exit(1)
component = None component = None
# Release, not package version number: # Release, not package version number:

View File

@ -31,7 +31,7 @@ import os
import sys import sys
from debian.changelog import Version from debian.changelog import Version
from distro_info import UbuntuDistroInfo from distro_info import UbuntuDistroInfo, DistroDataOutdated
from ubuntutools.config import UDTConfig, ubu_email from ubuntutools.config import UDTConfig, ubu_email
from ubuntutools.lp import udtexceptions from ubuntutools.lp import udtexceptions
@ -45,8 +45,11 @@ from ubuntutools.question import confirmation_prompt, EditBugReport
def main(): def main():
ubu_info = UbuntuDistroInfo() ubu_info = UbuntuDistroInfo()
DEFAULT_SOURCE = 'unstable' DEFAULT_SOURCE = 'unstable'
try:
if ubu_info.is_lts(ubu_info.devel()): if ubu_info.is_lts(ubu_info.devel()):
DEFAULT_SOURCE = 'testing' DEFAULT_SOURCE = 'testing'
except DistroDataOutdated, e:
print >> sys.stderr, str(e)
# Our usage options. # Our usage options.
usage = ('Usage: %prog [options] ' usage = ('Usage: %prog [options] '

View File

@ -18,6 +18,7 @@ import optparse
import sys import sys
from devscripts.logger import Logger from devscripts.logger import Logger
from distro_info import DistroDataOutdated
from ubuntutools.misc import (system_distribution, vendor_to_distroinfo, from ubuntutools.misc import (system_distribution, vendor_to_distroinfo,
codename_to_distribution) codename_to_distribution)
@ -26,15 +27,21 @@ from ubuntutools.rdepends import query_rdepends, RDependsException
def main(): def main():
system_distro_info = vendor_to_distroinfo(system_distribution())() system_distro_info = vendor_to_distroinfo(system_distribution())()
try:
default_release = system_distro_info.devel()
except DistroDataOutdated, e:
Logger.warn(e)
default_release = 'unstable'
parser = optparse.OptionParser('%prog [options] package', parser = optparse.OptionParser('%prog [options] package',
description="List reverse-dependencies of package. " description="List reverse-dependencies of package. "
"If the package name is prefixed with src: then the " "If the package name is prefixed with src: then the "
"reverse-dependencies of all the binary packages that " "reverse-dependencies of all the binary packages that "
"the specified source package builds will be listed.") "the specified source package builds will be listed.")
parser.add_option('-r', '--release', metavar='RELEASE', parser.add_option('-r', '--release', metavar='RELEASE',
default=system_distro_info.devel(), default=default_release,
help='Query dependencies in RELEASE. ' help='Query dependencies in RELEASE. '
'Default: %s' % system_distro_info.devel()) 'Default: %s' % default_release)
parser.add_option('-R', '--without-recommends', parser.add_option('-R', '--without-recommends',
action='store_false', dest='recommends', default=True, action='store_false', dest='recommends', default=True,
help='Only consider Depends relationships, ' help='Only consider Depends relationships, '
@ -76,8 +83,12 @@ def main():
if not distribution: if not distribution:
parser.error('Unknown release codename %s' % options.release) parser.error('Unknown release codename %s' % options.release)
distro_info = vendor_to_distroinfo(distribution)() distro_info = vendor_to_distroinfo(distribution)()
try:
options.release = distro_info.codename(options.release, options.release = distro_info.codename(options.release,
default=options.release) default=options.release)
except DistroDataOutdated:
# We already printed a warning
pass
try: try:
data = query_rdepends(package, options.release, options.arch, **opts) data = query_rdepends(package, options.release, options.arch, **opts)

View File

@ -37,6 +37,31 @@ await_response() {
echo echo
} }
usage() {
prog=$(basename $0)
cat <<EOF
Usage: $prog [options]
Configure your machine for packaging work
Options:
-h, --help show this help message and exit
EOF
exit $1
}
while [ $# -gt 0 ]; do
case "$1" in
-h|--help)
usage 0
;;
*)
usage 1
;;
esac
shift
done
# ################################################################## # ##################################################################
if [ "$(lsb_release -is)" != "Ubuntu" ] if [ "$(lsb_release -is)" != "Ubuntu" ]

View File

@ -22,17 +22,19 @@
# #
# ################################################################## # ##################################################################
import optparse
import os import os
import re import re
import shutil import shutil
import sys import sys
from tempfile import mkdtemp from tempfile import mkdtemp
from distro_info import UbuntuDistroInfo from distro_info import UbuntuDistroInfo, DistroDataOutdated
from ubuntutools.config import ubu_email from ubuntutools.config import ubu_email
from ubuntutools.question import YesNoQuestion, EditFile from ubuntutools.question import YesNoQuestion, EditFile
from ubuntutools.subprocess import call, check_call, Popen, PIPE from ubuntutools.subprocess import call, check_call, Popen, PIPE
from ubuntutools.update_maintainer import update_maintainer, restore_maintainer
try: try:
from debian.changelog import Changelog from debian.changelog import Changelog
@ -69,6 +71,13 @@ Thanks for considering the patch.
""" % ("\n".join([a for a in entry.changes()])) """ % ("\n".join([a for a in entry.changes()]))
return msg return msg
def build_source_package():
if os.path.isdir('.bzr'):
cmd = ['bzr', 'bd', '-S', '--', '-uc', '-us', '-nc']
else:
cmd = ['debuild', '-S', '-uc', '-us', '-nc']
check_call(cmd)
def gen_debdiff(tmpdir, changelog): def gen_debdiff(tmpdir, changelog):
pkg = changelog.package pkg = changelog.package
@ -118,7 +127,11 @@ def check_file(fname, critical = True):
sys.exit(1) sys.exit(1)
def submit_bugreport(body, debdiff, deb_version, changelog): def submit_bugreport(body, debdiff, deb_version, changelog):
try:
devel = UbuntuDistroInfo().devel() devel = UbuntuDistroInfo().devel()
except DistroDataOutdated, e:
print str(e)
devel = ''
if os.path.dirname(sys.argv[0]).startswith('/usr/bin'): if os.path.dirname(sys.argv[0]).startswith('/usr/bin'):
editor_path = '/usr/share/ubuntu-dev-tools' editor_path = '/usr/share/ubuntu-dev-tools'
@ -190,6 +203,10 @@ reportbug --configure for its configuration wizard.
sys.exit(1) sys.exit(1)
def main(): def main():
parser = optparse.OptionParser(
description='Submit the Ubuntu changes in a package to Debian. '
'Run inside an unpacked Ubuntu source package.')
parser.parse_args()
check_reportbug_config() check_reportbug_config()
changelog_file = (check_file('debian/changelog', critical = False) or changelog_file = (check_file('debian/changelog', critical = False) or
check_file('../debian/changelog')) check_file('../debian/changelog'))
@ -204,8 +221,16 @@ def main():
fp.write(bug_body) fp.write(bug_body)
fp.close() fp.close()
restore_maintainer('debian')
build_source_package()
update_maintainer('debian')
debdiff = gen_debdiff(tmpdir, changelog) debdiff = gen_debdiff(tmpdir, changelog)
# Build again as the user probably doesn't expect the Maintainer to be
# reverted in the most recent build
build_source_package()
EditFile(debdiff, 'debdiff').edit(optional=True) EditFile(debdiff, 'debdiff').edit(optional=True)
submit_bugreport(body, debdiff, deb_version, changelog) submit_bugreport(body, debdiff, deb_version, changelog)

View File

@ -31,7 +31,7 @@ import urllib
import debian.debian_support import debian.debian_support
from devscripts.logger import Logger from devscripts.logger import Logger
from distro_info import UbuntuDistroInfo from distro_info import UbuntuDistroInfo, DistroDataOutdated
from lazr.restfulclient.errors import HTTPError from lazr.restfulclient.errors import HTTPError
from ubuntutools.archive import (DebianSourcePackage, UbuntuSourcePackage, from ubuntutools.archive import (DebianSourcePackage, UbuntuSourcePackage,
@ -294,7 +294,15 @@ def fetch_source_pkg(package, dist, version, component, ubuntu_release,
if dist is None: if dist is None:
ubu_info = UbuntuDistroInfo() ubu_info = UbuntuDistroInfo()
dist = 'testing' if ubu_info.is_lts(ubu_info.devel()) else 'unstable' try:
if ubu_info.is_lts(ubu_info.devel()):
dist = 'testing'
else:
dist = 'unstable'
except DistroDataOutdated, e:
Logger.warn(e)
dist = 'unstable'
requested_version = version requested_version = version
if type(version) == str: if type(version) == str:
version = Version(version) version = Version(version)

View File

@ -20,6 +20,7 @@
# #
# ################################################################## # ##################################################################
import optparse
import sys import sys
from ubuntutools import subprocess from ubuntutools import subprocess
@ -37,7 +38,10 @@ def extract(iso, path):
return stdout return stdout
def main(): def main():
isos = sys.argv[1:] parser = optparse.OptionParser(usage='%prog [options] iso...',
description='Given an ISO, %prog will display the Ubuntu version '
'information')
isos = parser.parse_args()[1]
err = False err = False
for iso in isos: for iso in isos:

View File

@ -24,7 +24,7 @@ import re
from debian.deb822 import Changes from debian.deb822 import Changes
from devscripts.logger import Logger from devscripts.logger import Logger
from distro_info import DebianDistroInfo from distro_info import DebianDistroInfo, DistroDataOutdated
from httplib2 import Http, HttpLib2Error from httplib2 import Http, HttpLib2Error
from ubuntutools.lp.lpapicache import (Launchpad, Distribution, PersonTeam, from ubuntutools.lp.lpapicache import (Launchpad, Distribution, PersonTeam,
@ -35,7 +35,10 @@ def get_debian_srcpkg(name, release):
debian = Distribution('debian') debian = Distribution('debian')
debian_archive = debian.getArchive() debian_archive = debian.getArchive()
try:
release = DebianDistroInfo().codename(release, None, release) release = DebianDistroInfo().codename(release, None, release)
except DistroDataOutdated, e:
Logger.warn(e)
return debian_archive.getSourcePackage(name, release) return debian_archive.getSourcePackage(name, release)

View File

@ -29,7 +29,7 @@ import tempfile
from debian.changelog import Changelog, Version from debian.changelog import Changelog, Version
from devscripts.logger import Logger from devscripts.logger import Logger
from distro_info import DebianDistroInfo from distro_info import DebianDistroInfo, DistroDataOutdated
from ubuntutools.archive import rmadison, FakeSPPH from ubuntutools.archive import rmadison, FakeSPPH
from ubuntutools.question import confirmation_prompt, YesNoQuestion from ubuntutools.question import confirmation_prompt, YesNoQuestion
@ -49,7 +49,10 @@ def _get_srcpkg(distro, name, release):
if distro == 'debian': if distro == 'debian':
# Canonicalise release: # Canonicalise release:
debian_info = DebianDistroInfo() debian_info = DebianDistroInfo()
try:
release = debian_info.codename(release, default=release) release = debian_info.codename(release, default=release)
except DistroDataOutdated, e:
Logger.warn(e)
lines = list(rmadison(distro, name, suite=release, arch='source')) lines = list(rmadison(distro, name, suite=release, arch='source'))
if not lines: if not lines:

View File

@ -24,15 +24,6 @@ import setup
from ubuntutools import subprocess from ubuntutools import subprocess
from ubuntutools.test import unittest from ubuntutools.test import unittest
BLACKLIST = {
'check-mir': 'No Help',
'check-symbols': 'No Help',
'grep-merges': 'No Help',
'pbuilder-dist-simple': 'No Help',
'setup-packaging-environment': 'Throws Error',
'submittodebian': 'No Help',
'ubuntu-iso': 'No Help',
}
TIMEOUT = 5 TIMEOUT = 5
def load_tests(loader, tests, pattern): def load_tests(loader, tests, pattern):
@ -51,9 +42,6 @@ class HelpTestCase(unittest.TestCase):
@classmethod @classmethod
def make_help_tester(cls, script): def make_help_tester(cls, script):
def tester(self): def tester(self):
if script in BLACKLIST:
raise unittest.SkipTest("Blacklisted: " + BLACKLIST[script])
null = open('/dev/null', 'r') null = open('/dev/null', 'r')
process = subprocess.Popen(['./' + script, '--help'], process = subprocess.Popen(['./' + script, '--help'],
close_fds=True, stdin=null, close_fds=True, stdin=null,

View File

@ -30,6 +30,11 @@ _PREVIOUS_UBUNTU_MAINTAINER = (
) )
_UBUNTU_MAINTAINER = "Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>" _UBUNTU_MAINTAINER = "Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>"
class MaintainerUpdateException(Exception):
pass
class Control(object): class Control(object):
"""Represents a debian/control file""" """Represents a debian/control file"""
@ -79,6 +84,12 @@ class Control(object):
self._content = pattern.sub(r"\1\n" + original_maintainer, self._content = pattern.sub(r"\1\n" + original_maintainer,
self._content) self._content)
def remove_original_maintainer(self):
"""Strip out out the XSBC-Original-Maintainer line"""
pattern = re.compile("^(?:[XSBC]*-)?Original-Maintainer:.*?$.*?^",
re.MULTILINE | re.DOTALL)
self._content = pattern.sub('', self._content)
def _get_distribution(changelog_file): def _get_distribution(changelog_file):
"""get distribution of latest changelog entry""" """get distribution of latest changelog entry"""
@ -88,6 +99,38 @@ def _get_distribution(changelog_file):
# Strip things like "-proposed-updates" or "-security" from distribution # Strip things like "-proposed-updates" or "-security" from distribution
return distribution.split("-", 1)[0] return distribution.split("-", 1)[0]
def _find_files(debian_directory, verbose):
"""Find possible control files.
Returns (changelog, control files list)
Raises an exception if none can be found.
"""
possible_contol_files = [os.path.join(debian_directory, f) for
f in ["control.in", "control"]]
changelog_file = os.path.join(debian_directory, "changelog")
control_files = [f for f in possible_contol_files if os.path.isfile(f)]
# Make sure that a changelog and control file is available
if len(control_files) == 0:
raise MaintainerUpdateException(
"No control file found in %s." % debian_directory)
if not os.path.isfile(changelog_file):
raise MaintainerUpdateException(
"No changelog file found in %s." % debian_directory)
# If the rules file accounts for XSBC-Original-Maintainer, we should not
# touch it in this package (e.g. the python package).
rules_file = os.path.join(debian_directory, "rules")
if os.path.isfile(rules_file) and \
'XSBC-Original-' in open(rules_file).read():
if verbose:
print "XSBC-Original is managed by 'rules' file. Doing nothing."
control_files = []
return (changelog_file, control_files)
def update_maintainer(debian_directory, verbose=False): def update_maintainer(debian_directory, verbose=False):
"""updates the Maintainer field of an Ubuntu package """updates the Maintainer field of an Ubuntu package
@ -99,38 +142,20 @@ def update_maintainer(debian_directory, verbose=False):
Policy: https://wiki.ubuntu.com/DebianMaintainerField Policy: https://wiki.ubuntu.com/DebianMaintainerField
""" """
possible_contol_files = [os.path.join(debian_directory, f) for try:
f in ["control.in", "control"]] changelog_file, control_files = _find_files(debian_directory, verbose)
except MaintainerUpdateException, e:
changelog_file = os.path.join(debian_directory, "changelog") Logger.error(str(e))
control_files = [f for f in possible_contol_files if os.path.isfile(f)] raise
# Make sure that a changelog and control file is available
if len(control_files) == 0:
Logger.error("No control file found in %s.", debian_directory)
return(1)
if not os.path.isfile(changelog_file):
Logger.error("No changelog file found in %s.", debian_directory)
return(1)
# If the rules file accounts for XSBC-Original-Maintainer, we should not
# touch it in this package (e.g. the python package).
rules_file = os.path.join(debian_directory, "rules")
if os.path.isfile(rules_file) and \
'XSBC-Original-' in open(rules_file).read():
if verbose:
print "XSBC-Original is managed by 'rules' file. Doing nothing."
return(0)
distribution = _get_distribution(changelog_file) distribution = _get_distribution(changelog_file)
for control_file in control_files: for control_file in control_files:
control = Control(control_file) control = Control(control_file)
original_maintainer = control.get_maintainer() original_maintainer = control.get_maintainer()
if original_maintainer is None: if original_maintainer is None:
Logger.error("No Maintainer field found in %s.", control_file) Logger.error("No Maintainer field found in %s.", control_file)
return(1) raise MaintainerUpdateException("No Maintainer field found")
if original_maintainer.strip().lower() in _PREVIOUS_UBUNTU_MAINTAINER: if original_maintainer.strip().lower() in _PREVIOUS_UBUNTU_MAINTAINER:
if verbose: if verbose:
@ -149,7 +174,7 @@ def update_maintainer(debian_directory, verbose=False):
if distribution in ("stable", "testing", "unstable", "experimental"): if distribution in ("stable", "testing", "unstable", "experimental"):
if verbose: if verbose:
print "The package targets Debian. Doing nothing." print "The package targets Debian. Doing nothing."
return(0) return
if control.get_original_maintainer() is not None: if control.get_original_maintainer() is not None:
Logger.warn("Overwriting original maintainer: %s", Logger.warn("Overwriting original maintainer: %s",
@ -162,4 +187,24 @@ def update_maintainer(debian_directory, verbose=False):
control.set_maintainer(_UBUNTU_MAINTAINER) control.set_maintainer(_UBUNTU_MAINTAINER)
control.save() control.save()
return(0) return
def restore_maintainer(debian_directory, verbose=False):
"""Restore the original maintainer"""
try:
changelog_file, control_files = _find_files(debian_directory, verbose)
except MaintainerUpdateException, e:
Logger.error(str(e))
raise
for control_file in control_files:
control = Control(control_file)
orig_maintainer = control.get_original_maintainer()
if not orig_maintainer:
continue
if verbose:
print "Restoring original maintainer: %s" % orig_maintainer
control.set_maintainer(orig_maintainer)
control.remove_original_maintainer()
control.save()

View File

@ -18,7 +18,10 @@ import optparse
import os import os
import sys import sys
from ubuntutools.update_maintainer import update_maintainer from ubuntutools.update_maintainer import (update_maintainer,
restore_maintainer,
MaintainerUpdateException)
def main(): def main():
script_name = os.path.basename(sys.argv[0]) script_name = os.path.basename(sys.argv[0])
@ -28,6 +31,9 @@ def main():
parser.add_option("-d", "--debian-directory", dest="debian_directory", parser.add_option("-d", "--debian-directory", dest="debian_directory",
help="location of the 'debian' directory (default: " help="location of the 'debian' directory (default: "
"%default).", metavar="PATH", default="./debian") "%default).", metavar="PATH", default="./debian")
parser.add_option("-r", "--restore",
help="Restore the original maintainer",
action='store_true', default=False)
parser.add_option("-q", "--quiet", help="print no informational messages", parser.add_option("-q", "--quiet", help="print no informational messages",
dest="quiet", action="store_true", default=False) dest="quiet", action="store_true", default=False)
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
@ -37,7 +43,15 @@ def main():
"specified: %s") % (script_name, ", ".join(args)) "specified: %s") % (script_name, ", ".join(args))
sys.exit(1) sys.exit(1)
sys.exit(update_maintainer(options.debian_directory, not options.quiet)) if not options.restore:
operation = update_maintainer
else:
operation = restore_maintainer
try:
operation(options.debian_directory, not options.quiet)
except MaintainerUpdateException:
sys.exit(1)
if __name__ == "__main__": if __name__ == "__main__":
main() main()