Magellan Linux

Diff of /trunk/bootstrap/mage-bootstrap.sh.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/bootstrap/scripts/mage-bootstrap.sh revision 339 by niro, Thu Feb 23 16:46:43 2006 UTC trunk/bootstrap/mage-bootstrap.sh.in revision 3117 by niro, Wed Aug 7 18:36:52 2019 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  # $Header: /home/cvsd/magellan-cvs/magellan-src/bootstrap/scripts/mage-bootstrap.sh,v 1.4 2006-02-23 16:46:43 niro Exp $  # $Id$
3    
4  TOOLCHAIN=""  TOOLCHAIN=""
5  BASESYSTEM=""  BASESYSTEM=""
# Line 8  MROOT="" Line 8  MROOT=""
8  ABORT_AFTER_STAGE1=false  ABORT_AFTER_STAGE1=false
9  MY_MAGEDIR=""  MY_MAGEDIR=""
10  MY_PKGDIR=""  MY_PKGDIR=""
11    MAGEUPDATE=true
12    MAGEUPDATETARBALL=false
13    
14  die()  die()
15  {  {
# Line 55  read_magerc() Line 57  read_magerc()
57   local SMAGE2RSYNC   local SMAGE2RSYNC
58    
59   # sanity checks   # sanity checks
60     [ -f /etc/mage.rc.global ] && source /etc/mage.rc.global || \
61     die "get_value_from_magefile: /etc/mage.rc.global not found."
62   [ -f ${magerc} ] && source ${magerc} || \   [ -f ${magerc} ] && source ${magerc} || \
63   die "get_value_from_magefile: ${magerc} not found."   die "get_value_from_magefile: ${magerc} not found."
64   [ -z "${var}" ] && die "get_value_from_magefile: \$var not given."   [ -z "${var}" ] && die "get_value_from_magefile: \$var not given."
# Line 75  add_initrc() Line 79  add_initrc()
79    
80  enter_chroot()  enter_chroot()
81  {  {
82   mount -t proc proc ${MROOT}/proc || die "mount proc"   is_loc_mounted "${MROOT}/proc" || mount -t proc proc ${MROOT}/proc
83   mount -o bind /dev ${MROOT}/dev || die "mount dev"   is_loc_mounted "${MROOT}/sys" || mount -t sysfs sysfs ${MROOT}/sys
84     is_loc_mounted "${MROOT}/dev" || mount -o bind /dev ${MROOT}/dev
85    
86   chroot ${MROOT} /bin/bash -i /.installrc || die "chr00ting"   chroot ${MROOT} /bin/bash -i /.installrc || die "chr00ting"
87    
88   umount ${MROOT}/dev ${MROOT}/proc || die "mount proc/dev"   is_loc_mounted "${MROOT}/dev" && umount ${MROOT}/dev
89     is_loc_mounted "${MROOT}/sys" && umount ${MROOT}/sys
90     is_loc_mounted "${MROOT}/proc" && umount ${MROOT}/proc
91    
92   [ -f ${MROOT}/.installrc ] && rm ${MROOT}/.installrc   [ -f ${MROOT}/.installrc ] && rm ${MROOT}/.installrc
93  }  }
# Line 101  trap_exit() Line 108  trap_exit()
108  {  {
109   is_loc_mounted "${MROOT}/dev" && umount ${MROOT}/dev   is_loc_mounted "${MROOT}/dev" && umount ${MROOT}/dev
110   is_loc_mounted "${MROOT}/proc" && umount ${MROOT}/proc   is_loc_mounted "${MROOT}/proc" && umount ${MROOT}/proc
111     is_loc_mounted "${MROOT}/sys" && umount ${MROOT}/sys
112   is_loc_mounted "${MY_MAGEDIR}" && umount ${MY_MAGEDIR}   is_loc_mounted "${MY_MAGEDIR}" && umount ${MY_MAGEDIR}
113   is_loc_mounted "${MY_PKGDIR}" && umount ${MY_PKGDIR}   is_loc_mounted "${MY_PKGDIR}" && umount ${MY_PKGDIR}
114   echo "bootstrap aborted"   echo "bootstrap aborted"
# Line 109  trap_exit() Line 117  trap_exit()
117    
118  print_usage()  print_usage()
119  {  {
120   echo "mage-bootstrap, version $Id: mage-bootstrap.sh,v 1.4 2006-02-23 16:46:43 niro Exp $"   echo "mage-bootstrap, version @VERSION@"
121   echo "Usage: $(basename $0) --opt arg ..."   echo "Usage: $(basename $0) --opt arg ..."
122   echo   echo
123   echo "Options:"   echo "Options:"
124   echo " --profile,    -p  --  select a profile (needed)"   echo " --profile,        -p  --  select a profile (needed)"
125   echo " --root,       -r  --  location to new root (needed)"   echo " --root,           -r  --  location to new root (needed)"
126   echo " --magerc,     -m  --  location of mage.rc (needed)"   echo " --magerc,         -m  --  location of mage.rc (needed)"
127   echo   echo
128   echo " --toolchain,  -t  --  select other toolchain than from profile"   echo " --toolchain,      -t  --  select other toolchain than from profile"
129   echo " --basesystem, -b  --  select other basesystem than from profile"   echo " --basesystem,     -b  --  select other basesystem than from profile"
130   echo " --stage1,     -s1 --  if set, abort after stage1 (toolchain)"   echo " --stage1,         -s1 --  if set, abort after stage1 (toolchain)"
131   echo " --help,       -h  --  prints this help"   echo " --update-tarball, -ut --  update via tarball not rsync"
132     echo " --no-update,      -u  --  do not update the mage tree"
133     echo " --help,           -h  --  prints this help"
134   echo   echo
135    
136   exit 1   exit 1
# Line 142  do Line 152  do
152   --root|-r) shift; MROOT="$1" ;;   --root|-r) shift; MROOT="$1" ;;
153   --stage1|-s1) ABORT_AFTER_STAGE1=true ;;   --stage1|-s1) ABORT_AFTER_STAGE1=true ;;
154   --magerc|-m) shift; MAGERC="$1" ;;   --magerc|-m) shift; MAGERC="$1" ;;
155     --update-tarball|-ut) MAGEUPDATETARBALL=true ;;
156     --no-update|-u) MAGEUPDATE=false ;;
157   --help|-h) print_usage ;;   --help|-h) print_usage ;;
158   '') shift;;   '') shift;;
159   *) 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 ;;
# Line 183  mount -o bind ${MROOT}/${MY_PKGDIR} ${MY Line 195  mount -o bind ${MROOT}/${MY_PKGDIR} ${MY
195  ln -snf ${MY_MAGEDIR}/profiles/${PROFILE} /etc/mage-profile || die "link profile"  ln -snf ${MY_MAGEDIR}/profiles/${PROFILE} /etc/mage-profile || die "link profile"
196    
197  # update mage tree  # update mage tree
198  mage update || die "update mage-tree"  if [[ ${MAGEUPDATE} = true ]]
199    then
200     if [[ ${MAGEUPDATETARBALL} = true ]]
201     then
202     MAGERC="${MAGERC}" mage update-tarball || die "update mage-tree"
203     else
204     MAGERC="${MAGERC}" mage update || die "update mage-tree"
205     fi
206    fi
207    
208  # now get the toolchain and the basesystem layout file  # now get the toolchain and the basesystem layout file
209  # [ -z "${TOOLCHAIN}" ] && TOOLCHAIN="toolchain.defaults"  # [ -z "${TOOLCHAIN}" ] && TOOLCHAIN="toolchain.defaults"
# Line 192  mage update || die "update mage-tree" Line 212  mage update || die "update mage-tree"
212  # TOOLCHAIN="$(< /etc/mage-profile/${TOOLCHAIN})"  # TOOLCHAIN="$(< /etc/mage-profile/${TOOLCHAIN})"
213  # BASESYSTEM="$(< /etc/mage-profile/${BASESYSTEM})"  # BASESYSTEM="$(< /etc/mage-profile/${BASESYSTEM})"
214    
215  # this way toolchain and basesytem can be packages;  # this way toolchain and basesystem can be packages;
216  # 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
217  [ -z "${TOOLCHAIN}" ] && TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)"  [ -z "${TOOLCHAIN}" ] && TOOLCHAIN="$(< ${MY_MAGEDIR}/profiles/${PROFILE}/toolchain.defaults)"
218  [ -z "${BASESYSTEM}" ] && BASESYSTEM="$(< /etc/mage-profile/basesystem.defaults)"  [ -z "${BASESYSTEM}" ] && BASESYSTEM="$(< ${MY_MAGEDIR}/profiles/${PROFILE}/basesystem.defaults)"
219    
220  # install toolchain  # install toolchain
221  CONFIG_PROTECT="-*" MROOT="${MROOT}" mage install ${TOOLCHAIN} || die "toolchain install"  if ! MROOT="${MROOT}" MAGERC="${MAGERC}" magequery -n ${TOOLCHAIN}
222    then
223     CONFIG_PROTECT="-*" MROOT="${MROOT}" MAGERC="${MAGERC}" mage install ${TOOLCHAIN} || die "toolchain install"
224    fi
225    
226  # umount dirs, they are not needed anymore  # umount dirs, they are not needed anymore
227  umount ${MY_MAGEDIR} ${MY_PKGDIR} || die "umount mage/pkgdir"  umount ${MY_MAGEDIR} ${MY_PKGDIR} || die "umount mage/pkgdir"
# Line 213  then Line 236  then
236   echo "Stage1 complete; user requested to abort after this step."   echo "Stage1 complete; user requested to abort after this step."
237   echo "Exiting ..."   echo "Exiting ..."
238   exit 0   exit 0
239    else
240     echo "Stage1 complete; continuing."
241  fi  fi
242    
243  # now create an initrc for the installation of the basesystem  # now create an initrc for the installation of the basesystem
244  :> ${MROOT}/.installrc  :> ${MROOT}/.installrc
245    add_initrc "export MAGE_BOOTSTRAP=true"
246  add_initrc "export HOME=/root"  add_initrc "export HOME=/root"
247  add_initrc "export PATH=/bin:/usr/bin:/sbin:/usr/sbin"  add_initrc "export PATH=/bin:/usr/bin:/sbin:/usr/sbin"
248  add_initrc "export BASESYSTEM=${BASESYSTEM}"  add_initrc "export BASESYSTEM=${BASESYSTEM}"
249  add_initrc "export PROFILE=${PROFILE}"  add_initrc "export PROFILE=${PROFILE}"
250  add_initrc "export CONFIG_PROTECT=-*"  add_initrc "export CONFIG_PROTECT=-*"
251  add_initrc "export MY_MAGEDIR=${MY_MAGEDIR}"  add_initrc "export MY_MAGEDIR=${MY_MAGEDIR}"
252    if [[ -n ${MAGERC} ]]
253    then
254     # unset global MAGERC here (bash-5 inclusion issues)
255     add_initrc 'unset MAGERC'
256    fi
257    
258  # add proxies if defined  # add proxies if defined
259  [[ -n ${http_proxy} ]] && add_initrc "export http_proxy=${http_proxy}"  [[ -n ${http_proxy} ]] && add_initrc "export http_proxy=${http_proxy}"
# Line 239  add_initrc "mage clean" Line 270  add_initrc "mage clean"
270  enter_chroot  enter_chroot
271    
272  echo "System bootstrap to '${MROOT}' finished."  echo "System bootstrap to '${MROOT}' finished."
   
273  exit 0  exit 0
   

Legend:
Removed from v.339  
changed lines
  Added in v.3117