diff options
author | Alastair Tse <liquidx@gentoo.org> | 2006-08-07 22:54:57 +0000 |
---|---|---|
committer | Alastair Tse <liquidx@gentoo.org> | 2006-08-07 22:54:57 +0000 |
commit | caf5a6c86f70896414e3edf9ccf69e98588b3aec (patch) | |
tree | 3d5228fab92e05784c03893bd91db5e09650770b | |
parent | how did that get in there? (diff) | |
download | liquidx-caf5a6c86f70896414e3edf9ccf69e98588b3aec.tar.gz liquidx-caf5a6c86f70896414e3edf9ccf69e98588b3aec.tar.bz2 liquidx-caf5a6c86f70896414e3edf9ccf69e98588b3aec.zip |
app-portage/eaudit. This is a very very simple tool to just list all
the installed packages, along with whether a package is a "WORLD"
package and what USE flags were used. It is useful for bug reporting
and also for administrating and replicating gentoo installations.
svn path=/; revision=40
-rw-r--r-- | app-portage/eaudit/Manifest | 11 | ||||
-rw-r--r-- | app-portage/eaudit/eaudit-0.1.ebuild | 21 | ||||
-rw-r--r-- | app-portage/eaudit/files/digest-eaudit-0.1 | 1 | ||||
-rwxr-xr-x | app-portage/eaudit/files/eaudit | 95 |
4 files changed, 128 insertions, 0 deletions
diff --git a/app-portage/eaudit/Manifest b/app-portage/eaudit/Manifest new file mode 100644 index 0000000..031c21b --- /dev/null +++ b/app-portage/eaudit/Manifest @@ -0,0 +1,11 @@ +AUX eaudit 2992 RMD160 8284b595f7c96e5bc03968cb924ac0b1c43e828b SHA1 b66bff3d6ce74a21f78016ff8522a538cdf3e9ed SHA256 a1b0448f808968fd3920cb3c584079a33134a2aeb6d7b3d977f19f661a957ab0 +MD5 a157051892589167dff1493885b6fa2b files/eaudit 2992 +RMD160 8284b595f7c96e5bc03968cb924ac0b1c43e828b files/eaudit 2992 +SHA256 a1b0448f808968fd3920cb3c584079a33134a2aeb6d7b3d977f19f661a957ab0 files/eaudit 2992 +EBUILD eaudit-0.1.ebuild 499 RMD160 6dfd9d2f5a5d198090d5c9087f0dea813f003dcc SHA1 cf7fee1a539f0647aca7cf81dd4a32dcb8e262c0 SHA256 2eedc7ee32c8e0cd7f6a625cb96e3e6e330c2e8d086ef586f5ec643a15b31310 +MD5 1272c3ad231d5fdc799d41ab191105e6 eaudit-0.1.ebuild 499 +RMD160 6dfd9d2f5a5d198090d5c9087f0dea813f003dcc eaudit-0.1.ebuild 499 +SHA256 2eedc7ee32c8e0cd7f6a625cb96e3e6e330c2e8d086ef586f5ec643a15b31310 eaudit-0.1.ebuild 499 +MD5 68b329da9893e34099c7d8ad5cb9c940 files/digest-eaudit-0.1 1 +RMD160 c0da025038ed83c687ddc430da9846ecb97f3998 files/digest-eaudit-0.1 1 +SHA256 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b files/digest-eaudit-0.1 1 diff --git a/app-portage/eaudit/eaudit-0.1.ebuild b/app-portage/eaudit/eaudit-0.1.ebuild new file mode 100644 index 0000000..b22907d --- /dev/null +++ b/app-portage/eaudit/eaudit-0.1.ebuild @@ -0,0 +1,21 @@ +# Copyright 1999-2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/dev-python/feedparser/feedparser-4.1.ebuild,v 1.6 2006/07/16 13:58:13 liquidx Exp $ + +DESCRIPTION="Ultra simple audit tool to compare installations." +HOMEPAGE="http://www.liquidx.net/" +SRC_URI="" +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="x86" +IUSE="" +RDEPEND=">=dev-lang/python-2.4" +DEPEND="" + +src_compile() { + return +} + +src_install() { + dobin ${FILESDIR}/eaudit +} diff --git a/app-portage/eaudit/files/digest-eaudit-0.1 b/app-portage/eaudit/files/digest-eaudit-0.1 new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/app-portage/eaudit/files/digest-eaudit-0.1 @@ -0,0 +1 @@ + diff --git a/app-portage/eaudit/files/eaudit b/app-portage/eaudit/files/eaudit new file mode 100755 index 0000000..89055f9 --- /dev/null +++ b/app-portage/eaudit/files/eaudit @@ -0,0 +1,95 @@ +#!/usr/bin/python +# +# eaudit - Lists installed packages with useflags. +# +# Copyright (c) 2006, Alastair Tse <alastair@liquidx.net> +# All rights reserved. +# + +from optparse import OptionParser +from os.path import join +import os +import sys +import string + +__doc__ = "Lists installed packages in human and machine readable form." +__version__ = '0.1' + +PKG_DB = '/var/db/pkg' +PKG_WORLD = '/var/lib/portage/world' + +def strip_ver(pkg_ver): + parts = pkg_ver.split('-') + for i in range(1, len(parts)): + if parts[i][0] in string.digits: + return '-'.join(parts[:i]), '-'.join(parts[i:]) + return pkg_ver, '' + +def world(): + world_index = {} + for cat_pkg in open(PKG_WORLD).xreadlines(): + cat, pkg = cat_pkg.strip().split('/') + if cat in world_index: + world_index[cat].add(pkg) + else: + world_index[cat] = set([pkg]) + return world_index + +def allpkgs(): + """ An iterator that outputs all packages in the form: + category, package, version, path_to_db + """ + for cat in sorted(os.listdir(PKG_DB)): + for pkg_ver in sorted(os.listdir(join(PKG_DB, cat))): + pkg, ver = strip_ver(pkg_ver) + yield cat, pkg, ver, join(PKG_DB, cat, pkg_ver) + +def use_status(path): + """ Returns a set of enable and disabled useflags for packages. """ + use_flags = set(open(join(path, 'USE')).read().split()) + iuse_flags = set(open(join(path, 'IUSE')).read().split()) + + use_enabled = sorted(use_flags & iuse_flags) + use_disabled = sorted(iuse_flags - set(use_enabled)) + return use_enabled, use_disabled + +def listpkgs(with_use = False, with_status = False, format = '%s %s %s'): + + world_index = world() + print world_index + + for cat, pkg, ver, path in allpkgs(): + output = '' + if with_status: + if pkg in world_index.get(cat, set()): + output += 'W ' + else: + output += ' ' + + output += format % (cat, pkg, ver) + + if with_use: + enabled, disabled = use_status(path) + output += ' ' + ' '.join(enabled + ['-%s' % u for u in disabled]) + + print output + +def main(args = sys.argv[1:]): + parser = OptionParser(version = '%%prog %s' % __version__, + usage = '%prog [-u|-s]', + description = __doc__) + parser.add_option('-u', '--use', action='store_true', + help = 'List USE flags') + parser.add_option('-s', '--status', action='store_true', + help = 'Display WORLD status') + parser.add_option('-f', '--format', default='%s %s %s', + help = 'Display format for category, package, version. ' + 'Example: "%s/%s-%s" = "sys-apps/portage-2.1"') + + options, params = parser.parse_args(args) + listpkgs(with_use = options.use, with_status = options.status, + format = options.format) + + +if __name__ == "__main__": + main() |