Переход с Layman на repos.conf

legacy27 3.6.6
parent f204e530e8
commit 8cdddda360

@ -44,7 +44,7 @@ from contextlib import contextmanager
import tempfile import tempfile
from calculate.lib.utils.git import Git, GitError, MTimeKeeper, NotGitError from calculate.lib.utils.git import Git, GitError, MTimeKeeper, NotGitError
from calculate.lib.utils.portage import (Layman, EmergeLog, from calculate.lib.utils.portage import (ReposConf, EmergeLog,
EmergeLogNamedTask, EmergeLogNamedTask,
PackageInformation, PackageInformation,
get_packages_files_directory, get_packages_files_directory,
@ -343,6 +343,27 @@ class Update(MethodsInterface):
git.trimRepository(rpath, cb_progress=self.setProgress) git.trimRepository(rpath, cb_progress=self.setProgress)
return True return True
def migrateLayman(self, reposdir, laymandir, repname, rpath_orig):
if rpath_orig.startswith("/var/db/repos/"):
dn_name = os.path.basename(rpath_orig)
repos_fullname = pathJoin(reposdir, dn_name)
layman_fullname = pathJoin(laymandir, dn_name)
if (not os.path.islink(layman_fullname) and
os.path.isdir(layman_fullname) and
not os.path.exists(repos_fullname)):
self.startTask(_("Move {repname} from {laymandir} to {reposdir}").format(
repname=repname.capitalize(),
laymandir="/var/lib/layman",
reposdir="/var/db/repos"))
symlink_target = os.path.relpath(repos_fullname, laymandir)
if not os.path.exists(reposdir):
makeDirectory(reposdir)
os.rename(layman_fullname, repos_fullname)
os.symlink(symlink_target, layman_fullname)
#print "MYDEBUG", reposdir, laymandir, rpath_orig
self.endTask(True)
return True
@variable_module("update") @variable_module("update")
def syncRepositories(self, repname, fallback_sync=False, def syncRepositories(self, repname, fallback_sync=False,
clean_on_error=True): clean_on_error=True):
@ -369,15 +390,15 @@ class Update(MethodsInterface):
mtime = MTimeKeeper(path.join(rpath, "profiles/updates")) mtime = MTimeKeeper(path.join(rpath, "profiles/updates"))
mtime.save() mtime.save()
self.migrateLayman(dv.Get('cl_update_repos_storage'),
dv.Get('cl_update_layman_storage'), repname, rpath_orig)
try: try:
if clean_on_error: if clean_on_error:
try: try:
layman = Layman(dv.Get('cl_update_layman_installed'), repconf = ReposConf(dv.Get('cl_update_reposconf'),
dv.Get('cl_update_layman_make'), dv.Get('cl_update_reposconf_dir'),
dv.Get('cl_update_layman_conf'), prefix=chroot_path)
prefix=chroot_path) repconf.add(repname, url, rpath_orig)
if repname not in ("portage", "gentoo"):
layman.add(repname, url, rpath_orig)
if not self._syncRepository(repname, url, rpath, revision, if not self._syncRepository(repname, url, rpath, revision,
cb_progress=self.setProgress, cb_progress=self.setProgress,
clean=check_status, clean=check_status,
@ -414,12 +435,10 @@ class Update(MethodsInterface):
clean=check_status): clean=check_status):
return "skip" return "skip"
layman = Layman(dv.Get('cl_update_layman_installed'), repconf = ReposConf(dv.Get('cl_update_reposconf'),
dv.Get('cl_update_layman_make'), dv.Get('cl_update_reposconf_dir'),
dv.Get('cl_update_layman_conf'), prefix=chroot_path)
prefix=chroot_path) repconf.add(repname, url, rpath_orig)
if repname not in ("portage", "gentoo"):
layman.add(repname, url, rpath_orig)
finally: finally:
mtime.restore() mtime.restore()
return True return True
@ -478,34 +497,34 @@ class Update(MethodsInterface):
if all(not path.exists(path.join(rpath, x)) for x in cachenames): if all(not path.exists(path.join(rpath, x)) for x in cachenames):
OverlayOwnCache(self.clVars).discard(name) OverlayOwnCache(self.clVars).discard(name)
def syncLaymanRepository(self, repname): def syncOtherRepository(self, repname):
""" """
Обновить репозиторий через layman Обновить репозиторий через emerge --sync
""" """
layman = self.get_prog_path('/usr/bin/layman') emerge = self.get_prog_path('/usr/bin/emerge')
if not layman: if not emerge:
raise UpdateError(_("The Layman tool is not found")) raise UpdateError(_("The Emerge is not found"))
rpath = self.clVars.Select('cl_update_other_rep_path', rpath = self.clVars.Select('cl_update_other_rep_path',
where='cl_update_other_rep_name', eq=repname, where='cl_update_other_rep_name', eq=repname,
limit=1) limit=1)
laymanname = path.basename(rpath) repdirname = path.basename(rpath)
self.stash_cache(rpath, laymanname) self.stash_cache(rpath, repdirname)
try: try:
if Git.is_git(rpath): if Git.is_git(rpath):
self.addProgress() self.addProgress()
p = PercentProgress(layman, "-s", laymanname, part=1, atty=True) p = PercentProgress(emerge, "--sync", repname, part=1, atty=True)
for perc in p.progress(): for perc in p.progress():
self.setProgress(perc) self.setProgress(perc)
else: else:
p = process(layman, "-s", repname, stderr=STDOUT) p = process(emerge, "--sync", repname, stderr=STDOUT)
if p.failed(): if p.failed():
raise UpdateError( raise UpdateError(
_("Failed to update the {rname} repository").format( _("Failed to update the {rname} repository").format(
rname=repname), rname=repname),
addon=p.read()) addon=p.read())
finally: finally:
self.unstash_cache(rpath, laymanname) self.unstash_cache(rpath, repdirname)
return True return True
def _regenCache_process(self, progname, repname, cpu_num): def _regenCache_process(self, progname, repname, cpu_num):
@ -568,7 +587,7 @@ class Update(MethodsInterface):
def _eixUpdateCommand(self, eix_cmd, countRep): def _eixUpdateCommand(self, eix_cmd, countRep):
return PercentProgress(eix_cmd, "-F", part=countRep or 1, atty=True) return PercentProgress(eix_cmd, "-F", part=countRep or 1, atty=True)
def eixUpdate(self, repositroies): def eixUpdate(self, repositories):
""" """
Выполенине eix-update для репозиторием Выполенине eix-update для репозиторием
@ -580,7 +599,7 @@ class Update(MethodsInterface):
if not eixupdate: if not eixupdate:
raise UpdateError(_("The Eix tool is not found")) raise UpdateError(_("The Eix tool is not found"))
self.addProgress() self.addProgress()
countRep = len(repositroies) countRep = len(repositories)
p = self._eixUpdateCommand(eixupdate, countRep) p = self._eixUpdateCommand(eixupdate, countRep)
for perc in p.progress(): for perc in p.progress():
self.setProgress(perc) self.setProgress(perc)
@ -1610,19 +1629,19 @@ class Update(MethodsInterface):
self.endTask() self.endTask()
return True return True
def update_layman(self): def update_rep_list(self):
""" """
Обновить базу layman Обновить список доступных репозиториев
:param builder_path: :param builder_path:
:return: :return:
""" """
cmd = "/usr/bin/layman" cmd = "/usr/bin/eselect"
cmd_path = self.get_prog_path(cmd) cmd_path = self.get_prog_path(cmd)
if not cmd_path: if not cmd_path:
raise UpdateError(_("Failed to find the %s command") % cmd) raise UpdateError(_("Failed to find the %s command") % cmd)
layman = emerge_parser.CommandExecutor(cmd_path, ["-f"]) repsync = emerge_parser.CommandExecutor(cmd_path, ["repository", "list"])
layman.execute() repsync.execute()
return layman.success() return repsync.success()
def rename_custom_files(self): def rename_custom_files(self):
""" """

@ -142,18 +142,18 @@ def get_synchronization_tasks(object_name):
'condition': lambda Get, GetBool: (Get('update.cl_update_sync_rep') and 'condition': lambda Get, GetBool: (Get('update.cl_update_sync_rep') and
not GetBool('update.cl_update_usetag_set')), not GetBool('update.cl_update_usetag_set')),
}, },
{'name': 'update_layman', {'name': 'update_rep_list',
'message': __("Layman cache update"), 'message': __("Repository cache update"),
'method': Object('update_layman()'), 'method': Object('update_rep_list()'),
'condition': lambda Get: (isPkgInstalled( 'condition': lambda Get: (isPkgInstalled(
"app-portage/layman", prefix=Get('cl_chroot_path')) and "app-eselect/eselect-repository", prefix=Get('cl_chroot_path')) and
Get('cl_chroot_path') != "/"), Get('cl_chroot_path') != "/"),
'essential': False, 'essential': False,
}, },
{'name': 'sync_other_reps', {'name': 'sync_other_reps',
'foreach': 'update.cl_update_other_rep_name', 'foreach': 'update.cl_update_other_rep_name',
'message': __("Syncing the {eachvar:capitalize} repository"), 'message': __("Syncing the {eachvar:capitalize} repository"),
'method': Object('syncLaymanRepository(eachvar)'), 'method': Object('syncOtherRepository(eachvar)'),
'condition': lambda GetBool: GetBool('update.cl_update_other_set') 'condition': lambda GetBool: GetBool('update.cl_update_other_set')
}, },
{'name': 'trim_reps', {'name': 'trim_reps',

@ -31,9 +31,9 @@ from calculate.lib.utils.files import readFile, listDirectory, process, pathJoin
from calculate.lib.configparser import ConfigParser from calculate.lib.configparser import ConfigParser
from calculate.lib.cl_lang import setLocalTranslate from calculate.lib.cl_lang import setLocalTranslate
from calculate.lib.utils.text import simplify_profiles from calculate.lib.utils.text import simplify_profiles, _u8
from calculate.lib.utils.git import Git, GitError from calculate.lib.utils.git import Git, GitError
from calculate.lib.utils.portage import Layman from calculate.lib.utils.portage import ReposConf
from ..profile import (RepositoryStorageSet, DEFAULT_BRANCH, from ..profile import (RepositoryStorageSet, DEFAULT_BRANCH,
LocalStorage, ProfileRepository, CacheStorage) LocalStorage, ProfileRepository, CacheStorage)
@ -164,30 +164,26 @@ class VariableClUpdateRepUrl(Variable):
value = [] value = []
class VariableClUpdateLaymanConfig(ReadonlyVariable): class VariableClUpdateLaymanStorage(Variable):
""" """
Объект конфига layman Путь к репозиториям
""" """
type = "object" param_name = "storage"
fallback_value = "var/lib/layman"
def get(self): def get(self):
chroot = self.Get('cl_chroot_path') return pathJoin(self.Get('cl_chroot_path'), self.fallback_value)
cp = ConfigParser()
cp.read(path.join(chroot, 'etc/layman/layman.cfg'))
return cp
class VariableClUpdateLaymanStorage(Variable): class VariableClUpdateReposStorage(Variable):
""" """
Путь к репозиториям layman Путь к репозиториям
""" """
param_name = "storage" param_name = "storage"
fallback_value = "var/lib/layman" fallback_value = "var/db/repos"
def get(self): def get(self):
cp = self.Get('cl_update_layman_config') return pathJoin(self.Get('cl_chroot_path'), self.fallback_value)
res = cp.get('MAIN', self.param_name, fallback=self.fallback_value)
return pathJoin(self.Get('cl_chroot_path'), res)
class VariableClUpdateRepPath(ReadonlyVariable): class VariableClUpdateRepPath(ReadonlyVariable):
@ -199,7 +195,7 @@ class VariableClUpdateRepPath(ReadonlyVariable):
'gentoo': 'usr/portage'} 'gentoo': 'usr/portage'}
def get(self): def get(self):
repPath = self.Get('cl_update_layman_storage') repPath = self.Get('cl_update_repos_storage')
chroot_path = self.Get('cl_chroot_path') chroot_path = self.Get('cl_chroot_path')
def generatePaths(names): def generatePaths(names):
@ -569,21 +565,15 @@ class VariableClUpdateOtherRepData(ReadonlyTableVariable):
source = ['cl_update_other_rep_name', source = ['cl_update_other_rep_name',
'cl_update_other_rep_path'] 'cl_update_other_rep_path']
portdir_overlay = "main.cl_portdir_overlay"
def generator(self): def generator(self):
repNames = self.Get('update.cl_update_rep_name') repNames = self.Get('update.cl_update_rep_name')
chroot_path = self.Get('cl_chroot_path') chroot_path = self.Get('cl_chroot_path')
layman = Layman(self.Get('update.cl_update_layman_installed'), reposconf = ReposConf(
self.Get('update.cl_update_layman_make'), self.Get('update.cl_update_reposconf'),
self.Get('update.cl_update_layman_conf'), self.Get('update.cl_update_reposconf_dir'),
prefix=chroot_path) prefix=chroot_path)
layman_overlays = layman.get_installed() for rname, rpath in reposconf.get_other_repositories():
for rpath in self.Get(self.portdir_overlay): yield (_u8(rname), pathJoin(chroot_path, _u8(rpath)))
repo_file = path.join(rpath, "profiles/repo_name")
rname = readFile(repo_file).strip() or path.basename(rpath)
if rname in layman_overlays and rname not in repNames:
yield (rname, rpath)
def get(self, hr=HumanReadable.No): def get(self, hr=HumanReadable.No):
return list(self.generator()) return list(self.generator())
@ -607,28 +597,21 @@ class VariableClUpdateOtherRepPath(FieldValue, ReadonlyVariable):
column = 1 column = 1
class VariableClUpdateLaymanInstalled(VariableClUpdateLaymanStorage): class VariableClUpdateReposconfDir(ReadonlyVariable):
""" """
Путь до файла layman installed.xml Директорий с файлами, описывающими репозитории
""" """
param_name = "installed"
fallback_value = "var/lib/layman/installed.xml"
def get(self):
chroot = self.Get('cl_chroot_path')
return path.join(chroot, '/etc/portage/repos.conf')
class VariableClUpdateLaymanMake(VariableClUpdateLaymanStorage): class VariableClUpdateReposconf(ReadonlyVariable):
""" """
Путь до файла make.conf изменяемого layman`ом Путь конфигурационного файла repos.conf, содержащего Calculate репозитории
""" """
param_name = "make_conf"
fallback_value = "var/lib/layman/make.conf"
class VariableClUpdateLaymanConf(VariableClUpdateLaymanStorage): value_format = "{update.cl_update_reposconf_dir}/calculate.conf"
"""
Путь до конфигурационного файла репозиториев для layman
"""
param_name = "repos_conf"
fallback_value = "etc/portage/repos.conf/layman.conf"
class VariableClUpdatePretendSet(Variable): class VariableClUpdatePretendSet(Variable):
@ -687,7 +670,7 @@ class VariableClUpdateProfileStorage(ReadonlyVariable):
def get(self): def get(self):
git = self.Get('cl_update_git') git = self.Get('cl_update_git')
return RepositoryStorageSet( return RepositoryStorageSet(
LocalStorage(git, '/var/lib/layman'), LocalStorage(git, '/var/db/repos'),
CacheStorage(git, '/var/calculate/tmp/update')) CacheStorage(git, '/var/calculate/tmp/update'))
@ -1288,14 +1271,16 @@ class DataVarsUpdateProfile(SimpleDataVars):
env.VariableClFeatures(), env.VariableClFeatures(),
env.VariableClMakeProfile(), env.VariableClMakeProfile(),
env.VariableClEbuildPhase(), env.VariableClEbuildPhase(),
VariableClUpdateReposStorage(section="update"),
VariableClUpdateLaymanStorage(section="update"),
VariableClUpdateReposconf(section="update"),
VariableClUpdateReposconfDir(section="update"),
VariableClUpdateRepData(section="update"), VariableClUpdateRepData(section="update"),
VariableClUpdateRepPath(section="update"), VariableClUpdateRepPath(section="update"),
VariableClUpdateRepRev(section="update"), VariableClUpdateRepRev(section="update"),
VariableClUpdateBranch(section="update"), VariableClUpdateBranch(section="update"),
VariableClUpdateBranchName(section="update"), VariableClUpdateBranchName(section="update"),
VariableClUpdateUsetagSet(section="update"), VariableClUpdateUsetagSet(section="update"),
VariableClUpdateLaymanConfig(section="update"),
VariableClUpdateLaymanStorage(section="update"),
VariableClUpdateRepName(section="update"), VariableClUpdateRepName(section="update"),
VariableClUpdateRep(section="update"), VariableClUpdateRep(section="update"),
VariableClUpdateRepUrl(section="update"), VariableClUpdateRepUrl(section="update"),

Loading…
Cancel
Save