Fix update_seed use by not using nor building binary packages during the seed update.
[catalyst.git] / targets / stage1 / stage1-chroot.sh
old mode 100755 (executable)
new mode 100644 (file)
index 6d4449b..ed83f38
@@ -1,57 +1,62 @@
 #!/bin/bash
-               
-env-update
-source /etc/profile
-case $1 in
-       build)
-               export ROOT=${2}
-               install -d $ROOT
-               for x in $(/tmp/build.sh)
-               do
-                       echo $x >> /tmp/build.log
-                       USE="-* build" emerge --usepkg --buildpkg --noreplace $x || exit 1
-               done
-       ;;
-
-       clean)
-               export ROOT=${2}
-               keepers="sys-kernel/linux-headers sys-devel/binutils sys-devel/gcc sys-apps/baselayout sys-libs/glibc virtual/glibc virtual/kernel"
-               if [ ${clst_rel_type} = "hardened" ]
-               then
-                       keepers="${keepers} sys-devel/hardened-gcc"
-               fi
-               # set everything to uid 999 (nouser)
-               cd ${ROOT}
-               install -d var/db/pkg2
-               for x in $keepers
-               do
-                       category=${x%%/*}
-                       package=${x##*/}
-                       [ "`ls var/db/pkg/${x}* 2>/dev/null`" = "" ] && continue
-                       install -d var/db/pkg2/${category}
-                       mv var/db/pkg/${category}/${package}* var/db/pkg2/${category}
-               done
-               rm -rf var/db/pkg
-               mv var/db/pkg2 var/db/pkg
-
-               # clean out man, info and doc files
-               rm -rf usr/share/{man,doc,info}/*
-
-               # zap all .pyc and .pyo files
-               find -iname "*.py[co]" -exec rm -f {} \;
-
-               # cleanup all .a files except libgcc.a, *_nonshared.a and /usr/lib/portage/bin/*.a
-               find -iname "*.a" | `find -iname "*.a" | grep -v 'libgcc.a' | grep -v 'nonshared.a' | grep -v '/usr/lib/portage/bin/' | grep -v 'libgcc_eh.a'` | xargs rm -f
-
-               chroot ${ROOT} /bin/bash << EOF
-               #now, some finishing touches to initialize gcc-config....
-               unset ROOT
-               if [ -e /usr/sbin/gcc-config ]
-               then
-                       mythang=\$( cd /etc/env.d/gcc; ls ${clst_CHOST}-* )
-                       gcc-config \${mythang}; env-update; source /etc/profile
+
+source /tmp/chroot-functions.sh
+
+# We do this first, so we know our package list for --debug
+export clst_buildpkgs="$(/tmp/build.py)"
+
+# Setup our environment
+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/portage/make.profile link and the 'packages' files."
+       exit 1
+fi
+
+## Setup seed pkgmgr to ensure latest
+clst_root_path=/ setup_pkgmgr
+
+# 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
-EOF
-               ;;
-esac
-       
+       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
+# 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"
+
+sed -i '/USE="${USE} -build"/d' /etc/portage/make.conf
+
+# 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