From 943483576878797ebfe3d72a84b5975234c24718 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Thu, 15 Nov 2007 19:04:14 +0000 Subject: [PATCH] Merged from trunk 8470:8481 | 8471 | make.globals should not be relative to config_root because | | zmedico | it only contains constants. | | 8472 | Revert accidental hunk from bug 198491. Haven't tested this | | zmedico | yet. | | 8473 | Bug #198491 - Disable termios.OPOST post-processing of | | zmedico | output on the slave pty file descriptor since otherwise | | | weird things like \n -> \r\n transformations may occur. | | | Thanks to Ulrich Mueller for this patch. | | 8474 | Remove the workaround for \n -> \r\n transformations in | | zmedico | SpawnTestCase.testLogfile() since the problem is solved by | | | the patch from bug #198491. | | 8475 | Create classes to encapsulate eache of the depgraph argument | | zmedico | types: atoms, packages and sets. | | 8476 | Fix incorrect type in depgraph._missing_args. | | zmedico | | | 8477 | revert getMergeList to return CPVs again instead of atoms | | genone | | | 8478 | Move glsa-check from gentoolkit into portage so the | | genone | gentoolkit version can be removed after 2.2 is released | | 8479 | move checkfile parsing into its own function | | genone | | | 8480 | if multiple glsas result in the same cat/pkg:slot being | | genone | affected only use the highest resulting atom | | 8481 | fix typo and missing classmethod declaration | | genone | | svn path=/main/branches/prefix/; revision=8504 --- bin/emaint | 3 +- bin/glsa-check | 336 +++++++++++++++++++++++++ pym/_emerge/__init__.py | 87 +++++-- pym/portage/__init__.py | 11 +- pym/portage/glsa.py | 17 +- pym/portage/sets/security.py | 31 ++- pym/portage/sets/shell.py | 3 +- pym/portage/tests/ebuild/test_spawn.py | 9 +- 8 files changed, 452 insertions(+), 45 deletions(-) create mode 100644 bin/glsa-check diff --git a/bin/emaint b/bin/emaint index ef03c2477..2bffd0f42 100755 --- a/bin/emaint +++ b/bin/emaint @@ -2,9 +2,8 @@ import sys, os, time, signal from optparse import OptionParser, OptionValueError -if not hasattr(__builtins__, "set"): - from sets import Set as set import re + try: import portage except ImportError: diff --git a/bin/glsa-check b/bin/glsa-check new file mode 100644 index 000000000..8d955526a --- /dev/null +++ b/bin/glsa-check @@ -0,0 +1,336 @@ +#!/usr/bin/python + +# $Header: $ +# This program is licensed under the GPL, version 2 + +import os +import sys + +try: + import portage +except ImportError: + from os import path as osp + sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) + import portage + +from portage.output import * + +from getopt import getopt, GetoptError + +__program__ = "glsa-check" +__author__ = "Marius Mauch " +__version__ = "1.0" + +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"] +] + +# 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": + sys.stderr.write("\nSyntax: glsa-check