From d7842fb21d9846ef2d54c60d524b36aee00b3b8b Mon Sep 17 00:00:00 2001 From: layman Date: Fri, 6 Apr 2018 09:50:06 +0200 Subject: [PATCH] gentooup: better adaption to packagebuilding chroots --- gentooup.sh | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/gentooup.sh b/gentooup.sh index f24eeab..b2df768 100755 --- a/gentooup.sh +++ b/gentooup.sh @@ -7,6 +7,10 @@ PORTAGE_UPGRADE_OPTIONS=("-vuNDk") PORTAGE_ASK="-a" +INTERACTIVE=1 + +CHROOTED=0 + SYNC_COMMAND="emaint sync -a" int_handler() { @@ -27,6 +31,11 @@ if [[ ! -t 1 ]] ; then echo "Waiting 10s for manual abortion..." sleep 10 PORTAGE_ASK="" + INTERACTIVE=0 +fi + +if [ "$(stat -c %d:%i /)" != "$(stat -c %d:%i /proc/1/root/.)" ]; then + CHROOTED=1 fi if [[ ${1} == "--no-sync" || ${2} == "--no-sync" ]] ; then @@ -54,15 +63,15 @@ echo "emerge options: ${PORTAGE_OPTIONS[*]}" emerge $PORTAGE_ASK "${PORTAGE_UPGRADE_OPTIONS[@]}" "${PORTAGE_OPTIONS[@]}" world echo "emerge return value: $?" -if [[ -t 1 ]] ; then +if [[ $INTERACTIVE == 1 ]] ; then dispatch-conf echo "dispatch-conf return value: $?" emerge "${PORTAGE_UPGRADE_OPTIONS[@]}" "${PORTAGE_OPTIONS[@]}" world - echo emerge return value: $? + echo "emerge return value: $?" dispatch-conf - echo dispatch-conf return value: $? + echo "dispatch-conf return value: $?" fi SETS=("@preserved-rebuild") @@ -85,18 +94,22 @@ fi echo "**************** clean /etc/portage/ ***************" portpeek -rq -echo "**************** clean /usr/portage/distfiles ***********" -eclean-dist -d +#Currently chroots are used to build and preserve packages! +if [[ $CHROOTED == 0 ]] ; then + echo "**************** clean /usr/portage/distfiles ***********" + eclean-dist -d -echo "**************** clean /usr/portage/packages ***********" -eclean-pkg + echo "**************** clean /usr/portage/packages ***********" + eclean-pkg -if [[ -n "$(which buildCurrentSymlinkedKernel.sh 2> /dev/null)" ]] ; then - buildCurrentSymlinkedKernel.sh -elif [[ -x "${HOME}/bin/buildCurrentSymlinkedKernel.sh" ]] ; then - "${HOME}/bin/buildCurrentSymlinkedKernel.sh" + if [[ -n "$(which buildCurrentSymlinkedKernel.sh 2> /dev/null)" ]] ; then + buildCurrentSymlinkedKernel.sh + elif [[ -x "${HOME}/bin/buildCurrentSymlinkedKernel.sh" ]] ; then + "${HOME}/bin/buildCurrentSymlinkedKernel.sh" + fi fi + echo "***************** remove unneeded packages *******************" echo Started at "$STARTDATE" emerge -a "${PORTAGE_OPTIONS[@]}" --depclean