|
|
|
@ -42,6 +42,7 @@ from utils.common import (_error, _warning, getTupleVersion, getPortageUidGid,
|
|
|
|
|
isBootstrapDataOnly)
|
|
|
|
|
from utils.text import _u
|
|
|
|
|
from utils.portage import (isPkgInstalled, reVerSplitToPV, EmergeLog,
|
|
|
|
|
getInstalledAtom,
|
|
|
|
|
EmergeLogPackageTask, getPkgUses, RepositoryPath)
|
|
|
|
|
from utils.content import PkgContents, checkContents, getCfgFiles, fillContents
|
|
|
|
|
from utils.files import (getModeFile, listDirectory, removeDir, typeFile,
|
|
|
|
@ -2047,6 +2048,7 @@ class templateFunction(_error, _warning, _shareTemplate, _shareTermsFunction,
|
|
|
|
|
return "%s/%s" % (category, pkgName)
|
|
|
|
|
|
|
|
|
|
currentBelong = ""
|
|
|
|
|
currentBelongSlot = ""
|
|
|
|
|
alreadyInformed = []
|
|
|
|
|
|
|
|
|
|
def __init__(self, objVar):
|
|
|
|
@ -3330,8 +3332,7 @@ class templateFunction(_error, _warning, _shareTemplate, _shareTermsFunction,
|
|
|
|
|
"""
|
|
|
|
|
term = funArgv.replace(" ", "")
|
|
|
|
|
funcPkg = term
|
|
|
|
|
funcMerge = term.partition(":")[0].partition("[")[0]
|
|
|
|
|
replace = self.funcMerge(funcMerge, resS, localVars, "", nameTemp)
|
|
|
|
|
replace = self.funcMerge(funcPkg, resS, localVars, "", nameTemp)
|
|
|
|
|
if replace == "1":
|
|
|
|
|
replace = self.funcPkg(funcPkg, resS, localVars, "", nameTemp)
|
|
|
|
|
return textTemplateTmp[:resS.start()] + replace + \
|
|
|
|
@ -3377,24 +3378,31 @@ class templateFunction(_error, _warning, _shareTemplate, _shareTermsFunction,
|
|
|
|
|
term = funArgv.replace(" ", "")
|
|
|
|
|
funcPkg = term
|
|
|
|
|
funcPkg, spl, uses = funcPkg.partition('[')
|
|
|
|
|
funcPkg, spl, slot = funcPkg.partition(":")
|
|
|
|
|
if uses:
|
|
|
|
|
uses = uses.rstrip("]")
|
|
|
|
|
if not funcPkg:
|
|
|
|
|
funcPkg = self.get_pkgname_by_filename(self.nameTemplate)
|
|
|
|
|
self.currentBelong = funcPkg
|
|
|
|
|
self.currentBelongSlot = slot
|
|
|
|
|
if self.objVar.Get('cl_action') == 'patch':
|
|
|
|
|
if funcPkg == "%s/%s" % (
|
|
|
|
|
self.objVar.Get('core.cl_core_pkg_category'),
|
|
|
|
|
self.objVar.Get('core.cl_core_pkg_name')):
|
|
|
|
|
replace = self.objVar.Get('core.cl_core_pkg_version')
|
|
|
|
|
if uses:
|
|
|
|
|
from os import environ
|
|
|
|
|
pkg_use = environ.get("USE", "").split(" ")
|
|
|
|
|
for use in filter(None, uses.split(',')):
|
|
|
|
|
if (use[0] == "-" and use[1:] in pkg_use or
|
|
|
|
|
use[0] != "-" and use not in pkg_use):
|
|
|
|
|
replace = ""
|
|
|
|
|
if check_skip(funcPkg):
|
|
|
|
|
spec_slot = self.objVar.Get('core.cl_core_pkg_slot')
|
|
|
|
|
spec_slot = spec_slot.partition('/')[0]
|
|
|
|
|
if not slot or spec_slot == slot:
|
|
|
|
|
replace = self.objVar.Get('core.cl_core_pkg_version')
|
|
|
|
|
if uses:
|
|
|
|
|
from os import environ
|
|
|
|
|
pkg_use = environ.get("USE", "").split(" ")
|
|
|
|
|
for use in filter(None, uses.split(',')):
|
|
|
|
|
if (use[0] == "-" and use[1:] in pkg_use or
|
|
|
|
|
use[0] != "-" and use not in pkg_use):
|
|
|
|
|
replace = ""
|
|
|
|
|
if check_skip(funcPkg):
|
|
|
|
|
replace = ""
|
|
|
|
|
else:
|
|
|
|
|
replace = ""
|
|
|
|
|
else:
|
|
|
|
|
replace = ""
|
|
|
|
@ -3698,7 +3706,7 @@ class templateFunction(_error, _warning, _shareTemplate, _shareTermsFunction,
|
|
|
|
|
return textTemplateTmp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChangedFiles:
|
|
|
|
|
class ChangedFiles(object):
|
|
|
|
|
"""
|
|
|
|
|
Object which contains modified files and package
|
|
|
|
|
"""
|
|
|
|
@ -3712,10 +3720,14 @@ class ChangedFiles:
|
|
|
|
|
if not fn in self.data:
|
|
|
|
|
self.data[fn] = []
|
|
|
|
|
|
|
|
|
|
def addObj(self, filename, action, pkg):
|
|
|
|
|
def addObj(self, filename, action, pkg, slot=""):
|
|
|
|
|
if slot:
|
|
|
|
|
pkgslot = "{}:{}".format(pkg,slot)
|
|
|
|
|
else:
|
|
|
|
|
pkgslot = pkg
|
|
|
|
|
self._createEntry(filename)
|
|
|
|
|
self.data[filename].append((pkg, action))
|
|
|
|
|
self.pkgs.add(pkg)
|
|
|
|
|
self.data[filename].append((pkgslot, action))
|
|
|
|
|
self.pkgs.add(pkgslot)
|
|
|
|
|
|
|
|
|
|
def getPkgs(self):
|
|
|
|
|
return self.pkgs
|
|
|
|
@ -3911,17 +3923,21 @@ class Template(_file, _terms, _warning, xmlShare, _shareTemplate):
|
|
|
|
|
if self.functObj:
|
|
|
|
|
self.functObj.recalculateBaseDir()
|
|
|
|
|
|
|
|
|
|
def _addFile(self, filesApl, pkg=None):
|
|
|
|
|
def _addFile(self, filesApl, pkg=None, slot=None):
|
|
|
|
|
"""
|
|
|
|
|
Add files to ChangedFiles
|
|
|
|
|
"""
|
|
|
|
|
for fn in filesApl:
|
|
|
|
|
if os.path.exists(fn):
|
|
|
|
|
self.changedFiles.addObj(fn, ChangedFiles.FILE_MODIFIED,
|
|
|
|
|
pkg or self.functObj.currentBelong)
|
|
|
|
|
self.changedFiles.addObj(
|
|
|
|
|
fn, ChangedFiles.FILE_MODIFIED,
|
|
|
|
|
pkg or self.functObj.currentBelong,
|
|
|
|
|
slot or self.functObj.currentBelongSlot)
|
|
|
|
|
else:
|
|
|
|
|
self.changedFiles.addObj(fn, ChangedFiles.FILE_REMOVED,
|
|
|
|
|
pkg or self.functObj.currentBelong)
|
|
|
|
|
self.changedFiles.addObj(
|
|
|
|
|
fn, ChangedFiles.FILE_REMOVED,
|
|
|
|
|
pkg or self.functObj.currentBelong,
|
|
|
|
|
slot or self.functObj.currentBelongSlot)
|
|
|
|
|
|
|
|
|
|
def execute_command(self, cmd, lang):
|
|
|
|
|
env = dict(os.environ)
|
|
|
|
@ -4348,6 +4364,7 @@ gettext -d cl_template "$*"
|
|
|
|
|
# Текущий словарь переменных для ini()
|
|
|
|
|
self.functObj.currDictIni = {}
|
|
|
|
|
self.functObj.currentBelong = ""
|
|
|
|
|
self.functObj.currentBelongSlot = ""
|
|
|
|
|
self.functObj.currentAction = HParams.ActionType.Merge
|
|
|
|
|
# Словарь времен модификации env файлов для ini()
|
|
|
|
|
self.functObj.timeConfigsIni = {}
|
|
|
|
@ -4426,10 +4443,10 @@ gettext -d cl_template "$*"
|
|
|
|
|
for pkg in self.objVar.Get('cl_merge_pkg'):
|
|
|
|
|
if not pkg:
|
|
|
|
|
continue
|
|
|
|
|
category = isPkgInstalled(pkg)
|
|
|
|
|
if category:
|
|
|
|
|
atom = list(sorted(getInstalledAtom(pkg)))
|
|
|
|
|
if atom:
|
|
|
|
|
pkgContents = PkgContents("{CATEGORY}/{PF}".format(
|
|
|
|
|
**category[0]))
|
|
|
|
|
**atom[-1]))
|
|
|
|
|
for filename in pkgContents.content.keys():
|
|
|
|
|
if not filename in self.cltObj.filterApplyTemplates:
|
|
|
|
|
self.cltObj.filterApplyTemplates[
|
|
|
|
@ -4541,10 +4558,10 @@ gettext -d cl_template "$*"
|
|
|
|
|
get_digest = lambda x: hashlib.md5(readFile(x)).hexdigest()
|
|
|
|
|
for pkg in list(set(filter(None, list(self.changedFiles.getPkgs()) +
|
|
|
|
|
self.objVar.Get('cl_merge_pkg')))):
|
|
|
|
|
category = isPkgInstalled(pkg, prefix=chrootPath)
|
|
|
|
|
if category:
|
|
|
|
|
atom = list(sorted(getInstalledAtom(pkg, prefix=chrootPath)))
|
|
|
|
|
if atom:
|
|
|
|
|
pkgContents = PkgContents("{CATEGORY}/{PF}".format(
|
|
|
|
|
**category[0]), prefix=chrootPath)
|
|
|
|
|
**atom[-1]), prefix=chrootPath)
|
|
|
|
|
protected = []
|
|
|
|
|
checked_map = {}
|
|
|
|
|
for filename, action in self.changedFiles.getPkgFiles(pkg):
|
|
|
|
@ -4662,6 +4679,7 @@ gettext -d cl_template "$*"
|
|
|
|
|
statInfo = stInfo[stat.ST_MODE]
|
|
|
|
|
prevModule = self.objVar.defaultModule
|
|
|
|
|
prevBelong = self.functObj.currentBelong
|
|
|
|
|
prevBelongSlot = self.functObj.currentBelongSlot
|
|
|
|
|
prevAction = self.functObj.currentAction
|
|
|
|
|
try:
|
|
|
|
|
if stat.S_ISREG(statInfo):
|
|
|
|
@ -4705,6 +4723,7 @@ gettext -d cl_template "$*"
|
|
|
|
|
finally:
|
|
|
|
|
self.objVar.defaultModule = prevModule
|
|
|
|
|
self.functObj.currentBelong = prevBelong
|
|
|
|
|
self.functObj.currentBelongSlot = prevBelongSlot
|
|
|
|
|
self.functObj.currentAction = prevAction
|
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
@ -5056,7 +5075,8 @@ gettext -d cl_template "$*"
|
|
|
|
|
if objHead.typeAppend == HParams.AppendParams.Remove:
|
|
|
|
|
if os.path.isdir(applyDir):
|
|
|
|
|
self.changedFiles.addObj(applyDir, ChangedFiles.DIR_REMOVED,
|
|
|
|
|
self.functObj.currentBelong)
|
|
|
|
|
self.functObj.currentBelong,
|
|
|
|
|
self.functObj.currentBelongSlot)
|
|
|
|
|
# удаляем директорию
|
|
|
|
|
try:
|
|
|
|
|
removeDir(applyDir)
|
|
|
|
@ -5162,7 +5182,8 @@ gettext -d cl_template "$*"
|
|
|
|
|
# (переменная шаблона ur_login)
|
|
|
|
|
if os.path.exists(applyDir):
|
|
|
|
|
self.changedFiles.addObj(applyDir, ChangedFiles.DIR_EXISTS,
|
|
|
|
|
self.functObj.currentBelong)
|
|
|
|
|
self.functObj.currentBelong,
|
|
|
|
|
self.functObj.currentBelongSlot)
|
|
|
|
|
tUid, tGid = getModeFile(applyDir, mode="owner")
|
|
|
|
|
if (self.uid, self.gid) != (tUid, tGid):
|
|
|
|
|
if not self.chownConfDir(applyDir, self.uid, self.gid,
|
|
|
|
@ -5170,7 +5191,8 @@ gettext -d cl_template "$*"
|
|
|
|
|
return "", False, []
|
|
|
|
|
else:
|
|
|
|
|
self.changedFiles.addObj(applyDir, ChangedFiles.DIR_CREATED,
|
|
|
|
|
self.functObj.currentBelong)
|
|
|
|
|
self.functObj.currentBelong,
|
|
|
|
|
self.functObj.currentBelongSlot)
|
|
|
|
|
crDirs = self.createDir(applyDir, False, self.uid, self.gid)
|
|
|
|
|
if not crDirs:
|
|
|
|
|
return "", False, []
|
|
|
|
@ -5261,6 +5283,7 @@ gettext -d cl_template "$*"
|
|
|
|
|
return pathFile
|
|
|
|
|
# not current package file
|
|
|
|
|
pkg = self.functObj.currentBelong
|
|
|
|
|
slot = self.functObj.currentBelongSlot
|
|
|
|
|
if not pkg:
|
|
|
|
|
if not self.allContents:
|
|
|
|
|
fillContents(self.allContents,
|
|
|
|
@ -5272,17 +5295,20 @@ gettext -d cl_template "$*"
|
|
|
|
|
pkg = self.allContents[origName]
|
|
|
|
|
else:
|
|
|
|
|
return pathFile
|
|
|
|
|
pkg = isPkgInstalled(pkg, sortByVersion=True, prefix=chrootPath)
|
|
|
|
|
if not pkg:
|
|
|
|
|
if slot:
|
|
|
|
|
pkgslot = "{}:{}".format(pkg,slot)
|
|
|
|
|
else:
|
|
|
|
|
pkgslot = pkg
|
|
|
|
|
atom = list(sorted(getInstalledAtom(pkgslot, prefix=chrootPath)))
|
|
|
|
|
if not atom:
|
|
|
|
|
return pathFile
|
|
|
|
|
if checkContents("{CATEGORY}/{PF}".format(**pkg[-1]),
|
|
|
|
|
if checkContents("{CATEGORY}/{PF}".format(**atom[-1]),
|
|
|
|
|
pathFile,
|
|
|
|
|
prefix=chrootPath,
|
|
|
|
|
reservedFile='/var/lib/calculate/-CONTENTS-{PN}'.format(
|
|
|
|
|
**pkg[-1]) \
|
|
|
|
|
if self.objVar.Get(
|
|
|
|
|
'cl_ebuild_phase') == 'postinst' \
|
|
|
|
|
else None):
|
|
|
|
|
**atom[-1]) \
|
|
|
|
|
if self.objVar.Get('cl_ebuild_phase') == 'postinst' \
|
|
|
|
|
else None):
|
|
|
|
|
return pathFile
|
|
|
|
|
real_filename = os.path.basename(pathFile)
|
|
|
|
|
real_dirname = os.path.dirname(pathFile)
|
|
|
|
@ -5480,7 +5506,8 @@ gettext -d cl_template "$*"
|
|
|
|
|
if self.functObj.currentBelong:
|
|
|
|
|
self.changedFiles.addObj(pathOrigFile,
|
|
|
|
|
ChangedFiles.FILE_REMOVED,
|
|
|
|
|
self.functObj.currentBelong)
|
|
|
|
|
self.functObj.currentBelong,
|
|
|
|
|
self.functObj.currentBelongSlot)
|
|
|
|
|
return [], False
|
|
|
|
|
# Пропускаем обработку шаблона
|
|
|
|
|
elif typeAppendTemplate == HParams.AppendParams.Skip:
|
|
|
|
@ -6434,6 +6461,7 @@ class templateClt(scanDirectoryClt, Template):
|
|
|
|
|
if self.templDirNameFile == os.path.split(path)[1]:
|
|
|
|
|
return True
|
|
|
|
|
self.functObj.currentBelong = ""
|
|
|
|
|
self.functObj.currentBelongSlot = ""
|
|
|
|
|
# Проверка на переменные в названии файла
|
|
|
|
|
if not self.getNeedTemplate(path):
|
|
|
|
|
if self.getError():
|
|
|
|
|