--- trunk/bootstrap/scripts/mage-bootstrap.sh 2006/02/23 16:46:43 339 +++ trunk/bootstrap/mage-bootstrap.sh.in 2019/08/07 18:36:52 3117 @@ -1,5 +1,5 @@ #!/bin/bash -# $Header: /home/cvsd/magellan-cvs/magellan-src/bootstrap/scripts/mage-bootstrap.sh,v 1.4 2006-02-23 16:46:43 niro Exp $ +# $Id$ TOOLCHAIN="" BASESYSTEM="" @@ -8,6 +8,8 @@ ABORT_AFTER_STAGE1=false MY_MAGEDIR="" MY_PKGDIR="" +MAGEUPDATE=true +MAGEUPDATETARBALL=false die() { @@ -55,6 +57,8 @@ local SMAGE2RSYNC # sanity checks + [ -f /etc/mage.rc.global ] && source /etc/mage.rc.global || \ + die "get_value_from_magefile: /etc/mage.rc.global not found." [ -f ${magerc} ] && source ${magerc} || \ die "get_value_from_magefile: ${magerc} not found." [ -z "${var}" ] && die "get_value_from_magefile: \$var not given." @@ -75,12 +79,15 @@ enter_chroot() { - mount -t proc proc ${MROOT}/proc || die "mount proc" - mount -o bind /dev ${MROOT}/dev || die "mount dev" + is_loc_mounted "${MROOT}/proc" || mount -t proc proc ${MROOT}/proc + is_loc_mounted "${MROOT}/sys" || mount -t sysfs sysfs ${MROOT}/sys + is_loc_mounted "${MROOT}/dev" || mount -o bind /dev ${MROOT}/dev chroot ${MROOT} /bin/bash -i /.installrc || die "chr00ting" - umount ${MROOT}/dev ${MROOT}/proc || die "mount proc/dev" + is_loc_mounted "${MROOT}/dev" && umount ${MROOT}/dev + is_loc_mounted "${MROOT}/sys" && umount ${MROOT}/sys + is_loc_mounted "${MROOT}/proc" && umount ${MROOT}/proc [ -f ${MROOT}/.installrc ] && rm ${MROOT}/.installrc } @@ -101,6 +108,7 @@ { is_loc_mounted "${MROOT}/dev" && umount ${MROOT}/dev is_loc_mounted "${MROOT}/proc" && umount ${MROOT}/proc + is_loc_mounted "${MROOT}/sys" && umount ${MROOT}/sys is_loc_mounted "${MY_MAGEDIR}" && umount ${MY_MAGEDIR} is_loc_mounted "${MY_PKGDIR}" && umount ${MY_PKGDIR} echo "bootstrap aborted" @@ -109,18 +117,20 @@ print_usage() { - echo "mage-bootstrap, version $Id: mage-bootstrap.sh,v 1.4 2006-02-23 16:46:43 niro Exp $" + echo "mage-bootstrap, version @VERSION@" echo "Usage: $(basename $0) --opt arg ..." echo echo "Options:" - echo " --profile, -p -- select a profile (needed)" - echo " --root, -r -- location to new root (needed)" - echo " --magerc, -m -- location of mage.rc (needed)" + echo " --profile, -p -- select a profile (needed)" + echo " --root, -r -- location to new root (needed)" + echo " --magerc, -m -- location of mage.rc (needed)" echo - echo " --toolchain, -t -- select other toolchain than from profile" - echo " --basesystem, -b -- select other basesystem than from profile" - echo " --stage1, -s1 -- if set, abort after stage1 (toolchain)" - echo " --help, -h -- prints this help" + echo " --toolchain, -t -- select other toolchain than from profile" + echo " --basesystem, -b -- select other basesystem than from profile" + echo " --stage1, -s1 -- if set, abort after stage1 (toolchain)" + echo " --update-tarball, -ut -- update via tarball not rsync" + echo " --no-update, -u -- do not update the mage tree" + echo " --help, -h -- prints this help" echo exit 1 @@ -142,6 +152,8 @@ --root|-r) shift; MROOT="$1" ;; --stage1|-s1) ABORT_AFTER_STAGE1=true ;; --magerc|-m) shift; MAGERC="$1" ;; + --update-tarball|-ut) MAGEUPDATETARBALL=true ;; + --no-update|-u) MAGEUPDATE=false ;; --help|-h) print_usage ;; '') shift;; *) echo "Unkown option '$1', use --help or -h to get more info."; exit 1 ;; @@ -183,7 +195,15 @@ ln -snf ${MY_MAGEDIR}/profiles/${PROFILE} /etc/mage-profile || die "link profile" # update mage tree -mage update || die "update mage-tree" +if [[ ${MAGEUPDATE} = true ]] +then + if [[ ${MAGEUPDATETARBALL} = true ]] + then + MAGERC="${MAGERC}" mage update-tarball || die "update mage-tree" + else + MAGERC="${MAGERC}" mage update || die "update mage-tree" + fi +fi # now get the toolchain and the basesystem layout file # [ -z "${TOOLCHAIN}" ] && TOOLCHAIN="toolchain.defaults" @@ -192,13 +212,16 @@ # TOOLCHAIN="$(< /etc/mage-profile/${TOOLCHAIN})" # BASESYSTEM="$(< /etc/mage-profile/${BASESYSTEM})" -# this way toolchain and basesytem can be packages; +# this way toolchain and basesystem can be packages; # only if nothing set the layout files from the profile will be taken -[ -z "${TOOLCHAIN}" ] && TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)" -[ -z "${BASESYSTEM}" ] && BASESYSTEM="$(< /etc/mage-profile/basesystem.defaults)" +[ -z "${TOOLCHAIN}" ] && TOOLCHAIN="$(< ${MY_MAGEDIR}/profiles/${PROFILE}/toolchain.defaults)" +[ -z "${BASESYSTEM}" ] && BASESYSTEM="$(< ${MY_MAGEDIR}/profiles/${PROFILE}/basesystem.defaults)" # install toolchain -CONFIG_PROTECT="-*" MROOT="${MROOT}" mage install ${TOOLCHAIN} || die "toolchain install" +if ! MROOT="${MROOT}" MAGERC="${MAGERC}" magequery -n ${TOOLCHAIN} +then + CONFIG_PROTECT="-*" MROOT="${MROOT}" MAGERC="${MAGERC}" mage install ${TOOLCHAIN} || die "toolchain install" +fi # umount dirs, they are not needed anymore umount ${MY_MAGEDIR} ${MY_PKGDIR} || die "umount mage/pkgdir" @@ -213,16 +236,24 @@ echo "Stage1 complete; user requested to abort after this step." echo "Exiting ..." exit 0 +else + echo "Stage1 complete; continuing." fi # now create an initrc for the installation of the basesystem :> ${MROOT}/.installrc +add_initrc "export MAGE_BOOTSTRAP=true" add_initrc "export HOME=/root" add_initrc "export PATH=/bin:/usr/bin:/sbin:/usr/sbin" add_initrc "export BASESYSTEM=${BASESYSTEM}" add_initrc "export PROFILE=${PROFILE}" add_initrc "export CONFIG_PROTECT=-*" add_initrc "export MY_MAGEDIR=${MY_MAGEDIR}" +if [[ -n ${MAGERC} ]] +then + # unset global MAGERC here (bash-5 inclusion issues) + add_initrc 'unset MAGERC' +fi # add proxies if defined [[ -n ${http_proxy} ]] && add_initrc "export http_proxy=${http_proxy}" @@ -239,6 +270,4 @@ enter_chroot echo "System bootstrap to '${MROOT}' finished." - exit 0 -