|
|
@ -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)
|
|
|
|
if repname not in ("portage", "gentoo"):
|
|
|
|
repconf.add(repname, url, rpath_orig)
|
|
|
|
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)
|
|
|
|
if repname not in ("portage", "gentoo"):
|
|
|
|
repconf.add(repname, url, rpath_orig)
|
|
|
|
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):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|