]> SALOME platform Git repositories - tools/install.git/blob - config_files/HappyDoc-r2_1.sh
Salome HOME
Merge bug fixes from SALOME_3_DS branch
[tools/install.git] / config_files / HappyDoc-r2_1.sh
1 #!/bin/sh
2
3 check_version(){
4 check_lib_version happydoc $PATH
5 if [ "$?" -ne "0" ]; then
6    return 1
7 fi
8 happydoc 2&> /dev/null
9 if [ "$?" -eq "0" ]; then
10     ver=`happydoc | grep "HappyDoc version 2.1" | sort -u | awk '{print $NF}'`
11     if [ "$ver" == "2.1" ]; then
12         return 0
13     fi
14 fi
15 return 1
16 }
17
18 print_env(){
19 cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh <<EOF 
20 #$DELIM ${PRODUCT_TYPE} $DELIM
21 export PATH=\${INSTALL_ROOT}/${PRODUCT}/bin:\${PATH}
22 export PYTHONPATH=\${INSTALL_ROOT}/${PRODUCT}/lib/python\${PYTHON_VERSION}/site-packages:\${PYTHONPATH}
23 ##
24 EOF
25 (test -w ${PRODUCT_DIR} && cp ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh ${PRODUCT_DIR})
26 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}"
27 }
28
29 # looks for the native product and collects it's environment (used by make_env())
30 try_native(){
31 happydoc="`find_in_path happydoc ${PATH}`"
32 if [ -n "${happydoc}" ] ; then
33     ver=`happydoc | grep "HappyDoc version 2.1" | sort -u | awk '{print $NF}'`
34     cat > ${INSTALL_WORK}/try_native.py <<EOF 
35 import sys
36 try :
37     import happydoclib
38     sys.exit(0)    
39 except ImportError, r :
40     sys.exit(1)
41 EOF
42     python ${INSTALL_WORK}/try_native.py
43     if [ $? -eq 0 ] && [ "$ver" == "2.1" ] ; then
44         tmp="${happydoc} ${happydoc} \${PATH} ${PATH}";  
45         path=`sort_path ${tmp}`
46         pythonpath=`python -c "import happydoclib; print happydoclib.__file__" 2>/dev/null`
47         pythonpath=`dirname $pythonpath`
48         pythonpath=`dirname $pythonpath`
49         tmp="${pythonpath} ${pythonpath} \${PYTHONPATH} ${PYTHONPATH}";  
50         pythonpath=`sort_path ${tmp}`
51         cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh <<EOF 
52 #$DELIM ${PRODUCT_TYPE} $DELIM
53 export PATH=${path}
54 export PYTHONPATH=${pythonpath}
55 ##
56 EOF
57         make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}"
58         rm -f ${INSTALL_WORK}/try_native.py
59         return 0
60     fi
61 fi
62 rm -f ${INSTALL_WORK}/try_native.py
63 return 1
64 }
65
66 try_preinstalled(){
67 try_existing ${PRODUCT_DIR} ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE}
68 return $?
69 }
70
71 install_source()
72 {
73 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE}
74 source ${INSTALL_WORK}/$SHRC
75
76 check_jb tar xfz ${SOURCE_DIR}/HappyDoc_r2_1.tar.gz -C ${INSTALL_WORK}
77
78 cd ${PRODUCT_WORK}
79 makedir ${PRODUCT_DIR}
80 check_job ${PRODUCT_DIR}/INSTALL.LOG python setup.py install --prefix=${PRODUCT_DIR}
81 #file_pth=${PRODUCT_DIR}/lib/python\${PYTHON_VERSION}/site-packages/happydoclib.pth
82 #if [ ! -f ${file_pth} ] ; then
83 #    touch ${file_pth}
84 #    cat > ${file_pth} <<EOF 
85 #happydoclib
86 #EOF
87 #fi
88
89 #du -sk ${PRODUCT_WORK} > ${PRODUCT_DIR}/size.log
90 cd ${PRODUCT_DIR}; rm -fr ${PRODUCT_WORK}
91 print_env
92 }
93
94 install_binary()
95 {
96 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE}
97 source ${INSTALL_WORK}/$SHRC
98
99 check_jb tar xfz ${SOURCE_DIR}/HappyDoc-r2_1.tar.gz -C ${INSTALL_ROOT}
100
101 print_env
102 }
103
104 export PROCEDURE=$1;
105 export INSTALL_WORK=$2;
106 export SOURCE_DIR=$3;
107 export INSTALL_ROOT=$4;
108 export PRODUCT_SEQUENCE=$5;
109 if [ $# == 6 ] ; then export PRODUCT_TYPE=$6 ; else export PRODUCT_TYPE="happydoc" ; fi
110 export PRODUCT="HappyDoc-r2_1"
111 export PRODUCT_DIR=${INSTALL_ROOT}/${PRODUCT}
112 export PRODUCT_WORK=${INSTALL_WORK}/${PRODUCT}
113 source ./common.sh
114 $PROCEDURE