/var/lib/sorcery/modules/libcrossinstall

     1	#!/bin/bash
     2	#--------------------------------------------------------------------
     3	## Library for doing install_root stuff. It is home to menu's for
     4	## install_root and related variables. Future install_root specific
     5	## and cross install related code might live here.
     6	## @Copyright Copyright (C) 2004 The Source Mage Team
     7	## @Note The description may be wrong.
     8	#--------------------------------------------------------------------
     9	
    10	#---------------------------------------------------------------------
    11	##
    12	## This menu function is called only if the CROSS_INSTALL is turned on,
    13	## it provides the user with a choice of the default INSTALL_ROOT,
    14	## TRACK_ROOT, STATE_ROOT, and someday CODEX_ROOT
    15	##
    16	#---------------------------------------------------------------------
    17	function install_root_menu() {
    18	
    19	  debug "libcrossinstall" "cross_install_menu is being built now..."
    20	  local C_HELP="Fill in your own preferred install cache location."
    21	  local I_HELP="Fill in your own preferred install root location."
    22	  local S_HELP="Fill in your own preferred state root location."
    23	  local T_HELP="Fill in your own preferred track root location."
    24	
    25	  while
    26	
    27	    COMMAND=`eval $DIALOG '  --title "Install Root Menu"                     \
    28	                             --item-help                                     \
    29	                             --ok-label      "Select"                        \
    30	                             --cancel-label  "Exit"                          \
    31	                             --menu                                          \
    32	                             ""                                              \
    33	                             0 0 0                                           \
    34	                             "C"  "Set install cache location"     "$C_HELP" \
    35	                             "I"  "Set install root location"      "$I_HELP" \
    36	                             "S"  "Set state root location"        "$S_HELP" \
    37	                             "T"  "Set track root location"        "$T_HELP"'`
    38	
    39	  do
    40	
    41	    case $COMMAND in
    42	      C)  set_install_cache_menu  ;;
    43	      I)  set_install_root_menu   ;;
    44	      S)  set_state_root_menu     ;;
    45	      T)  set_track_root_menu     ;;
    46	    esac
    47	
    48	  done
    49	
    50	}
    51	
    52	#---------------------------------------------------------------------
    53	##
    54	## This menu function allows the user to fill in an INSTALL_CACHE location.
    55	##
    56	#---------------------------------------------------------------------
    57	function set_install_cache_menu() {
    58	
    59	  debug "libcrossinstall" "set_install_cache_menu - is starting..."
    60	  local PROMPT="Please enter the install cache location where cache tarballs will be stored"
    61	  if  NEW_INSTALL_CACHE=`eval $DIALOG '  --ok-label  "Commit"         \
    62	                                    --inputbox                   \
    63	                                    "$PROMPT"                    \
    64	                                    0 0  "$INSTALL_CACHE"'`
    65	  then
    66	    INSTALL_CACHE=${NEW_INSTALL_CACHE%/}
    67	    remove_config $LOCAL_CONFIG "INSTALL_CACHE"
    68	    modify_config  $LOCAL_ROOTS_CONFIG "INSTALL_CACHE"  "$INSTALL_CACHE"
    69	  fi
    70	}
    71	
    72	#---------------------------------------------------------------------
    73	##
    74	## This menu function allows the user to fill in an INSTALL_ROOT location.
    75	##
    76	#---------------------------------------------------------------------
    77	function set_install_root_menu() {
    78	
    79	  debug "libcrossinstall" "set_install_root_menu - is starting..."
    80	  local PROMPT="Please enter the install root location where you want file installed"
    81	  if  NEW_INSTALL_ROOT=`eval $DIALOG '  --ok-label  "Commit"         \
    82	                                    --inputbox                   \
    83	                                    "$PROMPT"                    \
    84	                                    0 0  "$INSTALL_ROOT"'`
    85	  then
    86	    INSTALL_ROOT=${NEW_INSTALL_ROOT%/}
    87	    remove_config  $LOCAL_CONFIG "INSTALL_ROOT"
    88	    modify_config  $LOCAL_ROOTS_CONFIG "INSTALL_ROOT"  "$INSTALL_ROOT"
    89	  fi
    90	}
    91	
    92	#---------------------------------------------------------------------
    93	##
    94	## This menu function allows the user to fill in an STATE_ROOT location.
    95	##
    96	#---------------------------------------------------------------------
    97	function set_state_root_menu() {
    98	
    99	  debug "libcrossinstall" "set_state_root_menu - is starting..."
   100	  local PROMPT="Please enter location where you want state files to be"
   101	  if  NEW_STATE_ROOT=`eval $DIALOG '  --ok-label  "Commit"         \
   102	                                    --inputbox                 \
   103	                                    "$PROMPT"                  \
   104	                                    0 0  "$STATE_ROOT"'`
   105	  then
   106	    STATE_ROOT=${NEW_STATE_ROOT%/}
   107	    remove_config  $LOCAL_CONFIG "STATE_ROOT"
   108	    modify_config  $LOCAL_ROOTS_CONFIG "STATE_ROOT"  "$STATE_ROOT"
   109	  fi
   110	}
   111	
   112	#---------------------------------------------------------------------
   113	##
   114	## This menu function allows the user to fill in an TRACK_ROOT location.
   115	##
   116	#---------------------------------------------------------------------
   117	function set_track_root_menu() {
   118	
   119	  debug "libcrossinstall" "set_track_root_menu - is starting..."
   120	  local PROMPT="Please enter the location where you want files tracked relative to"
   121	  if  NEW_TRACK_ROOT=`eval $DIALOG '  --ok-label  "Commit"         \
   122	                                    --inputbox                 \
   123	                                    "$PROMPT"                  \
   124	                                    0 0  "$TRACK_ROOT"'`
   125	  then
   126	    TRACK_ROOT=${NEW_TRACK_ROOT%/}
   127	    modify_config  $LOCAL_ROOTS_CONFIG "TRACK_ROOT"  "$TRACK_ROOT"
   128	  fi
   129	}
   130	
   131	#------------------------------
   132	## Will install sorcery in install_root directory, by running
   133	## the install script bundled with the tarball
   134	## This expects the user to have the sorcery tarball already downloaded
   135	## and in $SOURCE_CACHE.
   136	#------------------------------
   137	function replicate_sorcery() {
   138	  SOURCE=$SOURCE_CACHE/sorcery-$SORCERY_BRANCH.tar.bz2
   139	  SOURCE_DIRECTORY=$BUILD_DIRECTORY/sorcery
   140	
   141	  if ! test -f $SOURCE ; then
   142	    message "Cant find source in $SOURCE, please update or download sorcery"
   143	    return 1
   144	  fi
   145	
   146	  mk_source_dir  $SOURCE_DIRECTORY              &&
   147	  cd $INSTALL_ROOT/usr/src                      &&
   148	  bzip2  -cdf   $SOURCE                         |
   149	  tar --owner=root --group=root -xf /dev/stdin  &&
   150	  cd      $SOURCE_DIRECTORY                     &&
   151	  echo `pwd`                                    &&
   152	  ./install  $INSTALL_ROOT
   153	  rc=$?
   154	  cd ..
   155	
   156	  if [ $rc -eq 0 ] ; then
   157	    rm_source_dir
   158	  else
   159	    if [[  $CLEAN_SOURCE == on ]]; then
   160	      rm_source_dir
   161	    fi
   162	  fi
   163	  return $rc
   164	}
   165	
   166	
   167	#---------------------------------------------------------------------
   168	## @License
   169	##
   170	## This software is free software; you can redistribute it and/or modify
   171	## it under the terms of the GNU General Public License as published by
   172	## the Free Software Foundation; either version 2 of the License, or
   173	## (at your option) any later version.
   174	##
   175	## This software is distributed in the hope that it will be useful,
   176	## but WITHOUT ANY WARRANTY; without even the implied warranty of
   177	## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   178	## GNU General Public License for more details.
   179	##
   180	## You should have received a copy of the GNU General Public License
   181	## along with this software; if not, write to the Free Software
   182	## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   183	##
   184	#---------------------------------------------------------------------