upgrade.sh
author Cristian Berner <cristian.berner@openbravo.com>
Fri, 17 Apr 2020 13:43:57 +0200
changeset 129 1c5993cd986c
parent 91 d01694731df9
permissions -rwxr-xr-x
Related to ISSUE-41898: Add .gitignore matching .hgignore
david@28
     1
#!/bin/sh
david@28
     2
david@28
     3
#
david@28
     4
# *************************************************************************
david@28
     5
# * The contents of this file are subject to the Openbravo  Public  License
david@28
     6
# * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
david@28
     7
# * Version 1.1  with a permitted attribution clause; you may not  use this
david@28
     8
# * file except in compliance with the License. You  may  obtain  a copy of
david@28
     9
# * the License at http://www.openbravo.com/legal/license.html 
david@28
    10
# * Software distributed under the License  is  distributed  on  an "AS IS"
david@28
    11
# * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
david@28
    12
# * License for the specific  language  governing  rights  and  limitations
david@28
    13
# * under the License. 
david@28
    14
# * The Original Code is Openbravo ERP. 
david@28
    15
# * The Initial Developer of the Original Code is Openbravo SLU 
david@28
    16
# * All portions are Copyright (C) 2012 Openbravo SLU 
david@28
    17
# * All Rights Reserved. 
david@28
    18
# * Contributor(s):  ______________________________________.
david@28
    19
# ************************************************************************
david@28
    20
#
david@28
    21
david@28
    22
clear
david@28
    23
david@28
    24
if [ ! -f locations ]; then
david@28
    25
  cp locations.template locations
david@28
    26
fi
david@28
    27
david@28
    28
while read myline
david@28
    29
do
david@28
    30
  if [ `expr "$myline" : "^sc\.source\.zip"` = "13" ]; then
david@28
    31
    srcPath=$(echo $myline | sed 's,^sc\.source\.zip\=,,')
david@28
    32
  elif [ `expr "$myline" : "^org\.openbravo\.userinterface\.smartclient"` = "39" ]; then
david@28
    33
    obScModuleDir=$(echo $myline | sed 's,^org\.openbravo\.userinterface\.smartclient\=,,')
david@28
    34
  fi
david@28
    35
done < locations
david@28
    36
david@28
    37
firstParam="0"
david@28
    38
if [ $1 ]; then
david@28
    39
  firstParam=$1
david@28
    40
  if [ $firstParam = "this" ] && [ $2 ]; then
david@28
    41
    srcPath=$2
david@29
    42
  elif [ $firstParam = "obmodule" ] && [ $2 ]; then
david@28
    43
    obScModuleDir=$2
david@28
    44
  fi
david@28
    45
fi
david@28
    46
david@28
    47
#STEP A
david@28
    48
if [ $firstParam = "this" ]; then
david@28
    49
david@28
    50
  #1)
david@28
    51
  srcFile=$(echo $srcPath | sed 's,.*/,,')
david@91
    52
  srcDir=$(echo $srcFile | sed 's,.zip$,,')
david@28
    53
  currentDir=$PWD
david@28
    54
david@28
    55
  if [ `expr "$srcPath" : ".*http"` = "4" ] || [ `expr "$srcPath" : ".*ftp"` = "3" ]; then
david@28
    56
    wget $srcPath
david@28
    57
  else
david@28
    58
    cp $srcPath .
david@28
    59
  fi
david@28
    60
david@28
    61
  if [ -f "$srcFile" ]; then
david@28
    62
    unzip -o $srcFile
david@28
    63
    rm -rf $srcFile
david@28
    64
david@28
    65
    if [ -d "$srcDir" ]; then
david@28
    66
david@28
    67
      #2)
david@28
    68
      isomorphicDir=web/org.openbravo.userinterface.smartclient/isomorphic
david@28
    69
      rm -rf $isomorphicDir
david@28
    70
      mv $srcDir/smartclientRuntime/isomorphic $isomorphicDir
david@28
    71
      rm -rf docs
david@28
    72
      mv $srcDir/smartclientSDK/docs .
david@28
    73
      mv $srcDir/smartclientSDK/source/client $isomorphicDir
david@28
    74
      mv $srcDir/smartclientSDK/source/copyright.txt $isomorphicDir
david@28
    75
      mv $srcDir/smartclientSDK/isomorphic/system/reference $isomorphicDir/system/reference
david@28
    76
      rm -rf selenium
david@28
    77
      mv $srcDir/smartclientSDK/tools/selenium selenium
david@28
    78
david@28
    79
      #3)
david@28
    80
      cd $isomorphicDir/skins
