Добавлено переименование custom.{short} файлов при переключении профиля

legacy27
vanhempi 84446e44bc
commit 81b3b9535f

@ -1620,3 +1620,38 @@ class Update(MethodsInterface):
layman = emerge_parser.CommandExecutor(cmd_path, ["-f"])
layman.execute()
return layman.success()
def rename_custom_files(self):
"""
Переименовать все custom файлы: keywords, use, sets и т.д. в связи
с изменением профиля
"""
newdv = self.clVars.Get("cl_update_profile_datavars")
cur_short = self.clVars.Get("os_linux_shortname").lower()
new_short = newdv["os_linux_shortname"].lower()
if cur_short != new_short:
for fn in ("/etc/portage/package.keywords/custom.{}",
"/etc/portage/package.use/custom.{}",
"/etc/portage/package.mask/custom.{}",
"/etc/portage/package.unmask/custom.{}",
"/etc/portage/sets/custom.{}",
"/etc/portage/make.conf/custom.{}"):
fn_source = fn.format(cur_short)
fn_target = fn.format(new_short)
try:
if path.exists(fn_source) and not path.exists(fn_target):
os.rename(fn_source, fn_target)
except (OSError, IOError) as e:
self.printWARNING(str(e))
world_sets_fn = "/var/lib/portage/world_sets"
if path.exists(world_sets_fn):
worlds_sets = readFile(world_sets_fn)
new_worlds_sets = re.sub("^@custom.{}$".format(cur_short),
"@custom.{}".format(new_short),
worlds_sets, flags=re.M)
try:
with open(world_sets_fn, 'w') as fd:
fd.write(new_worlds_sets)
except IOError as e:
self.printWARNING(str(e))
return True

@ -120,6 +120,9 @@ class ClUpdateProfileAction(Action):
'message': __("Switching to profile {cl_update_profile_system}"),
'method': 'Update.setProfile(cl_update_profile_system)'
},
{'name': 'rename_custom',
'method': 'Update.rename_custom_files()',
},
{'name': 'revision',
'message': __("Fixing the settings"),
'method': 'Update.applyProfileTemplates(cl_template_clt_set,'

Ladataan…
Peruuta
Tallenna