mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 16:11:15 +00:00
pbuilder-dist: Use ubuntutools.logger.
This commit is contained in:
commit
eb22cc206b
3
debian/changelog
vendored
3
debian/changelog
vendored
@ -9,8 +9,9 @@ ubuntu-dev-tools (0.113) UNRELEASED; urgency=low
|
|||||||
(LP: #706010)
|
(LP: #706010)
|
||||||
* bash_completion/pbuilder-dist: Use *-distro-info to determine pbuilder
|
* bash_completion/pbuilder-dist: Use *-distro-info to determine pbuilder
|
||||||
file names.
|
file names.
|
||||||
|
* pbuilder-dist: Use ubuntutools.logger.
|
||||||
|
|
||||||
-- Stefano Rivera <stefanor@ubuntu.com> Sat, 22 Jan 2011 15:17:15 +0200
|
-- Stefano Rivera <stefanor@ubuntu.com> Sat, 22 Jan 2011 17:55:56 +0200
|
||||||
|
|
||||||
ubuntu-dev-tools (0.112) unstable; urgency=low
|
ubuntu-dev-tools (0.112) unstable; urgency=low
|
||||||
|
|
||||||
|
2
debian/copyright
vendored
2
debian/copyright
vendored
@ -70,7 +70,7 @@ Copyright: 2007-2010, Canonical Ltd.
|
|||||||
2006-2007, Pete Savage <petesavage@ubuntu.com>
|
2006-2007, Pete Savage <petesavage@ubuntu.com>
|
||||||
2009, Ryan Kavanagh <ryanakca@kubuntu.org>
|
2009, Ryan Kavanagh <ryanakca@kubuntu.org>
|
||||||
2007, Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
2007, Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
||||||
2010, Stefano Rivera <stefanor@ubuntu.com>
|
2010-2011, Stefano Rivera <stefanor@ubuntu.com>
|
||||||
2008, Terence Simpson <tsimpson@ubuntu.com>
|
2008, Terence Simpson <tsimpson@ubuntu.com>
|
||||||
License: GPL-2+
|
License: GPL-2+
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007-2010 Siegfried-A. Gevatter <rainct@ubuntu.com>
|
# Copyright (C) 2007-2010, Siegfried-A. Gevatter <rainct@ubuntu.com>,
|
||||||
# With some changes by Iain Lane <iain@orangesquash.org.uk>,
|
# 2010-2011, Stefano Rivera <stefanor@ubuntu.com>
|
||||||
# Stefano Rivera <stefanor@ubuntu.com>
|
# With some changes by Iain Lane <iain@orangesquash.org.uk>
|
||||||
# Based upon pbuilder-dist-simple by Jamin Collins and Jordan Mantha.
|
# Based upon pbuilder-dist-simple by Jamin Collins and Jordan Mantha.
|
||||||
#
|
#
|
||||||
# ##################################################################
|
# ##################################################################
|
||||||
@ -34,6 +34,7 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from ubuntutools.distro_info import DebianDistroInfo
|
from ubuntutools.distro_info import DebianDistroInfo
|
||||||
|
from ubuntutools.logger import Logger
|
||||||
import ubuntutools.misc
|
import ubuntutools.misc
|
||||||
|
|
||||||
class PbuilderDist:
|
class PbuilderDist:
|
||||||
@ -82,7 +83,7 @@ class PbuilderDist:
|
|||||||
paths = set(os.environ['PATH'].split(':'))
|
paths = set(os.environ['PATH'].split(':'))
|
||||||
paths |= set(('/sbin', '/usr/sbin', '/usr/local/sbin'))
|
paths |= set(('/sbin', '/usr/sbin', '/usr/local/sbin'))
|
||||||
if not any(os.path.exists(os.path.join(p, builder)) for p in paths):
|
if not any(os.path.exists(os.path.join(p, builder)) for p in paths):
|
||||||
print >> sys.stderr, 'Error: Could not find "%s".' % builder
|
Logger.error('Could not find "%s".', builder)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
##############################################################
|
##############################################################
|
||||||
@ -91,20 +92,18 @@ class PbuilderDist:
|
|||||||
'~/pbuilder/'))
|
'~/pbuilder/'))
|
||||||
|
|
||||||
if 'SUDO_USER' in os.environ:
|
if 'SUDO_USER' in os.environ:
|
||||||
print >> sys.stderr, ("Warning: pbuilder-dist running under sudo. "
|
Logger.warn('Running under sudo. '
|
||||||
"This is probably not what you want. "
|
'This is probably not what you want. '
|
||||||
"pbuilder-dist will use sudo itself, "
|
'pbuilder-dist will use sudo itself, when necessary.')
|
||||||
"when necessary.")
|
|
||||||
if os.stat(os.environ['HOME']).st_uid != os.getuid():
|
if os.stat(os.environ['HOME']).st_uid != os.getuid():
|
||||||
print >> sys.stderr, "Error: You don't own $HOME"
|
Logger.error("Error: You don't own $HOME")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if not os.path.isdir(self.base):
|
if not os.path.isdir(self.base):
|
||||||
try:
|
try:
|
||||||
os.makedirs(self.base)
|
os.makedirs(self.base)
|
||||||
except OSError:
|
except OSError:
|
||||||
print >> sys.stderr, ('Error: Cannot create base directory "%s"'
|
Logger.error('Cannot create base directory "%s"', self.base)
|
||||||
% self.base)
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if 'PBUILDAUTH' in os.environ:
|
if 'PBUILDAUTH' in os.environ:
|
||||||
@ -126,8 +125,7 @@ class PbuilderDist:
|
|||||||
variable or finalize pbuilder-dist's execution.
|
variable or finalize pbuilder-dist's execution.
|
||||||
"""
|
"""
|
||||||
if not distro.isalpha():
|
if not distro.isalpha():
|
||||||
print >> sys.stderr, ('Error: "%s" is an invalid distribution '
|
Logger.error('"%s" is an invalid distribution codename.', distro)
|
||||||
'codename.' % distro)
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if not os.path.isfile(os.path.join('/usr/share/debootstrap/scripts/',
|
if not os.path.isfile(os.path.join('/usr/share/debootstrap/scripts/',
|
||||||
@ -141,7 +139,7 @@ class PbuilderDist:
|
|||||||
if answer not in ('y', 'Y'):
|
if answer not in ('y', 'Y'):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
print >> sys.stderr, 'Please install package "debootstrap".'
|
Logger.error('Please install package "debootstrap".')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
self.target_distro = distro
|
self.target_distro = distro
|
||||||
@ -161,13 +159,12 @@ class PbuilderDist:
|
|||||||
self.operation = 'build'
|
self.operation = 'build'
|
||||||
return [operation]
|
return [operation]
|
||||||
else:
|
else:
|
||||||
print >> sys.stderr, ('Error: Could not find file "%s".'
|
Logger.error('Could not find file "%s".', operation)
|
||||||
% operation)
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
print >> sys.stderr, ('Error: "%s" is not a recognized '
|
Logger.error('"%s" is not a recognized argument.\n'
|
||||||
'argument.\nPlease use one of these: '
|
'Please use one of these: %s.',
|
||||||
'%s.') % (operation, ', '.join(arguments))
|
operation, ', '.join(arguments))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
self.operation = operation
|
self.operation = operation
|
||||||
@ -202,8 +199,7 @@ class PbuilderDist:
|
|||||||
try:
|
try:
|
||||||
os.makedirs(result)
|
os.makedirs(result)
|
||||||
except OSError:
|
except OSError:
|
||||||
print >> sys.stderr, ('Error: Cannot create results directory '
|
Logger.error('Cannot create results directory "%s"', result)
|
||||||
'"%s"' % result)
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
arguments = [
|
arguments = [
|
||||||
@ -219,10 +215,7 @@ class PbuilderDist:
|
|||||||
elif self.builder == 'cowbuilder':
|
elif self.builder == 'cowbuilder':
|
||||||
arguments += ['--basepath', prefix + '-base.cow']
|
arguments += ['--basepath', prefix + '-base.cow']
|
||||||
else:
|
else:
|
||||||
print >> sys.stderr, 'Error: Unrecognized builder "%s".' % \
|
Logger.error('Unrecognized builder "%s".', self.builder)
|
||||||
self.builder
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
if self.logfile:
|
if self.logfile:
|
||||||
arguments += ['--logfile', self.logfile]
|
arguments += ['--logfile', self.logfile]
|
||||||
@ -260,7 +253,7 @@ class PbuilderDist:
|
|||||||
and self.target_distro not in self._debian_distros):
|
and self.target_distro not in self._debian_distros):
|
||||||
if not os.path.exists(
|
if not os.path.exists(
|
||||||
'/usr/share/keyrings/ubuntu-archive-keyring.gpg'):
|
'/usr/share/keyrings/ubuntu-archive-keyring.gpg'):
|
||||||
print >> sys.stderr, 'Error: ubuntu-keyring not installed'
|
Logger.error('ubuntu-keyring not installed')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
arguments += [
|
arguments += [
|
||||||
'--debootstrapopts',
|
'--debootstrapopts',
|
||||||
@ -270,8 +263,7 @@ class PbuilderDist:
|
|||||||
and self.target_distro in self._debian_distros):
|
and self.target_distro in self._debian_distros):
|
||||||
if not os.path.exists(
|
if not os.path.exists(
|
||||||
'/usr/share/keyrings/debian-archive-keyring.gpg'):
|
'/usr/share/keyrings/debian-archive-keyring.gpg'):
|
||||||
print >> sys.stderr, ('Error: debian-archive-keyring not '
|
Logger.error('debian-archive-keyring not installed')
|
||||||
'installed')
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
arguments += [
|
arguments += [
|
||||||
'--debootstrapopts',
|
'--debootstrapopts',
|
||||||
@ -344,12 +336,12 @@ def main():
|
|||||||
|
|
||||||
if ('-' in script_name and parts[0] not in ('pbuilder', 'cowbuilder')
|
if ('-' in script_name and parts[0] not in ('pbuilder', 'cowbuilder')
|
||||||
or len(parts) > 3):
|
or len(parts) > 3):
|
||||||
print >> sys.stderr, ('Error: "%s" is not a valid name for a '
|
Logger.error('"%s" is not a valid name for a "pbuilder-dist" '
|
||||||
'"pbuilder-dist" executable.') % script_name
|
'executable.', script_name)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if len(args) < 1:
|
if len(args) < 1:
|
||||||
print >> sys.stderr, 'Insufficient number of arguments.'
|
Logger.error('Insufficient number of arguments.')
|
||||||
show_help(1)
|
show_help(1)
|
||||||
|
|
||||||
if args[0] in ('-h', '--help', 'help'):
|
if args[0] in ('-h', '--help', 'help'):
|
||||||
@ -391,15 +383,14 @@ def main():
|
|||||||
args.remove('--main-only')
|
args.remove('--main-only')
|
||||||
|
|
||||||
if len(args) < 1:
|
if len(args) < 1:
|
||||||
print >> sys.stderr, 'Insufficient number of arguments.'
|
Logger.error('Insufficient number of arguments.')
|
||||||
show_help(1)
|
show_help(1)
|
||||||
|
|
||||||
# Parse the operation
|
# Parse the operation
|
||||||
args = app.set_operation(args.pop(0)) + args
|
args = app.set_operation(args.pop(0)) + args
|
||||||
|
|
||||||
if app.operation == 'build' and '.dsc' not in ' '.join(args):
|
if app.operation == 'build' and '.dsc' not in ' '.join(args):
|
||||||
print >> sys.stderr, ('Error: You have to specify a .dsc file '
|
Logger.error('You have to specify a .dsc file if you want to build.')
|
||||||
'if you want to build.')
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Execute the pbuilder command
|
# Execute the pbuilder command
|
||||||
@ -412,5 +403,5 @@ if __name__ == '__main__':
|
|||||||
try:
|
try:
|
||||||
main()
|
main()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print >> sys.stderr, 'Manually aborted.'
|
Logger.error('Manually aborted.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user