]> Creatis software - creaToolsTools.git/commitdiff
redmine feature # 1708
authorMichael Sdika <Michael.Sdika@creatis.insa-lyon.fr>
Wed, 17 Oct 2012 14:41:19 +0000 (14:41 +0000)
committerMichael Sdika <Michael.Sdika@creatis.insa-lyon.fr>
Wed, 17 Oct 2012 14:41:19 +0000 (14:41 +0000)
creation of the "installscript" bash script
the install can be done in one pass
root passwd is ask when necessary (at most once)
all options are given from command line (not interactive)
detect itself linux distrib, number of processor, user login/group
add packages list for Mandriva distrib.
add the RelWithDebug compilation option.
example in READMe.txt

Linux/README.txt
Linux/installscript [new file with mode: 0755]
Linux/scripts/ThirdParty-install-Base-Stuff.sh
Linux/scripts/ThirdParty-install-ITK.sh
Linux/scripts/ThirdParty-install-VTK.sh
Linux/scripts/ThirdParty-install.sh

index f0d3b4f3da5627a0b1e52dd15cfac0f3c2ba2ac9..cbab0d5779a50aa09dd85a7e208a916ded68ed4b 100644 (file)
@@ -1,4 +1,32 @@
 
+#######################################
+two solution to install the creatools under Linux:
+-- the new install script (called installscript) 
+-- the old interactive script (menu.sh) (obsolete will disappear in a near future)
+
+
+===================================
+doc for installscript
+===================================
+
+-- some example:
+
+# to configure only
+./installscript -gdir $HOME/work/creatools/creainstall config
+or
+./installscript -cvs sdika -ncore 4 -gdir $HOME/work/creatools/creainstall config
+
+# to configure / compile-install all packages and the creatools themselves 
+./installscript -cvs sdika -ncore 4 -gdir $HOME/work/creatools/creainstall all
+
+# compile-install only one part (vtk  for example) ONCE CONFIG HAS BEEN RUN 
+./installscript 3rd-vtk
+
+
+
+
+===================================
+doc for menu.sh
 ===================================
 WARNING :
 Use always bash (never use sh!)
