--- trunk/mage/usr/lib/mage/smage2.sh 2007/03/19 19:09:59 439 +++ trunk/mage/usr/lib/mage/smage2.sh 2009/08/04 19:40:19 890 @@ -4,7 +4,7 @@ # needs pkgbuild_dir (mage) # SMAGE2 -# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.53 2007-03-19 19:09:59 niro Exp $ +# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 niro Exp $ #01.10.2004 # added ccache support @@ -20,6 +20,8 @@ SMAGESUFFIX="smage2" MLIBDIR=/usr/lib/mage SMAGEVERSION="$( < ${MLIBDIR}/version)" +SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log" + ## only for tests -> normally in /etc/rc.d/init.d/functions COLRED="\033[1;6m\033[31m" @@ -171,6 +173,9 @@ my_SOURCEDIR="${SOURCEDIR}/${PNAME}" fi + # create the SOURCEDIR + install -d ${my_SOURCEDIR} + # if an mirrored file than replace first the mirror uri if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]] then @@ -186,7 +191,7 @@ --tries 3 \ --continue \ --progress bar \ - --directory-prefix="${my_SOURCEDIR}" \ + --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ "${my_SRC_URI_MIRROR}" if [[ $? = 0 ]] then @@ -210,7 +215,7 @@ --tries 3 \ --continue \ --progress bar \ - --directory-prefix="${my_SOURCEDIR}" \ + --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ "${my_SRC_URI_MIRROR}" if [[ $? = 0 ]] then @@ -234,7 +239,55 @@ --tries 3 \ --continue \ --progress bar \ - --directory-prefix="${my_SOURCEDIR}" \ + --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ + "${my_SRC_URI_MIRROR}" + if [[ $? = 0 ]] + then + break + else + continue + fi + fi + done + elif [[ -n $(echo ${my_SRC_URI} | grep 'kde://') ]] + then + for mirror in ${KDE_MIRRORS} + do + my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|kde:/|${mirror}|g")" + + if [[ ${FETCHING} = true ]] + then + echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" + wget \ + --passive-ftp \ + --tries 3 \ + --continue \ + --progress bar \ + --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ + "${my_SRC_URI_MIRROR}" + if [[ $? = 0 ]] + then + break + else + continue + fi + fi + done + elif [[ -n $(echo ${my_SRC_URI} | grep 'gnome://') ]] + then + for mirror in ${GNOME_MIRRORS} + do + my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnome:/|${mirror}|g")" + + if [[ ${FETCHING} = true ]] + then + echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" + wget \ + --passive-ftp \ + --tries 3 \ + --continue \ + --progress bar \ + --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ "${my_SRC_URI_MIRROR}" if [[ $? = 0 ]] then @@ -253,7 +306,7 @@ --tries 3 \ --continue \ --progress bar \ - --directory-prefix="${my_SOURCEDIR}" \ + --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \ "${my_SRC_URI}" fi fi @@ -314,6 +367,7 @@ ./configure \ --prefix=/usr \ --host=${CHOST} \ + --build=${CHOST} \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ --datadir=/usr/share \ @@ -357,7 +411,7 @@ SRCFILE=$1 - if [ -z "$2" ] + if [[ -z $2 ]] then DEST=${BUILDDIR} else @@ -372,7 +426,11 @@ IFTAR="${IFTAR##*.}" if [[ ${IFTAR} = tar ]] then - tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} + tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.bz2 unpack failed." + else + pushd ${DEST} > /dev/null + bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed." + popd > /dev/null fi ;; gz) @@ -380,14 +438,33 @@ IFTAR="${IFTAR##*.}" if [[ ${IFTAR} = tar ]] then - tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} + tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.gz unpack failed." + else + pushd ${DEST} > /dev/null + zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed." + popd > /dev/null fi ;; - tbz2) - tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} + tbz2|mpks|mpk) + tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed." ;; tgz) - tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} + tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed." + ;; + rar) + unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed." + ;; + zip|xpi) + unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed." + ;; + rpm) + pushd ${DEST} > /dev/null + rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed." + tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed." + if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]] + then + rm ${DEST}/${SRCFILE/.rpm/.tar.gz} + fi ;; *) die "munpack failed" @@ -399,14 +476,38 @@ { local PATCHOPTS local PATCHFILE + local i PATCHOPTS=$1 PATCHFILE=$2 + if [[ -z $2 ]] + then + PATCHFILE=$1 + + ## patch level auto-detection, get patch level + for ((i=0; i < 10; i++)) + do + patch --dry-run -Np${i} -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} > /dev/null + if [[ $? = 0 ]] + then + PATCHOPTS="-Np${i}" + break + fi + done + fi + echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}" patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} } +mlibtoolize() +{ + local opts="$@" + [[ -z ${opts} ]] && opts="--copy --force" + + libtoolize ${opts} || die "running: mlibtoolize ${opts}" +} minstalldocs() { @@ -461,7 +562,7 @@ { if [ -x /usr/bin/distcc ] then - echo "Using DistCC for compilation ..." + echo -e "${COLBLUE}---${COLGREEN} Using DistCC for compilation ...${COLDEFAULT}" export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH" export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed" @@ -476,7 +577,7 @@ { if [ -x /usr/bin/ccache ] then - echo "Using CCache for compilation ..." + echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}" export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH" fi } @@ -555,7 +656,7 @@ # special tags: # PKGTYPE type of pkg # INHERITS which functions get included -# SPECIAL_FUNCTIONS special functions wich should also be added +# SPECIAL_FUNCTIONS special functions which should also be added # warning: they get killed before the build starts ! # # MAGE_TREE_DEST target destination of the generated tree @@ -591,7 +692,7 @@ > ${dest} # header - echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.53 2007-03-19 19:09:59 niro Exp $' >> ${dest} + echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 niro Exp $' >> ${dest} echo >> ${dest} # pgkname and state @@ -699,15 +800,15 @@ # now unset all uneeded vars to be safe # unset PKGNAME <-- don't do that; smage needs this var # unset to be safe (quotes needed !) - for i in ${SPECIAL_FUNCTIONS} - do - unset "${i}" - done +# for i in ${SPECIAL_FUNCTIONS} +# do +# unset "${i}" +# done unset SPECIAL_FUNCTIONS - for i in ${SPECIAL_VARS} - do - unset "${i}" - done +# for i in ${SPECIAL_VARS} +# do +# unset "${i}" +# done unset SPECIAL_VARS unset STATE unset DESCRIPTION @@ -784,6 +885,7 @@ # fix target as it may be empty ! [ -n "${target}" ] && target="-${target}" + # build pkgname pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" @@ -841,6 +943,16 @@ echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}" } +step_by_step() +{ + if [[ ${STEP_BY_STEP} = true ]] + then + echo "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}" + echo "Press [enter] to continue" + read + fi +} + # print out our version showversion @@ -961,14 +1073,30 @@ regen_mage_tree - # build md5sum for existing packages - generate_package_md5sum \ - --pcat "${PCATEGORIE}" \ - --pname "${PNAME}" \ - --pver "${PVER}" \ - --pbuild "${PBUILD}" \ - --parch "${ARCH}" \ - --target "${target}" + # build several targets + if [ -n "${MAGE_TARGETS}" ] + then + for target in ${MAGE_TARGETS} + do + # build md5sum for existing packages + generate_package_md5sum \ + --pcat "${PCATEGORIE}" \ + --pname "${PNAME}" \ + --pver "${PVER}" \ + --pbuild "${PBUILD}" \ + --parch "${ARCH}" \ + --target "${target}" + done + else + # build md5sum for existing packages + generate_package_md5sum \ + --pcat "${PCATEGORIE}" \ + --pname "${PNAME}" \ + --pver "${PVER}" \ + --pbuild "${PBUILD}" \ + --parch "${ARCH}" \ + --target "${target}" + fi exit 0 fi @@ -1044,7 +1172,7 @@ then if [[ -d ${SOURCEDIR}/${PNAME} ]] then - echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" + echo -e "${COLBLUE}===${COLGREEN} deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" rm -rf ${SOURCEDIR}/${PNAME} fi fi @@ -1107,9 +1235,16 @@ mage rmstamp fi -src_prepare || die "src_prepare failed" -src_compile || die "src_compile failed" -src_install || die "src_install failed" +# setup build loggins +[[ ! -d /var/log/smage ]] && install -d /var/log/smage +echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log + +src_prepare || die "src_prepare failed" | ${SMAGE_LOG_CMD} +step_by_step $_ +src_compile || die "src_compile failed" | ${SMAGE_LOG_CMD} +step_by_step $_ +src_install || die "src_install failed" | ${SMAGE_LOG_CMD} +step_by_step $_ # compressing doc, info & man files @@ -1190,6 +1325,13 @@ ;; esac +if [[ ${SMAGE_BUILD_LOGGING} != false ]] +then + bzip2 -9f /var/log/smage/${PKGNAME}.log +else + [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log +fi + # for sure unset NOPKGBUILD unset NOSTRIP