* debian/control:

- Improve description of pbuilder-dist and mention cowbuilder-dist.
  * pbuilder-dist:
     - Abort if the host's architecture can't be determined.
     - Error out instead of showing a traceback if pbuilder-dist is called
       without any argument.
  * pbuilder-dist, ubuntutools/misc.py:
     - Move the functions used to determine the hosts architecture and
       distribution to the ubuntutools.misc module.
This commit is contained in:
Siegfried-Angel Gevatter Pujals 2009-10-25 13:57:39 +01:00
parent c293aa80cf
commit ab78b51a9f
3 changed files with 81 additions and 51 deletions

15
debian/changelog vendored
View File

@ -1,22 +1,29 @@
ubuntu-dev-tools (0.82) UNRELEASED; urgency=low ubuntu-dev-tools (0.82) UNRELEASED; urgency=low
[ Iain Lane ] [ Iain Lane ]
* debian/control: Readd XS-Python-Version - this is more standard * debian/control: Re-add XS-Python-Version - this is more standard
* debian/pyversions: Drop * debian/pyversions: Drop
[ Nathan Handler ] [ Nathan Handler ]
* debian/control: Mention lp-project-upload in Description * debian/control: Mention lp-project-upload in Description
[ Siegfried-Angel Gevatter Pujals ] [ Siegfried-Angel Gevatter Pujals ]
* debian/control: Improve description of pbuilder-dist and mention * debian/control:
cowbuilder-dist. - Improve description of pbuilder-dist and mention cowbuilder-dist.
* pbuilder-dist:
- Abort if the host's architecture can't be determined.
- Error out instead of showing a traceback if pbuilder-dist is called
without any argument.
* pbuilder-dist, ubuntutools/misc.py:
- Move the functions used to determine the hosts architecture and
distribution to the ubuntutools.misc module.
[ Luca Falavigna ] [ Luca Falavigna ]
* ubuntutools/requestsync/lp.py: explicitly import exceptions for * ubuntutools/requestsync/lp.py: explicitly import exceptions for
backward compatibility with Python 2.5. backward compatibility with Python 2.5.
* debian/control: re-enable support for python2.5. * debian/control: re-enable support for python2.5.
-- Luca Falavigna <dktrkranz@debian.org> Mon, 19 Oct 2009 20:46:33 +0200 -- Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com> Sun, 25 Oct 2009 13:46:58 +0100
ubuntu-dev-tools (0.81) karmic; urgency=low ubuntu-dev-tools (0.81) karmic; urgency=low

View File

@ -31,6 +31,8 @@
import sys import sys
import os import os
import ubuntutools.misc
debian_distros = ['etch', 'lenny', 'squeeze', 'sid', 'stable', \ debian_distros = ['etch', 'lenny', 'squeeze', 'sid', 'stable', \
'testing', 'unstable', 'experimental'] 'testing', 'unstable', 'experimental']
@ -93,28 +95,9 @@ class pbuilder_dist:
if 'PBUILDAUTH' in os.environ: if 'PBUILDAUTH' in os.environ:
self.auth = os.environ['PBUILDAUTH'] self.auth = os.environ['PBUILDAUTH']
self.system_architecture = host_architecture() self.system_architecture = ubuntutools.misc.host_architecture()
self.system_distro = ubuntutools.misc.system_distribution()
if not self.system_architecture or 'not found' in self.system_architecture: if not self.system_architecture or not self.system_distro:
print 'Error: Not running on a Debian based system; could not detect its architecture.'
if os.path.isfile('/etc/lsb-release'):
for line in open('/etc/lsb-release'):
line = line.strip()
if line.startswith('DISTRIB_CODENAME'):
self.system_distro = line[17:]
break
else:
import commands
output = commands.getoutput('lsb_release -c').split()
if len(output) == 2:
self.system_distro = output[1]
else:
print 'Error: Not running on a Debian based system; could not find lsb_release.'
exit(1)
if not self.system_distro:
print 'Error: Could not determine what distribution you are running.'
exit(1) exit(1)
self.target_distro = self.system_distro self.target_distro = self.system_distro
@ -255,16 +238,6 @@ class pbuilder_dist:
return self.auth + ' /usr/sbin/' + self.builder + ' ' + ' '.join(arguments) return self.auth + ' /usr/sbin/' + self.builder + ' ' + ' '.join(arguments)
def host_architecture():
""" host_architecture -> string
Detect the host's architecture and return it as a string
(i386/amd64/other values).
"""
return os.uname()[4].replace('x86_64', 'amd64').replace('i586', 'i386').replace('i686', 'i386')
def ask(question): def ask(question):
""" ask(question) -> string """ ask(question) -> string
@ -330,7 +303,7 @@ def main():
if len(parts) > 2: if len(parts) > 2:
requested_arch = parts[2] requested_arch = parts[2]
elif args[0] in ('i386', 'amd64'): elif len(args) > 0 and args[0] in ('i386', 'amd64'):
requested_arch = args.pop(0) requested_arch = args.pop(0)
else: else:
requested_arch = None requested_arch = None

View File

@ -1,28 +1,78 @@
# #
# misc.py - misc functions for the Ubuntu Developer Tools scripts. # misc.py - misc functions for the Ubuntu Developer Tools scripts.
# #
# Copyright (C) 2008 Jonathan Davies <jpds@ubuntu.com> # Copyright (C) 2008 Jonathan Davies <jpds@ubuntu.com>
# Copyright (C) 2008 Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com> # Copyright (C) 2008-2009 Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
# #
# This program is free software; you can redistribute it and/or # ##################################################################
# modify it under the terms of the GNU General Public License #
# as published by the Free Software Foundation; either version 3 # This program is free software; you can redistribute it and/or
# of the License, or (at your option) any later version. # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# Please see the /usr/share/common-licenses/GPL file for the full text of # See file /usr/share/common-licenses/GPL for more details.
# the GNU General Public License license.
# #
# ##################################################################
# Modules. # Modules.
import os import os
def system_distribution():
""" system_distro() -> string
Detect the system's distribution and return it as a string. If the
name of the distribution can't be determined, print an error message
and return None.
"""
# We try to avoid calling the "lsb_release" as looking up the value
# directly is faster. However, Debian doesn't have /etc/lsb-release
# so we need to fallback to the former there.
if os.path.isfile('/etc/lsb-release'):
for line in open('/etc/lsb-release'):
line = line.strip()
if line.startswith('DISTRIB_CODENAME'):
return line[17:]
else:
import commands
output = commands.getoutput('lsb_release -c').split()
if len(output) == 2:
return output[1]
print 'Error: Could not determine what distribution you are running.'
return None
def host_architecture():
""" host_architecture -> string
Detect the host's architecture and return it as a string
(i386/amd64/other values). If the architecture can't be determined,
print an error message and return None.
"""
arch = os.uname()[4].replace('x86_64', 'amd64').replace('i586', 'i386'
).replace('i686', 'i386')
if not arch or 'not found' in arch:
print 'Error: Not running on a Debian based system; could not ' \
'detect its architecture.'
return None
return arch
def readlist(filename, uniq=True): def readlist(filename, uniq=True):
""" Read a list of words from the indicated file. """ """ readlist(filename, uniq) -> list
Read a list of words from the indicated file. If 'uniq' is True, filter
out duplicated words.
"""
if not os.path.isfile(filename): if not os.path.isfile(filename):
print 'File "%s" does not exist.' % filename print 'File "%s" does not exist.' % filename