summaryrefslogtreecommitdiffstats
path: root/installer
blob: 14626a4d3d610c5d3ab8504e6f9bbc86119e302e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#!/bin/bash

function error
{
  echo ""
  echo "    ========================================================================  "
  echo "  ((                      An Error has Been Encountered                     ))"
  echo "    ========================================================================  "
  echo ""
  echo ""
  echo "        In the most cases, some libraries are missing or cannot be found."
  echo "      Think to install the *-dev or *-devel packages of your distribution."
  echo "                     For example, if libmng cannot be found,"
  echo "  please check if libmng AND libmng-devel packages are installed on your system."
  echo "      See the reported errors to know which librarie need to be installed."
  echo ""
  echo $'\a' # Beep to avert user of the error
  exit 1
}

##echo "  ((                      An error has been encountered                     ))"
##echo "  ((654321 987654321 987654321 98765432  23456789 123456789 123456789 123456))"
##echo" ((654321 987654321 987654321 98765432  23456789 123456789 123456789 123456))"

clear
echo ""
echo "    ========================================================================  "
echo "  ((                    BasKet Note Pads Quick Installer                    ))"
echo "    ========================================================================  "
echo ""
echo ""
echo "              Welcome to the BasKet Note Pads installer assistant."
echo "             It will configure, build and install BasKet Note Pads."
echo ""
echo ""
echo "                             What do you want to do?"
echo ""
echo "  1/ Install BasKet Note Pads system wide (you will need the root password)"
echo "  2/ Install BasKet Note Pads in your user folder"
#echo "  3/ Uninstall BasKet Note Pads (you should not: it is so fantastic ;-) )"
echo ""

echo -n "Your choice (default is 1): "
read -n 1 WHAT_TO_DO
echo ""

if [ "_$WHAT_TO_DO" == "_2" ]; then
  SYS_WIDE=0
  WHAT_TO_DO=2 # To transform it from string to int
else
#  if [ $WHAT_TO_DO == 3 ]; then
#    SYS_WIDE=1
#  else  # [ WHAT_TO_DO == 1 ] or default
    SYS_WIDE=1
    WHAT_TO_DO=1 # If user entered another number than those he should
#  fi
fi

if [ $SYS_WIDE == 0 ]; then
  prefix=`kde-config --localprefix --expandvars`
else
  prefix=`kde-config --prefix --expandvars`
fi

# Uninstall of BasKet:
if [ $WHAT_TO_DO == 3 ]; then
  # Search installed basket:
  prefix=`kde-config --localprefix --expandvars` # First loacally
  if [ -f $prefix/bin/basket ]; then
    SYS_WIDE=0
  else
    prefix=`kde-config --prefix --expandvars`    # And then system wide
    if [ -f $prefix/bin/basket ]; then
      SYS_WIDE=1
    else
      echo "BasKet Note Pads does not seem to be installed."
      exit 1
    fi
  fi
  # TODO: Also definitively remove your baskets?
  # At this stage, SYS_WIDE and prefix are set and uninstall can begin:
  if [ $SYS_WIDE == 1 ]; then
    su
    make uninstall || ./configure --prefix=$prefix && make uninstall
    logout
  else
    make uninstall || ./configure --prefix=$prefix && make uninstall
  fi
  exit 0
fi

appVersion=$(cat basket.spec | grep "%define version " | cut -d " " -f 3)
isDevel=$(echo "$appVersion" | grep -i -E "(alpha|beta|pre|rc|svn)")

clear
echo ""
echo "    ========================================================================  "
echo "  ((                    BasKet Note Pads Quick Installer                    ))"
echo "    ========================================================================  "
echo ""
echo ""
echo ""
echo ""
echo "      If you do not know what they are, you can ignore errors or warnings."
echo ""
echo "                      The process can take several minutes."
echo "                  A beep will notify you when it will be done."
echo "                              Press ENTER to start."
echo ""
echo ""

read -s -n 1 # read 1 character without echo, ended by ENTER

if [ ! -e configure ]; then
  clear
  echo ""
  echo "    ========================================================================  "
  echo "  ((                          Preparation from SVN                          ))"
  echo "    ========================================================================  "
  echo ""
  echo ""

  echo "make -f Makefile.cvs"
  make -f Makefile.cvs || error
fi

clear
echo ""
echo "    ========================================================================  "
echo "  ((                       Step 1 / 3 : Configuration                       ))"
echo "    ========================================================================  "
echo ""
echo ""

if [ "_$isDevel" == "_" ]; then
  echo "./configure --prefix=$prefix"
  ./configure --prefix=$prefix || error
else
  echo "./configure --enable-debug=full --prefix=$prefix"
  ./configure --enable-debug=full --prefix=$prefix || error
fi

clear
echo ""
echo "    ========================================================================  "
echo "  ((                        Step 2 / 3 : Compilation                        ))"
echo "    ========================================================================  "
echo ""
echo ""

echo "make"
make || error

clear
echo ""
echo "    ========================================================================  "
echo "  ((                        Step 3 / 3 : Installation                       ))"
echo "    ========================================================================  "
echo ""
echo ""
echo "                 The application has successfuly been compiled."
echo ""
echo ""

echo $'\a' # Beep to avert user the configuration/compilation is ended and he must act to enter the password

if [ "_$SYS_WIDE" == "_n" ]; then
  # First make the bin folder to not copy basket file to bin file if bin/ doesn't exist
  mkdir $prefix/bin
  make install
else
  echo "            Please now enter the root password in order to install "
  echo "                        BasKet Note Pads on the system."
  echo ""
  sudo make install || exit 1
  echo ""
  echo ""
fi

clear
echo ""
echo "    ========================================================================  "
echo "  ((                  End of BasKet Note Pads Installation                  ))"
echo "    ========================================================================  "
echo ""
echo ""
echo "                    Do you want to run BasKet Note Pads now?"
echo "       If an older version is currently running it will be exited before."
echo ""
echo "   Notice that you willn't have to exit BasKet : it will be restored each time"
echo "                               you log in to KDE."
echo ""
echo ""

echo -n "Start or restart BasKet Note Pads? [y/n] (default is y): "
read -n 1 RESTART
if [ "_$RESTART" != "_" ]; then # If pressed Enter, a new line was already print
  echo ""
fi

if [ "_$RESTART" != "_n" ]; then
  # Get the pid of the process basket, if currently running
  pid=`ps aux | awk '$11 == "basket" { print $2 }'`
  if [ "_$pid" == "_" ]; then
    dummy=0
  else
    kill -s SIGTERM $pid
  fi

  if [ "_$SYS_WIDE" == "_n" ]; then
    echo "$prefix/bin/basket"
    $prefix/bin/basket
  else
    echo "basket"
    basket
  fi
fi

clear
echo ""
echo "    ========================================================================  "
echo "  ((   Congratulation: BasKet Note Pads is now Installed onto your System   ))"
echo "    ========================================================================  "
echo ""
echo ""
echo "   In the future, if you want to uninstall BasKet Note Pads, you will have to"
if [ "_$SYS_WIDE" == "_n" ]; then
  echo "                enter the command make uninstall in this folder."
else
  echo "            enter the command su -c 'make uninstall' in this folder."
fi
echo ""
echo ""