david@28
    81
      rm -rf $(ls | grep -v Enterprise$ | grep -v SmartClient$ | grep -v standard$)
david@28
    82
      cd $currentDir
david@28
    83
david@37
    84
      #4)
david@28
    85
      rm -rf $isomorphicDir/system/reference/inlineExamples/serverExamples
david@28
    86
      rm -rf $isomorphicDir/system/reference/inlineExamples/dataIntegration
david@28
    87
david@37
    88
      #5)
david@28
    89
      sed 's/.*ds.xml.*/\/\/&/' $isomorphicDir/client/modules/ISC_DataBinding.js > $isomorphicDir/client/modules/ISC_DataBinding.js2
david@28
    90
      rm -rf $isomorphicDir/client/modules/ISC_DataBinding.js
david@28
    91
      mv $isomorphicDir/client/modules/ISC_DataBinding.js2 $isomorphicDir/client/modules/ISC_DataBinding.js
david@28
    92
david@37
    93
      #6)
david@37
    94
      find $isomorphicDir/ -type f -name "*.gz" -exec rm -rf {} \;
david@37
    95
david@37
    96
      #7)
david@37
    97
      ant combineSource
david@37
    98
david@37
    99
      #8)
david@37
   100
      cp ISC_Combined.js $isomorphicDir/ISC_Combined.uncompressed.js
david@37
   101
      rm -rf ISC_Combined.js
david@37
   102
david@37
   103
      #9)
david@37
   104
      cp $isomorphicDir/client/modules/ISC_History.js $isomorphicDir/ISC_History.uncompressed.js
david@37
   105
david@28
   106
      #We are finish, just change permissions and remove the remaining not used content in the unziped SmartClient_*** folder
david@28
   107
      rm -rf $srcDir
david@28
   108
      find . -type f | grep -v '\.hg' | sed 's/ /\\ /g' | xargs chmod a-x
david@28
   109
      chmod a+x upgrade.sh
david@28
   110
david@28
   111
david@28
   112
    else
david@28
   113
      echo "\033[41m-------------------------------------------------------------------\033[0m"
david@28
   114
      echo "\033[1;41mERROR:\033[0m $srcFile was expected to be unziped to $srcDir, but it isn't \033[0m"
david@28
   115
      echo "\033[41m-------------------------------------------------------------------\033[0m"
david@28
   116
      echo ""
david@28
   117
    fi
david@28
   118
david@28
   119
  else
david@28
   120
    echo "\033[41m-------------------------------------------------------------------\033[0m"
david@28
   121
    echo "\033[1;41mERROR:\033[0m Can not get file $srcPath \033[0m"
david@28
   122
    echo "\033[41m-------------------------------------------------------------------\033[0m"
david@28
   123
    echo ""
david@28
   124
  fi
david@28
   125
david@28
   126
#STEP B
david@28
   127
elif [ $firstParam = "obmodule" ]; then
david@28
   128
  obScModuleDir=$(echo $obScModuleDir | sed 's,/$,,')
david@28
   129
david@28
   130
  if [ -d "$obScModuleDir" ]; then
david@28
   131
david@28
   132
    #1)
david@28
   133
    ant combine
david@28
   134
david@28
   135
    #2)
david@28
   136
    cp ISC_Combined.js $obScModuleDir/web/org.openbravo.userinterface.smartclient/isomorphic
david@28
   137
david@28
   138
    #3)
david@32
   139
    cp web/org.openbravo.userinterface.smartclient/isomorphic/system/modules/ISC_History.js $obScModuleDir/web/org.openbravo.userinterface.smartclient/isomorphic
david@32
   140
david@32
   141
    #4)
david@67
   142
    cp web/org.openbravo.userinterface.smartclient/isomorphic/system/helpers/empty.html $obScModuleDir/web/org.openbravo.userinterface.smartclient/isomorphic/system/helpers
david@67
   143
david@67
   144
    #5)
david@28
   145
    rm -rf $obScModuleDir/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/smartclient
david@30
   146
    cp -r web/org.openbravo.userinterface.smartclient/isomorphic/skins/Enterprise $obScModuleDir/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/smartclient
david@28
   147
david@67
   148
    #6.1)
david@28
   149
    tmp_fileNameA=$obScModuleDir/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/smartclient/load_skin.js
david@28
   150
    tmp_fileNameB=$obScModuleDir/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/smartclient/load_skin.js2
david@28
   151
    sed 's/isc\.Page\.setSkinDir/\/\/ isc.Page.setSkinDir/' $tmp_fileNameA > $tmp_fileNameB
