#!/bin/sh
# This script tries twice to emerge all necessary packages for kde4
## Script setup
EMERGE="emerge"
_EBUILDS=( boost app-crypt/qca app-text/poppler app-text/poppler-bindings taglib strigi qimageblitz soprano kdelibs kdepimlibs kdebase plasma-extras kdemultimedia kdeutils
)
# Activate this flag to speed-up your compile time (http://gentoo-wiki.com/TIP_Speeding_up_portage_with_tmpfs)
# (Note that you need to have alot of RAM)
_MNT_TMPFS=0
# Size of tmpfs in MB.
_TMPFS_SIZE=512
# for baselayout 1*:
. /sbin/functions.sh
# for baselayout 2*:
#. /lib/rcscripts/sh/functions.sh
## You should not have to edit below this line.
trap "exit_hdlr $?" SIGHUP SIGINT SIGTERM SIGQUIT SIGABRT
_FAIL_FLAG="0"
_FAIL_LIST=""
# mounts tmpfs on /var/tmp/portage with user specificated size
function mount_tmpfs(){
if (($_MNT_TMPFS == 0)); then return 0; fi
if [ -z "$(mount|grep /var/tmp/portage)" ]; then
mount -t tmpfs tmpfs /var/tmp/portage -o size=${1}M && einfo "mounting ramdisk of size ${1}MB on /var/tmp/portage";
if [ -z "$(mount|grep /var/tmp/portage)" ]; then einfo "mounting of tmpfs failed... continuing with ordinary emerge"; fi
else
einfo "/var/tmp/portage was already mounted... leaving unchanged."
_MNT_TMPFS=0 # prevent the script from unmounting it in the end
fi
}
function umount_tmpfs(){
if (($_MNT_TMPFS == 0)); then return 0; fi
if [ ! -z "$(mount|grep /var/tmp/portage)" ]; then
einfo "unmounting tmpfs"
if ! umount /var/tmp/portage; then eerror "Failed to unmount tmpfs"; fi
fi
}
function compile(){
${EMERGE} ${1} && _FAIL_FLAG="1"
}
function exit_hdlr() {
echo ""
if (($_CNT < ${#_EBUILDS[*]})); then
if (($_CNT > 1)); then
einfo "Update aborted. To resume, run: SKIP=$((_CNT-1)) $0"
fi
fi
if [ -z "$_FAIL_LIST" ]; then
einfo "All packages successfully emerged."
else
eerror "The following packages failed on emerge: $_FAIL_LIST"
fi
umount_tmpfs
exit ${1}
}
# the value passed to mount_tmpfs is the size of the tmpfs
mount_tmpfs ${_TMPFS_SIZE}
if [ "$1" == "debug" ]; then
DEBUG="USE=\"$USE debug\" FEATURES=\"$FEATURES nostrip\""
fi
# use the SKIP variable to skip the first packages (e.g. SKIP=20 ./e17update.sh)
if [ ! -z "$SKIP" ]; then
einfo "Skipping $SKIP ebuilds..."
else
SKIP=0
fi
_CNT=0
for package in ${_EBUILDS[*]}; do
_FAIL_FLAG=0
let "_CNT++"
if (($_CNT <= $SKIP)); then continue; fi
einfo "Compiling $package ($_CNT out of ${#_EBUILDS[*]})"
compile ${package}
if [ "$_FAIL_FLAG" == "0" ]; then
ewarn "emerge of $package failed... retrying once"
sleep 3
# Try with an older automake (known issue)
if [ "$_FAIL_FLAG" == "0" ]; then
eerror "emerge of $package failed again... bailing out"
if [ -x /usr/bin/beep ]; then /usr/bin/beep -r 3 -d 50; fi
_FAIL_LIST="${_FAIL_LIST} $package"
fi
fi
echo ""
sleep 3
done
exit_hdlr 0