diff --git a/Linux/installscript b/Linux/installscript
new file mode 100755 (executable)
index 0000000..b825124
--- /dev/null
@@ -0,0 +1,460 @@
+#!/bin/bash -e
+
+#########################################################################
+############     Local Functions  #######################################
+#########################################################################
+
+##########################################
+# check that $1 is one of $2, $3, ...
+function checkVal  {
+    local val=$1
+    shift
+    for x in $* ; do
+        if [ "$val" == "$x" ] ; then
+            echo "true"
+            return
+        fi
+    done
+    echo "false"
+}
+
+###########################################
+function bigDisplay {
+    echo " ================================================================================================"
+    echo " ================================================================================================"
+    echo " ======= $1"                                       
+    echo " ================================================================================================"
+    echo " ================================================================================================"
+}
+
+###########################################
+function checkDistrib {
+    local OS=$1
+
+    if [ "`checkVal $OS MacOS Fedora Ubuntu Mandriva`" == "false" ] ; then
+        echo "Operating System not supported: $OS"
+        echo "Currently supported system: Fedora Ubuntu MacOS"
+        exit 1
+    fi
+}
+
+###########################################
+function getDistrib {
+    local OS=`uname`
+
+      if [ "$OS" == Darwin ] ; then OS=MacOS;
+    elif [ "$OS" == Linux  ] ; then OS=`awk 'NR==1{print $1}' /etc/issue`
+    else OS=""
+    fi
+
+#    checkDistrib $OS
+
+    echo $OS
+}
+
+###########################################
+function getncore {
+    if [ `uname` == Darwin ] ; then # MacOS
+        system_profiler | grep Processor | awk '$1=="Number" {print $4}'
+    else
+        cat /proc/cpuinfo | grep processor | wc -l
+    fi
+}
+
+###########################################
+function getbashrc {
+    if [ ! -f $HOME/.bashrc ] ; then
+        touch $HOME/.bashrc
+    fi
+    echo $HOME/.bashrc
+
+
+#    # Do it, while we are under user, not under root! # JPR
+#    if [ -f $HOME/.bashrc ] ; then
+#        echo $HOME/.bashrc
+#    else
+#        if [ -f $HOME/.profile ] ; then
+#            echo $HOME/.profile
+#        else
+#            echo "=============== BIG TROUBLE : neither $HOME/.bashrc nor $HOME/.profile file found" > /dev/stderr
+#            echo "=============== You'd better abort the program and (try to) fix the issue" > /dec/stderr
+#            read a # just to let the user time enough to read the message...
+#        fi
+#    fi
+}
+
+
+###########################################
+function printconfig {
+
+    echo
+    echo "Current Configuration:"
+    echo "  Operating System                           : $OperatingSystem"
+    echo "  Number of Cores                            : $corenumber"  
+    echo "  Name of the Generation Directory           : $generationdir"
+    echo "  Install Prefix for Third Party Libraries   : $installPrefixThird"  
+    echo "  Install Prefix for CreaTools               : $installPrefix"
+    echo "  Boolean for Doc Generation                 : $docgeneration"
+    echo "  Where do you want to get source files from : $sourcesFrom"
+    if [ $sourcesFrom = CVS ] ; then
+    echo "  CVS User Name                              : $cvsUserName"
+    fi
+    echo "  Login User Name                            : $loginUserName"
+    echo "  Login Group Name                           : $loginGroupName"
+    echo "  Build type                                 : $buildType"          
+    echo "  Gdcm version                               : $gdcmVersion"
+    echo "  ITK version                                : $ITKVersion"
+    echo
+
+}
+
+
+
+##################################################################################################
+##################################################################################################
+##################################################################################################
+##################################################################################################
+##################################################################################################
+##################################################################################################
+
+configureFile="scripts/CreaTools-configure.sh"
+
+
+# default configuration parameters
+OperatingSystem=`getDistrib`
+corenumber=`getncore`
+generationdir=$HOME/CreatoolsGenerationDir
+installPrefixThird=
+installPrefix=
+docgeneration=OFF
+sourcesFrom=HTML
+
+cvsUserName=
+loginUserName=$USER
+loginGroupName=$GROUP
+buildType=RelWithDebug
+gdcmVersion=GDCM1
+ITKVersion=ITK3
+export ETC_BASHRC=`getbashrc`
+
+
+
+
+
+function usage {
+    echo "menu.sh [options] command" 
+    echo "creatools configure/compile/install script" 
+    echo "" 
+    echo "" 
+    echo "OPTIONS ARE USE FOR CONFIGURATION ONLY: THEY WILL BE IGNORED IF <COMMAND> IS NOT \"CONFIG\" OR \"ALL\"" 
+    echo "" 
+    echo "" 
+    echo "    command:" 
+    echo "         all               : configure / compile / install" 
+    echo "         "                 
+    echo "         config            : set the configuration parameters only" 
+    echo "         "                 
+    echo "         3rd               : Get, Compile, Install all 3rd party library "
+    echo "         3rd-base          : Install basic tools (cmake, doxygen...)"
+    echo "         3rd-vtk           : Get, Compile, Install vtk"
+    echo "         3rd-itk           : Get, Compile, Install itk"
+    echo "         3rd-gdcm          : Get, Compile, Install gdcm"
+    echo "         3rd-wx            : Get, Compile, Install wx widget (for Mac Users)"
+    echo "   "
+    echo "         creatools         : Get Compile and Install the CreaTools"
+    echo "         creatools-get     : Get the CreaTools"
+    echo "         creatools-cmp     : Compile the CreaTools"
+    echo "         creatools-install : Install the CreaTools"
+    echo "   "
+    echo "         uninstall         : uninstall the creatools"
+    echo "   "
+    echo "         printconfig       : print the configuration" 
+    echo "         help              : print help"
+    echo "         env               : print some environnement variables"
+    echo "   "
+    echo "   "
+    echo "   "
+    echo "   "
+    echo "    configure options: !!!!! IGNORED IF COMMAND IS NOT CONFIG OR ALL !!!!!!" 
+    echo "        -os <os>              : operating system distribution (default $OperatingSystem)"
+    echo "        -ncore <n>            : number of core to use (default $corenumber)"
+    echo "        -gdir <dir>           : generation directory (default $generationdir)"
+    echo "        -instprefix <dir>     : creatools install prefix" 
+    echo "        -instprefix3 <dir>    : 3rd party library install prefix" 
+    echo "        -cvs <cvsusername>    : get creatools from cvs (CREATIS user only)"
+    echo "        -build                : build type Release, RelWithDebug or Debug (default RelWithDebug)"
+    echo ""
+    echo "     experimental configure options (use at your own risk!!):"
+    echo "        -gdcm2         : use GDCM2 "
+    echo "        -doc           : generate documentation"
+    echo "        -itk4          : use ITK4"
+    echo "" 
+    exit 1
+}
+
+##################################################
+# parse command line
+while [ $# -ge 1 ] ; do
+    case $1 in
+        -os)                OperatingSystem=$2;                        shift 2;;
+        -ncore)             corenumber=$2;                             shift 2;;                     
+        -gdir)              generationdir=$2;                          shift 2;;                     
+        -instprefix)        installPrefix=$2;                          shift 2;;
+        -instprefix3)       installPrefixThird=$2;                     shift 2;;
+        -doc)               docgeneration=ON;                          shift 1;;
+        -cvs)               sourcesFrom=CVS; cvsUserName=$2;           shift 2;;
+        -gdcm2)             gdcmVersion=GDCM2;                         shift 1;;
+        -itk4)              ITKVersion=ITK4;                           shift 1;;
+        -build)             buildType=$2;                              shift 2;;
+        *) break;;
+    esac
+done
+
+if [ $# -le 0 ] ; then usage; fi
+
+command=$1
+
+# check that command is valid
+if [ `checkVal $command all config 3rd 3rd-base 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx creatools creatools-get creatools-cmp creatools-install uninstall printconfig help env` == "false" ] ; then
+    echo "Unrecognized command: $command"
+    echo ""
+    usage
+fi
+
+
+############################## use existing configuration if command is not config or all
+if [ `checkVal $command config all` == false ] ; then
+    if [ ! -f $configureFile ] ; then
+        echo "scripts/CreaTools-configure.sh does not exists"
+        echo "please run the scripts with command \"config\" or \"all\""
+        exit
+    fi
+    source $configureFile
+    if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
+        echo WARNING
+        echo "the curently used Third Party libraries are NOT in $installPrefixThird but ... in :"
+        grep "installPrefixThird=" $ETC_BASHRC
+        echo "VTK_DIR  : " $VTK_DIR
+        echo "ITK_DIR  : " $ITK_DIR
+        echo "GDCM_DIR : " $GDCM_DIR
+        echo "(Have a look at $ETC_BASHRC=, edit it or run again Install Third Party Libraries if you disagree)"
+    
+#        exit
+    fi
+    
+fi
+
+##################################################################################
+############################ check configuration parameters
+# check distrib
+checkDistrib $OperatingSystem
+
+# complete default install prefix
+if [ -z "$installPrefix" ]      ; then installPrefix=$generationdir/creatools_install; fi
+if [ -z "$installPrefixThird" ] ; then installPrefixThird=$generationdir/thirdparty_install; fi
+
+# check build type
+if [ `checkVal $buildType Release Debug RelWithDebug` == "false" ] ; then
+    echo "Unsupported build type: $buildType"
+    echo "Please use one of: Release Debug RelWithDebug"
+    exit 1
+fi
+
+
+##################################################################################
+############################  write configuration file
+if [ `checkVal $command config all` == true ] ; then
+    echo "#!/bin/bash"                            >  $configureFile
+    echo                                          >> $configureFile
+    echo "#File generated by 'menu.sh'"           >> $configureFile
+    echo "#DO NOT edit !"                         >> $configureFile
+    echo "#(except if you *do* know what you do)" >> $configureFile
+    echo                                          >> $configureFile
+    echo "OperatingSystem=$OperatingSystem"       >> $configureFile
+    echo "corenumber=$corenumber"                 >> $configureFile   
+    echo "generationdir=$generationdir"           >> $configureFile
+    echo "installPrefix=$installPrefix"           >> $configureFile
+    echo "installPrefixThird=$installPrefixThird" >> $configureFile
+    echo "docgeneration=$docgeneration"           >> $configureFile
+    echo "sourcesFrom=$sourcesFrom"               >> $configureFile
+    echo "cvsUserName=$cvsUserName"               >> $configureFile 
+    echo "loginUserName=$loginUserName"           >> $configureFile
+    echo "loginGroupName=$loginGroupName"         >> $configureFile
+    echo "buildType=$buildType"                   >> $configureFile
+    echo "gdcmVersion=$gdcmVersion"               >> $configureFile
+    echo "ITKVersion=$ITKVersion"                 >> $configureFile
+    echo "ETC_BASHRC=$ETC_BASHRC"                 >> $configureFile
+fi
+
+
+
+################################### print current configuration
+printconfig
+
+
+##################################################################################
+##################################################################################
+############   Process commands
+##################################################################################
+##################################################################################
+
+
+################################################################################## config printconfig
+# config or printconfig : already done
+if [ `checkVal $command config printconfig` == true ] ; then
+    exit
+fi
+
+
+################################################################################## 3rd library
+# install packaged dependencies as root
+if [ `checkVal $command all 3rd 3rd-base` == true ] ; then
+    bigDisplay "INSTALL PACKAGES DEPENDENCIES"
+    if [ "`whoami`" == root ] ; then
+        bash scripts/ThirdParty-install-Base-Stuff.sh
+    else 
+        # must log as root
+        echo "Please enter the root passwd to add necessary packages:"; 
+        su -c "bash scripts/ThirdParty-install-Base-Stuff.sh"   
+    fi
+    bash scripts/ThirdParty-install.sh
+fi
+
+# vtk
+if [ `checkVal $command all 3rd 3rd-vtk` == true ] ; then
+    bigDisplay "INSTALL VTK"
+    bash scripts/ThirdParty-install-VTK.sh
+fi
+
+# gdcm
+if [ `checkVal $command all 3rd 3rd-gdcm` == true ] ; then
+    bigDisplay "INSTALL $gdcmVersion"
+    bash scripts/ThirdParty-install-gdcm.sh
+fi
+
+# itk
+if [ `checkVal $command all 3rd 3rd-itk` == true ] ; then
+    bigDisplay "INSTALL $ITKVersion"
+    bash scripts/ThirdParty-install-ITK.sh
+fi
+
+## ??
+#if [ `checkVal $command all 3rd` == true ] ; then
+#    bash scripts/ThirdParty-install.sh
+#fi
+
+# Setup the user .bashrc correctly
+if [ `checkVal $command all 3rd 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx ` == true ] ; then
+    bigDisplay "FINALIZE 3RD PARTY LIBRARY INSTALLATION"
+    bash scripts/ThirdParty-install-Finalize.sh
+    source $ETC_BASHRC
+    if [ `checkVal $command 3rd 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx ` == true ] ; then
+        bigDisplay "Third Party Install Done" 
+        bigDisplay "Please copy paste the following command or open a new terminal: source ~/.bashrc" 
+    fi
+fi
+
+################################################################################## creatools
+
+# download creatools
+if [ `checkVal $command all creatools creatools-get` == true ] ; then
+    bigDisplay "DOWNLOAD CREATOOLS"
+    bash scripts/CreaTools-load.sh
+fi
+
+# compile creatools
+if [ `checkVal $command all creatools creatools-cmp` == true ] ; then
+    bigDisplay "COMPILE CREATOOLS"
+    source $ETC_BASHRC
+    bash -x scripts/CreaTools-compile.sh
+
+    # To allow (*very* aware) user to patch code, later
+    if [ ! -e $generationdir/creatools_source ] ; then
+        echo "You probabely made a mistake : "
+        echo "Directory $loginUserName $generationdir/creatools_source not found"
+        echo "Make sure you know the mistake"
+        echo "Hit any key to continue"
+        echo "Fix the mistake!"
+        read a
+    else
+        chown -R $loginUserName  $generationdir/creatools_source
+        chgrp -R $loginGroupName $generationdir/creatools_source
+    fi
+fi
+     
+#install creatools
+if [ `checkVal $command all creatools creatools-install` == true ] ; then
+    bigDisplay "INSTALL CREATOOLS"
+    source $ETC_BASHRC
+    bash scripts/CreaTools-install.sh
+    source $ETC_BASHRC
+fi
+
+################################################################################## uninstall
+
+if [ `checkVal $command uninstall` == true ] ; then
+    bigDisplay "UNINSTALL CREATOOLS"
+    bash scripts/CreaTools-uninstall.sh 
+fi
+
+################################################################################## help
+if [ `checkVal $command help` == true ] ; then
+    cat README.txt
+fi
+
+################################################################################## print env variables
+if [ `checkVal $command env` == true ] ; then
+    if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
+        echo WARNING
+        echo
+        echo "the curently used Third Party libraries are NOT in $installPrefixThird but in :"
+        grep "installPrefixThird=" $ETC_BASHRC
+        echo "VTK_DIR  : " $VTK_DIR
+        echo "ITK_DIR  : " $ITK_DIR
+        echo "GDCM_DIR : " $GDCM_DIR
+        echo
+        echo "installPrefixThird ... " $installPrefixThird
+    fi
+            
+    if [ -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
+        echo  "Third party config file : " $installPrefixThird/share/creatools_third_party_library_config.sh
+        echo  ------
+        cat $installPrefixThird/share/creatools_third_party_library_config.sh
+        echo  ------
+    fi
+     
+    echo
+     
+    if [ -f $installPrefix/share/creatools_base_library_config.sh ] ; then
+       echo  "Creatools base library config file : " $installPrefix/share/creatools_base_library_config.sh
+       echo  ------ 
+       cat $installPrefix/share/creatools_base_library_config.sh
+       echo  ------ 
+       echo
+       echo "installPrefix ... " $installPrefix
+    fi
+
+    echo  ------
+    echo "VTK_DIR  :                 " $VTK_DIR
+    echo "ITK_DIR  :                 " $ITK_DIR
+    echo "GDCM_DIR :                 " $GDCM_DIR
+    echo
+    echo "crea_DIR :                 " $crea_DIR
+    echo "BBTK_DIR :                 " $BBTK_DIR
+    echo "creaMaracasVisu_DIR :      " $creaMaracasVisu_DIR
+    echo "creaEnvironment_DIR :      " $creaEnvironment_DIR
+    echo "creaBruker_DIR :           " $creaBruker_DIR
+    echo "creaImageIO_DIR :          " $creaImageIO_DIR
+    echo "creaContours_DIR :         " $creaContours_DIR
+    echo "creaRigidRegistration_DIR :" $creaRigidRegistration_DIR
+    echo "bbtkGEditor_DIR :          " $bbtkGEditor_DIR
+    echo "creaTools_DIR :            " $creaTools_DIR
+    echo "creaMiniTools_DIR :        " $creaMiniTools_DIR
+    echo "Ido_DIR :                  " $Ido_DIR
+    echo "==================================="
+    echo
+
+fi
+
+
+
index 7220629fc79321a38bb781955c3b79539048eb79..214c92aad8f3bf34cfa57710ed1ea362bbedb73e 100644 (file)
@@ -49,6 +49,32 @@ if [ true = true ]
 then
   # ///\TODO what about SuSE? Debian? Mandriva? Gentoo?
   case "$OperatingSystem" in
+  Mandriva)
+     urpmi cmake                
+     urpmi cmake-qtgui            
+     urpmi doxygen              
+     urpmi graphviz             
+     urpmi texlive              
+     urpmi latex2html           
+     urpmi libwxgtk2.8    
+     urpmi lib64wxgtk2.8    
+     urpmi boost-devel          
+     urpmi sqlite-devel         
+     urpmi qt4-common
+     urpmi libqt4-devel             
+     urpmi lib64qt4-devel             
+     #urpmi mesa-libOSMesa-devel 
+     urpmi lib64mesagl1-devel
+     urpmi libmesagl1-devel
+     urpmi lib64xt-devel
+     urpmi libxt-devel
+     urpmi lib64wxgtk2.8-devel
+     urpmi libwxgtk2.8-devel
+     urpmi gcc-c++
+     urpmi cvs
+     urpmi rpm-build
+
+     ;;
   Fedora)
      yum install wget                 -y
      yum install cmake                -y