david@28
   152
    rm -rf $tmp_fileNameA
david@28
   153
    mv $tmp_fileNameB $tmp_fileNameA
david@28
   154
    sed 's/isc\.Page\.loadStyleSheet/\/\/ isc.Page.loadStyleSheet/' $tmp_fileNameA > $tmp_fileNameB
david@28
   155
    rm -rf $tmp_fileNameA
david@28
   156
    mv $tmp_fileNameB $tmp_fileNameA
david@28
   157
david@28
   158
    tmp_lineNo=$(awk '/isc.Page.setSkinDir/ {print NR}' $tmp_fileNameA)
david@28
   159
    tmp_newLineNo=$(($tmp_lineNo+1))
david@28
   160
    sed ''$tmp_newLineNo'i\ \ \ \ isc.Page.setSkinDir("[ISOMORPHIC]/../openbravo/skins/Default/smartclient/");' $tmp_fileNameA > $tmp_fileNameB
david@28
   161
    rm -rf $tmp_fileNameA
david@28
   162
    mv $tmp_fileNameB $tmp_fileNameA
david@34
   163
    tmp_newLineNo=$(($tmp_lineNo+2))
david@56
   164
    sed ''$tmp_newLineNo'i\ \ \ \ isc.Browser.useCSS3 = false;' $tmp_fileNameA > $tmp_fileNameB
david@34
   165
    rm -rf $tmp_fileNameA
david@34
   166
    mv $tmp_fileNameB $tmp_fileNameA
david@91
   167
    tmp_newLineNo=$(($tmp_lineNo+3))
david@91
   168
    sed ''$tmp_newLineNo'i\ \ \ \ isc.Browser.useSpriting = false;' $tmp_fileNameA > $tmp_fileNameB
david@91
   169
    rm -rf $tmp_fileNameA
david@91
   170
    mv $tmp_fileNameB $tmp_fileNameA
david@28
   171
david@67
   172
    #6.2)
david@28
   173
    sed 's/isc\.loadSkin()/isc.loadSkin();/' $tmp_fileNameA > $tmp_fileNameB
david@28
   174
    rm -rf $tmp_fileNameA
david@28
   175
    mv $tmp_fileNameB $tmp_fileNameA
david@28
   176
    sed 's/isc\.loadSkin();;/isc.loadSkin();/' $tmp_fileNameA > $tmp_fileNameB
david@28
   177
    rm -rf $tmp_fileNameA
david@28
   178
    mv $tmp_fileNameB $tmp_fileNameA
david@28
   179
david@28
   180
    rm -rf ISC_Combined.js
david@28
   181
david@28
   182
  else
david@28
   183
    echo "\033[41m-------------------------------------------------------------------\033[0m"
david@28
   184
    echo "\033[1;41mERROR:\033[0m Target directory doesn't exist: $obScModuleDir \033[0m"
david@28
   185
    echo "\033[41m-------------------------------------------------------------------\033[0m"
david@28
   186
    echo ""
david@28
   187
  fi
david@28
   188
david@28
   189
else
david@28
   190
david@28
   191
    echo "\033[1;32m-------------------------------------------------------------------\033[0m"
david@28
   192
    echo "\033[1;30mThis is an unsupported tool for automatic upgrade this module and"
david@28
   193
    echo "\033[1;01morg.openbravo.userinterface.smartclient. Use it at your own risk."
david@28
   194
    echo "\033[1;32m-------------------------------------------------------------------\033[0m"
david@28
   195
    echo "\033[1;01mYou must pass at least one argument"
david@28
   196
    echo "\033[1;32m-------------------------------------------------------------------\033[0m"
david@28
   197
    echo ""
david@28
   198
    echo "  sh upgrade.sh this            <-- it upgrades this module"
david@28
   199
    echo "                                    with this file $srcPath"
david@28
   200
    echo ""
david@28
   201
    echo "  sh upgrade.sh this <file>     <-- it upgrades this module"
david@28
   202
    echo "                                    with the <file> given as second argument"
david@28
   203
    echo ""
david@28
   204
    echo "  sh upgrade.sh obmodule        <-- it upgrades org.openbravo.userinterface.smartclient module"
david@28
   205
    echo "                                    placed at $obScModuleDir"
david@28
   206
    echo ""
david@28
   207
    echo "  sh upgrade.sh obmodule <dir>  <-- it upgrades org.openbravo.userinterface.smartclient module"
david@28
   208
    echo "                                    placed at the <dir> path given as second argument"
david@28
   209
    echo ""
david@28
   210
david@28
   211
fi