summarylogtreecommitdiffstats
path: root/setup.sh.in
blob: afafff8b69020512f3c38fd5721cce53b95bc3b4 (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
#!/bin/sh

set -e

bootstrap_install() {
	install -dv "$destdir"
	install -dv "$bindir"
	install -dv "$libdir"
	install -dv "$docdir"
	install -d "$prefix/bin/"
	install -d "$prefix/share/applications/"
	for eta in ./eve-transl${qtver}-??.tar.gz ;do
		install -m 0644 "$eta" "$libdir"
	done
	if [ -f "./dxvk-$dvver.tar.gz" ] ;then
		install -d "$libdir/dxvk/"
		echo "$dvver" >"$libdir/dxvk/version"
		chmod 0644 "$libdir/dxvk/version"
		tar xf ./dxvk-$dvver.tar.gz -C $libdir/dxvk/ --no-same-owner \
			--strip-components=1 dxvk-$dvver/x32 dxvk-$dvver/x64
	fi
	install -m 0644 "./evesetup.shlib" "$libdir"
	install -m 0644 "./evelauncher-${elver}.tar.gz" "$libdir"
	install -m 0644 "./evelauncher.kwinrule" "$docdir"
	install -m 0644 "./evelauncher.lua" "$docdir"
	sed -i s,./eve-transl,$libdir/eve-transl, ./evelauncher.sh
	for cmd in backup launcher.sh regedit restore wine winecfg winetricks ;do
		cmd=eve$cmd
		if [ -f "./$cmd" ] ;then
			sed -i s,SETUPDIR=\"\",SETUPDIR=\"$destdir\", ./$cmd
			sed -i s,./evesetup.shlib,$libdir/evesetup.shlib, ./$cmd
			install "./$cmd" "$bindir/"
		else
			if [ "$cmd" = "everestore" ] ;then
				ln -s evebackup "$bindir/$cmd"
			else
				ln -s evewine "$bindir/$cmd"
			fi
		fi
		[ "$bindir" != "$prefix/bin" ] && ln -s "$bindir/$cmd" "$prefix/bin/$cmd"
		if [ ! "$cmd" = "evewine" ] ;then
			oexec=$(grep Exec= ./${cmd%.*}.desktop)
			sed -i s,$oexec,Exec=$prefix/bin/$cmd, ./${cmd%.*}.desktop
			install -m 0644 "./${cmd%.*}.desktop" "$prefix/share/applications/"
		fi
	done
	for icons in $(find . -type f -name '*.png') ;do
		install -D -m 0644 "$icons" "$prefix/share/${icons#*/}"
	done
	if [ -x $(which gtk-update-icon-cache) ] ;then
		if [ -f "${prefix}/share/icons/hicolor/icon-theme.cache" ] ;then
			gtk-update-icon-cache -t -f "${prefix}/share/icons/hicolor" 2>/dev/null
			chmod 0644 "${prefix}/share/icons/hicolor/icon-theme.cache"
		fi
	fi
}

bootstrap_remove() {
	for icons in $(find . -type f -name '*.png') ;do
		rm -f "$prefix/share/${icons#*/}"
	done
	for cmd in backup launcher.sh regedit restore wine winecfg winetricks ;do
		cmd=eve$cmd
		rm -fv "$prefix/bin/$cmd"
		if [ ! "$cmd" = "evewine" ] ;then
			rm -f "$prefix/share/applications/${cmd%.*}.desktop"
		fi
	done
	printf "\nRemove $destdir...\n"
	rm -rf "$destdir"
}

build_lib() {
	if [ ! -r "./evelauncher-$elver.tar.gz" ] ;then
		printf "\nDownload evelauncher-$elver.tar.gz...\n\n"
		curl -L -O https://binaries.eveonline.com/evelauncher-$elver.tar.gz
	fi
	rcsum="$(sha256sum ./evelauncher-$elver.tar.gz| cut -d' ' -f1)"
	if [ "$rcsum" != "$elcsum" ] ;then
		printf "\n\nError: Checksum evelauncher-$elver.tar.gz mismatch!"
		printf "\nLeaving.\n\n"
		exit 0
	fi
	printf "\n\nExtract evelauncher-$elver.tar.gz..."
	tar xf evelauncher-$elver.tar.gz
	echo "done."
	printf "\nClean up evelauncher directory..."
	cd evelauncher/
	rm -f ./*.a ./*.la ./*.pem ./*.prl ./libxcb*
	chmod 0755 ./*
	chmod 0644 ./*.qm ./*.conf ./errorpage/*
	echo "done."
	printf "\nReplace identical files with symbolic links..."
	ln -sf evelauncher.sh LogLite.sh
	ln -sf libicudata.so.55.1 libicudata.so
	ln -sf libicudata.so.55.1 libicudata.so.55
	ln -sf libicui18n.so.55.1 libicui18n.so
	ln -sf libicui18n.so.55.1 libicui18n.so.55
	ln -sf libicuuc.so.55.1 libicuuc.so
	ln -sf libicuuc.so.55.1 libicuuc.so.55
	ln -sf libgpr.so.6.0.0 libgpr.so
	ln -sf libgpr.so.6.0.0 libgpr.so.6
	ln -sf libgrpc++.so.1.12.0 libgrpc++.so
	ln -sf libgrpc++.so.1.12.0 libgrpc++.so.1
	ln -sf libgrpc++.so.1.12.0 libgrpc++.so.6
	ln -sf libgrpc.so.6.0.0 libgrpc.so
	ln -sf libgrpc.so.6.0.0 libgrpc.so.6
	ln -sf libpng12.so.0.54.0 libpng12.so.0
	ln -sf libprotobuf.so.16.0.0 libprotobuf.so
	ln -sf libprotobuf.so.16.0.0 libprotobuf.so.16
	echo "done."
	printf "\nRemove unneeded symbols from files..."
	find ./ -maxdepth 1 -type f -exec strip -s {} 2>/dev/null \;
	echo "done."
	printf "\nRepack evelauncher-$elver.tar.gz..."
	cd ../
	rm evelauncher-$elver.tar.gz
	tar czf evelauncher-$elver.tar.gz evelauncher/
	rm -rf evelauncher/
	echo "done."
}

get_dxvk() {
	if [ ! -r "./dxvk-$dvver.tar.gz" ] ;then
		printf "\nDownload dxvk-$dvver.tar.gz...\n\n"
		curl -L -O https://github.com/doitsujin/dxvk/releases/download/v$dvver/dxvk-$dvver.tar.gz
	fi
	rcsum="$(sha256sum ./dxvk-$dvver.tar.gz| cut -d' ' -f1)"
	if [ "$rcsum" != "$dvcsum" ] ;then
		printf "\n\nWarning: Checksum dxvk-$dvver.tar.gz mismatch, ignored.\n"
		rm ./dxvk-$dvver.tar.gz 2>/dev/null || true
	fi
}

check_req() {
	if [ ! -r "$(find /usr/lib -type f -name 'libxcb-xinerama*' 2>/dev/null)" ] ;then
		req="${req}libxcb-xinerama\n"
	fi
	if [ ! -x "$(which 7z 2>/dev/null)" ] ;then
		req="${req}7z\n"
	fi
	if [ ! -x "$(which curl 2>/dev/null)" ] ;then
		req="${req}curl\n"
	fi
	if [ ! -x "$(which wine 2>/dev/null)" ] ;then
		req="${req}wine\n"
	fi
	if [ "x$req" != "x" ] ;then
		printf "\nError: Following requirements are missing:\n"
		printf "\n$req\n"
		printf "\nPlease install these requirements with your Package Manager.\n"
		printf "\nLeaving.\n\n"
		exit 0
	fi
}

prefix="/usr"
destdir="/opt/evesetup"
bindir="$destdir/bin"
libdir="$destdir/lib"
docdir="$destdir/doc"
qtver="5.12"
elver=""
elcsum=""
dvver=""
dvcsum=""
rcsum=""
key=""

if [ $(id -u) -ne 0 ] ;then
	printf "\nEVE Online Launcher Setup need root permissions."
	printf "\nLeaving.\n\n"
	exit 0
fi

if [ -d "$destdir" ] ;then
	printf "\n"
	read -p 'Remove EVE Online Launcher Setup? (Y/n) ' key
	if [ "x$(echo $key | tr [:upper:] [:lower:])" != "xn" ] ;then
		printf "\nRemoving...\n\n"
		bootstrap_remove
	fi
else
	printf "\n"
	read -p 'Install EVE Online Launcher Setup? (Y/n) ' key
	if [ "x$(echo $key | tr [:upper:] [:lower:])" != "xn" ] ;then
		printf "\nInstalling...\n"
		check_req
		build_lib
		get_dxvk
		printf "\n"
		bootstrap_install
		printf "\nYou can now start EVE Online Launcher and his Tools:\n\n"
		for cmd in *.desktop ;do
			oexec=$(grep Exec= $cmd | cut -d= -f2); oexec=${oexec##*/}
			[ ! "$oexec" = "evelauncher.sh" ] && \
			printf " $oexec\t- $(grep Comment= $cmd | cut -d= -f2)\n"
		done
		printf "\n evelauncher.sh\t- EVE Online Launcher\n"
	fi
fi
printf "\nDone.\n\n"