1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/bootstrap/scripts/mage-bootstrap.sh,v 1.3 2006-02-23 16:46:03 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/bootstrap/scripts/mage-bootstrap.sh,v 1.8 2008-06-23 19:26:40 niro Exp $ |
3 |
|
|
4 |
TOOLCHAIN="" |
TOOLCHAIN="" |
5 |
BASESYSTEM="" |
BASESYSTEM="" |
8 |
ABORT_AFTER_STAGE1=false |
ABORT_AFTER_STAGE1=false |
9 |
MY_MAGEDIR="" |
MY_MAGEDIR="" |
10 |
MY_PKGDIR="" |
MY_PKGDIR="" |
11 |
|
MAGEUPDATE=true |
12 |
|
|
13 |
die() |
die() |
14 |
{ |
{ |
56 |
local SMAGE2RSYNC |
local SMAGE2RSYNC |
57 |
|
|
58 |
# sanity checks |
# sanity checks |
59 |
|
[ -f /etc/mage.rc.global ] && source /etc/mage.rc.global || \ |
60 |
|
die "get_value_from_magefile: /etc/mage.rc.global not found." |
61 |
[ -f ${magerc} ] && source ${magerc} || \ |
[ -f ${magerc} ] && source ${magerc} || \ |
62 |
die "get_value_from_magefile: ${magerc} not found." |
die "get_value_from_magefile: ${magerc} not found." |
63 |
[ -z "${var}" ] && die "get_value_from_magefile: \$var not given." |
[ -z "${var}" ] && die "get_value_from_magefile: \$var not given." |
112 |
|
|
113 |
print_usage() |
print_usage() |
114 |
{ |
{ |
115 |
echo "mage-bootstrap, version $Version$" |
echo "mage-bootstrap, version @VERSION@" |
116 |
echo "Usage: $(basename $0) --opt arg ..." |
echo "Usage: $(basename $0) --opt arg ..." |
117 |
echo |
echo |
118 |
echo "Options:" |
echo "Options:" |
123 |
echo " --toolchain, -t -- select other toolchain than from profile" |
echo " --toolchain, -t -- select other toolchain than from profile" |
124 |
echo " --basesystem, -b -- select other basesystem than from profile" |
echo " --basesystem, -b -- select other basesystem than from profile" |
125 |
echo " --stage1, -s1 -- if set, abort after stage1 (toolchain)" |
echo " --stage1, -s1 -- if set, abort after stage1 (toolchain)" |
126 |
|
echo " --no-update, -u -- do not update the mage tree" |
127 |
echo " --help, -h -- prints this help" |
echo " --help, -h -- prints this help" |
128 |
echo |
echo |
129 |
|
|
146 |
--root|-r) shift; MROOT="$1" ;; |
--root|-r) shift; MROOT="$1" ;; |
147 |
--stage1|-s1) ABORT_AFTER_STAGE1=true ;; |
--stage1|-s1) ABORT_AFTER_STAGE1=true ;; |
148 |
--magerc|-m) shift; MAGERC="$1" ;; |
--magerc|-m) shift; MAGERC="$1" ;; |
149 |
|
--no-update|-u) shift; MAGEUPDATE=false ;; |
150 |
--help|-h) print_usage ;; |
--help|-h) print_usage ;; |
151 |
'') shift;; |
'') shift;; |
152 |
*) echo "Unkown option '$1', use --help or -h to get more info."; exit 1 ;; |
*) echo "Unkown option '$1', use --help or -h to get more info."; exit 1 ;; |
188 |
ln -snf ${MY_MAGEDIR}/profiles/${PROFILE} /etc/mage-profile || die "link profile" |
ln -snf ${MY_MAGEDIR}/profiles/${PROFILE} /etc/mage-profile || die "link profile" |
189 |
|
|
190 |
# update mage tree |
# update mage tree |
191 |
mage update || die "update mage-tree" |
if [[ ${MAGEUPDATE} = true ]] |
192 |
|
then |
193 |
|
MAGERC="${MAGERC}" mage update || die "update mage-tree" |
194 |
|
fi |
195 |
|
|
196 |
# now get the toolchain and the basesystem layout file |
# now get the toolchain and the basesystem layout file |
197 |
# [ -z "${TOOLCHAIN}" ] && TOOLCHAIN="toolchain.defaults" |
# [ -z "${TOOLCHAIN}" ] && TOOLCHAIN="toolchain.defaults" |
200 |
# TOOLCHAIN="$(< /etc/mage-profile/${TOOLCHAIN})" |
# TOOLCHAIN="$(< /etc/mage-profile/${TOOLCHAIN})" |
201 |
# BASESYSTEM="$(< /etc/mage-profile/${BASESYSTEM})" |
# BASESYSTEM="$(< /etc/mage-profile/${BASESYSTEM})" |
202 |
|
|
203 |
# this way toolchain and basesytem can be packages; |
# this way toolchain and basesystem can be packages; |
204 |
# only if nothing set the layout files from the profile will be taken |
# only if nothing set the layout files from the profile will be taken |
205 |
[ -z "${TOOLCHAIN}" ] && TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)" |
[ -z "${TOOLCHAIN}" ] && TOOLCHAIN="$(< ${MY_MAGEDIR}/profiles/${PROFILE}/toolchain.defaults)" |
206 |
[ -z "${BASESYSTEM}" ] && BASESYSTEM="$(< /etc/mage-profile/basesystem.defaults)" |
[ -z "${BASESYSTEM}" ] && BASESYSTEM="$(< ${MY_MAGEDIR}/profiles/${PROFILE}/basesystem.defaults)" |
207 |
|
|
208 |
# install toolchain |
# install toolchain |
209 |
CONFIG_PROTECT="-*" MROOT="${MROOT}" mage install ${TOOLCHAIN} || die "toolchain install" |
CONFIG_PROTECT="-*" MROOT="${MROOT}" MAGERC="${MAGERC}" mage install ${TOOLCHAIN} || die "toolchain install" |
210 |
|
|
211 |
# umount dirs, they are not needed anymore |
# umount dirs, they are not needed anymore |
212 |
umount ${MY_MAGEDIR} ${MY_PKGDIR} || die "umount mage/pkgdir" |
umount ${MY_MAGEDIR} ${MY_PKGDIR} || die "umount mage/pkgdir" |
225 |
|
|
226 |
# now create an initrc for the installation of the basesystem |
# now create an initrc for the installation of the basesystem |
227 |
:> ${MROOT}/.installrc |
:> ${MROOT}/.installrc |
228 |
|
add_initrc "export MAGE_BOOTSTRAP=true" |
229 |
add_initrc "export HOME=/root" |
add_initrc "export HOME=/root" |
230 |
add_initrc "export PATH=/bin:/usr/bin:/sbin:/usr/sbin" |
add_initrc "export PATH=/bin:/usr/bin:/sbin:/usr/sbin" |
231 |
add_initrc "export BASESYSTEM=${BASESYSTEM}" |
add_initrc "export BASESYSTEM=${BASESYSTEM}" |
248 |
enter_chroot |
enter_chroot |
249 |
|
|
250 |
echo "System bootstrap to '${MROOT}' finished." |
echo "System bootstrap to '${MROOT}' finished." |
|
|
|
251 |
exit 0 |
exit 0 |
|
|
|