index 61ba301a8e980026b5269cf74739a015ed39ffef..5fcdfbfb11dc76ddbbc4e7b157b26cfe8e2d21ac 100644 (file)
@@ -109,12 +109,12 @@ fi
 
 #fi # JPR ------------1
 
-if [ $buildType = "Debug" ]
-then
-   debug="ON"
-else
-   debug="OFF"
-fi
+#if [ $buildType = "Debug" ]
+#then
+#   debug="ON"
+#else
+#   debug="OFF"
+#fi
 
 # the following stupid test is used at debug time; Please don't remove!
 #if [ true = false ]
index 36ac0308439e775faf0b6e9c390c18bc2d0857e7..e1638934ccdfc0503e21d715b7de4bd7b55eb2f2 100644 (file)
@@ -85,12 +85,12 @@ fi
   tar -xzvf VTK-5.6.1.patchCreatis.tar.gz
  fi
 
-if [ $buildType = "Debug" ]
-then
-   debug="ON"
-else
-   debug="OFF"
-fi
+#if [ $buildType = "Debug" ]
+#then
+#   debug="ON"
+#else
+#   debug="OFF"
+#fi
 
 # the following stupid test is used at debug time; Please don't remove!
 #if [ true = false ]
index c06dd1e8a428ac3671cae6dda42b3ae10628c0e7..187ffd313293d6042781c32883bf3b07e62e7069 100644 (file)
@@ -118,5 +118,6 @@ if [ true = true ]
 then
   cd $sourcesDir
  # pourquoi ne copie-t-on plus? JPR
+ mkdir -p $installPrefixThird/bin
  cp tth $installPrefixThird/bin
 fi