summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Mauch <genone@gentoo.org>2007-11-09 15:38:48 +0000
committerMarius Mauch <genone@gentoo.org>2007-11-09 15:38:48 +0000
commitd042fff18f2b7621dc0ec11c57e9c5b1936c8ca2 (patch)
tree902329b6b4a82924e214decc2af127c025f9fc60
parenteff61dab0a1725e73dac3c2d8709fc200dfca598 (diff)
downloadportage-d042fff18f2b7621dc0ec11c57e9c5b1936c8ca2.tar.gz
portage-d042fff18f2b7621dc0ec11c57e9c5b1936c8ca2.tar.bz2
portage-d042fff18f2b7621dc0ec11c57e9c5b1936c8ca2.zip
move checkfile parsing into its own function
svn path=/main/trunk/; revision=8479
-rw-r--r--bin/glsa-check6
-rw-r--r--pym/portage/glsa.py15
-rw-r--r--pym/portage/sets/security.py11
3 files changed, 18 insertions, 14 deletions
diff --git a/bin/glsa-check b/bin/glsa-check
index d79dda6fb..8d955526a 100644
--- a/bin/glsa-check
+++ b/bin/glsa-check
@@ -126,15 +126,11 @@ from portage.glsa import *
vardb = portage.db[portage.settings["ROOT"]]["vartree"].dbapi
portdb = portage.db["/"]["porttree"].dbapi
-checkfile = os.path.join(portage.settings["ROOT"], CACHE_PATH.lstrip(os.sep), "glsa")
# build glsa lists
completelist = get_glsa_list(portage.settings)
-if os.access(checkfile, os.R_OK):
- checklist = [line.strip() for line in open(checkfile, "r").readlines()]
-else:
- checklist = []
+checklist = get_applied_glsas(portage.settings)
todolist = [e for e in completelist if e not in checklist]
glsalist = []
diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py
index 91f719c8f..2d2f27b30 100644
--- a/pym/portage/glsa.py
+++ b/pym/portage/glsa.py
@@ -19,6 +19,18 @@ opMapping = {"le": "<=", "lt": "<", "eq": "=", "gt": ">", "ge": ">=",
NEWLINE_ESCAPE = "!;\\n" # some random string to mark newlines that should be preserved
SPACE_ESCAPE = "!;_" # some random string to mark spaces that should be preserved
+def get_applied_glsas(settings):
+ """
+ Return a list of applied or injected GLSA IDs
+
+ @type settings: portage.config
+ @param settings: portage config instance
+ @rtype: list
+ @return: list of glsa IDs
+ """
+ return grabfile(os.path.join(os.sep, settings["ROOT"], CACHE_PATH.lstrip(os.sep), "glsa"))
+
+
# TODO: use the textwrap module instead
def wrap(text, width, caption=""):
"""
@@ -553,8 +565,7 @@ class Glsa:
@rtype: Boolean
@returns: True if the GLSA was applied, False if not
"""
- aList = grabfile(os.path.join(os.sep, self.config["ROOT"], CACHE_PATH.lstrip(os.sep), "glsa"))
- return (self.nr in aList)
+ return (self.nr in get_applied_glsas())
def inject(self):
"""
diff --git a/pym/portage/sets/security.py b/pym/portage/sets/security.py
index a172e6f8c..24661a42e 100644
--- a/pym/portage/sets/security.py
+++ b/pym/portage/sets/security.py
@@ -5,7 +5,6 @@
import os
import portage.glsa as glsa
from portage.util import grabfile, write_atomic
-from portage.const import CACHE_PATH
from portage.sets.base import PackageSet
__all__ = ["SecuritySet", "NewGlsaSet", "NewAffectedSet", "AffectedSet"]
@@ -21,13 +20,12 @@ class SecuritySet(PackageSet):
self._settings = settings
self._vardbapi = vardbapi
self._portdbapi = portdbapi
- self._checkfile = os.path.join(os.sep, self._settings["ROOT"], CACHE_PATH.lstrip(os.sep), "glsa")
self._least_change = least_change
def getGlsaList(self, skip_applied):
glsaindexlist = glsa.get_glsa_list(self._settings)
if skip_applied:
- applied_list = grabfile(self._checkfile)
+ applied_list = glsa.get_applied_glsas(self._settings)
glsaindexlist = set(glsaindexlist).difference(applied_list)
glsaindexlist = list(glsaindexlist)
glsaindexlist.sort()
@@ -48,12 +46,11 @@ class SecuritySet(PackageSet):
def updateAppliedList(self):
glsaindexlist = self.getGlsaList(True)
- applied_list = grabfile(self._checkfile)
+ applied_list = glsa.get_applied_glsas(self._settings)
for glsaid in glsaindexlist:
myglsa = glsa.Glsa(glsaid, self._settings, self._vardbapi, self._portdbapi)
- if not myglsa.isVulnerable():
- applied_list.append(glsaid)
- write_atomic(self._checkfile, "\n".join(applied_list))
+ if not myglsa.isVulnerable() and not myglsa.nr in applied_list:
+ myglsa.inject()
def singleBuilder(cls, options, settings, trees):
if "use_emerge_resoler" in options \