#!/bin/bash ############################################################################# # Script to update / backup / downgrade Enlightenment-0.17 # # The gentoolkit package is required # # ppurka # ############################################################################# # emerge --oneshot -av eet edb evas ecore embryo imlib2 edje epeg epsilon esmart engrave ewl e e_utils engage e_modules # >>>>>>>>>>>>>>>>>> STRATEGY <<<<<<<<<<<<<<<<<<<< # # # # If -b switch is present, then: # # 1. backup all binary files via quickpkg # # 2. Do not update cvs # # 3. Do not backup cvs # # 4. Do not emerge any package # # # # If -o switch is present, then: # # 1. emerge -K all files # # 2. Do not backup binary files # # 3. Do not update cvs # # 4. Do not backup cvs # # # # If no switch is present, then: # # 1. Ask if cvs backup is desired & backup (rsync) if so desired # # 2. Ask if binary backup is desired & backup (quickpkg) if so desired # # (only for files which are to be emerged) # # 3. Emerge package if there has been a cvs update # # # # >>>>>>>>>>>>>>>>>> STRATEGY <<<<<<<<<<<<<<<<<<<< # ### Set the colors that will be used ### yellow="\E[1;33m" red="\E[1;31m" green="\E[1;32m" underline="\E[4m" bold="\E[1m" normal="\E[0m" # Print out information. # Usage: info "Whatever you want to print" info(){ echo -e " $yellow *$normal ${@}"; } # Print out information without ending with a newline. This adds a space at end # Usage: infon "Whatever you want to print" infon(){ echo -ne " $yellow *$normal ${@} "; } # Print out error information. # Usage: Err "Whatever you want to print" Err(){ echo -e " $red *$normal [$red ERROR!!$normal ] ${@}"; } DISTDIR=`portageq distdir` BACKUPDIR="/mnt/stuff/softwares/backups/e17" CONTINUE=1 BACKUP= CVSUPDATE=1 RESUME=0 OLDPKG= TMPFILE="$HOME/tmp/e_emerge.log" E_LIST="dev-libs/eet\ dev-db/edb\ x11-libs/evas\ x11-libs/ecore\ dev-libs/embryo\ media-libs/imlib2\ media-libs/edje\ media-libs/epeg\ media-libs/epsilon\ x11-libs/esmart\ dev-libs/engrave\ x11-libs/ewl\ x11-wm/e\ dev-util/e_utils\ x11-misc/engage" # x11-plugins/e_modules" # sys-fs/evfs\ # x11-libs/etk\ # app-misc/entropy\ help () { echo -e " $yellow $( basename ${0} )$normal"; info "Usage: $( basename ${0} ) [options]"; info "Options:"; info "-h | --help This help text"; info "-nc| --no-color Do not use color in output"; info "-b | --backup Backup current installation using quickpkg"; info "-o | --oldpkg Install the old binary packages which were backed up earlier"; info "-r | --resume Resume previous incomplete install"; echo ""; exit 0; } if [[ ! -z "$@" ]]; then for i in "$@" do case $i in -h | --help) help; ;; -nc | --no-color) unset yellow red green underline bold; ;; -b | --backup) if [[ ! -z "${OLDPKG}" || $RESUME = 1 ]]; then Err "Can not give -b, -o or -r options together!"; help; else BACKUP=1; CVSUPDATE=0; CONTINUE=0; fi ;; -o | --oldpkg) if [[ $BACKUP -eq 1 || $RESUME = 1 ]]; then Err "Can not give -b, -o or -r options together!"; help; else OLDPKG="-K"; CONTINUE=0; fi ;; -r | --resume) if [[ $BACKUP -eq 1 || ! -z "${OLDPKG}" ]]; then Err "Can not give -b, -o or -r options together!"; help; else if [[ -f ${TMPFILE} ]]; then RESUME=1; else Err "${TMPFILE} does not exist. Can not resume!"; exit 1; fi fi ;; *) Err "Invalid Options!"; help; ;; esac done fi if [[ -z "${BACKUP}" && -z "$OLDPKG" && $RESUME -eq 0 ]]; then # Backup of cvs source >>>>>>>>>>>>>>>>>>> infon "Do you want to run rsync to backup current cvs? [Enter/Yes or No]: "; read -n 1 REPLY; echo; case $REPLY in "" | [yY]) rsync --progress --delete -ab "${DISTDIR}/cvs-src/e17" "$BACKUPDIR";echo; ;; *) info "Continuing to further backups";echo; ;; esac # <<<<<<<<<<<<<<<<<<<<<<<<<<< # Backup of binary packages, which have cvs updates available >>>>>>>>>> infon "Do you want to package current installed packages using $yellow quickpkg$normal (Only packages with updates in cvs will be backed up)? [Enter/Yes or No]: "; read -n 1 REPLY; echo; case $REPLY in "" | [yY]) BACKUP=1; info "Packages currently installed will be backed up using quickpkg"; info "Continuing to emerge";echo; ;; *) BACKUP=0; info "The binary packages currently installed will not be backed up"; info "Continuing to emerge";echo; ;; esac # <<<<<<<<<<<<<<<<<<<<<<<<<<<< fi [[ $RESUME -eq 0 ]] && echo "${BACKUP}" > ${TMPFILE}; [[ $RESUME -eq 1 ]] && BACKUP=`head -n 1 ${TMPFILE}`; for i in ${E_LIST} do echo; info "Considering $i"; [[ $RESUME -eq 1 && ! -z "$(grep -x ${i} ${TMPFILE})" ]] && info "Skipping $i" && continue; [[ $CONTINUE -eq 1 && $RESUME -eq 1 && ! -z "$(grep -x 11 ${TMPFILE})" ]] && CONTINUE=0; # Test if a dependency has been updated >>>>>>>>>>>>>> if [[ $CONTINUE -eq 1 ]]; then info "Updating $i cvs"; E_PATH=`equery which $i`; UPDATE_UNPACK=`ebuild $E_PATH unpack 2>&1` UPDATE=`echo "${UPDATE_UNPACK}" | grep -e "^[UP] "`; UPDATE_ERR=`echo "${UPDATE_UNPACK}" | grep -e "\!\!\!"`; [[ ! -z "${UPDATE_ERR}" ]] && Err "cvs update of $i failed :-( Full Error message is given below:\n${UPDATE_UNPACK}" && ebuild "${E_PATH}" clean && exit 1; ebuild "${E_PATH}" clean; if [[ ! -z "${UPDATE}" ]]; then echo "${UPDATE}"; CONTINUE=0; echo "11" >> ${TMPFILE}; info "Waiting 5 sec before continuing with backup and emerge from $i onwards"; echo -ne " $red *$normal " for j in $( seq 1 5 ) do echo -ne "$red$(( 6-j ))$normal "; sleep 1; done echo; else info "$i has no updates in cvs"; fi fi [[ $CONTINUE -eq 0 && $BACKUP -eq 1 ]] && quickpkg $i; if [[ $CONTINUE -eq 0 && $CVSUPDATE -eq 1 ]];then if ! emerge --oneshot ${OLDPKG} $i; then Err "Emerge of $i failed :-("; exit 1; fi fi echo "${i}" >> ${TMPFILE}; done # Remove temporary file .. all emerged successfully :-) \rm -f ${TMPFILE};