source: main/trunk/greenstone2/makegs2.sh@ 32005

Last change on this file since 32005 was 32005, checked in by ak19, 7 years ago

Different (and simpler) fix for GS2 imagemagick env clash on sourcing GS2 setup vs running wget after sourcing setup. For GS2 binaries, we never had an imagemagick living in the ext folder, as we got one of our precompiled imagemagick binaries and only unpacked it in ext before moving it into the GS2/bin/OS folder. And now when compiling up GS2 with makegs2.sh, we have the new option of passing in imagemagick as an argument and it also grab the appropriate imagemagick binary and put it into GS2/bin/OS. In either case, there's no imagemagick in the ext folder, which may be for GS3 and/or when imagemagick is compiled up from scratch in a GS checkout.

  • Property svn:executable set to *
File size: 5.1 KB
Line 
1#!/bin/bash
2
3# run as: ./makegs2.sh [gnome-lib] [imagemagick]
4# If gnome-lib passed in, will compile GS2 using gnome-lib
5# which checks out gnome-lib src from svn if possible and if needed (if no ext/gnome-lib-minimal)
6# If you pass in imagemagick, it will grab the appropriate linux/darwin binary, untar
7# this and put its OS subfolder renamed as imagemagick into the bin/os folder.
8
9# Note, Mac (darwin) machines don't always display all env vars on doing env/printenv,
10# e.g. DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH are hidden
11# To display hidden vars follow:
12# http://www.commandlinefu.com/commands/view/6899/print-all-environment-variables-including-hidden-ones
13# but remove capital T from command, making: for _a in {A..Z} {a..z};do _z=\${!${_a}*};for _i in `eval echo "${_z}"`;do echo -e "$_i: ${!_i}";done;done|cat -Tsv
14# into: for _a in {A..Z} {a..z};do _z=\${!${_a}*};for _i in `eval echo "${_z}"`;do echo -e "$_i: ${!_i}";done;done|cat -sv
15# Can redirect the output of the command into files and do a diff to see difference in environment.
16
17getgnomelib=
18getimagick=
19
20# https://stackoverflow.com/questions/20449680/unix-boolean-operators-a-o
21if [[ "x$1" == "xgnome-lib" ]]; then
22 getgnomelib=$1
23elif [[ "x$1" == "ximagemagick" ]]; then
24 getimagick=$1
25fi
26
27if [[ "x$2" == "xgnome-lib" ]]; then
28 getgnomelib=$2
29elif [[ "x$2" == "ximagemagick" ]]; then
30 getimagick=$2
31fi
32
33if [ "x$getgnomelib" != "x" ]; then
34 echo "Will be getting gnomelib"
35fi
36if [ "x$getimagick" != "x" ]; then
37 echo "Will be getting imagemagick"
38fi
39
40if [[ "x$getgnomelib" == "x" && "x$getimagick" == "x" ]]; then
41 echo "No recognised args provided"
42fi
43
44gsdlhome=`pwd`
45echo "**** GSDLHOME: $gsdlhome"
46
47bitness=`uname -m`
48# if we're 64 bit, add -fPIC to CFLAGS. Check if bitness contains substring "64"
49if [[ $bitness == *"64"* ]]; then
50 export CFLAGS="-fPIC $CFLAGS"
51 echo "64 bit unix system, incl -fPIC in CFLAGS so it is now: $CFLAGS"
52fi
53
54# Compile by chaining the commands with && so it stops at that stage after an error
55cd $gsdlhome
56if [ "x$getgnomelib" = "xgnome-lib" ]; then
57 ./configure --enable-gnome-lib-ext --enable-apache-httpd \
58 && make \
59 && make install
60else
61 ./configure --enable-apache-httpd \
62 && make \
63 && make install
64fi
65
66status=$?
67echo "****************************************"
68if [ $status = 0 ] ; then
69 # 5. Message to warn user that the env of this x-term uses gnome-lib
70 # and GUIs may not work from this console
71 if [ "x$getgnomelib" = "xgnome-lib" ]; then
72 echo "*** The environment for this console has been set to compile Greenstone with gnome-lib."
73 echo "*** As a result, graphical applications may not work well."
74 echo "*** In such a case, open a new console."
75 else
76 echo "Finished compiling Greenstone2. (Compiled without gnome-lib)"
77 fi
78else
79 echo "@@@ Error compiling up Greenstone. Return status: $status"
80fi
81if [[ $bitness == *"64"* ]]; then
82 echo ""
83 echo "This unix is 64 bit. So added -fPIC to CFLAGS, which is now: $CFLAGS"
84fi
85echo "****************************************"
86
87
88imgpkg=
89if [ "x$getimagick" = "ximagemagick" ]; then
90 os=`uname`
91
92 if [ "x$os" = "xDarwin" ]; then
93 # by default, resort to the Mac Leopard (10.5, kernel 12.6.0)'s imagemagick binary
94 imgpkg=http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-darwin-10.5.tar.gz
95
96 kernelVersion=`uname -r`
97 # El Capitan is MacOS version 10.11 but its kernelVersion is 15.6.0
98 if [ "x$kernelVersion" = "x15.6.0" ]; then
99 echo "Getting imagemagick built for El Capitan"
100 imgpkg=http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-darwin-10.11.tar.gz
101 else
102 echo "Getting imagemagick built on Mac Leopard"
103 fi
104
105 pushd ext
106 curl $imgpkg > imagemagick.tar.gz
107 tar -xvzf imagemagick.tar.gz
108 mv imagemagick/darwin ../bin/darwin/imagemagick
109 popd
110
111 else
112 # linux
113 pushd ext
114 if [[ $bitness == *"64"* ]]; then
115 echo "Getting 64 bit imagemagick precompiled binary"
116 wget http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-linux-x64.tar.gz
117 tar -xvzf imagemagick-linux-x64.tar.gz
118 else
119 echo "Getting 32 bit imagemagick precompiled binary"
120 wget http://trac.greenstone.org/export/head/gs2-extensions/imagemagick/trunk/imagemagick-linux.tar.gz
121 tar -xvzf imagemagick-linux.tar.gz
122 fi
123
124 mv imagemagick/linux ../bin/linux/imagemagick
125 popd
126 fi
127
128 # the setup script in the ext/imagemagick folder clashes with wget because it sets DYLD(_FALLBACK)_LIBRARY_PATH
129 # on sourcing GS2's setup.bash. Since we're not using the imagemagick in the ext folder for GS2, as the
130 # precompiled imagemagick binary is moved into GS2/bin/OS, in a GS2 bin release and now here too (in a compiled GS2),
131 # we can remove ext/imagemagick. The env vars it sets refer to the ext/imagemagick folder anyway, which we don't use
132 # for our GS2 binaries, or for GS2 compiled versions using the precompiled imagemagick binary, as imagemagick will
133 # live in GS2/bin/OS in such cases..
134 rm -rf ext/imagemagick
135
136fi
Note: See TracBrowser for help on using the repository browser.