--- trunk/mage/usr/lib/mage/smage2.sh 2009/04/26 15:57:42 832 +++ trunk/mage/usr/lib/mage/smage2.sh 2009/11/20 19:41:27 941 @@ -73,6 +73,14 @@ exit 1 } +die_pipestatus() +{ + local pos="$1" + local comment="$2" + + [ ${PIPESTATUS[${pos}]} -gt 0 ] && die "${comment}" +} + xtitle() { if [[ ${TERM} = xterm ]] @@ -171,6 +179,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 +197,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 +221,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 +245,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 @@ -258,7 +269,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 @@ -282,7 +293,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 @@ -301,7 +312,7 @@ --tries 3 \ --continue \ --progress bar \ - --directory-prefix="${my_SOURCEDIR}" \ + --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \ "${my_SRC_URI}" fi fi @@ -362,6 +373,7 @@ ./configure \ --prefix=/usr \ --host=${CHOST} \ + --build=${CHOST} \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ --datadir=/usr/share \ @@ -879,6 +891,7 @@ # fix target as it may be empty ! [ -n "${target}" ] && target="-${target}" + # build pkgname pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" @@ -898,7 +911,7 @@ : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} # setup md5 dir - dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5" + dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5" install -d ${dest} # gen md5sum @@ -936,6 +949,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 @@ -1056,14 +1079,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 @@ -1128,6 +1167,7 @@ source ${SMAGENAME} || die "source failed" PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" MD5DIR="$(dirname ${SMAGENAME})/md5" +SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log" xtitle "Compiling ${PKGNAME}" echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}" @@ -1202,9 +1242,21 @@ 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 | ${SMAGE_LOG_CMD} +die_pipestatus 0 "src_prepare failed" +step_by_step $_ + +src_compile | ${SMAGE_LOG_CMD} +die_pipestatus 0 "src_compile failed" +step_by_step $_ + +src_install | ${SMAGE_LOG_CMD} +die_pipestatus 0 "src_install failed" +step_by_step $_ # compressing doc, info & man files @@ -1285,6 +1337,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