setup_pkgmgr(): Make the 'build' use flag passed in
[catalyst.git] / targets / stage1 / stage1-chroot.sh
index 1b7204f1617eaed020c5d04c1decabf46e08fa44..eccbd3fb1e9fef232fea4039a6494e5f6cdd664f 100755 (executable)
@@ -1,27 +1,62 @@
 #!/bin/bash
 
+source /tmp/chroot-functions.sh
+
 # We do this first, so we know our package list for --debug
 export clst_buildpkgs="$(/tmp/build.py)"
 
-source /tmp/chroot-functions.sh
-
 # Setup our environment
-export STAGE1_USE="$(portageq envvar STAGE1_USE)"
-export USE="-* bindist build ${STAGE1_USE}"
-export FEATURES="${clst_myfeatures} nodoc noman noinfo"
+BOOTSTRAP_USE="$(portageq envvar BOOTSTRAP_USE)"
+[ -n "${clst_BINDIST}" ] && BOOTSTRAP_USE="${BOOTSTRAP_USE} bindist"
+
+FEATURES="${clst_myfeatures} nodoc noman noinfo -news"
 
 ## Sanity check profile
 if [ -z "${clst_buildpkgs}" ]
 then
        echo "Your profile seems to be broken."
        echo "Could not build a list of build packages."
-       echo "Double check your /etc/make.profile link and the 'packages' files."
+       echo "Double check your /etc/portage/make.profile link and the 'packages' files."
        exit 1
 fi
 
+## Setup seed pkgmgr to ensure latest
+clst_root_path=/ setup_pkgmgr "build"
+
+# Update stage3
+if [ -n "${clst_update_seed}" ]; then
+       if [ "${clst_update_seed}" == "yes" ]; then
+               echo "Updating seed stage..."
+               if [ -n "${clst_update_seed_command}" ]; then
+                       clst_root_path=/ run_merge "--buildpkg=n ${clst_update_seed_command}"
+               else
+                       clst_root_path=/ run_merge "--update --deep --newuse --complete-graph --rebuild-if-new-ver gcc"
+               fi
+       elif [ "${clst_update_seed}" != "no" ]; then
+               echo "Invalid setting for update_seed: ${clst_update_seed}"
+               exit 1
+       fi
+
+       # reset emerge options for the target
+       clst_update_seed=no setup_myemergeopts
+else
+       echo "Skipping seed stage update..."
+fi
+
+make_destpath /tmp/stage1root
+
 ## START BUILD
-clst_root_path=/ setup_pkgmgr
+# First, we drop in a known-good baselayout
+[ -e /etc/portage/make.conf ] && \
+       echo 'USE="${USE} -build"' >> /etc/portage/make.conf
+run_merge "--oneshot --nodeps sys-apps/baselayout"
 
-USE="-build" run_merge "--oneshot --nodeps virtual/baselayout"
+sed -i '/USE="${USE} -build"/d' /etc/portage/make.conf
 
-USE="-* bindist build ${STAGE1_USE} ${HOSTUSE}" run_merge "--noreplace --oneshot --newuse ${clst_buildpkgs}"
+# Now, we install our packages
+[ -e /etc/portage/make.conf ] && \
+       echo "USE=\"-* build ${BOOTSTRAP_USE} ${clst_HOSTUSE}\"" \
+       >> /etc/portage/make.conf
+run_merge "--oneshot ${clst_buildpkgs}"
+sed -i "/USE=\"-* build ${BOOTSTRAP_USE} ${clst_HOSTUSE}\"/d" \
+       /etc/portage/make.conf