#!/bin/bash setVariables() { #Where to put the SVN source files (~80-90 MB) SRCDIR="/root/hula" #Where are your distfiles? # DISTDIR=`portageq distdir` DISTDIR="/opt/distfiles" #Where to put the /net-mail/hula/* ebuild files # OVERLAY=`portageq portdir_overlay|cut -d " " -f1` OVERLAY="/usr/local/portage/overlay" } setColors() { C_NOCOLOR="\033[0m" C_TITLE="\033[1;37m" C_ACTION="\033[1;32m" C_ERROR="\033[1;31m" } checkVariables() { #check if the above files/directories exist... ERROR=0 if [ ! -d ${DISTDIR} ]; then echo -e "${C_ERROR}! \"${DISTDIR}\" does not exist!${C_NOCOLOR}" let ERROR++ fi if [ ! -d ${OVERLAY} ]; then echo -e "${C_ERROR}! \"${OVERLAY}\" does not exist!${C_NOCOLOR}" let ERROR++ fi exitOnError ${ERROR} } getRevision() { if [ -f "${SRCDIR}/trunk/.svn/entries" ]; then REVISION=`cat "${SRCDIR}/trunk/.svn/entries" | grep revision= | cut -d "\"" -f 2` echo -e "${C_ACTION}*${C_NOCOLOR} Detected rev: ${REVISION}" else echo "! Hula source files not found in \"${SRCDIR}\"..." echo "! Please run this script with the -u (update) or -a (all) parameter..." exitOnError 1 fi } createSymlink() { getRevision if [ -d "${SRCDIR}/trunk/hula-r${REVISION}" ]; then echo -e "${C_ACTION}*${C_NOCOLOR} Found a perfect symlink..." else echo -e "${C_ACTION}*${C_NOCOLOR} Removing old symlinks" rm -f ${SRCDIR}/trunk/hula-r* echo -e "${C_ACTION}*${C_NOCOLOR} Creating new symlink (hula-r${REVISION})" cd ${SRCDIR}/trunk ln -s hula hula-r${REVISION} fi } svnCheckout() { echo -e "${C_TITLE}Updating from SVN${C_NOCOLOR}" mkdir -p "${SRCDIR}" cd "${SRCDIR}" #echo -e "${C_ACTION}*${C_NOCOLOR} To check out without passwords, follow instructions on \"http://www.hula-project.org/Setting_Up_Public_Keys_for_forge.novell.com\"" echo -e "${C_ACTION}*${C_NOCOLOR} Logging into SVN. If prompted for a password, enter \"anonymous\" (without quotes, twice)" svn checkout svn+ssh://anonymous@forgesvn1.novell.com/svn/hula/trunk exitOnError ${?} } exitOnError() { errorCode=${1} if [ ${errorCode} -gt 0 ]; then echo echo -e "${C_ERROR}!!! Something went wrong! Errorcode: ${errorCode} !!!${C_NOCOLOR}" echo exit ${errorCode} fi } createTarball() { echo -e "${C_TITLE}Creating tarball${C_NOCOLOR}" createSymlink echo -e "${C_ACTION}*${C_NOCOLOR} Creating \"${DISTDIR}/hula-r${REVISION}.tgz\" (~80-90 MB of source code)" cd "${SRCDIR}/trunk" tar zchf "${DISTDIR}/hula-r${REVISION}.tgz" hula-r${REVISION}/ exitOnError ${?} echo -e "${C_ACTION}*${C_NOCOLOR} Done..." } updateEbuild() { echo -e "${C_TITLE}Updating Ebuild${C_NOCOLOR}" getRevision cd ${SRCDIR} echo -e "${C_ACTION}*${C_NOCOLOR} Creating \"${OVERLAY}/net-mail/hula\"" mkdir -p "${OVERLAY}/net-mail/hula" exitOnError ${?} echo -e "${C_ACTION}*${C_NOCOLOR} Creating \"${OVERLAY}/net-mail/hula/hula-${REVISION}.ebuild\"" createNewEbuild "${OVERLAY}/net-mail/hula/hula-${REVISION}.ebuild" exitOnError ${?} if [ ! -f "${OVERLAY}/net-mail/hula/files/hula" ]; then echo -e "${C_ACTION}*${C_NOCOLOR} Creating \"${OVERLAY}/net-mail/hula/files/hula\"" createNewInitscript "${OVERLAY}/net-mail/hula/files/hula" exitOnError ${?} fi if [ ! -f "${OVERLAY}/net-mail/hula/files/define_spamassassin.patch" ]; then echo -e "${C_ACTION}*${C_NOCOLOR} Creating \"${OVERLAY}/net-mail/hula/files/define_spamassassin.patch\"" createNewSpamassassinPatch "${OVERLAY}/net-mail/hula/files/define_spamassassin.patch" exitOnError ${?} fi echo -e "${C_ACTION}*${C_NOCOLOR} Creating digest for new ebuild (hula-${REVISION}.ebuild)" cd "${OVERLAY}/net-mail/hula" ebuild hula-${REVISION}.ebuild digest > /dev/null exitOnError ${?} echo -e "${C_ACTION}*${C_NOCOLOR} Done..." } displayOptions() { echo "Create \"hula\" tarball and ebuild from SubVersioN script..." echo echo "Usage: ${1}