commit:     ddc1b50d47ffde9b9bbceb83ce0b5a6cb7045e1b
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 18 23:32:08 2020 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed Apr 22 05:51:22 2020 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=ddc1b50d

catalyst: Simplify config_profile_link()

I see no use in making this a resume point since making a symlink is a
cheap operation.

Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>

 catalyst/base/stagebase.py | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index cc997688..0531cf61 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -3,6 +3,9 @@ import os
 import platform
 import shutil
 import sys
+
+from pathlib import Path
+
 import toml
 
 from snakeoil import fileutils
@@ -902,24 +905,16 @@ class StageBase(TargetBase, ClearBase, GenBase):
                 self.snapcache_lock.unlock()
 
     def config_profile_link(self):
-        if "autoresume" in self.settings["options"] \
-                and self.resume.is_enabled("config_profile_link"):
-            log.notice(
-                'Resume point detected, skipping config_profile_link 
operation...')
-        else:
-            # TODO: zmedico and I discussed making this a directory and pushing
-            # in a parent file, as well as other user-specified configuration.
-            log.info('Configuring profile link...')
-            clear_path(self.settings['chroot_path'] +
-                       self.settings['port_conf'] + '/make.profile')
-            ensure_dirs(self.settings['chroot_path'] +
-                        self.settings['port_conf'])
-            cmd(['ln', '-sf',
-                 '../..' + self.settings['portdir'] +
-                 '/profiles/' + self.settings['target_profile'],
-                 self.settings['chroot_path'] + self.settings['port_conf'] + 
'/make.profile'],
-                env=self.env)
-            self.resume.enable("config_profile_link")
+        log.info('Configuring profile link...')
+        make_profile = Path(self.settings['chroot_path'],
+                            self.settings['port_conf'],
+                            'make.profile')
+        make_profile.unlink()
+        make_profile.symlink_to(Path('../..',
+                                     self.settings['portdir'],
+                                     'profiles',
+                                     self.settings['target_profile']),
+                                target_is_directory=True)
 
     def setup_confdir(self):
         if "autoresume" in self.settings["options"] \

Reply via email to