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 = []
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=""):
"""
@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):
"""
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"]
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()
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 \