Set FEATURES=-news before emerging ccache/distcc/icecream
[catalyst.git] / targets / support / chroot-functions.sh
old mode 100755 (executable)
new mode 100644 (file)
index 38a7af8..1a44c92
@@ -61,10 +61,11 @@ get_libdir() {
 
 setup_myfeatures(){
        setup_myemergeopts
+       export FEATURES="-news"
        if [ -n "${clst_CCACHE}" ]
        then
                export clst_myfeatures="${clst_myfeatures} ccache"
-               clst_root_path=/ run_merge --oneshot --nodeps dev-util/ccache || exit 1
+               clst_root_path=/ run_merge --oneshot --nodeps --noreplace dev-util/ccache || exit 1
        fi
 
        if [ -n "${clst_DISTCC}" ]
@@ -73,7 +74,16 @@ setup_myfeatures(){
                export DISTCC_HOSTS="${clst_distcc_hosts}"
                [ -e /etc/make.conf ] && \
                        echo 'USE="${USE} -avahi -gtk -gnome"' >> /etc/make.conf
-               clst_root_path=/ run_merge --oneshot --nodeps sys-devel/distcc || exit 1
+               # We install distcc to / on stage1, then use --noreplace, so we need to
+               # have some way to check if we need to reinstall distcc without being
+               # able to rely on USE, so we check for the distcc user and force a
+               # reinstall if it isn't found.
+               if [ "$(getent passwd distcc | cut -d: -f1)" != "distcc" ]
+               then
+                       clst_root_path=/ run_merge --oneshot --nodeps sys-devel/distcc || exit 1
+               else
+                       clst_root_path=/ run_merge --oneshot --nodeps --noreplace sys-devel/distcc || exit 1
+               fi
                sed -i '/USE="${USE} -avahi -gtk -gnome"/d' /etc/make.conf
                mkdir -p /etc/distcc
                echo "${clst_distcc_hosts}" > /etc/distcc/hosts
@@ -81,17 +91,17 @@ setup_myfeatures(){
                # This sets up automatic cross-distcc-fu according to
                # http://www.gentoo.org/doc/en/cross-compiling-distcc.xml
                CHOST=$(portageq envvar CHOST)
-               # TODO: change to use get_libdir
-               cd /usr/lib/distcc/bin
+               LIBDIR=$(get_libdir)
+               cd /usr/${LIBDIR}/distcc/bin
                rm cc gcc g++ c++ 2>/dev/null
-               echo -e '#!/bin/bash\nexec /usr/lib/distcc/bin/'${CHOST}'-g${0:$[-2]} "$@"' > ${CHOST}-wrapper
-               chmod a+x /usr/lib/distcc/bin/${CHOST}-wrapper
+               echo -e '#!/bin/bash\nexec /usr/'${LIBDIR}'/distcc/bin/'${CHOST}'-g${0:$[-2]} "$@"' > ${CHOST}-wrapper
+               chmod a+x /usr/${LIBDIR}/distcc/bin/${CHOST}-wrapper
                for i in cc gcc g++ c++; do ln -s ${CHOST}-wrapper ${i}; done
        fi
 
        if [ -n "${clst_ICECREAM}" ]
        then
-               clst_root_path=/ run_merge --oneshot --nodeps sys-devel/icecream || exit 1
+               clst_root_path=/ run_merge --oneshot --nodeps --noreplace sys-devel/icecream || exit 1
 
                # This sets up automatic cross-icecc-fu according to
                # http://gentoo-wiki.com/HOWTO_Setup_An_ICECREAM_Compile_Cluster#Icecream_and_cross-compiling
@@ -105,7 +115,7 @@ setup_myfeatures(){
                export PATH="/usr/lib/icecc/bin:${PATH}"
                export PREROOTPATH="/usr/lib/icecc/bin"
        fi
-       export FEATURES="${clst_myfeatures}"
+       export FEATURES="${clst_myfeatures} -news"
 }
 
 setup_myemergeopts(){
@@ -114,15 +124,16 @@ setup_myemergeopts(){
                clst_myemergeopts="--verbose"
        else
                clst_myemergeopts="--quiet"
+               bootstrap_opts="${bootstrap_opts} -q"
        fi
        if [ -n "${clst_FETCH}" ]
        then
-               export bootstrap_opts="-f"
+               export bootstrap_opts="${bootstrap_opts} -f"
                export clst_myemergeopts="${clst_myemergeopts} -f"
        elif [ -n "${clst_PKGCACHE}" ]
        then
                export clst_myemergeopts="${clst_myemergeopts} --usepkg --buildpkg --newuse"
-               export bootstrap_opts="-r"
+               export bootstrap_opts="${bootstrap_opts} -r"
        fi
 }
 
@@ -155,18 +166,18 @@ setup_pkgmgr(){
        # portage to avoid frying our /etc/make.conf file.  Otherwise, we could
        # just let emerge system could merge it.
        [ -e /etc/make.conf ] && echo 'USE="${USE} build"' >> /etc/make.conf
-       run_merge --oneshot --nodeps virtual/portage
+       run_merge --oneshot --nodeps sys-apps/portage
        sed -i '/USE="${USE} build"/d' /etc/make.conf
 }
 
 cleanup_distcc() {
+       LIBDIR=$(get_libdir)
        rm -rf /etc/distcc/hosts
        for i in cc gcc c++ g++; do
-               # TODO: change to use get_libdir
-               rm -f /usr/lib/distcc/bin/${i}
-               ln -s /usr/bin/distcc /usr/lib/distcc/bin/${i}
+               rm -f /usr/${LIBDIR}/distcc/bin/${i}
+               ln -s /usr/bin/distcc /usr/${LIBDIR}/distcc/bin/${i}
        done
-       rm -f /usr/lib/distcc/bin/*-wrapper
+       rm -f /usr/${LIBDIR}/distcc/bin/*-wrapper
 }
 
 cleanup_icecream() {
@@ -189,7 +200,15 @@ cleanup_stages() {
                cleanup_icecream
        fi
        case ${clst_target} in
-               stage1|stage2|stage3)
+               stage3|system)
+                       run_merge --depclean --with-bdeps=n
+                       ;;
+               *)
+                       echo "Skipping depclean operation for ${clst_target}"
+                       ;;
+       esac
+       case ${clst_target} in
+               stage1|stage2|stage3|system)
                        rm -f /var/lib/portage/world
                        touch /var/lib/portage/world
                        ;;
@@ -199,7 +218,6 @@ cleanup_stages() {
        esac
 
        rm -f /var/log/emerge.log /var/log/portage/elog/*
-       rm -rf /var/tmp/*
 }
 
 update_env_settings(){
@@ -265,6 +283,9 @@ show_debug() {
                echo "Profile/target info:"
                echo "Profile inheritance:"
                python -c 'import portage; print portage.settings.profiles'
+               echo
+               # TODO: make this work on non-portage
+               emerge --info
                # TODO: grab our entire env
                # <zmedico> to get see the ebuild env you can do something like:
                # `set > /tmp/env_dump.${EBUILD_PHASE}` inside /etc/portage/bashrc
@@ -273,20 +294,19 @@ show_debug() {
                echo "STAGE1_USE:            $(portageq envvar STAGE1_USE)"
                echo
                echo "USE (profile):         $(portageq envvar USE)"
-               echo "USE (stage1):          ${USE}"
                echo "FEATURES (profile):    $(portageq envvar FEATURES)"
-               echo "FEATURES (stage1):     ${FEATURES}"
                echo
                echo "ARCH:                  $(portageq envvar ARCH)"
                echo "CHOST:                 $(portageq envvar CHOST)"
                echo "CFLAGS:                $(portageq envvar CFLAGS)"
                echo
-               echo "PROFILE_ARCH:          $(portageq envvar PROFILE_ARCH)"
-               echo
+               echo "These should be blank on non-multilib profiles."
                echo "ABI:                   $(portageq envvar ABI)"
                echo "DEFAULT_ABI:           $(portageq envvar DEFAULT_ABI)"
                echo "KERNEL_ABI:            $(portageq envvar KERNEL_ABI)"
+               echo "LIBDIR:                $(get_libdir)"
                echo "MULTILIB_ABIS:         $(portageq envvar MULTILIB_ABIS)"
+               echo "PROFILE_ARCH:          $(portageq envvar PROFILE_ARCH)"
                echo
        fi
 }