| 1 | #! /bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | #% @(#)update.sh 19.1 (ESO-IPG) 02/25/03 13:51:12 |
| 3 | # .COPYRIGHT: Copyright (c) 1988 European Southern Observatory, |
| 4 | # all rights reserved |
| 5 | # .TYPE command |
| 6 | # .NAME update.sh |
| 7 | # .LANGUAGE shell script |
| 8 | # .ENVIRONMENT Unix Systems. Executable under SHELL and C-SHELL |
| 9 | # .COMMENTS Updating procedure of the MIDAS system. |
| 10 | # The MIDAS system is installed with the "install" |
| 11 | # command and is executed just once. Henceforth, the |
| 12 | # system will be updated for any modification with the |
| 13 | # "update" command. |
| 14 | # |
| 15 | # Usage: update [options] |
| 16 | # |
| 17 | # options: are options for the "make" command. This option |
| 18 | # will be exported to all the directories of the |
| 19 | # update procedure. |
| 20 | # Multiple definitions for keywords must be: |
| 21 | # e.g. CFLAGS=\"-O -g -I/usr/include\" |
| 22 | # to avoid quotes to be interpreted by the shell. |
| 23 | # |
| 24 | # The command executes the following steps: |
| 25 | # |
| 26 | # - $MIDASHOME/$MIDVERS/local/make_options is read if exists.# It contains local options for "make" commands.a |
| 27 | # |
| 28 | # |
| 29 | # - MIDAS is structured in "core" (all directories |
| 30 | # in file "core.cnf" are included in the installation). |
| 31 | # and "packages" (optional, they are clasified in |
| 32 | # "applic", "stdred" and "contrib".) A package is |
| 33 | # selected for installation if it is marked with file |
| 34 | # "SELECTED". |
| 35 | # |
| 36 | # - Running "make options" in all the directories updating |
| 37 | # only those files involved in the update. |
| 38 | # |
| 39 | # .AUTHOR Carlos Guirao |
| 40 | # .VERSION 3.1 910725: New implementation. |
| 41 | |
| 42 | umask 002 |
| 43 | # |
| 44 | # First of all, goto the config directory adn |
| 45 | # <dirname> & <basename> commands emulated with <sed> |
| 46 | # cd `dirname $0` |
| 47 | # MIDVERS=`basename $VERSDIR` |
| 48 | # MIDASHOME=`dirname $VERSDIR` |
| 49 | # |
| 50 | if [scip-shell system . . `[`. -z "$MIDASHOME" -o -z "$MIDVERS" ] ; then |
| 51 | cd `echoscip-shell system . . echo. $0 | sedscip-shell system . . sed. -e 's/[^\/]*$//' -e 's/^$/./' -e 's/\/$//'` |
| 52 | MID_INSTALL=`pwdscip-shell system . . pwd.` |
| 53 | VERSDIR=`echoscip-shell system . . echo. $MID_INSTALL | sedscip-shell system . . sed. 's/\/install\/unix$//'` |
| 54 | MIDVERS=`echoscip-shell system . . echo. $VERSDIR | sedscip-shell system . . sed. -e 's/^.*\///'` |
| 55 | MIDASHOME=`echoscip-shell system . . echo. $VERSDIR | sedscip-shell system . . sed. -e 's/[^\/]*$//' -e 's/^$/./' -e 's/\/$//'` |
| 56 | else |
| 57 | cd $MIDASHOME/$MIDVERS/install/unix |
| 58 | fi |
| 59 | |
| 60 | MID_INSTALL=$MIDASHOME/$MIDVERS/install/unix |
| 61 | MID_HOME=$MIDASHOME/$MIDVERS |
| 62 | |
| 63 | # |
| 64 | # Local options for makes commands will be read if they exits in the |
| 65 | # make_options file, from the local directory. |
| 66 | # Other options can be set in the command line of this script as the |
| 67 | # second parameter: $2. These option will replace those local option with |
| 68 | # the same name |
| 69 | # |
| 70 | if [scip-shell system . . `[`. -r $MID_HOME/local/make_options ] |
| 71 | then |
| 72 | echoscip-shell system . . echo. "" |
| 73 | echoscip-shell system . . echo. "*************************************************" |
| 74 | echoscip-shell system . . echo. "********* READING YOUR LOCAL OPTIONS ************" |
| 75 | echoscip-shell system . . echo. "*************************************************" |
| 76 | echoscip-shell system . . echo. "" |
| 77 | catscip-shell system . . cat. $MID_HOME/local/make_options | awkscip-shell system . . awk. -F# '{print $1}' |
| 78 | echoscip-shell system . . echo. "" |
| 79 | fi |
| 80 | |
| 81 | echoscip-shell system . . echo. "*********************************************************************" |
| 82 | echoscip-shell system . . echo. "******************** MIDAS UPDATING PROCEDURE ***********************" |
| 83 | echoscip-shell system . . echo. "*********************************************************************" |
| 84 | echoscip-shell system . . echo. "******************** MIDASHOME: $MIDASHOME VERSION: $MIDVERS" |
| 85 | echoscip-shell system . . echo. "******************** DATE: `datescip-shell system . . date.`" |
| 86 | echoscip-shell system . . echo. "******************** COMMAND: $0 $*" |
| 87 | |
| 88 | for dir in `awkscip-shell system . . awk. -F# '{ print $1 }' $MID_INSTALL/core.cnf` |
| 89 | do |
| 90 | echoscip-shell system . . echo. "" |
| 91 | echoscip-shell system . . echo. "**********************************************" |
| 92 | echoscip-shell system . . echo. "****** UPDATING IN $dir" |
| 93 | echoscip-shell system . . echo. "**********************************************" |
| 94 | echoscip-shell system . . echo. "****** DATE: `datescip-shell system . . date.`" |
| 95 | if [scip-shell system . . `[`. ! -d $MID_HOME/$dir ]; then |
| 96 | echoscip-shell system . . echo. "Warning. $dir .No such directory." |
| 97 | continue |
| 98 | fi |
| 99 | cd $MID_HOME/$dir |
| 100 | eval make "$@" all |
| 101 | done |
| 102 | |
| 103 | for categ in applic stdred contrib gui |
| 104 | do |
| 105 | if [scip-shell system . . `[`. ! -d $MID_HOME/$categ ]; then |
| 106 | continue |
| 107 | fi |
| 108 | cd $MID_HOME/$categ |
| 109 | first_packages=`(lsscip-shell system . . ls. */SELECTED_BY* | awkscip-shell system . . awk. -F/ '{print $1}' | sortscip-shell system . . sort. -u) 2>/dev/nullscip-shell filesystem . . `/dev/null`.` |
| 110 | if [scip-shell system . . `[`. -n "$first_packages" ]; then |
| 111 | excluded=`echoscip-shell system . . echo. $first_packages | sedscip-shell system . . sed. -e 's/^/\^/' -e 's/$/\$/' -e 's/ /\$|\^/g'` |
| 112 | packages=`(lsscip-shell system . . ls. */SELECTED | awkscip-shell system . . awk. -F/ '{print $1}' | grepscip-shell system . . grep. -E -v "$excluded") 2>/dev/nullscip-shell filesystem . . `/dev/null`.` |
| 113 | else |
| 114 | packages=`(lsscip-shell system . . ls. */SELECTED | awkscip-shell system . . awk. -F/ '{print $1}') 2>/dev/nullscip-shell filesystem . . `/dev/null`.` |
| 115 | fi |
| 116 | for pack in $first_packages $packages |
| 117 | do |
| 118 | for dir in etc libsrc src proc help |
| 119 | do |
| 120 | if [scip-shell system . . `[`. -f $pack/$dir/makefile ]; then |
| 121 | echoscip-shell system . . echo. "" |
| 122 | echoscip-shell system . . echo. "**********************************************" |
| 123 | echoscip-shell system . . echo. "****** UPDATING IN ./$categ/$pack/$dir" |
| 124 | echoscip-shell system . . echo. "**********************************************" |
| 125 | cd $pack/$dir |
| 126 | eval make "$@" all |
| 127 | cd $MID_HOME/$categ |
| 128 | fi |
| 129 | done |
| 130 | done |
| 131 | done |
| 132 | cd $MID_HOME |
| 133 | |
| 134 | echoscip-shell system . . echo. "" |
| 135 | echoscip-shell system . . echo. "*********************************************************************" |
| 136 | echoscip-shell system . . echo. "************************ END UPDATING PROCEDURE *********************" |
| 137 | echoscip-shell system . . echo. "*********************************************************************" |
| 138 | echoscip-shell system . . echo. "********** END DATE: `datescip-shell system . . date.`" |