#!/bin/sh
# This script updates your e17 installation.
# Customize the _EBUILDS variable to specify which packages to update.
## Script setup
# Select package manager, emerge or paludis:
PACKAGE_MANAGER="emerge"
# Guys stop messing with the order of the libs -_-
# Minimal -- emerge e gets you this in the wrong order
_EBUILDS=( dev-libs/eet dev-db/edb x11-libs/evas x11-libs/ecore dev-libs/efreet
dev-libs/embryo media-libs/edje media-libs/emotion media-libs/imlib2
media-libs/epeg media-libs/epsilon x11-libs/ewl x11-libs/e_dbus x11-wm/e
# few more usefull apps, also only add programs after this line
# unless you know what you are doing.
#x11-libs/esmart x11-misc/entrance x11-terms/enterminus
)
# 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 (memory is allocated only when needed).
_TMPFS_SIZE=512
## You should not have to edit below this line.
if [ -x "/sbin/functions.sh" ]; then
. /sbin/functions.sh
elif [ -x "/lib/rcscripts/sh/functions.sh" ]; then
. /lib/rcscripts/sh/functions.sh
fi
trap "exit_hdlr $?" SIGHUP SIGINT SIGTERM SIGQUIT SIGABRT
layman --sync=enlightenment
_FAIL_FLAG="0"
_FAIL_LIST=""
# mounts tmpfs on ${WORKING_DIR} with user specificied size
function mount_tmpfs(){
if (($_MNT_TMPFS == 0)); then return 0; fi
if [ -z "$(mount|grep ${WORKING_DIR})" ]; then
mount -t tmpfs tmpfs ${WORKING_DIR} -o size=${_TMPFS_SIZE}M && einfo "mounting ramdisk of size ${_TMPFS_SIZE}MB on ${WORKING_DIR}";
if [ -z "$(mount|grep ${WORKING_DIR})" ]; then einfo "mounting of tmpfs failed... continuing with ordinary emerge"; fi
else
einfo "${WORKING_DIR} 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 ${WORKING_DIR})" ]; then
einfo "unmounting tmpfs"
if ! umount ${WORKING_DIR}; 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: \e[36;01mSKIP=$((_CNT-1)) $0\e[0m"
fi
fi
if [ -z "$_FAIL_LIST" ]; then
einfo "All packages successfully emerged."
else
eerror "The following packages failed on emerge: \e[31;01m$_FAIL_LIST\e[0m"
fi
umount_tmpfs
exit ${1}
}
if [ "$1" == "debug" ]; then
DEBUG="USE=\"$USE debug\" FEATURES=\"$FEATURES nostrip\""
fi
case "${PACKAGE_MANAGER}" in
"emerge" )
EMERGE="/usr/bin/emerge"
WORKING_DIR="/var/tmp/portage"
;;
"paludis" )
EMERGE="/usr/bin/paludis -i"
WORKING_DIR="/var/tmp/paludis"
;;
esac
# 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
mount_tmpfs
_CNT=0
for package in ${_EBUILDS[*]}; do
_FAIL_FLAG=0
let "_CNT++"
if (($_CNT <= $SKIP)); then continue; fi
einfo "Compiling \e[32;01m$package\e[0m (\e[33;01m$_CNT out of ${#_EBUILDS[*]}\e[0m)"
compile ${package}
if [ "$_FAIL_FLAG" == "0" ]; then
ewarn "emerge of \e[33;01m$package\e[0m failed... retrying once"
sleep 3
# Try with an older automake (known issue)
E17_WANT_AUTOMAKE=1.9 compile $package
if [ "$_FAIL_FLAG" == "0" ]; then
eerror "emerge of \e[31;01m$package\e[0m 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