mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-10 08:21:29 +00:00
* 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:
commit
0f5ab96310
@ -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))
|
||||
|
10
check-mir
10
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'):
|
||||
|
@ -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 <<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
|
||||
|
||||
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
|
||||
|
||||
|
19
debian/changelog
vendored
19
debian/changelog
vendored
@ -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.
|
||||
|
3
dgetlp
3
dgetlp
@ -43,6 +43,7 @@ except ImportError:
|
||||
sys.exit(1)
|
||||
|
||||
from ubuntutools import subprocess
|
||||
import ubuntutools.misc
|
||||
|
||||
USAGE = u"""Usage: %prog [-d|(-v|-q)] <Launchpad URL>
|
||||
|
||||
@ -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
|
||||
|
14
grep-merges
14
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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',
|
||||
|
12
mk-sbuild
12
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 <<EOF
|
||||
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
|
||||
fi
|
||||
|
||||
|
@ -33,7 +33,7 @@ import os
|
||||
import sys
|
||||
|
||||
from devscripts.logger import Logger
|
||||
from distro_info import DebianDistroInfo, UbuntuDistroInfo
|
||||
from distro_info import DebianDistroInfo, UbuntuDistroInfo, DistroDataOutdated
|
||||
|
||||
import ubuntutools.misc
|
||||
from ubuntutools.config import UDTConfig
|
||||
@ -266,11 +266,17 @@ class PbuilderDist:
|
||||
othermirrors = []
|
||||
if self.target_distro in self._debian_distros:
|
||||
debian_info = DebianDistroInfo()
|
||||
if (debian_info.codename(self.target_distro) or self.target_distro
|
||||
in (debian_info.devel(), 'experimental')):
|
||||
try:
|
||||
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_updates = False
|
||||
self.enable_proposed = False
|
||||
elif codename == 'testing':
|
||||
self.enable_updates = False
|
||||
|
||||
if self.enable_security:
|
||||
othermirrors.append('deb %s %s/updates %s'
|
||||
@ -283,7 +289,13 @@ class PbuilderDist:
|
||||
othermirrors.append('deb %s %s-proposed-updates %s'
|
||||
% (mirror, self.target_distro, components))
|
||||
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_updates = False
|
||||
self.enable_proposed = False
|
||||
|
@ -30,29 +30,44 @@ OPERATION=$1
|
||||
DISTRIBUTION=`basename $0 | cut -f2 -d '-'`
|
||||
PROCEED=false
|
||||
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
|
||||
create|update|build|clean|login|execute)
|
||||
PROCEED=true
|
||||
;;
|
||||
-h|--help)
|
||||
usage 0
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
if [ $PROCEED = true ]; then
|
||||
shift
|
||||
if [ ! -d $BASE_DIR/${DISTRIBUTION}_result ]
|
||||
then mkdir -p $BASE_DIR/${DISTRIBUTION}_result/
|
||||
if [ ! -d $BASE_DIR/${DISTRIBUTION}_result ]; then
|
||||
mkdir -p $BASE_DIR/${DISTRIBUTION}_result/
|
||||
fi
|
||||
sudo pbuilder $OPERATION \
|
||||
--basetgz $BASE_DIR/$DISTRIBUTION-base.tgz \
|
||||
--distribution $DISTRIBUTION \
|
||||
--buildresult $BASE_DIR/$DISTRIBUTION_result \
|
||||
--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
|
||||
--othermirror "deb http://archive.ubuntu.com/ubuntu $DISTRIBUTION universe multiverse" "$@"
|
||||
|
@ -22,7 +22,7 @@ import sys
|
||||
import urllib2
|
||||
|
||||
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.config import UDTConfig
|
||||
@ -52,7 +52,10 @@ def is_suite(version):
|
||||
|
||||
def source_package_for(binary, release):
|
||||
"""Query DDE to find the source package for a particular binary"""
|
||||
try:
|
||||
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'
|
||||
% (release, binary))
|
||||
try:
|
||||
|
@ -30,7 +30,7 @@ import urllib2
|
||||
from optparse import OptionParser
|
||||
|
||||
from devscripts.logger import Logger
|
||||
from distro_info import UbuntuDistroInfo
|
||||
from distro_info import UbuntuDistroInfo, DistroDataOutdated
|
||||
|
||||
from ubuntutools.archive import UbuntuSourcePackage, DownloadError
|
||||
from ubuntutools.config import UDTConfig
|
||||
@ -89,7 +89,11 @@ def main():
|
||||
if len(args) > 1: # Custom distribution specified.
|
||||
version = str(args[1])
|
||||
else:
|
||||
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:
|
||||
|
@ -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'
|
||||
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] '
|
||||
|
@ -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)()
|
||||
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)
|
||||
|
@ -37,6 +37,31 @@ await_response() {
|
||||
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" ]
|
||||
|
@ -22,17 +22,19 @@
|
||||
#
|
||||
# ##################################################################
|
||||
|
||||
import optparse
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
from tempfile import mkdtemp
|
||||
|
||||
from distro_info import UbuntuDistroInfo
|
||||
from distro_info import UbuntuDistroInfo, DistroDataOutdated
|
||||
|
||||
from ubuntutools.config import ubu_email
|
||||
from ubuntutools.question import YesNoQuestion, EditFile
|
||||
from ubuntutools.subprocess import call, check_call, Popen, PIPE
|
||||
from ubuntutools.update_maintainer import update_maintainer, restore_maintainer
|
||||
|
||||
try:
|
||||
from debian.changelog import Changelog
|
||||
@ -69,6 +71,13 @@ Thanks for considering the patch.
|
||||
""" % ("\n".join([a for a in entry.changes()]))
|
||||
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):
|
||||
pkg = changelog.package
|
||||
|
||||
@ -118,7 +127,11 @@ def check_file(fname, critical = True):
|
||||
sys.exit(1)
|
||||
|
||||
def submit_bugreport(body, debdiff, deb_version, changelog):
|
||||
try:
|
||||
devel = UbuntuDistroInfo().devel()
|
||||
except DistroDataOutdated, e:
|
||||
print str(e)
|
||||
devel = ''
|
||||
|
||||
if os.path.dirname(sys.argv[0]).startswith('/usr/bin'):
|
||||
editor_path = '/usr/share/ubuntu-dev-tools'
|
||||
@ -190,6 +203,10 @@ reportbug --configure for its configuration wizard.
|
||||
sys.exit(1)
|
||||
|
||||
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()
|
||||
changelog_file = (check_file('debian/changelog', critical = False) or
|
||||
check_file('../debian/changelog'))
|
||||
@ -204,8 +221,16 @@ def main():
|
||||
fp.write(bug_body)
|
||||
fp.close()
|
||||
|
||||
restore_maintainer('debian')
|
||||
build_source_package()
|
||||
update_maintainer('debian')
|
||||
|
||||
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)
|
||||
|
||||
submit_bugreport(body, debdiff, deb_version, changelog)
|
||||
|
12
syncpackage
12
syncpackage
@ -31,7 +31,7 @@ import urllib
|
||||
|
||||
import debian.debian_support
|
||||
from devscripts.logger import Logger
|
||||
from distro_info import UbuntuDistroInfo
|
||||
from distro_info import UbuntuDistroInfo, DistroDataOutdated
|
||||
from lazr.restfulclient.errors import HTTPError
|
||||
|
||||
from ubuntutools.archive import (DebianSourcePackage, UbuntuSourcePackage,
|
||||
@ -294,7 +294,15 @@ def fetch_source_pkg(package, dist, version, component, ubuntu_release,
|
||||
|
||||
if dist is None:
|
||||
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
|
||||
if type(version) == str:
|
||||
version = Version(version)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#
|
||||
# ##################################################################
|
||||
|
||||
import optparse
|
||||
import sys
|
||||
|
||||
from ubuntutools import subprocess
|
||||
@ -37,7 +38,10 @@ def extract(iso, path):
|
||||
return stdout
|
||||
|
||||
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
|
||||
|
||||
for iso in isos:
|
||||
|
@ -24,7 +24,7 @@ import re
|
||||
|
||||
from debian.deb822 import Changes
|
||||
from devscripts.logger import Logger
|
||||
from distro_info import DebianDistroInfo
|
||||
from distro_info import DebianDistroInfo, DistroDataOutdated
|
||||
from httplib2 import Http, HttpLib2Error
|
||||
|
||||
from ubuntutools.lp.lpapicache import (Launchpad, Distribution, PersonTeam,
|
||||
@ -35,7 +35,10 @@ def get_debian_srcpkg(name, release):
|
||||
debian = Distribution('debian')
|
||||
debian_archive = debian.getArchive()
|
||||
|
||||
try:
|
||||
release = DebianDistroInfo().codename(release, None, release)
|
||||
except DistroDataOutdated, e:
|
||||
Logger.warn(e)
|
||||
|
||||
return debian_archive.getSourcePackage(name, release)
|
||||
|
||||
|
@ -29,7 +29,7 @@ import tempfile
|
||||
|
||||
from debian.changelog import Changelog, Version
|
||||
from devscripts.logger import Logger
|
||||
from distro_info import DebianDistroInfo
|
||||
from distro_info import DebianDistroInfo, DistroDataOutdated
|
||||
|
||||
from ubuntutools.archive import rmadison, FakeSPPH
|
||||
from ubuntutools.question import confirmation_prompt, YesNoQuestion
|
||||
@ -49,7 +49,10 @@ def _get_srcpkg(distro, name, release):
|
||||
if distro == 'debian':
|
||||
# Canonicalise release:
|
||||
debian_info = DebianDistroInfo()
|
||||
try:
|
||||
release = debian_info.codename(release, default=release)
|
||||
except DistroDataOutdated, e:
|
||||
Logger.warn(e)
|
||||
|
||||
lines = list(rmadison(distro, name, suite=release, arch='source'))
|
||||
if not lines:
|
||||
|
@ -24,15 +24,6 @@ import setup
|
||||
from ubuntutools import subprocess
|
||||
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
|
||||
|
||||
def load_tests(loader, tests, pattern):
|
||||
@ -51,9 +42,6 @@ class HelpTestCase(unittest.TestCase):
|
||||
@classmethod
|
||||
def make_help_tester(cls, script):
|
||||
def tester(self):
|
||||
if script in BLACKLIST:
|
||||
raise unittest.SkipTest("Blacklisted: " + BLACKLIST[script])
|
||||
|
||||
null = open('/dev/null', 'r')
|
||||
process = subprocess.Popen(['./' + script, '--help'],
|
||||
close_fds=True, stdin=null,
|
||||
|
@ -30,6 +30,11 @@ _PREVIOUS_UBUNTU_MAINTAINER = (
|
||||
)
|
||||
_UBUNTU_MAINTAINER = "Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>"
|
||||
|
||||
|
||||
class MaintainerUpdateException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class Control(object):
|
||||
"""Represents a debian/control file"""
|
||||
|
||||
@ -79,6 +84,12 @@ class Control(object):
|
||||
self._content = pattern.sub(r"\1\n" + original_maintainer,
|
||||
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):
|
||||
"""get distribution of latest changelog entry"""
|
||||
@ -88,6 +99,38 @@ def _get_distribution(changelog_file):
|
||||
# Strip things like "-proposed-updates" or "-security" from distribution
|
||||
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):
|
||||
"""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
|
||||
"""
|
||||
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:
|
||||
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)
|
||||
try:
|
||||
changelog_file, control_files = _find_files(debian_directory, verbose)
|
||||
except MaintainerUpdateException, e:
|
||||
Logger.error(str(e))
|
||||
raise
|
||||
|
||||
distribution = _get_distribution(changelog_file)
|
||||
|
||||
for control_file in control_files:
|
||||
control = Control(control_file)
|
||||
original_maintainer = control.get_maintainer()
|
||||
|
||||
if original_maintainer is None:
|
||||
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 verbose:
|
||||
@ -149,7 +174,7 @@ def update_maintainer(debian_directory, verbose=False):
|
||||
if distribution in ("stable", "testing", "unstable", "experimental"):
|
||||
if verbose:
|
||||
print "The package targets Debian. Doing nothing."
|
||||
return(0)
|
||||
return
|
||||
|
||||
if control.get_original_maintainer() is not None:
|
||||
Logger.warn("Overwriting original maintainer: %s",
|
||||
@ -162,4 +187,24 @@ def update_maintainer(debian_directory, verbose=False):
|
||||
control.set_maintainer(_UBUNTU_MAINTAINER)
|
||||
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()
|
||||
|
@ -18,7 +18,10 @@ import optparse
|
||||
import os
|
||||
import sys
|
||||
|
||||
from ubuntutools.update_maintainer import update_maintainer
|
||||
from ubuntutools.update_maintainer import (update_maintainer,
|
||||
restore_maintainer,
|
||||
MaintainerUpdateException)
|
||||
|
||||
|
||||
def main():
|
||||
script_name = os.path.basename(sys.argv[0])
|
||||
@ -28,6 +31,9 @@ def main():
|
||||
parser.add_option("-d", "--debian-directory", dest="debian_directory",
|
||||
help="location of the 'debian' directory (default: "
|
||||
"%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",
|
||||
dest="quiet", action="store_true", default=False)
|
||||
(options, args) = parser.parse_args()
|
||||
@ -37,7 +43,15 @@ def main():
|
||||
"specified: %s") % (script_name, ", ".join(args))
|
||||
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__":
|
||||
main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user