diff --git a/backportpackage b/backportpackage index 37f6396..2ff056b 100755 --- a/backportpackage +++ b/backportpackage @@ -18,6 +18,7 @@ # # ################################################################## +import glob import optparse import os import shutil @@ -25,8 +26,8 @@ import sys import tempfile import lsb_release - from devscripts.logger import Logger +from httplib2 import Http, HttpLib2Error from ubuntutools.archive import (SourcePackage, DebianSourcePackage, UbuntuSourcePackage, DownloadError) @@ -85,6 +86,11 @@ def parse(args): parser.add_option('-u', '--upload', metavar='UPLOAD', 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', dest='prompt', default=True, @@ -132,6 +138,8 @@ def parse(args): opts.lpinstance = config.get_value('LPINSTANCE') if opts.upload is None: 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: parser.error('Please specify either a working dir or an upload target!') 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) +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, - builder, update, upload, prompt): + builder, update, upload, keyid, prompt): dirname = '%s-%s' % (pkg.source, release) srcdir = os.path.join(workdir, dirname) @@ -263,16 +296,28 @@ def do_backport(workdir, pkg, suffix, close, release, release_pocket, build, '--distribution', bp_dist, changelog], 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] + changes = fn_base + '_source.changes' if build: if 0 != do_build(workdir, fn_base + '.dsc', release, builder, update): sys.exit(1) + if keyid != False: + cmd = ['debsign'] + if keyid: + cmd.append('-k' + keyid) + cmd.append(changes) + check_call(cmd, cwd=workdir) if upload: - do_upload(workdir, pkg.source, bp_version, fn_base + '_source.changes', - upload, prompt) + do_upload(workdir, pkg.source, bp_version, changes, upload, prompt) shutil.rmtree(srcdir) @@ -318,6 +363,7 @@ def main(args): opts.builder, opts.update, opts.upload, + opts.key, opts.prompt) except DownloadError, e: error(str(e)) diff --git a/check-mir b/check-mir index a63bd99..2d707db 100755 --- a/check-mir +++ b/check-mir @@ -21,10 +21,13 @@ # this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -import apt import sys +import optparse import os.path +import apt + + def check_support(apt_cache, pkgname, alt=False): '''Check if pkgname is in main or restricted. @@ -118,6 +121,11 @@ def check_binary_dependencies(apt_cache, control): return any_unsupported 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() if not os.path.exists('debian/control'): diff --git a/check-symbols b/check-symbols index c0a0a03..bcb8b7f 100755 --- a/check-symbols +++ b/check-symbols @@ -29,21 +29,55 @@ # * nm (from binutils) 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="" DEBUG=False -if [[ -z $1 ]]; then - echo "Missing argument: source package name." - exit 1 +usage() { + prog=$(basename $0) + cat <&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 -if [[ -z $2 ]]; then - DEBDIR="/var/cache/pbuilder/result" -else - DEBDIR="$2" -fi +VERSION=$(apt-cache madison "$PACKAGE" | grep -- "$DISTRO"'/.*Sources$' | awk '{print $3}') +PACKAGES=$(apt-cache showsrc "$PACKAGE" | grep-dctrl -s Binary -F Version "$VERSION" | sed 's/Binary\:\ //g;s/\,//g' | sort -u) if [ `id -u` != "0" ] then @@ -67,7 +101,7 @@ do done if [[ -z $DEBLINE ]]; then - echo "Package doesn't exist: $1." + echo "Package doesn't exist: $PACKAGE." exit 1 fi diff --git a/debian/changelog b/debian/changelog index fe3261a..4b90ee6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,25 @@ ubuntu-dev-tools (0.142) UNRELEASED; urgency=low * mk-sbuild: Support kmod, when checking for overlayfs availability. * pbuilder-dist: improve bash_completion for *.dsc files. Thanks Maarten 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 ] * backportpackage: Add -c, --close flag to include a changelog closer. diff --git a/dgetlp b/dgetlp index 91337dc..f114848 100755 --- a/dgetlp +++ b/dgetlp @@ -43,6 +43,7 @@ except ImportError: sys.exit(1) from ubuntutools import subprocess +import ubuntutools.misc USAGE = u"""Usage: %prog [-d|(-v|-q)] @@ -253,6 +254,8 @@ def main(): default=False, help="Never print any output") (options, args) = parser.parse_args() + ubuntutools.misc.require_utf8() + if len(args) != 1: parser.error("Missing URL") Debug = options.debug diff --git a/grep-merges b/grep-merges index 20023a0..d9cfb3a 100755 --- a/grep-merges +++ b/grep-merges @@ -19,6 +19,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import optparse import sys import json @@ -28,12 +29,19 @@ import ubuntutools.misc def main(): - ubuntutools.misc.require_utf8() - if len(sys.argv) > 1: - match = sys.argv[1] + parser = optparse.OptionParser(usage='%prog [options] [string]', + description='List pending merges from Debian matching string') + args = parser.parse_args()[1] + + if len(args) > 1: + parser.error('Too many arguments') + elif len(args) == 1: + match = args[0] else: match = None + ubuntutools.misc.require_utf8() + for component in ('main', 'main-manual', 'restricted', 'restricted-manual', 'universe', 'universe-manual', diff --git a/mk-sbuild b/mk-sbuild index d79f672..e11d959 100755 --- a/mk-sbuild +++ b/mk-sbuild @@ -175,9 +175,15 @@ done # will not exist in the chroot. cd / -# Make sure we've got a regular user -if [ -w /etc/passwd ]; then - echo "Please run this script as a regular user, not root." >&2 +if [ -w /etc/passwd -a ! -e ~/.sbuildrc -a ! -e ~/.mk-sbuild.rc ]; then + cat >&2 < 1: # Custom distribution specified. version = str(args[1]) else: - version = os.getenv('DIST') or ubuntu_info.devel() + try: + version = os.getenv('DIST') or ubuntu_info.devel() + except DistroDataOutdated, e: + Logger.warn("%s\nOr specify a distribution.", e) + sys.exit(1) component = None # Release, not package version number: diff --git a/requestsync b/requestsync index c6b01c0..f5956b9 100755 --- a/requestsync +++ b/requestsync @@ -31,7 +31,7 @@ import os import sys 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.lp import udtexceptions @@ -45,8 +45,11 @@ from ubuntutools.question import confirmation_prompt, EditBugReport def main(): ubu_info = UbuntuDistroInfo() DEFAULT_SOURCE = 'unstable' - if ubu_info.is_lts(ubu_info.devel()): - DEFAULT_SOURCE = 'testing' + try: + if ubu_info.is_lts(ubu_info.devel()): + DEFAULT_SOURCE = 'testing' + except DistroDataOutdated, e: + print >> sys.stderr, str(e) # Our usage options. usage = ('Usage: %prog [options] ' diff --git a/reverse-depends b/reverse-depends index d54857b..89d7ef0 100755 --- a/reverse-depends +++ b/reverse-depends @@ -18,6 +18,7 @@ import optparse import sys from devscripts.logger import Logger +from distro_info import DistroDataOutdated from ubuntutools.misc import (system_distribution, vendor_to_distroinfo, codename_to_distribution) @@ -26,15 +27,21 @@ from ubuntutools.rdepends import query_rdepends, RDependsException def main(): 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', description="List reverse-dependencies of package. " "If the package name is prefixed with src: then the " "reverse-dependencies of all the binary packages that " "the specified source package builds will be listed.") parser.add_option('-r', '--release', metavar='RELEASE', - default=system_distro_info.devel(), + default=default_release, help='Query dependencies in RELEASE. ' - 'Default: %s' % system_distro_info.devel()) + 'Default: %s' % default_release) parser.add_option('-R', '--without-recommends', action='store_false', dest='recommends', default=True, help='Only consider Depends relationships, ' @@ -76,8 +83,12 @@ def main(): if not distribution: parser.error('Unknown release codename %s' % options.release) distro_info = vendor_to_distroinfo(distribution)() - options.release = distro_info.codename(options.release, - default=options.release) + try: + options.release = distro_info.codename(options.release, + default=options.release) + except DistroDataOutdated: + # We already printed a warning + pass try: data = query_rdepends(package, options.release, options.arch, **opts) diff --git a/setup-packaging-environment b/setup-packaging-environment index 2144011..dce699c 100755 --- a/setup-packaging-environment +++ b/setup-packaging-environment @@ -37,6 +37,31 @@ await_response() { echo } +usage() { + prog=$(basename $0) + cat <