commit:     2e9135319c1fca1f6d3ed84d9f13b0e300db49c7
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 19 22:06:11 2017 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Mar 19 22:06:11 2017 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=2e913531

Unify stage cleaning

Move the clear_portage() code to the python side clean().
Put that code behind the sticky-config option.

 catalyst/base/stagebase.py          |  9 +++++++++
 catalyst/fileops.py                 |  2 +-
 targets/stage2/stage2-controller.sh |  1 -
 targets/stage3/stage3-controller.sh |  1 -
 targets/stage4/stage4-controller.sh |  1 -
 targets/support/functions.sh        | 11 -----------
 6 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index a7aa7f41..7a41973c 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -1201,6 +1201,15 @@ class StageBase(TargetBase, ClearBase, GenBase):
                if os.path.exists(hosts_file + '.catalyst'):
                        os.rename(hosts_file + '.catalyst', hosts_file)
 
+               # optionally clean up portage configs
+               if ("portage_prefix" in self.settings and
+                       "sticky-config" not in self.settings["options"]):
+                       for _dir in "keywords", "mask", "unmask", "use":
+                               target = pjoin([self.settings['chroot_path'],
+                                       "/etc/portage/package.%s" % _dir,
+                                       self.settings["portage_prefix"]])
+                               clear_path(target)
+
                # Remove our overlay
                if os.path.exists(self.settings["chroot_path"] + 
self.settings["local_overlay"]):
                        clear_path(self.settings["chroot_path"] + 
self.settings["local_overlay"])

diff --git a/catalyst/fileops.py b/catalyst/fileops.py
index d2bd4530..ef4ee8d1 100644
--- a/catalyst/fileops.py
+++ b/catalyst/fileops.py
@@ -71,7 +71,7 @@ def clear_dir(target, mode=0o755, chg_flags=False, 
remove=False,
 
        mystat = None
        if os.path.isdir(target) and not os.path.islink(target):
-               log.info('Emptying directory: %s', target)
+               log.notice('Emptying directory: %s', target)
                # stat the dir, delete the dir, recreate the dir and set
                # the proper perms and ownership
                try:

diff --git a/targets/stage2/stage2-controller.sh 
b/targets/stage2/stage2-controller.sh
index 2eee79f3..25e51208 100755
--- a/targets/stage2/stage2-controller.sh
+++ b/targets/stage2/stage2-controller.sh
@@ -17,7 +17,6 @@ case $1 in
        ;;
 
        preclean)
-               clear_portage
                exec_in_chroot 
${clst_shdir}/${clst_target}/${clst_target}-preclean-chroot.sh
        ;;
 

diff --git a/targets/stage3/stage3-controller.sh 
b/targets/stage3/stage3-controller.sh
index 2d415e40..df1479ea 100755
--- a/targets/stage3/stage3-controller.sh
+++ b/targets/stage3/stage3-controller.sh
@@ -16,7 +16,6 @@ case $1 in
        ;;
 
        preclean)
-               clear_portage
                exec_in_chroot 
${clst_shdir}/${clst_target}/${clst_target}-preclean-chroot.sh
        ;;
 

diff --git a/targets/stage4/stage4-controller.sh 
b/targets/stage4/stage4-controller.sh
index 6a876c82..d42f302f 100755
--- a/targets/stage4/stage4-controller.sh
+++ b/targets/stage4/stage4-controller.sh
@@ -41,7 +41,6 @@ case $1 in
        ;;
 
        preclean)
-               clear_portage
                exec_in_chroot 
${clst_shdir}/${clst_target}/${clst_target}-preclean-chroot.sh ${clst_root_path}
        ;;
 

diff --git a/targets/support/functions.sh b/targets/support/functions.sh
index ac4ec6c7..cca2fd82 100755
--- a/targets/support/functions.sh
+++ b/targets/support/functions.sh
@@ -16,17 +16,6 @@ delete_from_chroot(){
        fi
 }
 
-clear_portage() {
-       if [ -n "${clst_portage_prefix}" ]; then
-               for dir in "keywords", "mask", "unmask", "use"; do
-                       [ -d 
${clst_chroot_path}/etc/portage/package.${dir}/${clst_portage_prefix} ] &&
-                               echo "Clear 
${clst_chroot_path}/etc/portage/package.${dir}/${clst_portage_prefix}"
-                       [ -d 
${clst_chroot_path}/etc/portage/package.${dir}/${clst_portage_prefix} ] &&
-                               rm -R 
"${clst_chroot_path}/etc/portage/package.${dir}/${clst_portage_prefix}"
-               done
-       fi
-}
-
 exec_in_chroot(){
 # Takes the full path to the source file as its argument
 # copies the file to the /tmp directory of the chroot

Reply via email to