info() { echo "This is a GPC Installation tool for UNIX/LINUX Systems. Simply execute this script to install GPC from scratch. When invoking first time, make sure your computer is online to the internet. Additional calls try to avoid downloading existing *.tar.gz files again in order to save time & money. The script was first derived based on instructions given in: http://www.gnu-pascal.de/alpha/ Use this script on your own risk. There is NO warranty. -------------- Scope of installation: LU: User installs into his local home dir --> install.gpc -i LR: Root installs machine wide --> install.gpc -i AU: User installs into his AFS home dir --> install.gpc -i AR: Root installs machine wide --> install.gpc -i AA: AFS admin installs site wide --> install.gpc -i -A -------I----------I--------------------I-----------I----------------------- File I who I I I Architecture System I installs I LINK= I BINARY= I Dependence -------I----------I--------------------I-----------I----------------------- I I I I I user I ~/bin/gpc I ~/.gnu I I (LU) I I I Local I----------I--------------------I-----------I----------------------- I I I I I root I /usr/local/bin/gpc I /usr/gnu I I (LR) I I I -------I----------I--------------------I-----------I----------------------- I I I I ~/.gnu -> ~/.gnu.@sys I user I ~/bin/gpc I ~/.gnu I mkdir ~/.gnu.`sys` I (AU) I I I I----------I--------------------I-----------I----------------------- I I I I AFS I root I /usr/sue/bin/gpc I /usr/gnu I I (AR) I I I I----------I--------------------I-----------I----------------------- I AFS I I I architecture dependent I admin I /usr/local/bin/gpc I /afs/... I link (see AU), not yet I (AA) I I I implemented -------I----------I--------------------I-----------I----------------------- -------------- Disk space requirements: - /tmp/install.gpc.\${USER} ~135 Mbyte (when using defaults & -V 0) - on ~/.gpc or /.. ~19 Mbyte -------------- Known limitations, problems: - Garbled *.tar.gz files may be produced by erroneous downloads (aborting etc.). To recover from garbled files use the -f switch. This forces fresh download of *.tar.gz files. - Repeated invocation of install.gpc as non root may fail due to wrong write permissions. Seen with file ../gpc-build/gcc/fixincl. As root remove dirs and files in directory ${SRC} exept *.tar.gz files - Checking prerequisits uncomplete, unsafe .. -> which gmake > /dev/null; echo $? # Returncode wrong on: HP-UX, SunOS Used therefore another tirty/unsafe trick to check gmake's existance. -> makeinfo: only ver 4.0 works on Linux, 1.68 fails, others not checked -> checking the needed programs and there existance in your PATH can be done with install.gpc -ck, output format is: Occurances Basename --> path_list_in_the_order_of_your_PATH Occurances should never be 0 -> using gnu tools mandatory (make, sed, grep, patch, ...) - The verbosity switch -V doesn't work the same way on different platforms. The aim is to cover batch mode (Hands off installation) and full verbosity, but: -> on SunOS it doesn't work as expected, log written to terminal -> ../configure unfortunately asks questions and simply needs to continue. With -V 0 the script may hang bacause any terminal output is written to the log fille. -> downloading with ftp not tested (unclear whether 'Hands off' would work) - Global site wide NFS/AFS-installation not yet implemented (ACLs etc.) Author: Ernst-Ludwig Bohnen, E-Mail: Ernst-Ludwig.Bohnen@desy.de History: 20010801 First version 20010802 Added FreeBSD for download with ftp, allow more methodes. Suggested by Stephen Hurd Couldn't test this change, don't have access to a FreeBSD host. 20010821 Added switches -V -ck -rf 20010901 Added patch for SunOS 20011001 Added -ftp switch, default is wget for downloading ../tar.gz Added -lv switch to see a list of available gpc versions 20020311 Changed default to gpc-20020304 Added -i switch, exchanged -v and -V 20020318 Added INSTALLER and LU, LR, AU, LU and AA. The scope of gpc- installation is somewhat more transparent now. Check for undefined MACHTYPE, new switch -mt Removed -rf switch, instead sourcing ~/.install.gpc.rc 20020411 Adaption with new URL: http://www.gnu-pascal.de/current Changed default to gpc-20020410 20020417 Removed the nasty MACHTYPE story Removed unused code for patching Added --help, --verbose & --version switch Changed -i into -m 'more info', prevents confusion with install 20020601 (re)introduced -i for explicitely start gpc installation, More flexibility with -pu -pd -pv switches to allow fallback, typing 'install.gpc -i' installs gpc-2.1 from http://www.gnu-pascal.de/current/gpc-20020510 20030630 Added: remove string 'core-' from gcc-core-3.2.1 dir name 20040703 Removed some stupid stuff Typing simply 'install.gpc -i' downloads and installs as default a somewhat old GPC version (gpc-20020510). For installing newer GPC/GCC versions you may create a file ~/.install.gpc.rc which overwrites default settings (don't forget to set the execution bit). Change the info to your needs. See the example below, which has been tested on SuSE 8.x and 9.x. Command line parameters take highest precedence. # ----- Example of ~/.install.gpc.rc ------------------- GCC_BSE='ftp://ftp.informatik.rwth-aachen.de/pub/gnu/gcc' GCC_VER='gcc-3.2.3' # gcc version GPC_URL='http://www.gnu-pascal.de' GPC_DIR='beta' GPC_VER='gpc-20040516' # gpc version (without .tar.gz!) # ----- End of ~/.install.gpc.rc ----------------------- " exit 1 ; } wr() { if [ "${VERBOSITY}" -gt 0 ] then echo "$1"; fi echo "INFO: $1" >> ${LOG}; } usage() { echo "Usage: install.gpc [ switches_in_any_order ] -f = forces new download, start from the very beginning -i = really install gpc -n = prevent final installation (download only) -V 0|1|2 = verbosity: 0=no print (batch), 1=print major steps, 2=print all --verbose = same as -V -ftp = use ftp for downloading, default is wget -lv = list gpc versions available -pu gpc-url = GPC URL, default: ${GPC_URL} -pd gpc-dir = GPC directory, default: ${GPC_DIR} -pv gpc-vers = GPC version, default: ${GPC_VER} -cb gcc-base = GCC base, default: ${GCC_BSE} -cv gcc-vers = GCC version, default: ${GCC_VER} -A = global site wide installation (AFS, NFS etc.) -ck = check commands on your PATH: N basename --> found_list -v|--version = print version in yyyymmdd format, this version is $VERSION -h|--help = help, print this text -m = info, print some more info Log files: $LOG $SUM" if [ -n "$1" ]; then echo; echo "$1" ; fi exit 1 ; } wr_summary() { # ------------- Write summary ------------------------------------------------- echo "====> Summary of GPC installation" > ${SUM} 2>&1 date >> ${SUM} 2>&1 echo "${SYSTEM}" >> ${SUM} 2>&1 echo "VERSION=${VERSION}" >> ${SUM} 2>&1 echo "MAKEINFO=${MAKEINFO}" >> ${SUM} 2>&1 echo "GPC_VER=${GPC_VER}" >> ${SUM} 2>&1 echo "GCC_VER=${GCC_VER}" >> ${SUM} 2>&1 echo "BINARY=${BINARY}" >> ${SUM} 2>&1 echo "LINK=${LINK}" >> ${SUM} 2>&1 echo "DOWNLOAD=${DOWNLOAD}" >> ${SUM} 2>&1 du -sk ${SRC} >> ${SUM} 2>&1 echo >> ${SUM} 2>&1 echo >> ${SUM} 2>&1 echo "====> Last 25 lines of the installation log" >> ${SUM} 2>&1 tail -25 ${LOG} >> ${SUM} 2>&1 } check() { if [ $1 != 0 ] then wr "ERROR, Returncode after $2 is $1"; wr_summary; exit 1; fi; } run() { wr "$1" case ${VERBOSITY} in 0) $1 >> ${LOG} 2>&1 ; check $? "$1" ;; # silent (batch mode) 1) $1 >> ${LOG} ; check $? "$1" ;; 2) $1 ; check $? "$1" ;; esac ; } dl() # Download: dl URL my_file_name { wr "Downloading $2" case ${DOWNLOAD} in WGET) run "wget ${OUTPUTFILE} -O $2 $1" ;; FTP) run "ftp $1" ;; *) usage "Unknown down load method: ${DOWNLOAD}" ;; esac ; } which_all() # which_all ${PATH} "cmnd1 cmnd2 ..." { # writes a list of installed commands for c in $1 do N=0 FL='' for d in `echo $2 | tr ':' ' '` do if [ -x ${d}/${c} ] then (( N=${N}+1 )) ; FL="${FL} ${d}/${c}" fi done echo "${N} $c --> ${FL}" done } list_versions() { cd ${SRC} VERBOSITY=0 dl ${GPC_BSE}/ FILES.gpc # get & extract gpc versions: gpc-yyyymmdd cat FILES.gpc | tr '" >=<' '\012' | grep gpc | grep tar.gz$ | \ sort -u | cut -d'.' -f1 | grep "^gpc-2.......$" ; } # --------------- Basic defaults ---- BEGIN ----------------------------------- SYSTEM=`uname` TMP_BSE="/tmp/${USER}" # Prevent conflicts between users GPC_URL='http://www.gnu-pascal.de' GPC_DIR='current' GPC_VER='gpc-20020510' # default gpc version GCC_BSE='ftp://ftp.informatik.rwth-aachen.de/pub/gnu/gcc' GCC_VER='gcc-2.95.2' # default gcc version SRC=${TMP_BSE}/install.gpc # source directory LOG=${SRC}/log # Log file SUM=${SRC}/log.summary.${SYSTEM} # short summary ESCAPE=: # default is do install INSTALL_GPC=false # install only if swith -i seen VERBOSITY=1 # report major steps only OUTPUTFILE='' # redundant:VERBOSITY 1,2 LIST_VERSIONS=false # get a list of GPC versions DOWNLOAD=WGET # default is wget .. VERSION='20030630' # install.gpc version seen with -v switch LINK_LU=${HOME}/bin/gpc; BINARY_LU=${HOME}/.gnu # Users local home dir LINK_LR=/usr/local/bin/gpc; BINARY_LR=/usr/gnu # Host wide LINK_AU=${HOME}/bin/gpc; BINARY_AU=${HOME}/.gnu # Users AFS home dir LINK_AR=/usr/sue/bin/gpc; BINARY_AR=/usr/gnu # Host wide LINK_AA=/usr/local/bin/gpc; BINARY_AA=/afs/products/gnu # AFS site wide # --------------- Basic defaults ---- END ------------------------------------- # --------------- Overwrites basic defaults from ~/.install.gpc.rc ------------ RC="${HOME}/.install.gpc.rc" if [ -x ${RC} ]; then . ${RC}; fi # --------------- Set scope of installation: USER/ROOT/AFS -------------------- if [ ! -d ${TMP_BSE} ] ; then mkdir -p ${TMP_BSE} ; fi # New dir if necessary if [ -d /afs ] # may not be a good indicator for AFS then INSTALLER="A" ; SYS=`sys` # if AFS is present, get system architecture else INSTALLER="L" # Local filesystem fi if [ "$USER" = "root" ] then INSTALLER="${INSTALLER}R" # Root installs machine wide else INSTALLER="${INSTALLER}U" # User into his home directory fi # ---------------- Read command line parameter, overwrites defaults & rc-file while [ $# -gt 0 ] do SWITCH=$1 case ${SWITCH} in -f) if [ -d ${SRC} ] then # force a fresh download wr "Cleaning up ${SRC}" rm -r ${SRC}/* fi ;; -i) INSTALL_GPC=true ;; # do installation -n) ESCAPE=exit ;; # NO final installation -V | --verbose) shift case $1 in 0) OUTPUTFILE='-o /dev/null';; # be silent (batch) 1|2) OUTPUTFILE='';; # see download process *) usage "Unknown verbosity level $1" ;; esac VERBOSITY=$1 ;; -ftp) DOWNLOAD=FTP ;; # ftp for download, default is wget -lv) LIST_VERSIONS=true ;; -pu) shift; GPC_URL=$1 ;; -pd) shift; GPC_DIR=$1 case ${GPC_DIR} in current | alpha | beta) ;; *) GPC_DIR=unknown usage "Valid values for -pd : current | alpha | beta";; esac ;; -pv) shift; GPC_VER=$1 ;; -cb) shift; GCC_BSE=$1 ;; -cv) shift; GCC_VER=$1 ;; -A) if [ "$USER" = "root" ] then echo "Must be an AFS-Administrator"; exit 2; fi INSTALLER="AA" ;; # AFS-Administrator -ck) which_all "gmake make makeinfo texinfo gcc ld gdb wget ftp sed patch gzip zip tar" ${PATH} exit 1 ;; -v|--version) echo "`basename $0`, version $VERSION"; exit ;;# print version -h|--help) usage ;; # print help & exit -m) info ;; # print more info & exit *) usage "Unknown switch: $1";; # unknown switch, exit esac if [ $# -gt 0 ]; then shift; else usage "Missing parameter for ${SWITCH}"; fi done # ---------------- Compose paths, links and URLs ------------------------------ case ${INSTALLER} in # scope of installation LU) LINK=${LINK_LU}; BINARY=${BINARY_LU} ;; # Users local home dir LR) LINK=${LINK_LR}; BINARY=${BINARY_LR} ;; # Host wide AU) LINK=${LINK_AU}; BINARY=${BINARY_AU} ;; # Users global AFS home dir AR) LINK=${LINK_AR}; BINARY=${BINARY_AR} ;; # Host wide AA) LINK=${LINK_AA}; BINARY=${BINARY_AA} # AFS admin site wide echo "AFS site wide installation not implemented"; exit 98 ;; *) echo "Fatal Error"; exit 99 ;; esac GPC_BSE="${GPC_URL}/${GPC_DIR}" GPC_TAR="${GPC_BSE}/${GPC_VER}.tar.gz" GCC_URL="${GCC_BSE}/${GCC_VER}.tar.gz" # ---------------- Prepare & cleanup ------------------------------------------ if [ ! -d ${SRC} ] ; then mkdir -p ${SRC}; fi # New dir if necessary if [ ${LIST_VERSIONS} = true ]; then list_versions; exit 3; fi if [ "${INSTALL_GPC}" = "false" ]; then usage "Needs -i to install gpc"; fi run "cd ${SRC}" # be very sure cd worked OK!! wr "Installing GPC on ${SYSTEM}" for f in `ls | grep -v ${GPC_VER}.tar.gz | grep -v ${GCC_VER}.tar.gz` do rm -f -r $f ; done # exclude *.tar.gz files # ---------------- Download gpc & untar --------------------------------------- if [ ! -f ${GPC_VER}.tar.gz ] # check if GPC exists then dl ${GPC_TAR} ${GPC_VER}.tar.gz ; fi wr "Creating ${GPC_VER}" # unzip & untar case ${VERBOSITY} in 0) gzip -c -d ${GPC_VER}.tar.gz|tar -xvf - >>${LOG} 2>&1;check $? "gzip/tar";; 1) gzip -c -d ${GPC_VER}.tar.gz|tar -xvf - >>${LOG}; check $? "gzip/tar";; 2) gzip -c -d ${GPC_VER}.tar.gz|tar -xvf - ; check $? "gzip/tar";; esac # ---------------- Download gcc & untar --------------------------------------- if [ ! -f ${GCC_VER}.tar.gz ] # check if GCC exists then dl ${GCC_URL} ${GCC_VER}.tar.gz ; fi wr "Creating ${GCC_VER}" # unzip & untar case ${VERBOSITY} in 0) gzip -c -d ${GCC_VER}.tar.gz|tar -xvf - >>${LOG} 2>&1;check $? "gzip/tar";; 1) gzip -c -d ${GCC_VER}.tar.gz|tar -xvf - >>${LOG}; check $? "gzip/tar";; 2) gzip -c -d ${GCC_VER}.tar.gz|tar -xvf - ; check $? "gzip/tar";; esac # ---------------- Permissions ------------------------------------------------ wr "Checking permissions" # needs yet some work if [ "$USER" = "root" ] # root doesn't has problems then chown -R root *; fi # set access rights, set group is problematical # chown -R $USER * ; # needs root permissions # should also set write permission to all files # - GPC Installation, check any action in order to detect data dependent errors # run "cd ${SRC}/${GPC_VER}" # run "mv p ${SRC}/${GCC_VER}/gcc/" GCC_VER=`echo ${GCC_VER} | sed "s/core-//"` # make it work, quick and dirty # run "mv ${SRC}/${GPC_VER}/p ${SRC}/${GCC_VER}/gcc/" run "ln -s ${SRC}/${GPC_VER}/p ${SRC}/${GCC_VER}/gcc/" # test run "${ESCAPE}" run "mkdir ${SRC}/gpc-build" run "cd ${SRC}/gpc-build" case ${INSTALLER} in LU) ;; LR) ;; AU) if [ ! -L ${BINARY} ]; then ln -s ${BINARY}.@sys ${BINARY}; fi if [ ! -d ${BINARY}.${SYS} ]; then mkdir ${BINARY}.${SYS}; fi ;; AR) ;; AA) echo "Fatal Error"; exit 98 ;; *) echo "Fatal Error"; exit 99 ;; esac run "${SRC}/${GCC_VER}/configure --enable-languages=pascal --prefix=${BINARY}" run "make" run "make install" run "cd gcc" run "make pascal.install" # ------------- Make a link to gpc executable --------------------------------- if [ -L ${LINK} ]; then rm ${LINK}; fi # make gpc visable on standard PATH ln -s ${BINARY}/bin/gpc ${LINK} # remove link and create a new one wr "GPC installation done, hopefully!" wr_summary # write short summary file