#!/bin/bash die() { echo "ERROR: $@" exit 1 } # get some settings from mage source /etc/mage.rc # which profile we are using ? PROFILE="$1" [ -z "${PROFILE}" ] && die "no profile given. Usage: $(basename $0) PROFILE" [ ! -f ./profiles/${PROFILE}/layout ] && die "Profile '${PROFILE}' layout file not found." # which packages to build # read them, end exclude the commented ones TOOLCHAIN_PACKAGES="$(< ./profiles/${PROFILE}/layout)" # where are the smage files ? TOOLCHAIN_SMAGE_DIR=$(pwd) # where gets the toolchain installed ? export ROOT="$(pwd)/tmp/${PROFILE}" # name and place of the tarball TOOLCHAIN_TARBALL="$(pwd)/magellan-toolchain-${PROFILE}.tar.bz2" echo "Compiling all packages for profile '${PROFILE}' ..." for i in ${TOOLCHAIN_PACKAGES} do # exclude commented and empty case ${i} in \#*|"") continue ;; esac PNAME_FULL="${i}" PNAME="${i%-*-*}" smage2 ${TOOLCHAIN_SMAGE_DIR}/${PNAME}/${PNAME_FULL}.smage2 || die "compile ${i}" done echo "All packages for profile '${PROFILE}' successfully compiled ..." [ ! -x ./minstallpkg.sh ] && die "minstallpkg not found. Cannot build ./tools dir." [ ! -d ${ROOT} ] && install -d ${ROOT} echo "Installing all packages for profile '${PROFILE}' to '${ROOT}' ..." for i in ${TOOLCHAIN_PACKAGES} do # exclude commented and empty case ${i} in \#*|"") continue ;; esac # fix pgk name -> add ARCH from mage.rc PNAME_FULL="${i}" PNAME="${i%-*-*}" PVER="$(echo ${PNAME_FULL%-*} | sed -e s:${PNAME}-::g)" PNAME_PVER_ARCH="${PNAME_FULL/-${PVER}-/-${PVER}-${ARCH}-}" ROOT=${ROOT} ./minstallpkg.sh ${PKGDIR}/${PNAME_PVER_ARCH}.mpk || die "install ${i}" done echo "All packages for profile '${PROFILE}' successfully installed ..." echo "Creating no the toolchain tarball ..." [ ! -d $(dirname ${TOOLCHAIN_TARBALL}) ] && install -d $(dirname ${TOOLCHAIN_TARBALL}) ( cd ${ROOT}; tar cvjpf ${TOOLCHAIN_TARBALL} ./ ) || die "error creating tarball" echo echo "All tasks done." echo "You find your tarball at ${TOOLCHAIN_TARBALL} ..." echo