From 81b3b9535f491a989fe306988e7d9ee9468a7b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A5=D0=B8=D1=80=D0=B5=D1=86=D0=BA=D0=B8=D0=B9=20=D0=9C?= =?UTF-8?q?=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Tue, 25 Dec 2018 10:10:11 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B8=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20custom.{short}=20=D1=84?= =?UTF-8?q?=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2=20=D0=BF=D1=80=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8=20=D0=BF=D1=80=D0=BE=D1=84=D0=B8=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pym/update/update.py | 35 +++++++++++++++++++++++++++ pym/update/utils/cl_update_profile.py | 3 +++ 2 files changed, 38 insertions(+) diff --git a/pym/update/update.py b/pym/update/update.py index c7a621a..9e46f17 100644 --- a/pym/update/update.py +++ b/pym/update/update.py @@ -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 diff --git a/pym/update/utils/cl_update_profile.py b/pym/update/utils/cl_update_profile.py index 35b55c3..6a9ae9f 100644 --- a/pym/update/utils/cl_update_profile.py +++ b/pym/update/utils/cl_update_profile.py @@ -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,'