Updated the README file with some contributor tips.
[basket4.git] / installer
blob14626a4d3d610c5d3ab8504e6f9bbc86119e302e
1 #!/bin/bash
3 function error
5 echo ""
6 echo " ======================================================================== "
7 echo " (( An Error has Been Encountered ))"
8 echo " ======================================================================== "
9 echo ""
10 echo ""
11 echo " In the most cases, some libraries are missing or cannot be found."
12 echo " Think to install the *-dev or *-devel packages of your distribution."
13 echo " For example, if libmng cannot be found,"
14 echo " please check if libmng AND libmng-devel packages are installed on your system."
15 echo " See the reported errors to know which librarie need to be installed."
16 echo ""
17 echo $'\a' # Beep to avert user of the error
18 exit 1
21 ##echo " (( An error has been encountered ))"
22 ##echo " ((654321 987654321 987654321 98765432 23456789 123456789 123456789 123456))"
23 ##echo" ((654321 987654321 987654321 98765432 23456789 123456789 123456789 123456))"
25 clear
26 echo ""
27 echo " ======================================================================== "
28 echo " (( BasKet Note Pads Quick Installer ))"
29 echo " ======================================================================== "
30 echo ""
31 echo ""
32 echo " Welcome to the BasKet Note Pads installer assistant."
33 echo " It will configure, build and install BasKet Note Pads."
34 echo ""
35 echo ""
36 echo " What do you want to do?"
37 echo ""
38 echo " 1/ Install BasKet Note Pads system wide (you will need the root password)"
39 echo " 2/ Install BasKet Note Pads in your user folder"
40 #echo " 3/ Uninstall BasKet Note Pads (you should not: it is so fantastic ;-) )"
41 echo ""
43 echo -n "Your choice (default is 1): "
44 read -n 1 WHAT_TO_DO
45 echo ""
47 if [ "_$WHAT_TO_DO" == "_2" ]; then
48 SYS_WIDE=0
49 WHAT_TO_DO=2 # To transform it from string to int
50 else
51 # if [ $WHAT_TO_DO == 3 ]; then
52 # SYS_WIDE=1
53 # else # [ WHAT_TO_DO == 1 ] or default
54 SYS_WIDE=1
55 WHAT_TO_DO=1 # If user entered another number than those he should
56 # fi
59 if [ $SYS_WIDE == 0 ]; then
60 prefix=`kde-config --localprefix --expandvars`
61 else
62 prefix=`kde-config --prefix --expandvars`
65 # Uninstall of BasKet:
66 if [ $WHAT_TO_DO == 3 ]; then
67 # Search installed basket:
68 prefix=`kde-config --localprefix --expandvars` # First loacally
69 if [ -f $prefix/bin/basket ]; then
70 SYS_WIDE=0
71 else
72 prefix=`kde-config --prefix --expandvars` # And then system wide
73 if [ -f $prefix/bin/basket ]; then
74 SYS_WIDE=1
75 else
76 echo "BasKet Note Pads does not seem to be installed."
77 exit 1
80 # TODO: Also definitively remove your baskets?
81 # At this stage, SYS_WIDE and prefix are set and uninstall can begin:
82 if [ $SYS_WIDE == 1 ]; then
84 make uninstall || ./configure --prefix=$prefix && make uninstall
85 logout
86 else
87 make uninstall || ./configure --prefix=$prefix && make uninstall
89 exit 0
92 appVersion=$(cat basket.spec | grep "%define version " | cut -d " " -f 3)
93 isDevel=$(echo "$appVersion" | grep -i -E "(alpha|beta|pre|rc|svn)")
95 clear
96 echo ""
97 echo " ======================================================================== "
98 echo " (( BasKet Note Pads Quick Installer ))"
99 echo " ======================================================================== "
100 echo ""
101 echo ""
102 echo ""
103 echo ""
104 echo " If you do not know what they are, you can ignore errors or warnings."
105 echo ""
106 echo " The process can take several minutes."
107 echo " A beep will notify you when it will be done."
108 echo " Press ENTER to start."
109 echo ""
110 echo ""
112 read -s -n 1 # read 1 character without echo, ended by ENTER
114 if [ ! -e configure ]; then
115 clear
116 echo ""
117 echo " ======================================================================== "
118 echo " (( Preparation from SVN ))"
119 echo " ======================================================================== "
120 echo ""
121 echo ""
123 echo "make -f Makefile.cvs"
124 make -f Makefile.cvs || error
127 clear
128 echo ""
129 echo " ======================================================================== "
130 echo " (( Step 1 / 3 : Configuration ))"
131 echo " ======================================================================== "
132 echo ""
133 echo ""
135 if [ "_$isDevel" == "_" ]; then
136 echo "./configure --prefix=$prefix"
137 ./configure --prefix=$prefix || error
138 else
139 echo "./configure --enable-debug=full --prefix=$prefix"
140 ./configure --enable-debug=full --prefix=$prefix || error
143 clear
144 echo ""
145 echo " ======================================================================== "
146 echo " (( Step 2 / 3 : Compilation ))"
147 echo " ======================================================================== "
148 echo ""
149 echo ""
151 echo "make"
152 make || error
154 clear
155 echo ""
156 echo " ======================================================================== "
157 echo " (( Step 3 / 3 : Installation ))"
158 echo " ======================================================================== "
159 echo ""
160 echo ""
161 echo " The application has successfuly been compiled."
162 echo ""
163 echo ""
165 echo $'\a' # Beep to avert user the configuration/compilation is ended and he must act to enter the password
167 if [ "_$SYS_WIDE" == "_n" ]; then
168 # First make the bin folder to not copy basket file to bin file if bin/ doesn't exist
169 mkdir $prefix/bin
170 make install
171 else
172 echo " Please now enter the root password in order to install "
173 echo " BasKet Note Pads on the system."
174 echo ""
175 sudo make install || exit 1
176 echo ""
177 echo ""
180 clear
181 echo ""
182 echo " ======================================================================== "
183 echo " (( End of BasKet Note Pads Installation ))"
184 echo " ======================================================================== "
185 echo ""
186 echo ""
187 echo " Do you want to run BasKet Note Pads now?"
188 echo " If an older version is currently running it will be exited before."
189 echo ""
190 echo " Notice that you willn't have to exit BasKet : it will be restored each time"
191 echo " you log in to KDE."
192 echo ""
193 echo ""
195 echo -n "Start or restart BasKet Note Pads? [y/n] (default is y): "
196 read -n 1 RESTART
197 if [ "_$RESTART" != "_" ]; then # If pressed Enter, a new line was already print
198 echo ""
201 if [ "_$RESTART" != "_n" ]; then
202 # Get the pid of the process basket, if currently running
203 pid=`ps aux | awk '$11 == "basket" { print $2 }'`
204 if [ "_$pid" == "_" ]; then
205 dummy=0
206 else
207 kill -s SIGTERM $pid
210 if [ "_$SYS_WIDE" == "_n" ]; then
211 echo "$prefix/bin/basket"
212 $prefix/bin/basket
213 else
214 echo "basket"
215 basket
219 clear
220 echo ""
221 echo " ======================================================================== "
222 echo " (( Congratulation: BasKet Note Pads is now Installed onto your System ))"
223 echo " ======================================================================== "
224 echo ""
225 echo ""
226 echo " In the future, if you want to uninstall BasKet Note Pads, you will have to"
227 if [ "_$SYS_WIDE" == "_n" ]; then
228 echo " enter the command make uninstall in this folder."
229 else
230 echo " enter the command su -c 'make uninstall' in this folder."
232 echo ""
233 echo ""