X-Git-Url: http://git.tremily.us/?a=blobdiff_plain;f=targets%2Fsupport%2Fchroot-functions.sh;h=ee820edebfe36916d67e33e277e989fe80987e89;hb=2426bb1f275c56150c07f8d1097296b00def7159;hp=418336cd1c0f2db2a91f2b7a544be9e21544b9be;hpb=295f5cfc6cfe7283db4ff9b505215cb31ec7ded0;p=catalyst.git diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh index 418336cd..ee820ede 100755 --- a/targets/support/chroot-functions.sh +++ b/targets/support/chroot-functions.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Set the profile +eselect profile set ${clst_target_profile} + # Trap these signals and kill ourselves if recieved # Force ourselves to die if any of these signals are recieved # most likely our controlling terminal is gone @@ -61,37 +64,47 @@ get_libdir() { setup_myfeatures(){ setup_myemergeopts + export FEATURES="-news clean-logs" if [ -n "${clst_CCACHE}" ] then export clst_myfeatures="${clst_myfeatures} ccache" - clst_root_path=/ run_merge --oneshot --nodeps --noreplace dev-util/ccache || exit 1 + clst_root_path=/ run_merge --oneshot --noreplace dev-util/ccache || exit 1 fi if [ -n "${clst_DISTCC}" ] then export clst_myfeatures="${clst_myfeatures} distcc" 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 --noreplace sys-devel/distcc || exit 1 - sed -i '/USE="${USE} -avahi -gtk -gnome"/d' /etc/make.conf + [ -e /etc/portage/make.conf ] && \ + echo 'USE="${USE} -avahi -gtk -gnome"' >> /etc/portage/make.conf + # 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 sys-devel/distcc || exit 1 + else + clst_root_path=/ run_merge --oneshot --noreplace sys-devel/distcc || exit 1 + fi + sed -i '/USE="${USE} -avahi -gtk -gnome"/d' /etc/portage/make.conf mkdir -p /etc/distcc echo "${clst_distcc_hosts}" > /etc/distcc/hosts # 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 --noreplace sys-devel/icecream || exit 1 + clst_root_path=/ run_merge --oneshot --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 +118,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,59 +127,68 @@ 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}" ] + # if we have PKGCACHE, and either update_seed is empty or 'no', make and use binpkgs + elif [ -n "${clst_PKGCACHE}" ] && [ -z "${clst_update_seed}" -o "${clst_update_seed}" = "no" ] then export clst_myemergeopts="${clst_myemergeopts} --usepkg --buildpkg --newuse" - export bootstrap_opts="-r" + export bootstrap_opts="${bootstrap_opts} -r" fi } setup_binutils(){ if [ -x /usr/bin/binutils-config ] then - mythang=$( cd /etc/env.d/binutils; ls ${clst_CHOST}-* | head -n 1 ) - if [ -z "${mythang}" ] + my_binutils=$( cd /etc/env.d/binutils; ls ${clst_CHOST}-* | head -n 1 ) + if [ -z "${my_binutils}" ] then - mythang=1 + my_binutils=1 fi - binutils-config ${mythang}; update_env_settings + binutils-config ${my_binutils}; update_env_settings fi } setup_gcc(){ if [ -x /usr/bin/gcc-config ] then - mythang=$( cd /etc/env.d/gcc; ls ${clst_CHOST}-* | head -n 1 ) - if [ -z "${mythang}" ] + my_gcc=$( cd /etc/env.d/gcc; ls ${clst_CHOST}-* | head -n 1 ) + if [ -z "${my_gcc}" ] then - mythang=1 + my_gcc=1 fi - gcc-config ${mythang}; update_env_settings + gcc-config ${my_gcc}; update_env_settings fi } setup_pkgmgr(){ # We need to merge our package manager with USE="build" set in case it is - # 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 - sed -i '/USE="${USE} build"/d' /etc/make.conf + # portage to avoid frying our /etc/portage/make.conf file. Otherwise, we could + # just let emerge @system could merge it. + # Use --update or portage might just waste time/cycles and reinstall the same version. + if [ -n "$1" ];then + echo "Adding USE='${USE} $1' to make.conf for portage build" + [ -e /etc/portage/make.conf ] && echo 'USE="${USE} $1"' >> /etc/portage/make.conf + run_merge --oneshot --update sys-apps/portage + sed -i '/USE="${USE} $1"/d' /etc/portage/make.conf + else + echo "Updating portage with USE='${USE}'" + run_merge --oneshot --update sys-apps/portage + fi } 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 +211,15 @@ cleanup_stages() { cleanup_icecream fi case ${clst_target} in - stage1|stage2|stage3) + stage3|system) + run_merge --depclean --with-bdeps=y + ;; + *) + 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 +229,6 @@ cleanup_stages() { esac rm -f /var/log/emerge.log /var/log/portage/elog/* - rm -rf /var/tmp/* } update_env_settings(){ @@ -215,11 +244,11 @@ die() { make_destpath() { # ROOT is / by default, so remove any ROOT= settings from make.conf - sed -i '/ROOT=/d' /etc/make.conf + sed -i '/ROOT=/d' /etc/portage/make.conf export ROOT=/ - if [ "${1}" != "/" -a -n "${1}" ] + if [ "${1}" != "/" -a -n "${1}" ] then - echo "ROOT=\"${1}\"" >> /etc/make.conf + echo "ROOT=\"${1}\"" >> /etc/portage/make.conf export ROOT=${1} fi if [ ! -d ${ROOT} ] @@ -232,8 +261,8 @@ run_merge() { # Sets up the ROOT= parameter # with no options ROOT=/ make_destpath ${clst_root_path} - - export EMERGE_WARNING_DELAY=0 + + export EMERGE_WARNING_DELAY=0 export CLEAN_DELAY=0 export EBEEP_IGNORE=0 export EPAUSE_IGNORE=0 @@ -264,7 +293,7 @@ show_debug() { echo "DEBUG:" echo "Profile/target info:" echo "Profile inheritance:" - python -c 'import portage; print portage.settings.profiles' + python -c 'import portage; print(portage.settings.profiles)' echo # TODO: make this work on non-portage emerge --info @@ -273,7 +302,7 @@ show_debug() { # `set > /tmp/env_dump.${EBUILD_PHASE}` inside /etc/portage/bashrc # XXX: Also, portageq does *not* source profile.bashrc at any time. echo - echo "STAGE1_USE: $(portageq envvar STAGE1_USE)" + echo "BOOTSTRAP_USE: $(portageq envvar BOOTSTRAP_USE)" echo echo "USE (profile): $(portageq envvar USE)" echo "FEATURES (profile): $(portageq envvar FEATURES)" @@ -330,7 +359,7 @@ function copy_symlink() { STACK=${2} [ "${STACK}" = "" ] && STACK=16 || STACK=$((${STACK} - 1 )) - if [ ${STACK} -le 0 ] + if [ ${STACK} -le 0 ] then echo "WARNING : ${TARGET} : too many levels of symbolic links !" return @@ -340,7 +369,7 @@ function copy_symlink() { mkdir -p ${clst_root_path}/`dirname ${1}` [ ! -e ${clst_root_path}/${1} ] && \ cp -vfdp ${1} ${clst_root_path}/${1} - + if [[ -n $(type -p realpath) ]]; then TARGET=`realpath ${1}` else @@ -393,4 +422,3 @@ Icon=text-editor" > /usr/share/applications/gentoo-handbook.desktop # We do this everywhere, so why not put it in this script run_default_funcs -