---
 targets/stage1/stage1-chroot.sh     |  1 +
 targets/stage2/stage2-chroot.sh     |  1 +
 targets/support/chroot-functions.sh | 13 ++++++++++---
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/targets/stage1/stage1-chroot.sh b/targets/stage1/stage1-chroot.sh
index ed83f38..7d8589f 100755
--- a/targets/stage1/stage1-chroot.sh
+++ b/targets/stage1/stage1-chroot.sh
@@ -21,6 +21,7 @@ then
 fi
 
 ## Setup seed pkgmgr to ensure latest
+export PKGMGR_BUILD='yes'
 clst_root_path=/ setup_pkgmgr
 
 # Update stage3
diff --git a/targets/stage2/stage2-chroot.sh b/targets/stage2/stage2-chroot.sh
index 61f5261..0f70a84 100755
--- a/targets/stage2/stage2-chroot.sh
+++ b/targets/stage2/stage2-chroot.sh
@@ -4,6 +4,7 @@ source /tmp/chroot-functions.sh
 
 # Setup the environment
 export FEATURES="${clst_myfeatures} nodoc noman noinfo -news"
+export PKGMGR_BUILD='yes'
 
 if [ "${clst_VERBOSE}" ]
 then
diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh
index 3495f14..6260c69 100755
--- a/targets/support/chroot-functions.sh
+++ b/targets/support/chroot-functions.sh
@@ -170,9 +170,16 @@ setup_pkgmgr(){
 	# portage to avoid frying our /etc/portage/make.conf file.  Otherwise, we could
 	# just let emerge @system could merge it.
 	# Use --update or portage will reinstall the same version.
-	[ -e /etc/portage/make.conf ] && echo 'USE="${USE} build"' >> /etc/portage/make.conf
-	run_merge --oneshot --update sys-apps/portage
-	sed -i '/USE="${USE} build"/d' /etc/portage/make.conf
+	if [ -n "${PKGMGR_BUILD}" ];then
+		echo "Adding USE='${USE} build' to make.conf for portage build"
+		[ -e /etc/portage/make.conf ] && echo 'USE="${USE} build"' >> /etc/portage/make.conf
+		run_merge --oneshot --update sys-apps/portage
+		sed -i '/USE="${USE} build"/d' /etc/portage/make.conf
+	else
+		echo "Updating portage with normal USE="
+		run_merge --oneshot --update sys-apps/portage
+	fi
+
 }
 
 cleanup_distcc() {

Reply via email to