From c819d146be6bce86d97019494173253e71b85d2f Mon Sep 17 00:00:00 2001 From: fuzzyray Date: Tue, 5 May 2009 17:39:24 +0000 Subject: Rearrange trunk to support gentoolkit version 0.3. Split into gentoolkit, gentoolkit-dev, and deprecated. Import djanderson's work on the gentoolkit library and equery svn path=/trunk/gentoolkit/; revision=589 --- src/glsa-check/Makefile | 20 ++ src/glsa-check/glsa-check | 371 +++++++++++++++++++++++++ src/glsa-check/glsa-check.1 | 57 ++++ src/glsa-check/glsa.py | 644 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1092 insertions(+) create mode 100644 src/glsa-check/Makefile create mode 100755 src/glsa-check/glsa-check create mode 100644 src/glsa-check/glsa-check.1 create mode 100644 src/glsa-check/glsa.py (limited to 'src/glsa-check') diff --git a/src/glsa-check/Makefile b/src/glsa-check/Makefile new file mode 100644 index 0000000..9ad5717 --- /dev/null +++ b/src/glsa-check/Makefile @@ -0,0 +1,20 @@ +# Copyright 2003 Karl Trygve Kalleberg +# Copyright 2003 Gentoo Technologies, Inc. +# Distributed under the terms of the GNU General Public License v2 +# +# $Header$ + +include ../../makedefs.mak + +all: + echo "YADDLETHORPE (vb.) (Of offended pooves.) To exit huffily from a boutique." + +dist: + mkdir -p ../../$(distdir)/src/glsa-check/ + cp Makefile glsa.py glsa-check glsa-check.1 ../../$(distdir)/src/glsa-check/ + +install: + install -d $(DESTDIR)/usr/lib/gentoolkit/pym/ + install -m 0755 glsa-check $(bindir)/ + install -m 0644 glsa.py $(DESTDIR)/usr/lib/gentoolkit/pym/ + install -m 0644 glsa-check.1 $(mandir)/ diff --git a/src/glsa-check/glsa-check b/src/glsa-check/glsa-check new file mode 100755 index 0000000..fe38331 --- /dev/null +++ b/src/glsa-check/glsa-check @@ -0,0 +1,371 @@ +#!/usr/bin/python + +# $Header: $ +# This program is licensed under the GPL, version 2 + +import os +import sys +sys.path.insert(0, "/usr/lib/gentoolkit/pym") +try: + import portage +except ImportError: + sys.path.insert(0, "/usr/lib/portage/pym") + import portage + +try: + from portage.output import * +except ImportError: + from output import * + +from getopt import getopt, GetoptError + +__program__ = "glsa-check" +__author__ = "Marius Mauch " +__version__ = "0.9" + +optionmap = [ +["-l", "--list", "list all unapplied GLSA"], +["-d", "--dump", "--print", "show all information about the given GLSA"], +["-t", "--test", "test if this system is affected by the given GLSA"], +["-p", "--pretend", "show the necessary commands to apply this GLSA"], +["-f", "--fix", "try to auto-apply this GLSA (experimental)"], +["-i", "--inject", "inject the given GLSA into the checkfile"], +["-n", "--nocolor", "disable colors (option)"], +["-e", "--emergelike", "do not use a least-change algorithm (option)"], +["-h", "--help", "show this help message"], +["-V", "--version", "some information about this tool"], +["-v", "--verbose", "print more information (option)"], +["-c", "--cve", "show CAN ids in listing mode (option)"], +["-m", "--mail", "send a mail with the given GLSAs to the administrator"] +] + +# print a warning as this is beta code (but proven by now, so no more warning) +#sys.stderr.write("WARNING: This tool is completely new and not very tested, so it should not be\n") +#sys.stderr.write("used on production systems. It's mainly a test tool for the new GLSA release\n") +#sys.stderr.write("and distribution system, it's functionality will later be merged into emerge\n") +#sys.stderr.write("and equery.\n") +#sys.stderr.write("Please read http://www.gentoo.org/proj/en/portage/glsa-integration.xml\n") +#sys.stderr.write("before using this tool AND before reporting a bug.\n\n") + +# option parsing +args = [] +params = [] +try: + args, params = getopt(sys.argv[1:], "".join([o[0][1] for o in optionmap]), \ + [x[2:] for x in reduce(lambda x,y: x+y, [z[1:-1] for z in optionmap])]) +# ["dump", "print", "list", "pretend", "fix", "inject", "help", "verbose", "version", "test", "nocolor", "cve", "mail"]) + args = [a for a,b in args] + + for option in ["--nocolor", "-n"]: + if option in args: + nocolor() + args.remove(option) + + verbose = False + for option in ["--verbose", "-v"]: + if option in args: + verbose = True + args.remove(option) + + list_cve = False + for option in ["--cve", "-c"]: + if option in args: + list_cve = True + args.remove(option) + + least_change = True + for option in ["--emergelike", "-e"]: + if option in args: + least_change = False + args.remove(option) + + # sanity checking + if len(args) <= 0: + sys.stderr.write("no option given: what should I do ?\n") + mode = "HELP" + elif len(args) > 1: + sys.stderr.write("please use only one command per call\n") + mode = "HELP" + else: + # in what mode are we ? + args = args[0] + for m in optionmap: + if args in [o for o in m[:-1]]: + mode = m[1][2:] + +except GetoptError, e: + sys.stderr.write("unknown option given: ") + sys.stderr.write(str(e)+"\n") + mode = "HELP" + +# we need a set of glsa for most operation modes +if len(params) <= 0 and mode in ["fix", "test", "pretend", "dump", "inject", "mail"]: + sys.stderr.write("\nno GLSA given, so we'll do nothing for now. \n") + sys.stderr.write("If you want to run on all GLSA please tell me so \n") + sys.stderr.write("(specify \"all\" as parameter)\n\n") + mode = "HELP" +elif len(params) <= 0 and mode == "list": + params.append("new") + +# show help message +if mode == "help" or mode == "HELP": + msg = "Syntax: glsa-check