mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
debian-distro-info, distro-info, ubuntu-distro-info: New tools.
This commit is contained in:
parent
90b34b936f
commit
3b97f4f3e5
13
data/debian.csv
Normal file
13
data/debian.csv
Normal file
@ -0,0 +1,13 @@
|
||||
version,codename,series,release,eol
|
||||
1.1,Buzz,buzz,1996-06-17,1997-06-05
|
||||
1.2,Rex,rex,1996-12-12,1998-06-05
|
||||
1.3,Bo,bo,1997-06-05,1999-03-09
|
||||
2.0,Hamm,hamm,1998-07-24,2000-03-09
|
||||
2.1,Slink,slink,1999-03-09,2000-10-30
|
||||
2.2,Potato,potato,2000-08-15,2003-07-30
|
||||
3.0,Woody,woody,2002-07-19,2006-06-30
|
||||
3.1,Sarge,sarge,2005-06-06,2008-03-30
|
||||
4.0,Etch,etch,2007-04-08,2010-02-14
|
||||
5.0,Lenny,lenny,2009-02-14
|
||||
6.0,Squeeze,squeeze
|
||||
,Sid,sid
|
Can't render this file because it has a wrong number of fields in line 11.
|
15
data/ubuntu.csv
Normal file
15
data/ubuntu.csv
Normal file
@ -0,0 +1,15 @@
|
||||
version,codename,series,release,eol,eol-server
|
||||
4.10,Warty Warthog,warty,2004-10-20,2006-04-30
|
||||
5.04,Hoary Hedgehog,hoary,2005-04-08,2006-10-31
|
||||
5.10,Breezy Badger,breezy,2005-10-13,2007-04-13
|
||||
6.06 LTS,Dapper Drake,dapper,2006-06-01,2009-07-14,2011-06-01
|
||||
6.10,Edgy Eft,edgy,2006-10-26,2008-04-25
|
||||
7.04,Feisty Fawn,feisty,2007-04-19,2008-10-19
|
||||
7.10,Gutsy Gibbon,gutsy,2007-10-18,2009-04-18
|
||||
8.04 LTS,Hardy Heron,hardy,2008-04-24,2011-04,2013-04
|
||||
8.10,Intrepid Ibex,intrepid,2008-10-30,2010-04-30
|
||||
9.04,Jaunty Jackalope,jaunty,2009-04-23,2010-10-23
|
||||
9.10,Karmic Koala,karmic,2009-10-29,2011-04
|
||||
10.04 LTS,Lucid Lynx,lucid,2010-04-29,2013-04,2015-04
|
||||
10.10,Maverick Meerkat,maverick,2010-10-10,2012-04
|
||||
11.04,Natty Narwhal,natty,2011-04-28,2012-10
|
|
98
debian-distro-info
Executable file
98
debian-distro-info
Executable file
@ -0,0 +1,98 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# Copyright (C) 2009-2011, Benjamin Drung <bdrung@ubuntu.com>
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
"""provides information about Debian's distributions"""
|
||||
|
||||
import optparse
|
||||
import os
|
||||
import sys
|
||||
|
||||
from ubuntutools.distro_info import convert_date, DebianDistroInfo
|
||||
|
||||
def main():
|
||||
script_name = os.path.basename(sys.argv[0])
|
||||
usage = "%s [options]" % (script_name)
|
||||
epilog = "See %s(1) for more info." % (script_name)
|
||||
parser = optparse.OptionParser(usage=usage, epilog=epilog)
|
||||
|
||||
parser.add_option("--date", dest="date", default=None,
|
||||
help="date for calculating the version (default: today).")
|
||||
parser.add_option("-a", "--all", dest="all",
|
||||
help="list all known versions",
|
||||
action="store_true", default=False)
|
||||
parser.add_option("-d", "--devel", dest="devel",
|
||||
help="latest development version",
|
||||
action="store_true", default=False)
|
||||
parser.add_option("-o", "--old", dest="old",
|
||||
help="latest old (stable) version",
|
||||
action="store_true", default=False)
|
||||
parser.add_option("-s", "--stable", dest="stable",
|
||||
help="latest stable version",
|
||||
action="store_true", default=False)
|
||||
parser.add_option("--supported", dest="supported",
|
||||
help="list of all supported stable versions",
|
||||
action="store_true", default=False)
|
||||
parser.add_option("-t", "--testing", dest="testing",
|
||||
help="current testing version",
|
||||
action="store_true", default=False)
|
||||
parser.add_option("--unsupported", dest="unsupported",
|
||||
help="list of all unsupported stable versions",
|
||||
action="store_true", default=False)
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if len(args) != 0:
|
||||
parser.error("This script does not take any additional parameters.")
|
||||
return 1
|
||||
|
||||
versions = [options.all, options.devel, options.old, options.stable,
|
||||
options.supported, options.testing, options.unsupported]
|
||||
if len([x for x in versions if x]) != 1:
|
||||
parser.error("You have to select exactly one of --all, --devel, --old, "
|
||||
"--stable, --supported, --testing, --unsupported.")
|
||||
return 1
|
||||
|
||||
if options.date is None:
|
||||
date = None
|
||||
else:
|
||||
try:
|
||||
date = convert_date(options.date)
|
||||
except ValueError:
|
||||
parser.error("Option --date needs to be an date in ISO 8601 "
|
||||
"format.")
|
||||
return 1
|
||||
|
||||
if options.all:
|
||||
for distro in DebianDistroInfo().all:
|
||||
print distro
|
||||
elif options.devel:
|
||||
print DebianDistroInfo().devel(date)
|
||||
elif options.old:
|
||||
print DebianDistroInfo().old(date)
|
||||
elif options.stable:
|
||||
print DebianDistroInfo().stable(date)
|
||||
elif options.supported:
|
||||
for distro in DebianDistroInfo().supported(date):
|
||||
print distro
|
||||
elif options.testing:
|
||||
print DebianDistroInfo().testing(date)
|
||||
elif options.unsupported:
|
||||
for distro in DebianDistroInfo().unsupported(date):
|
||||
print distro
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
6
debian/changelog
vendored
6
debian/changelog
vendored
@ -1,3 +1,9 @@
|
||||
ubuntu-dev-tools (0.113) UNRELEASED; urgency=low
|
||||
|
||||
* debian-distro-info, distro-info, ubuntu-distro-info: New tools.
|
||||
|
||||
-- Benjamin Drung <bdrung@debian.org> Fri, 21 Jan 2011 18:22:23 +0100
|
||||
|
||||
ubuntu-dev-tools (0.112) unstable; urgency=low
|
||||
|
||||
[ Robert Collins ]
|
||||
|
3
debian/control
vendored
3
debian/control
vendored
@ -72,7 +72,9 @@ Description: useful tools for Ubuntu developers
|
||||
- check-symbols - will compare and give you a diff of the exported symbols of
|
||||
all .so files in a binary package.
|
||||
- dch-repeat - used to repeat a change log into an older release.
|
||||
- debian-distro-info - provides information about Debian's distributions.
|
||||
- dgetlp - download a source package from the Launchpad library.
|
||||
- distro-info - provides information about the distributions' releases.
|
||||
- errno - search POSIX error codes by error number, name, or description
|
||||
- get-branches - used to branch/checkout all the bzr branches in a Launchpad
|
||||
team.
|
||||
@ -114,6 +116,7 @@ Description: useful tools for Ubuntu developers
|
||||
- syncpackage - helper to prepare .changes file to upload synced packages
|
||||
- ubuntu-build - give commands to the Launchpad build daemons from the
|
||||
command line.
|
||||
- ubuntu-distro-info - provides information about Ubuntu's distributions.
|
||||
- ubuntu-iso - output information of an Ubuntu ISO image.
|
||||
- update-maintainer - script to update maintainer field in ubuntu packages.
|
||||
- what-patch - determines what patch system, if any, a source package is
|
||||
|
17
debian/copyright
vendored
17
debian/copyright
vendored
@ -1,6 +1,6 @@
|
||||
Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135
|
||||
Name: Ubuntu Developer Tools
|
||||
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
|
||||
Format: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=165
|
||||
Upstream-Name: Ubuntu Developer Tools
|
||||
Upstream-Contact: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
|
||||
Source: https://launchpad.net/ubuntu-dev-tools
|
||||
|
||||
Files: *,
|
||||
@ -175,20 +175,27 @@ License: GPL-3+
|
||||
On Debian systems, the complete text of the GNU General Public License
|
||||
version 3 can be found in the /usr/share/common-licenses/GPL-3 file.
|
||||
|
||||
Files: doc/pull-debian-debdiff.1,
|
||||
Files: data/*,
|
||||
debian-distro-info,
|
||||
doc/debian-distro-info.1,
|
||||
doc/distro-info.1,
|
||||
doc/pull-debian-debdiff.1,
|
||||
doc/sponsor-patch.1,
|
||||
doc/suspicious-source.1,
|
||||
doc/ubuntu-dev-tools.5,
|
||||
doc/ubuntu-distro-info.1,
|
||||
doc/update-maintainer.1,
|
||||
doc/wrap-and-sort.1,
|
||||
pull-debian-debdiff,
|
||||
sponsor-patch,
|
||||
suspicious-source,
|
||||
test-data/*,
|
||||
ubuntu-distro-info,
|
||||
ubuntutools/archive.py,
|
||||
ubuntutools/builder.py,
|
||||
ubuntutools/config.py,
|
||||
ubuntutools/control.py,
|
||||
ubuntutools/distro_info.py,
|
||||
ubuntutools/logger.py,
|
||||
ubuntutools/question.py,
|
||||
ubuntutools/sponsor_patch/*,
|
||||
@ -196,7 +203,7 @@ Files: doc/pull-debian-debdiff.1,
|
||||
ubuntutools/update_maintainer.py,
|
||||
update-maintainer,
|
||||
wrap-and-sort
|
||||
Copyright: 2010, Benjamin Drung <bdrung@ubuntu.com>
|
||||
Copyright: 2009-2011, Benjamin Drung <bdrung@ubuntu.com>
|
||||
2010, Evan Broder <evan@ebroder.net>
|
||||
2008, Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
||||
2010-2011, Stefano Rivera <stefanor@ubuntu.com>
|
||||
|
4
debian/rules
vendored
4
debian/rules
vendored
@ -3,6 +3,10 @@
|
||||
%:
|
||||
dh $@ --with python2
|
||||
|
||||
override_dh_auto_install:
|
||||
dh_auto_install
|
||||
ln -s $(shell dpkg-vendor --query Vendor | tr '[:upper:]' '[:lower:]')-distro-info debian/ubuntu-dev-tools/usr/bin/distro-info
|
||||
|
||||
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
|
||||
override_dh_auto_test:
|
||||
set -e; \
|
||||
|
51
doc/debian-distro-info.1
Normal file
51
doc/debian-distro-info.1
Normal file
@ -0,0 +1,51 @@
|
||||
.\" Copyright (c) 2009-2011, Benjamin Drung <bdrung@ubuntu.com>
|
||||
.\"
|
||||
.\" Permission to use, copy, modify, and/or distribute this software for any
|
||||
.\" purpose with or without fee is hereby granted, provided that the above
|
||||
.\" copyright notice and this permission notice appear in all copies.
|
||||
.\"
|
||||
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
.\"
|
||||
.TH DEBIAN\-DISTRO\-INFO "1" "January 2011" "ubuntu-dev-tools"
|
||||
.SH NAME
|
||||
debian-distro-info \- provides information about Debian's distributions
|
||||
.SH SYNOPSIS
|
||||
.B debian-distro-info
|
||||
[\fIOPTIONS\fR]
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-\-date\fR
|
||||
date for calculating the version (default: today)
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
display help message and exit
|
||||
.TP
|
||||
\fB\-a\fR, \fB\-\-all\fR
|
||||
list all known versions
|
||||
.TP
|
||||
\fB\-d\fR, \fB\-\-devel\fR
|
||||
latest development version
|
||||
.TP
|
||||
\fB\-o\fR, \fB\-\-old\fR
|
||||
latest old (stable) version
|
||||
.TP
|
||||
\fB\-s\fR, \fB\-\-stable\fR
|
||||
latest stable version
|
||||
.TP
|
||||
\fB\-\-supported\fR
|
||||
list of all supported stable versions
|
||||
.TP
|
||||
\fB\-t\fR, \fB\-\-testing\fR
|
||||
latest testing version
|
||||
.TP
|
||||
\fB\-\-unsupported\fR
|
||||
list of all unsupported stable versions
|
||||
.SH AUTHOR
|
||||
The script and this manual page was written by
|
||||
Benjamin Drung <bdrung@ubuntu.com>.
|
59
doc/distro-info.1
Normal file
59
doc/distro-info.1
Normal file
@ -0,0 +1,59 @@
|
||||
.\" Copyright (c) 2009-2011, Benjamin Drung <bdrung@ubuntu.com>
|
||||
.\"
|
||||
.\" Permission to use, copy, modify, and/or distribute this software for any
|
||||
.\" purpose with or without fee is hereby granted, provided that the above
|
||||
.\" copyright notice and this permission notice appear in all copies.
|
||||
.\"
|
||||
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
.\"
|
||||
.TH DISTRO-INFO "1" "January 2011" "ubuntu-dev-tools"
|
||||
.SH NAME
|
||||
distro-info \- provides information about the distributions' releases
|
||||
.SH SYNOPSIS
|
||||
.B distro-info
|
||||
[\fIOPTIONS\fR]
|
||||
.SH DESCRIPTION
|
||||
.B distro-info
|
||||
is a symlink to the distro-info command of your distribution.
|
||||
On Debian it links to
|
||||
.B debian-distro-info
|
||||
and on Ubuntu it links to
|
||||
.B ubuntu-distro-info.
|
||||
All options, which are described in this manual page, are available in all
|
||||
.B distro-info
|
||||
commands. All other options, which are not described here, are distribution
|
||||
specific.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-\-date\fR
|
||||
date for calculating the version (default: today)
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
display help message and exit
|
||||
.TP
|
||||
\fB\-a\fR, \fB\-\-all\fR
|
||||
list all known versions
|
||||
.TP
|
||||
\fB\-d\fR, \fB\-\-devel\fR
|
||||
latest development version
|
||||
.TP
|
||||
\fB\-s\fR, \fB\-\-stable\fR
|
||||
latest stable version
|
||||
.TP
|
||||
\fB\-\-supported\fR
|
||||
list of all supported stable versions
|
||||
.TP
|
||||
\fB\-\-unsupported\fR
|
||||
list of all unsupported stable versions
|
||||
.SH SEE ALSO
|
||||
.BR debian-distro-info (1),
|
||||
.BR ubuntu-distro-info (1)
|
||||
.SH AUTHOR
|
||||
The script and this manual page was written by
|
||||
Benjamin Drung <bdrung@ubuntu.com>.
|
48
doc/ubuntu-distro-info.1
Normal file
48
doc/ubuntu-distro-info.1
Normal file
@ -0,0 +1,48 @@
|
||||
.\" Copyright (c) 2009-2011, Benjamin Drung <bdrung@ubuntu.com>
|
||||
.\"
|
||||
.\" Permission to use, copy, modify, and/or distribute this software for any
|
||||
.\" purpose with or without fee is hereby granted, provided that the above
|
||||
.\" copyright notice and this permission notice appear in all copies.
|
||||
.\"
|
||||
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
.\"
|
||||
.TH UBUNTU-DISTRO-INFO "1" "January 2011" "ubuntu-dev-tools"
|
||||
.SH NAME
|
||||
ubuntu-distro-info \- provides information about Ubuntu's distributions
|
||||
.SH SYNOPSIS
|
||||
.B ubuntu-distro-info
|
||||
[\fIOPTIONS\fR]
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-\-date\fR
|
||||
date for calculating the version (default: today)
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
display help message and exit
|
||||
.TP
|
||||
\fB\-a\fR, \fB\-\-all\fR
|
||||
list all known versions
|
||||
.TP
|
||||
\fB\-d\fR, \fB\-\-devel\fR
|
||||
latest development version
|
||||
.TP
|
||||
\fB\-\-lts\fR
|
||||
latest long term support (LTS) version
|
||||
.TP
|
||||
\fB\-s\fR, \fB\-\-stable\fR
|
||||
latest stable version
|
||||
.TP
|
||||
\fB\-\-supported\fR
|
||||
list of all supported stable versions
|
||||
.TP
|
||||
\fB\-\-unsupported\fR
|
||||
list of all unsupported stable versions
|
||||
.SH AUTHOR
|
||||
The script and this manual page was written by
|
||||
Benjamin Drung <bdrung@ubuntu.com>.
|
3
setup.py
3
setup.py
@ -18,6 +18,7 @@ scripts = ['404main',
|
||||
'check-mir',
|
||||
'check-symbols',
|
||||
'dch-repeat',
|
||||
'debian-distro-info',
|
||||
'dgetlp',
|
||||
'edit-patch',
|
||||
'errno',
|
||||
@ -50,6 +51,7 @@ scripts = ['404main',
|
||||
'suspicious-source',
|
||||
'syncpackage',
|
||||
'ubuntu-build',
|
||||
'ubuntu-distro-info',
|
||||
'ubuntu-iso',
|
||||
'update-maintainer',
|
||||
'what-patch',
|
||||
@ -68,6 +70,7 @@ if __name__ == '__main__':
|
||||
],
|
||||
data_files=[('/etc/bash_completion.d',
|
||||
glob.glob("bash_completion/*")),
|
||||
('share/ubuntu-dev-tools', glob.glob('data/*')),
|
||||
('share/doc/ubuntu-dev-tools/examples',
|
||||
glob.glob('examples/*')),
|
||||
('share/man/man1', glob.glob("doc/*.1")),
|
||||
|
93
ubuntu-distro-info
Executable file
93
ubuntu-distro-info
Executable file
@ -0,0 +1,93 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# Copyright (C) 2009-2011, Benjamin Drung <bdrung@ubuntu.com>
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
"""provides information about Ubuntu's distributions"""
|
||||
|
||||
import optparse
|
||||
import os
|
||||
import sys
|
||||
|
||||
from ubuntutools.distro_info import convert_date, UbuntuDistroInfo
|
||||
|
||||
def main():
|
||||
script_name = os.path.basename(sys.argv[0])
|
||||
usage = "%s [options]" % (script_name)
|
||||
epilog = "See %s(1) for more info." % (script_name)
|
||||
parser = optparse.OptionParser(usage=usage, epilog=epilog)
|
||||
|
||||
parser.add_option("--date", dest="date", default=None,
|
||||
help="date for calculating the version (default: today).")
|
||||
parser.add_option("-a", "--all", dest="all",
|
||||
help="list all known versions",
|
||||
action="store_true", default=False)
|
||||
parser.add_option("-d", "--devel", dest="devel",
|
||||
help="latest development version",
|
||||
action="store_true", default=False)
|
||||
parser.add_option("--lts", dest="lts",
|
||||
help="latest long term support (LTS) version",
|
||||
action="store_true", default=False)
|
||||
parser.add_option("-s", "--stable", dest="stable",
|
||||
help="latest stable version",
|
||||
action="store_true", default=False)
|
||||
parser.add_option("--supported", dest="supported",
|
||||
help="list of all supported stable versions",
|
||||
action="store_true", default=False)
|
||||
parser.add_option("--unsupported", dest="unsupported",
|
||||
help="list of all unsupported stable versions",
|
||||
action="store_true", default=False)
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if len(args) != 0:
|
||||
parser.error("This script does not take any additional parameters.")
|
||||
return 1
|
||||
|
||||
versions = [options.all, options.devel, options.lts, options.stable,
|
||||
options.supported, options.unsupported]
|
||||
if len([x for x in versions if x]) != 1:
|
||||
parser.error("You have to select exactly one of --all, --devel, --lts, "
|
||||
"--stable, --supported, --unsupported.")
|
||||
return 1
|
||||
|
||||
if options.date is None:
|
||||
date = None
|
||||
else:
|
||||
try:
|
||||
date = convert_date(options.date)
|
||||
except ValueError:
|
||||
parser.error("Option --date needs to be an date in ISO 8601 "
|
||||
"format.")
|
||||
return 1
|
||||
|
||||
if options.all:
|
||||
for distro in UbuntuDistroInfo().all:
|
||||
print distro
|
||||
elif options.devel:
|
||||
print UbuntuDistroInfo().devel(date)
|
||||
elif options.lts:
|
||||
print UbuntuDistroInfo().lts(date)
|
||||
elif options.stable:
|
||||
print UbuntuDistroInfo().stable(date)
|
||||
elif options.supported:
|
||||
for distro in UbuntuDistroInfo().supported(date):
|
||||
print distro
|
||||
elif options.unsupported:
|
||||
for distro in UbuntuDistroInfo().unsupported(date):
|
||||
print distro
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
174
ubuntutools/distro_info.py
Normal file
174
ubuntutools/distro_info.py
Normal file
@ -0,0 +1,174 @@
|
||||
# Copyright (C) 2009-2011, Benjamin Drung <bdrung@ubuntu.com>
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
"""provides information about Ubuntu's and Debian's distributions"""
|
||||
|
||||
import csv
|
||||
import datetime
|
||||
import os
|
||||
import sys
|
||||
|
||||
def convert_date(string):
|
||||
"""Convert a date string in ISO 8601 into a datetime object."""
|
||||
if string is None or string == "":
|
||||
date = None
|
||||
else:
|
||||
try:
|
||||
(year, month, day) = [int(x) for x in string.split("-")]
|
||||
date = datetime.date(year, month, day)
|
||||
except ValueError:
|
||||
(year, month) = [int(x) for x in string.split("-")]
|
||||
if month == 12:
|
||||
date = datetime.date(year, month, 31)
|
||||
else:
|
||||
date = datetime.date(year, month + 1, 1) - datetime.timedelta(1)
|
||||
return date
|
||||
|
||||
def _get_data_dir():
|
||||
"""Get the data directory based on the script location."""
|
||||
if os.path.dirname(sys.argv[0]) == "/usr/bin":
|
||||
data_dir = "/usr/share/ubuntu-dev-tools"
|
||||
else:
|
||||
data_dir = os.path.join(os.path.dirname(sys.argv[0]), "data")
|
||||
return data_dir
|
||||
|
||||
class DistroDataOutdated(Exception):
|
||||
"""Distribution data outdated."""
|
||||
|
||||
def __init__(self):
|
||||
super(DistroDataOutdated, self).__init__("Distribution data outdated.")
|
||||
|
||||
|
||||
class DistroInfo(object):
|
||||
"""Base class for distribution information.
|
||||
Use DebianDistroInfo or UbuntuDistroInfo instead of using this directly.
|
||||
"""
|
||||
|
||||
def __init__(self, distro):
|
||||
filename = os.path.join(_get_data_dir(), distro + ".csv")
|
||||
csvfile = open(filename)
|
||||
csv_reader = csv.DictReader(csvfile)
|
||||
self._rows = []
|
||||
for row in csv_reader:
|
||||
for column in ("release", "eol", "eol-server"):
|
||||
if column in row:
|
||||
row[column] = convert_date(row[column])
|
||||
self._rows.append(row)
|
||||
self._date = datetime.date.today()
|
||||
|
||||
@property
|
||||
def all(self):
|
||||
"""List all known distributions."""
|
||||
return [x["series"] for x in self._rows]
|
||||
|
||||
def devel(self, date=None):
|
||||
"""Get latest development distribution based on the given date."""
|
||||
if date is None:
|
||||
date = self._date
|
||||
distros = [x for x in self._rows
|
||||
if x["release"] is None or
|
||||
(date < x["release"] and
|
||||
(x["eol"] is None or date <= x["eol"]))]
|
||||
if not distros:
|
||||
raise DistroDataOutdated()
|
||||
return distros[-1]["series"]
|
||||
|
||||
def stable(self, date=None):
|
||||
"""Get latest stable distribution based on the given date."""
|
||||
if date is None:
|
||||
date = self._date
|
||||
distros = [x for x in self._rows
|
||||
if x["release"] is not None and date >= x["release"] and
|
||||
(x["eol"] is None or date <= x["eol"])]
|
||||
if not distros:
|
||||
raise DistroDataOutdated()
|
||||
return distros[-1]["series"]
|
||||
|
||||
def supported(self, date=None):
|
||||
"""Get list of all supported distributions based on the given date."""
|
||||
raise NotImplementedError()
|
||||
|
||||
def unsupported(self, date=None):
|
||||
"""Get list of all unsupported distributions based on the given date."""
|
||||
supported = self.supported(date)
|
||||
distros = [x["series"] for x in self._rows
|
||||
if x["series"] not in supported]
|
||||
return distros
|
||||
|
||||
|
||||
class DebianDistroInfo(DistroInfo):
|
||||
"""provides information about Debian's distributions"""
|
||||
|
||||
def __init__(self):
|
||||
super(DebianDistroInfo, self).__init__("debian")
|
||||
|
||||
def old(self, date=None):
|
||||
"""Get old (stable) Debian distribution based on the given date."""
|
||||
if date is None:
|
||||
date = self._date
|
||||
distros = [x for x in self._rows
|
||||
if x["release"] is not None and date >= x["release"]]
|
||||
if len(distros) < 2:
|
||||
raise DistroDataOutdated()
|
||||
return distros[-2]["series"]
|
||||
|
||||
def supported(self, date=None):
|
||||
"""Get list of all supported Debian distributions based on the given
|
||||
date."""
|
||||
if date is None:
|
||||
date = self._date
|
||||
distros = [x["series"] for x in self._rows
|
||||
if x["eol"] is None or date <= x["eol"]]
|
||||
return distros
|
||||
|
||||
def testing(self, date=None):
|
||||
"""Get latest testing Debian distribution based on the given date."""
|
||||
if date is None:
|
||||
date = self._date
|
||||
distros = [x for x in self._rows
|
||||
if x["release"] is None or
|
||||
(date < x["release"] and
|
||||
(x["eol"] is None or date <= x["eol"]))]
|
||||
if len(distros) < 2:
|
||||
raise DistroDataOutdated()
|
||||
return distros[-2]["series"]
|
||||
|
||||
|
||||
class UbuntuDistroInfo(DistroInfo):
|
||||
"""provides information about Ubuntu's distributions"""
|
||||
|
||||
def __init__(self):
|
||||
super(UbuntuDistroInfo, self).__init__("ubuntu")
|
||||
|
||||
def lts(self, date=None):
|
||||
"""Get latest long term support (LTS) Ubuntu distribution based on the
|
||||
given date."""
|
||||
if date is None:
|
||||
date = self._date
|
||||
distros = [x for x in self._rows if x["version"].find("LTS") >= 0 and
|
||||
date >= x["release"] and
|
||||
date <= x["eol"]]
|
||||
if not distros:
|
||||
raise DistroDataOutdated()
|
||||
return distros[-1]["series"]
|
||||
|
||||
def supported(self, date=None):
|
||||
"""Get list of all supported Ubuntu distributions based on the given
|
||||
date."""
|
||||
if date is None:
|
||||
date = self._date
|
||||
distros = [x["series"] for x in self._rows
|
||||
if date <= x["eol"] or
|
||||
(x["eol-server"] is not None and date <= x["eol-server"])]
|
||||
return distros
|
108
ubuntutools/test/test_distro_info.py
Normal file
108
ubuntutools/test/test_distro_info.py
Normal file
@ -0,0 +1,108 @@
|
||||
# test_distro_info.py - Test suite for ubuntutools.distro_info
|
||||
#
|
||||
# Copyright (C) 2011, Benjamin Drung <bdrung@ubuntu.com>
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
"""Test suite for ubuntutools.distro_info"""
|
||||
|
||||
import datetime
|
||||
|
||||
from ubuntutools.test import unittest
|
||||
from ubuntutools.distro_info import DebianDistroInfo, UbuntuDistroInfo
|
||||
|
||||
#pylint: disable=R0904
|
||||
class DebianDistroInfoTestCase(unittest.TestCase):
|
||||
"""TestCase object for ubuntutools.distro_info.DebianDistroInfo"""
|
||||
|
||||
#pylint: disable=C0103
|
||||
def setUp(self):
|
||||
self._distro_info = DebianDistroInfo()
|
||||
self._date = datetime.date(2011, 01, 10)
|
||||
|
||||
#pylint: enable=C0103
|
||||
def test_all(self):
|
||||
"""Test: List all known Debian distributions."""
|
||||
all_distros = set(["buzz", "rex", "bo", "hamm", "slink", "potato",
|
||||
"woody", "sarge", "etch", "lenny", "squeeze", "sid"])
|
||||
self.assertEqual(all_distros - set(self._distro_info.all), set())
|
||||
|
||||
def test_devel(self):
|
||||
"""Test: Get latest development Debian distribution."""
|
||||
self.assertEqual(self._distro_info.devel(self._date), "sid")
|
||||
|
||||
def test_old(self):
|
||||
"""Test: Get old (stable) Debian distribution."""
|
||||
self.assertEqual(self._distro_info.old(self._date), "etch")
|
||||
|
||||
def test_stable(self):
|
||||
"""Test: Get latest stable Debian distribution."""
|
||||
self.assertEqual(self._distro_info.stable(self._date), "lenny")
|
||||
|
||||
def test_supported(self):
|
||||
"""Test: List all supported Debian distribution."""
|
||||
self.assertEqual(self._distro_info.supported(self._date),
|
||||
["lenny", "squeeze", "sid"])
|
||||
|
||||
def test_testing(self):
|
||||
"""Test: Get latest testing Debian distribution."""
|
||||
self.assertEqual(self._distro_info.testing(self._date), "squeeze")
|
||||
|
||||
def test_unsupported(self):
|
||||
"""Test: List all unsupported Debian distribution."""
|
||||
unsupported = set(["buzz", "rex", "bo", "hamm", "slink", "potato",
|
||||
"woody", "sarge", "etch"])
|
||||
self.assertEqual(unsupported -
|
||||
set(self._distro_info.unsupported(self._date)), set())
|
||||
|
||||
|
||||
#pylint: disable=R0904
|
||||
class UbuntuDistroInfoTestCase(unittest.TestCase):
|
||||
"""TestCase object for ubuntutools.distro_info.UbuntuDistroInfo"""
|
||||
|
||||
#pylint: disable=C0103
|
||||
def setUp(self):
|
||||
self._distro_info = UbuntuDistroInfo()
|
||||
self._date = datetime.date(2011, 01, 10)
|
||||
|
||||
#pylint: enable=C0103
|
||||
def test_all(self):
|
||||
"""Test: List all known Ubuntu distributions."""
|
||||
all_distros = set(["warty", "hoary", "breezy", "dapper", "edgy",
|
||||
"feisty", "gutsy", "hardy", "intrepid", "jaunty",
|
||||
"karmic", "lucid", "maverick", "natty"])
|
||||
self.assertEqual(all_distros - set(self._distro_info.all), set())
|
||||
|
||||
def test_devel(self):
|
||||
"""Test: Get latest development Ubuntu distribution."""
|
||||
self.assertEqual(self._distro_info.devel(self._date), "natty")
|
||||
|
||||
def test_lts(self):
|
||||
"""Test: Get latest long term support (LTS) Ubuntu distribution."""
|
||||
self.assertEqual(self._distro_info.lts(self._date), "lucid")
|
||||
|
||||
def test_stable(self):
|
||||
"""Test: Get latest stable Ubuntu distribution."""
|
||||
self.assertEqual(self._distro_info.stable(self._date), "maverick")
|
||||
|
||||
def test_supported(self):
|
||||
"""Test: List all supported Ubuntu distribution."""
|
||||
supported = ["dapper", "hardy", "karmic", "lucid", "maverick", "natty"]
|
||||
self.assertEqual(self._distro_info.supported(self._date), supported)
|
||||
|
||||
def test_unsupported(self):
|
||||
"""Test: List all unsupported Ubuntu distribution."""
|
||||
unsupported = set(["warty", "hoary", "breezy", "edgy", "feisty",
|
||||
"gutsy", "intrepid", "jaunty"])
|
||||
self.assertEqual(unsupported -
|
||||
set(self._distro_info.unsupported(self._date)), set())
|
Loading…
x
Reference in New Issue
Block a user