commit:     c0d32754eb737d11b14c7a38c36014a98947ca12
Author:     Jorge Manuel B. S. Vicetto (jmbsvicetto) <jmbsvicetto <AT> gentoo 
<DOT> org>
AuthorDate: Sat Mar 11 00:43:29 2017 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Mar 16 22:56:11 2017 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=c0d32754

Add prepare_portage and clear_portage to functions.sh and to the controller.sh 
file for stages 2, 3 and 4.

Signed-off-by: Jorge Manuel B. S. Vicetto (jmbsvicetto) <jmbsvicetto <AT> 
gentoo.org>

 targets/stage2/stage2-controller.sh |  3 +++
 targets/stage3/stage3-controller.sh |  3 +++
 targets/stage4/stage4-controller.sh |  3 +++
 targets/support/functions.sh        | 23 +++++++++++++++++++++++
 4 files changed, 32 insertions(+)

diff --git a/targets/stage2/stage2-controller.sh 
b/targets/stage2/stage2-controller.sh
index 25e5120..41bd43b 100755
--- a/targets/stage2/stage2-controller.sh
+++ b/targets/stage2/stage2-controller.sh
@@ -10,6 +10,8 @@ case $1 in
        ;;
 
        run)
+               prepare_portage
+
                shift
                export clst_packages="$*"
                exec_in_chroot \
@@ -17,6 +19,7 @@ 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 df1479e..eaa40b3 100755
--- a/targets/stage3/stage3-controller.sh
+++ b/targets/stage3/stage3-controller.sh
@@ -10,12 +10,15 @@ case $1 in
        ;;
 
        run)
+               prepare_portage
+
                shift
                export clst_packages="$*"
                exec_in_chroot 
${clst_shdir}/${clst_target}/${clst_target}-chroot.sh
        ;;
 
        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 d42f302..4c5d5a0 100755
--- a/targets/stage4/stage4-controller.sh
+++ b/targets/stage4/stage4-controller.sh
@@ -10,6 +10,8 @@ case $1 in
        ;;
 
        pre-kmerge)
+               prepare_portage
+
                # Sets up the build environment before any kernels are compiled
                exec_in_chroot ${clst_shdir}/support/pre-kmerge.sh
        ;;
@@ -41,6 +43,7 @@ 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 cca2fd8..f743d41 100755
--- a/targets/support/functions.sh
+++ b/targets/support/functions.sh
@@ -16,6 +16,29 @@ delete_from_chroot(){
        fi
 }
 
+prepare_portage() {
+
+       echo "CATALYST_USE=\"${clst_CATALYST_USE}\"" >> 
${clst_chroot_path}${clst_make_conf}
+       sed -i -e "/^USE=\"/s//\${CATALYST_USE} ${USE} /" 
${clst_chroot_path}${clst_make_conf}
+}
+
+clear_portage() {
+       # Clean-up USE again
+       [ -e ${clst_chroot_path}${clst_make_conf} ] && echo "Drop 
\$CATALYST_USE from USE on ${clst_chroot_path}${clst_make_conf}"
+       [ -e ${clst_chroot_path}${clst_make_conf} ] && sed -i -e 
"/^USE=\"/s/\${CATALYST_USE} //" ${clst_chroot_path}${clst_make_conf}
+       [ -e ${clst_chroot_path}${clst_make_conf} ] && echo "Remove 
\$CATALYST_USE on ${clst_chroot_path}${clst_make_conf}"
+       [ -e ${clst_chroot_path}${clst_make_conf} ] && sed -i -e 
"/^CATALYST_USE/d" ${clst_chroot_path}${clist_make_conf}
+
+       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