summaryrefslogtreecommitdiffstats
path: root/Setup
blob: e6a2ef1ae4456b9166183285cdca665f080522f1 (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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#!/bin/bash

# TODO: 2.0: use kdialog

META_FULL_NAME="KShutDown"
META_VERSION="`cat VERSION`"

#if [[ (("$TERM" == "dumb") || ("$TERM" == "xterm")) && ("${1}" != "--launch-in-konsole") ]]; then
#	echo
#	echo "Press Ctrl+C to exit $META_FULL_NAME installer"
#	konsole --notabbar --notoolbar --workdir `dirname "${0}"` -T "$META_FULL_NAME Installer" -e ${0} --launch-in-konsole
#	exit
#fi

# installation dirs
DEFAULT_DIR=`kde-config --prefix`
if [ -z "$DEFAULT_DIR" ]; then
	DEFAULT_DIR="/usr"
fi
INSTALL_DIR="$DEFAULT_DIR"

# colors
DEF_C="\E[37;40m"
KEY_C="\E[31;40m"

# configure options
CONFIGURE_OPTIONS=""
FAST_COMPILATION="true"

# i18n
# english
I18N_TITLE_DOCS="Documentation and License"
I18N_TITLE_SETUP="Compilation and Installation"
I18N_CHANGE_DIR="Change installation directory (prefix)"
I18N_DISABLE_FAST="Disable fast compilation"
I18N_ENABLE_FAST="Enable fast compilation"
I18N_INSTALL="Install"
I18N_LICENSE="License"
I18N_NEWS="What's new? (q - quit)"
I18N_PRESS_ENTER="Press <Enter> to exit"
I18N_QUIT="Quit"
I18N_THANKS="Thank you for using"
I18N_MENU="K Menu: Accessories -> KShutDown"
I18N_CONF_WITH="Configuring with"
I18N_INST_FAILED="Installation failed!"
I18N_COMP_FAILED="Compilation failed!"
I18N_CONF_FAILED="Configuration failed!"
I18N_COMP_START="Compiling..."
I18N_MINU="       This may take a few minutes."
I18N_MISSING_DEPEN1="Make sure you have installed the 'kdelibs-devel' package"
I18N_MISSING_DEPEN2="       which is required to compile any KDE application."
I18N_ENTER_DIR="Enter a new prefix"
I18N_SETUP="Setup"
I18N_README="Readme"

# polish
if [[ ("$LANG" == "pl_PL.UTF-8") || ("$LANG" == "pl_PL") || ("$LANG" == "pl") ]]; then
	I18N_TITLE_DOCS="Dokumentacja i licencja"
	I18N_TITLE_SETUP="Kompilacja i instalacja"
	I18N_CHANGE_DIR="Zmien katalog instalacji (prefix)"
	I18N_DISABLE_FAST="Wylacz szybka kompilacje"
	I18N_ENABLE_FAST="Wlacz szybka kompilacje"
	I18N_INSTALL="Instaluj"
	I18N_LICENSE="Licencja"
	I18N_NEWS="Co nowego? (q - wyjscie)"
	I18N_PRESS_ENTER="Nacisnij <Enter>, aby wyjsc"
	I18N_QUIT="Zakoncz"
	I18N_THANKS="Dziekujemy za uzycie"
	I18N_MENU="Menu K: Akcesoria -> KShutDown"
	I18N_CONF_WITH="Konfigurowanie z"
	I18N_INST_FAILED="Instalacja nie powiodla sie!"
	I18N_COMP_FAILED="Kompilacja nie powiodla sie!"
	I18N_CONF_FAILED="Konfiguracja nie powiodla sie!"
	I18N_COMP_START="Kompilowanie..."
	I18N_MINU="       To moze potrwac kilka minut."
	I18N_MISSING_DEPEN1="Upewnij sie, ze masz zainstalowana paczke 'kdelibs-devel',"
	I18N_MISSING_DEPEN2="            ktora jest wymagana do kompilacji jakiejkolwiek aplikacji KDE."
	I18N_ENTER_DIR="Wprowadz nowy prefix"
	I18N_SETUP="Instalator"
	I18N_README="Przeczytaj (readme)"
fi

#italian
if [[ ("$LANG" == "it_IT.UTF-8") || ("$LANG" == "it_IT") || ("$LANG" == "it") ]]; then
	I18N_TITLE_DOCS="Documentazione e Licenza"
	I18N_TITLE_SETUP="Compilazione ed Installazione"
	I18N_CHANGE_DIR="Cambia la cartella di destinazione (prefix)"
	I18N_DISABLE_FAST="Disabilita compilazione veloce"
	I18N_ENABLE_FAST="Abilita compilazione veloce"
	I18N_INSTALL="Installa"
	I18N_LICENSE="Licenza"
	I18N_NEWS="Cosa c'è di nuovo? (q - esci)"
	I18N_PRESS_ENTER="Premi <Enter> per uscire"
	I18N_QUIT="Esci"
	I18N_THANKS="Grazie di usare"
	I18N_MENU="Menu K: Accessori -> KShutDown"
	I18N_CONF_WITH="Configurazione con"
	I18N_INST_FAILED="Installazione fallita!"
	I18N_COMP_FAILED="Compilazione fallita!"
	I18N_CONF_FAILED="Configurazione fallita!"
	I18N_COMP_START="Compilazione..."
	I18N_MINU="       Per questo potrebbero volerci alcuni minuti."
	I18N_MISSING_DEPEN1="Assicurati di aver installato il pacchetto 'kdelibs-devel'"
	I18N_MISSING_DEPEN2="       che è necessario per compilare ogni applicazione KDE."
	I18N_ENTER_DIR="Inserisci una nuova destinazione"
	I18N_SETUP="Installazione"
	I18N_README="Leggimi"
fi
# internal functions

ks_kill()
{
	echo
	echo
	echo "$I18N_SETUP: ${1}"
	echo
	echo "$I18N_PRESS_ENTER"
	read
	ks_quit 1
}

ks_quit()
{
	ks_reset
	exit ${1}
}

ks_reset()
{
	tput sgr0
}

ks_show_finish_info()
{
	echo
	echo "$I18N_THANKS $META_FULL_NAME!"
	echo "  The $META_FULL_NAME Team"
	echo
	echo "HOW TO RUN?"
	echo
	echo "$I18N_MENU"
	echo "Command: kshutdown"
	echo "Command line options: kshutdown --help"
	echo
	echo -e "$I18N_PRESS_ENTER"
	read
}

ks_show_menu()
{
	echo -e "$DEF_C"
	clear
	echo
	echo
	echo "				 $I18N_SETUP"
	echo "				$META_FULL_NAME $META_VERSION"
	echo
	echo
	echo -e "    ${KEY_C}${I18N_TITLE_SETUP}${DEF_C}"
	echo -e "    [${KEY_C}i${DEF_C}] $I18N_INSTALL (./configure --prefix=${INSTALL_DIR}, make, kdesu -c \"make install\")"
	echo -e "    [${KEY_C}p${DEF_C}] $I18N_CHANGE_DIR"
	if [ -n "$FAST_COMPILATION" ]; then
		echo -e "    [${KEY_C}f${DEF_C}] $I18N_DISABLE_FAST";
	else
		echo -e "    [${KEY_C}f${DEF_C}] $I18N_ENABLE_FAST (--enable-final)";
	fi
	echo
	echo -e "    ${KEY_C}${I18N_TITLE_DOCS}${DEF_C}"
	echo -e "    [${KEY_C}n${DEF_C}] $I18N_NEWS"
	echo -e "    [${KEY_C}l${DEF_C}] $I18N_LICENSE (GNU GPL)"
	echo -e "    [${KEY_C}r${DEF_C}] $I18N_README"
	echo
	echo -e "    [${KEY_C}q${DEF_C}] $I18N_QUIT"
	echo
	echo
	echo "    http://kshutdown.sourceforge.net"
}

while [ 1 ]; do
	ks_show_menu
	# wait for a single key
	read -n 1 -s

	# install
	if [[ ("$REPLY" == "i") || ( "$REPLY" == "I" ) ]]; then
		if [ -n "$FAST_COMPILATION" ]; then
			CONFIGURE_OPTIONS="--prefix=${INSTALL_DIR} --enable-final";
		else
			CONFIGURE_OPTIONS="--prefix=${INSTALL_DIR}";
		fi
		echo
		echo "$I18N_SETUP: $I18N_CONF_WITH '$CONFIGURE_OPTIONS'..."
		echo
		# configure
		if ! [ -f ./configure ]; then
			make -f admin/Makefile.common cvs
		fi
		if ./configure $CONFIGURE_OPTIONS; then
			echo "$I18N_SETUP: $I18N_COMP_START"
			echo "$I18N_MINU"
			if make; then
				if [ -w "${INSTALL_DIR}" ]; then
					if make install; then
						ks_show_finish_info
						ks_quit
					else
						ks_kill "$I18N_INST_FAILED"
					fi
				else
					if kdesu -c "make install"; then
						ks_show_finish_info
						ks_quit
					else
						ks_kill "$I18N_INST_FAILED"
					fi
				fi
			else
				ks_kill "$I18N_COMP_FAILED"
			fi
		else
			echo
			echo
			echo "$I18N_SETUP: $I18N_MISSING_DEPEN1"
			echo "$I18N_MISSING_DEPEN2"
			ks_kill "$I18N_CONF_FAILED"
		fi
		ks_quit

	# prefix
	elif [[ ("$REPLY" == "p") || ( "$REPLY" == "P" ) ]]; then
		echo
		echo "$I18N_ENTER_DIR [${DEFAULT_DIR}]: "
		read -e
		if [ -z "$REPLY" ]; then
			REPLY="$DEFAULT_DIR"
		fi
		INSTALL_DIR="$REPLY"

	# toggle fast compilation
	elif [[ ("$REPLY" == "f") || ( "$REPLY" == "F" ) ]]; then
		if [ -z "$FAST_COMPILATION" ]; then
			FAST_COMPILATION="true";
		else
			FAST_COMPILATION="";
		fi

	# news
	elif [[ ("$REPLY" == "n") || ( "$REPLY" == "N" ) ]]; then
		less "NEWS"

	# license
	elif [[ ("$REPLY" == "l") || ( "$REPLY" == "L" ) ]]; then
		less "COPYING"

	# readme
	elif [[ ("$REPLY" == "r") || ( "$REPLY" == "R" ) ]]; then
		less "README"

	# quit
	elif [[ ("$REPLY" == "q") || ( "$REPLY" == "Q" ) ]]; then
		ks_reset
		clear
		exit
	fi

done