root/gli/trunk/findgsdl.bat @ 19388

Revision 19388, 5.6 KB (checked in by ak19, 11 years ago)

3 changes. 1. Moved GLI.bat's the finding and setting of GSDLHOME (and GSDL3SRCHOME and GSDL3HOME) into a separate batfile: findgsdl.bat. 2. This bat file is now called by both gli.bat and client-gli.bat, since client-bat can from now on use the same logice to locate a local GS installation. The only difference is that if GSDLHOME is not found, then client-gli runs as before: no Download panel. 3. Client-gli.bat will not look for a gs2build directory located inside a client-gli checkout, but instead search for a local GSDLHOME (including in the directory directly above, in case client-gli.bat is run from a normal GS checkout. IF a GSDLHOME is found (and perl too), then client-gli will enable the Download panel - using the local GSDLHOME to do the downloading.

Line 
1:: By the time this script is called by gli.bat, PROGNAME,
2:: PROGABBR and GLILANG would be set.
3
4:: At the end of this script, GSDLHOME (and possibly GSDL3SRCHOME, GSDL3HOME)
5:: will have been set if a local GS installation was found. If not found, then
6:: GSDLHOME would not have been set.
7
8:findGSDL
9echo.
10if "%GLILANG%" == "en" (
11        echo %PROGNAME% ^(%PROGABBR%^)
12        echo Copyright ^(C^) 2008, New Zealand Digital Library Project, University Of Waikato
13        echo %PROGABBR% comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt
14        echo This is free software, and you are welcome to redistribute it
15    )
16
17if "%GLILANG%" == "es" (
18        echo Interfaz de la %PROGNAME% ^(%PROGNAME_EN% - %PROGABBR%^)
19        echo Copyright ^(C^) 2008, New Zealand Digital Library Project, University Of Waikato
20        echo La Interfaz de la %PROGNAME% NO INCLUYE ABSOLUTAMENTE NINGUNA GARANTÖA.
21        echo Para mayor informaci¢n vea los t‚rminos de la licencia en LICENSE.txt
22        echo Este es un software abierto, por lo que lo invitamos a que lo distribuya de forma gratuita
23    )
24
25if "%GLILANG%" == "fr" (
26        echo Interface du %PROGNAME% ^(%PROGNAME_EN% - %PROGABBR%^)
27        echo Copyright ^(C^) 2008, New Zealand Digital Library Project, University Of Waikato
28        echo %PROGABBR% est fourni sans AUCUNE GARANTIE; pour des d‚tails, voir LICENSE.txt
29        echo Ceci est un logiciel libre, et vous ˆtes invit‚ … le redistribuer
30    )
31
32if "%GLILANG%" == "ru" (
33        echo š¡«š®â¥ç­ë© š­â¥à䥩á %PROGNAME% ^(%PROGNAME_EN% - %PROGABBR%^)
34        echo Copyright ^(C^) 2008, New Zealand Digital Library Project, University Of Waikato
35        echo ˆƒ ­¥ € ¥â €‘Ž‹ž’Ž ˆŠ€Šˆ• ƒ€€’ˆ‰; €¥â «š á¬. ¢ ⥪á⥠LICENSE.TXT
36        echo â® - ᢮¡®€­® à á¯à®áâ࠭塞®¥ ¯à®£à ¬¬­®¥ ®¡¥á¯¥ç¥­š¥ š ‚ë ¬®Š¥â¥ à á¯à®áâà ­ïâì ¥£®
37    )
38
39echo.
40::  ---- Determine path to Greenstone home for GS2 and GS3 ----
41set GSDLPATH=
42:: Some users may set the above line manually, or it may be set as an argument
43
44set _VERSION=
45if not "%GSDLPATH%" == "" goto getVer
46    :: Otherwise gsdlpath is not yet set
47    :: Check the env vars first
48    if not "%GSDL3SRCHOME%" == "" goto ver3
49        if not "%GSDLHOME%" == "" goto ver2
50            :: If not set, the default location for the GLI is a subdirectory of Greenstone
51            set GSDLPATH=..
52            goto getVer             
53
54:getVer
55call gsdlver.bat %GSDLPATH% %_VERSION%
56:: Stand-alone GLI with no Greenstone installation to be detected
57:: otherwise
58if "%_VERSION%" == "1" goto noVer
59    ::if we are running GS2, free up any pre-set GS3 environment variables since we won't need them
60    if "%_VERSION%" == "2" set GSDL3SRCHOME=
61    if "%_VERSION%" == "2" set GSDL3HOME=
62    goto testGSDL
63    :: else _VERSION is 3, we continue:
64
65:ver3
66set _VERSION=3
67set GSDLPATH=%GSDL3SRCHOME%
68:: if GS2 is now also set, then both GS3 and GS2 are set:
69:: warn the user that we have defaulted to GS3
70if not "%GSDLHOME%" == "" (
71        echo Both Greenstone 2 and Greenstone 3 environments are set.
72        echo It is assumed you want to run Greenstone 3.
73        echo If you want to run Greenstone 2, please unset the
74        echo environment variable GSDL3SRCHOME before running GLI.
75        echo.
76    )
77goto testGSDL
78
79:ver2
80set _VERSION=2
81set GSDLPATH=%GSDLHOME%
82::free up the GS3 environment variables since we are running GS2 and don't need them
83set GSDL3SRCHOME=
84set GSDL3HOME=
85goto testGSDL
86
87:noVer
88if "%GLIMODE%" == "local" if "%GLILANG%" == "en" echo Error: can't determine which Greenstone version is being run.
89if "%GLIMODE%" == "client" if "%GLILANG%" == "en" echo Could not detect a Greenstone installation (no GSDLHOME).
90goto exit
91
92:testGSDL
93set CHECK=1
94call chkinst.bat "%GSDLPATH%" %_VERSION% %GLILANG% %CHECK% > nul
95if "%CHECK%" == "1" goto exit
96    :: otherwise installation worked well
97    goto prepGSDL
98
99
100:prepGSDL
101:: Greenstone 3 case
102if "%_VERSION%" == "3" goto prepGS3
103
104if not "%_VERSION%" == "2" echo "Greenstone version unknown"
105if not "%_VERSION%" == "2" goto exit
106
107:: Otherwise, we are dealing with Greenstone 2
108:: Setup Greenstone 2, unless it has already been done
109if not "%GSDLHOME%" == "" goto doneGSDL
110    call "%GSDLPATH%\setup.bat" SetEnv
111    goto doneGSDL
112
113
114:prepGS3
115set GSDL2PATH=
116:: Some users may set the above line manually
117
118if "%GSDL3SRCHOME%" == "" goto setup3
119    if "%GSDL3HOME%" == "" goto setup3
120        ::otherwise
121        goto gs2build
122
123
124:setup3
125:: Setup Greenstone 3, unless it has already been done
126    cd | winutil\setvar.exe GLIDIR > %TMP%\setgli.bat
127    call %TMP%\setgli.bat
128    del %TMP%\setgli.bat
129    cd "%GSDLPATH%"
130    call gs3-setup.bat SetEnv
131    cd %GLIDIR%
132    goto gs2build
133
134
135:gs2build
136    :: If Greenstone version 3 is running, we want to set gsdl2path
137    :: Determine GSDLHOME for GS3
138    if not "%GSDL2PATH%" == "" goto setupGS2
139        :: GSDL2PATH is not yet set.
140        :: And if GSDLHOME is not set either, then assume
141        :: that the gs2build subdir of GS3 exists
142        if "%GSDLHOME%" == "" set GSDL2PATH=%GSDL3SRCHOME%\gs2build
143        if "%GSDLHOME%" == "" goto setupGS2
144            :: Otherwise GSDLHOME is set, so set GSDL2PATH to GSDLHOME
145            echo GSDLHOME environment variable is set to %GSDLHOME%.   
146            echo Will use this to find build scripts.
147            set GSDL2PATH=%GSDLHOME%
148
149:setupGS2
150set CHECK=1
151call chkinst.bat "%GSDL2PATH%" 2 %GLILANG% %CHECK% > nul
152if "%CHECK%" == "1" goto exit
153    :: otherwise installation worked well
154    :: Setup Greenstone, unless it has already been done
155    if "%GSDLHOME%" == "" call "%GSDL2PATH%\setup.bat" SetEnv
156    :: Either way, we can now dispose of GSDL2PATH
157    set GSDL2PATH= 
158    goto doneGSDL
159
160
161:exit
162:: if exit, then something went wrong. GSDLHOME would be empty already
163
164:doneGSDL
165:: GSDLPATH is no longer needed, since GSDLHOME should now be set
166set GSDLPATH=
167set CHECK=
168set GLIDIR=
Note: See TracBrowser for help on using the browser.