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

legacy27 3.6.6
Хирецкий Михаил 4 роки тому
джерело f204e530e8
коміт 8cdddda360

@ -44,7 +44,7 @@ from contextlib import contextmanager
import tempfile
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,
PackageInformation,
get_packages_files_directory,
@ -343,6 +343,27 @@ class Update(MethodsInterface):
git.trimRepository(rpath, cb_progress=self.setProgress)
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")
def syncRepositories(self, repname, fallback_sync=False,
clean_on_error=True):
@ -369,15 +390,15 @@ class Update(MethodsInterface):
mtime = MTimeKeeper(path.join(rpath, "profiles/updates"))
mtime.save()
self.migrateLayman(dv.Get('cl_update_repos_storage'),
dv.Get('cl_update_layman_storage'), repname, rpath_orig)
try:
if clean_on_error:
try:
layman = Layman(dv.Get('cl_update_layman_installed'),
dv.Get('cl_update_layman_make'),
dv.Get('cl_update_layman_conf'),
prefix=chroot_path)
if repname not in ("portage", "gentoo"):
layman.add(repname, url, rpath_orig)
repconf = ReposConf(dv.Get('cl_update_reposconf'),
dv.Get('cl_update_reposconf_dir'),
prefix=chroot_path)
repconf.add(repname, url, rpath_orig)
if not self._syncRepository(repname, url, rpath, revision,
cb_progress=self.setProgress,
clean=check_status,
@ -414,12 +435,10 @@ class Update(MethodsInterface):
clean=check_status):
return "skip"
layman = Layman(dv.Get('cl_update_layman_installed'),
dv.Get('cl_update_layman_make'),
dv.Get('cl_update_layman_conf'),
prefix=chroot_path)
if repname not in ("portage", "gentoo"):
layman.add(repname, url, rpath_orig)
repconf = ReposConf(dv.Get('cl_update_reposconf'),
dv.Get('cl_update_reposconf_dir'),
prefix=chroot_path)
repconf.add(repname, url, rpath_orig)
finally:
mtime.restore()
return True
@ -478,34 +497,34 @@ class Update(MethodsInterface):
if all(not path.exists(path.join(rpath, x)) for x in cachenames):
OverlayOwnCache(self.clVars).discard(name)
def syncLaymanRepository(self, repname):
def syncOtherRepository(self, repname):
"""
Обновить репозиторий через layman
Обновить репозиторий через emerge --sync
"""
layman = self.get_prog_path('/usr/bin/layman')
if not layman:
raise UpdateError(_("The Layman tool is not found"))
emerge = self.get_prog_path('/usr/bin/emerge')
if not emerge:
raise UpdateError(_("The Emerge is not found"))
rpath = self.clVars.Select('cl_update_other_rep_path',
where='cl_update_other_rep_name', eq=repname,
limit=1)
laymanname = path.basename(rpath)
self.stash_cache(rpath, laymanname)
repdirname = path.basename(rpath)
self.stash_cache(rpath, repdirname)
try:
if Git.is_git(rpath):
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():
self.setProgress(perc)
else:
p = process(layman, "-s", repname, stderr=STDOUT)
p = process(emerge, "--sync", repname, stderr=STDOUT)
if p.failed():
raise UpdateError(
_("Failed to update the {rname} repository").format(
rname=repname),
addon=p.read())
finally:
self.unstash_cache(rpath, laymanname)
self.unstash_cache(rpath, repdirname)
return True
def _regenCache_process(self, progname, repname, cpu_num):
@ -568,7 +587,7 @@ class Update(MethodsInterface):
def _eixUpdateCommand(self, eix_cmd, countRep):
return PercentProgress(eix_cmd, "-F", part=countRep or 1, atty=True)
def eixUpdate(self, repositroies):
def eixUpdate(self, repositories):
"""
Выполенине eix-update для репозиторием
@ -580,7 +599,7 @@ class Update(MethodsInterface):
if not eixupdate:
raise UpdateError(_("The Eix tool is not found"))
self.addProgress()
countRep = len(repositroies)
countRep = len(repositories)
p = self._eixUpdateCommand(eixupdate, countRep)
for perc in p.progress():
self.setProgress(perc)
@ -1610,19 +1629,19 @@ class Update(MethodsInterface):
self.endTask()
return True
def update_layman(self):
def update_rep_list(self):
"""
Обновить базу layman
Обновить список доступных репозиториев
:param builder_path:
:return:
"""
cmd = "/usr/bin/layman"
cmd = "/usr/bin/eselect"
cmd_path = self.get_prog_path(cmd)
if not cmd_path:
raise UpdateError(_("Failed to find the %s command") % cmd)
layman = emerge_parser.CommandExecutor(cmd_path, ["-f"])
layman.execute()
return layman.success()
repsync = emerge_parser.CommandExecutor(cmd_path, ["repository", "list"])
repsync.execute()
return repsync.success()
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
not GetBool('update.cl_update_usetag_set')),
},
{'name': 'update_layman',
'message': __("Layman cache update"),
'method': Object('update_layman()'),
{'name': 'update_rep_list',
'message': __("Repository cache update"),
'method': Object('update_rep_list()'),
'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') != "/"),
'essential': False,
},
{'name': 'sync_other_reps',
'foreach': 'update.cl_update_other_rep_name',
'message': __("Syncing the {eachvar:capitalize} repository"),
'method': Object('syncLaymanRepository(eachvar)'),
'method': Object('syncOtherRepository(eachvar)'),
'condition': lambda GetBool: GetBool('update.cl_update_other_set')
},
{'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.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.portage import Layman
from calculate.lib.utils.portage import ReposConf
from ..profile import (RepositoryStorageSet, DEFAULT_BRANCH,
LocalStorage, ProfileRepository, CacheStorage)
@ -164,30 +164,26 @@ class VariableClUpdateRepUrl(Variable):
value = []
class VariableClUpdateLaymanConfig(ReadonlyVariable):
class VariableClUpdateLaymanStorage(Variable):
"""
Объект конфига layman
Путь к репозиториям
"""
type = "object"
param_name = "storage"
fallback_value = "var/lib/layman"
def get(self):
chroot = self.Get('cl_chroot_path')
cp = ConfigParser()
cp.read(path.join(chroot, 'etc/layman/layman.cfg'))
return cp
return pathJoin(self.Get('cl_chroot_path'), self.fallback_value)
class VariableClUpdateLaymanStorage(Variable):
class VariableClUpdateReposStorage(Variable):
"""
Путь к репозиториям layman
Путь к репозиториям
"""
param_name = "storage"
fallback_value = "var/lib/layman"
fallback_value = "var/db/repos"
def get(self):
cp = self.Get('cl_update_layman_config')
res = cp.get('MAIN', self.param_name, fallback=self.fallback_value)
return pathJoin(self.Get('cl_chroot_path'), res)
return pathJoin(self.Get('cl_chroot_path'), self.fallback_value)
class VariableClUpdateRepPath(ReadonlyVariable):
@ -199,7 +195,7 @@ class VariableClUpdateRepPath(ReadonlyVariable):
'gentoo': 'usr/portage'}
def get(self):
repPath = self.Get('cl_update_layman_storage')
repPath = self.Get('cl_update_repos_storage')
chroot_path = self.Get('cl_chroot_path')
def generatePaths(names):
@ -569,21 +565,15 @@ class VariableClUpdateOtherRepData(ReadonlyTableVariable):
source = ['cl_update_other_rep_name',
'cl_update_other_rep_path']
portdir_overlay = "main.cl_portdir_overlay"
def generator(self):
repNames = self.Get('update.cl_update_rep_name')
chroot_path = self.Get('cl_chroot_path')
layman = Layman(self.Get('update.cl_update_layman_installed'),
self.Get('update.cl_update_layman_make'),
self.Get('update.cl_update_layman_conf'),
prefix=chroot_path)
layman_overlays = layman.get_installed()
for rpath in self.Get(self.portdir_overlay):
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)
reposconf = ReposConf(
self.Get('update.cl_update_reposconf'),
self.Get('update.cl_update_reposconf_dir'),
prefix=chroot_path)
for rname, rpath in reposconf.get_other_repositories():
yield (_u8(rname), pathJoin(chroot_path, _u8(rpath)))
def get(self, hr=HumanReadable.No):
return list(self.generator())
@ -607,28 +597,21 @@ class VariableClUpdateOtherRepPath(FieldValue, ReadonlyVariable):
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):
"""
Путь до конфигурационного файла репозиториев для layman
"""
param_name = "repos_conf"
fallback_value = "etc/portage/repos.conf/layman.conf"
value_format = "{update.cl_update_reposconf_dir}/calculate.conf"
class VariableClUpdatePretendSet(Variable):
@ -687,7 +670,7 @@ class VariableClUpdateProfileStorage(ReadonlyVariable):
def get(self):
git = self.Get('cl_update_git')
return RepositoryStorageSet(
LocalStorage(git, '/var/lib/layman'),
LocalStorage(git, '/var/db/repos'),
CacheStorage(git, '/var/calculate/tmp/update'))
@ -1288,14 +1271,16 @@ class DataVarsUpdateProfile(SimpleDataVars):
env.VariableClFeatures(),
env.VariableClMakeProfile(),
env.VariableClEbuildPhase(),
VariableClUpdateReposStorage(section="update"),
VariableClUpdateLaymanStorage(section="update"),
VariableClUpdateReposconf(section="update"),
VariableClUpdateReposconfDir(section="update"),
VariableClUpdateRepData(section="update"),
VariableClUpdateRepPath(section="update"),
VariableClUpdateRepRev(section="update"),
VariableClUpdateBranch(section="update"),
VariableClUpdateBranchName(section="update"),
VariableClUpdateUsetagSet(section="update"),
VariableClUpdateLaymanConfig(section="update"),
VariableClUpdateLaymanStorage(section="update"),
VariableClUpdateRepName(section="update"),
VariableClUpdateRep(section="update"),
VariableClUpdateRepUrl(section="update"),

Завантаження…
Відмінити
Зберегти