blob: 073e247a58a57a2b90ff7cef9d8810b59c0fac86 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#!/bin/sh
2
3# Copyright (C) 2012 Wind River Systems, Inc.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 2 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12# See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18
19WORK_DIR="/opt/lsb-test"
20
21if [ `id -u` -ne 0 ]
22then
23 cat << EOF
24 In order to install and run LSB testsuite, you need administrator privileges.
25 You are currently running this script as an unprivileged user.
26
27EOF
28 exit 1
29fi
30
31ARCH=`uname -m`
32if [ ${ARCH} != "i686" ] && [ ${ARCH} != "x86_64" ] && [ ${ARCH} != "ppc" ] && [ ${ARCH} != "ppc64" ]
33then
34 echo "Error: Unsupported architecture"
35 exit 1
36fi
37
38which rpm
39if [ $? -ne 0 ]
40then
41 echo "No rpm command found"
42 exit 1
43fi
44
45RET=0
46
47cd ${WORK_DIR} || exit 1
48# Step 1: Download the LSB Packages
49echo ""
50echo "Download LSB packages..."
51echo ""
52
53if [ ! -e ./packages_list ]
54then
55 echo "Error: Could not find packages list" >&2
56 exit 1
57fi
58
59. ./packages_list
60
61PACKAGES_DIR="/var/opt/lsb/test/manager/packages/ftp.linuxfoundation.org/pub/lsb"
62
Brad Bishop316dfdd2018-06-25 12:45:53 -040063BASE_PACKAGES_DIR="${PACKAGES_DIR}/base/released-all/binary"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050064RUNTIME_BASE_PACKAGES_DIR="${PACKAGES_DIR}/test_suites/released-all/binary/runtime"
65RUNTIME_PACKAGES_DIR="${PACKAGES_DIR}/test_suites/${LSB_RELEASE}/binary/runtime"
66APP_PACKAGES_DIR="${PACKAGES_DIR}/app-battery/${LSB_RELEASE}/${LSB_ARCH}"
67APP_TESTFILES_DIR="${PACKAGES_DIR}/app-battery/tests"
68SNAPSHOTS_TESTFILES_DIR="${PACKAGES_DIR}/snapshots/appbat/tests"
69
70if [ ! -d ${PACKAGES_DIR} ]
71then
72 mkdir -p ${PACKAGES_DIR}
73fi
74
75if [ ! -d ${BASE_PACKAGES_DIR} ]
76then
77 mkdir -p ${BASE_PACKAGES_DIR}
78fi
79
80if [ ! -d ${RUNTIME_BASE_PACKAGES_DIR} ]
81then
82 mkdir -p ${RUNTIME_BASE_PACKAGES_DIR}
83fi
84
85if [ ! -d ${RUNTIME_PACKAGES_DIR} ]
86then
87 mkdir -p ${RUNTIME_PACKAGES_DIR}
88fi
89
90if [ ! -d ${APP_PACKAGES_DIR} ]
91then
92 mkdir -p ${APP_PACKAGES_DIR}
93fi
94
95if [ ! -d ${APP_TESTFILES_DIR} ]
96then
97 mkdir -p ${APP_TESTFILES_DIR}
98fi
99
100# Official download server list. You can replace them with your own server.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400101SERVER_IPADDR="140.211.169.28"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102SERVER_NAME="ftp.linuxfoundation.org"
103
104if ! `grep -F -q "${SERVER_NAME}" /etc/hosts`; then
105 echo "${SERVER_IPADDR} ${SERVER_NAME} ${SERVER_NAME}" >> /etc/hosts
106fi
107
108#ping -c 5 ${SERVER_NAME}
109#if [ $? -ne 0 ]
110#then
111# echo "The server: ${SERVER_NAME} is unreachable"
112# exit 1
113#fi
114
115SERVER1="\
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600116 http://${SERVER_NAME}/pub/lsb/base/released-all/binary"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500117SERVER2="\
118 http://${SERVER_NAME}/pub/lsb/test_suites/released-all/binary/runtime"
119SERVER3="\
120 http://${SERVER_NAME}/pub/lsb/test_suites/${LSB_RELEASE}/binary/runtime"
121SERVER4="\
122 http://${SERVER_NAME}/pub/lsb/app-battery/${LSB_RELEASE}/${LSB_ARCH}"
123SERVER5="\
124 http://${SERVER_NAME}/pub/lsb/app-battery/tests"
125
126# We using "curl" as a download tool, "wget" is an alternative.
127CURL=`which curl`
128WGET=`which wget`
129if [ ! -z ${CURL} ]
130then
131 DOWNLOAD_CMD="${CURL} -R -L -f --retry 3 --retry-delay 4 --connect-timeout 180 --compressed -C - -o"
132elif [ ! -z ${WGET} ]
133then
134 DOWNLOAD_CMD="${WGET} -c -t 5 -O"
135else
136 echo "Can not find a download tool, please install curl or wget."
137 exit 1
138fi
139
140cd ${BASE_PACKAGES_DIR}
141for pkg in ${BASE_PACKAGES_LIST}; do
142 if [ ! -f ${pkg} ]
143 then
144 #${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER1}/${pkg} > /dev/null 2>&1
145 ${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER1}/${pkg}
146 if [ $? -eq 0 ]
147 then
148 mv -f ${pkg}".#part" ${pkg}
149 echo "Download ${pkg} successfully."
150 else
151 echo "Download ${pkg} failed."
152 RET=1
153 fi
154 fi
155done
156
157cd ${RUNTIME_BASE_PACKAGES_DIR}
158for pkg in ${RUNTIME_BASE_PACKAGES_LIST}; do
159 if [ ! -f ${pkg} ]
160 then
161 #${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER2}/${pkg} > /dev/null 2>&1
162 ${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER2}/${pkg}
163 if [ $? -eq 0 ]
164 then
165 mv -f ${pkg}".#part" ${pkg}
166 echo "Download ${pkg} successfully."
167 else
168 echo "Download ${pkg} failed."
169 RET=1
170 fi
171 fi
172done
173
174cd ${RUNTIME_PACKAGES_DIR}
175for pkg in ${RUNTIME_PACKAGES_LIST}; do
176 if [ ! -f ${pkg} ]
177 then
178 #${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER3}/${pkg} > /dev/null 2>&1
179 ${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER3}/${pkg}
180 if [ $? -eq 0 ]
181 then
182 mv -f ${pkg}".#part" ${pkg}
183 echo "Download ${pkg} successfully."
184 else
185 echo "Download ${pkg} failed."
186 RET=1
187 fi
188 fi
189done
190
191cd ${APP_PACKAGES_DIR}
192for pkg in ${APP_PACKAGES_LIST}; do
193 if [ ! -f ${pkg} ]
194 then
195 #${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER4}/${pkg} > /dev/null 2>&1
196 ${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER4}/${pkg}
197 if [ $? -eq 0 ]
198 then
199 mv -f ${pkg}".#part" ${pkg}
200 echo "Download ${pkg} successfully."
201 else
202 echo "Download ${pkg} failed."
203 RET=1
204 fi
205 fi
206done
207
208cd ${APP_TESTFILES_DIR}
209for pkg in ${APP_TESTFILES_LIST}; do
210 if [ ! -f ${pkg} ]
211 then
212 #${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER5}/${pkg} > /dev/null 2>&1
213 ${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER5}/${pkg}
214 if [ $? -eq 0 ]
215 then
216 mv -f ${pkg}".#part" ${pkg}
217 echo "Download ${pkg} successfully."
218 else
219 echo "Download ${pkg} failed."
220 RET=1
221 fi
222 fi
223done
224
225if [ ${RET} -ne 0 ]
226then
227 echo "Download some packages failed. Please download them again."
228 exit 1
229fi
230
231# Step 2: Install the LSB Packages
232echo ""
233echo "Install LSB packages..."
234echo ""
235
236# Kill lighttpd
237ps aux | grep "lighttpd" | grep -v -q "grep"
238if [ $? -eq 0 ]
239then
240 killall lighttpd >/dev/null 2>&1
241fi
242
243# Start avahi-daemon
244ps aux | grep "avahi-daemon" | grep -v -q "grep"
245if [ $? -ne 0 ]
246then
247 /etc/init.d/avahi-daemon start >/dev/null 2>&1
248fi
249
250LSB_START_CMD="/opt/lsb/test/manager/bin/dist-checker-start.pl"
251LSB_STOP_CMD="/opt/lsb/test/manager/bin/dist-checker-stop.pl"
252
253PLATFORM_FILE="/etc/rpm/platform"
254
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500255RPM_INSTALL_CMD="rpm --quiet --nodeps --replacepkgs --nosignature -i --ignoreos"
256RPM_INSTALL_CMD_NOSCRIPTS="rpm --quiet --nodeps --replacepkgs --noscripts --nosignature -i --ignoreos"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500257
258# If the lsb has been started, stop it first.
259if [ -x ${LSB_STOP_CMD} ]
260then
261 ${LSB_STOP_CMD}
262fi
263
264if [ ! -d /etc/rpm ]
265then
266 mkdir -p /etc/rpm
267fi
268
269if [ ! -f ${PLATFORM_FILE} ]
270then
271 touch ${PLATFORM_FILE}
272fi
273
274if ! `grep -F -q "noarch-suse" ${PLATFORM_FILE}`; then
275 if [ ${ARCH} = i686 ];then
276 echo "i486-suse" >> ${PLATFORM_FILE}
277 echo "i486-noarch" >> ${PLATFORM_FILE}
278 echo "i486-pc" >> ${PLATFORM_FILE}
279 echo "noarch-suse" >> ${PLATFORM_FILE}
280 elif [ ${ARCH} = x86_64 ]; then
281 echo "i486-suse" >> ${PLATFORM_FILE}
282 echo "i486-noarch" >> ${PLATFORM_FILE}
283 echo "i486-pc" >> ${PLATFORM_FILE}
284 echo "i486-.*-linux.*" >> ${PLATFORM_FILE}
285 echo "noarch-suse" >> ${PLATFORM_FILE}
286 echo "${ARCH}-suse" >> ${PLATFORM_FILE}
287 echo "${ARCH}-noarch" >> ${PLATFORM_FILE}
288 echo "${ARCH}-pc" >> ${PLATFORM_FILE}
289 else
290 echo "${ARCH}-suse" >> ${PLATFORM_FILE}
291 echo "${ARCH}-noarch" >> ${PLATFORM_FILE}
292 echo "${ARCH}-pc" >> ${PLATFORM_FILE}
293 echo "noarch-suse" >> ${PLATFORM_FILE}
294 fi
295fi
296
297if [ -d ${BASE_PACKAGES_DIR} ]
298then
299 cd ${BASE_PACKAGES_DIR}
300 for pkg in ${BASE_PACKAGES_LIST}
301 do
302 rpm --quiet -q ${pkg%\.*}
303 if [ $? -ne 0 ]; then
304 $RPM_INSTALL_CMD ${pkg}
305 fi
306 done
307fi
308
309if [ -d ${RUNTIME_BASE_PACKAGES_DIR} ]
310then
311 cd ${RUNTIME_BASE_PACKAGES_DIR}
312 for pkg in ${RUNTIME_BASE_PACKAGES_LIST}
313 do
314 rpm --quiet -q ${pkg%\.*}
315 if [ $? -ne 0 ]; then
316 $RPM_INSTALL_CMD ${pkg}
317 fi
318 done
319fi
320
321if [ -d ${RUNTIME_PACKAGES_DIR} ]
322then
323 cd ${RUNTIME_PACKAGES_DIR}
324 for pkg in ${RUNTIME_PACKAGES_LIST}
325 do
326 rpm --quiet -q ${pkg%\.*}
327 if [ $? -ne 0 ]; then
328 $RPM_INSTALL_CMD ${pkg}
329 fi
330 done
331fi
332
333if [ -d ${APP_PACKAGES_DIR} ]
334then
335 cd ${APP_PACKAGES_DIR}
336 for pkg in ${APP_PACKAGES_LIST}
337 do
338 echo "${pkg}" | grep -q "apache\|xpdf"
339 if [ $? -eq 0 ]
340 then
341 rpm --quiet -q ${pkg%\.*}
342 if [ $? -ne 0 ]; then
343 $RPM_INSTALL_CMD_NOSCRIPTS ${pkg}
344 fi
345 else
346 rpm --quiet -q ${pkg%\.*}
347 if [ $? -ne 0 ]; then
348 $RPM_INSTALL_CMD ${pkg}
349 fi
350 fi
351 done
352fi
353
354if [ ! -d ${SNAPSHOTS_TESTFILES_DIR} ]
355then
356 mkdir -p ${SNAPSHOTS_TESTFILES_DIR}
357fi
358
359if [ -d ${APP_TESTFILES_DIR} ]
360then
361 cd ${APP_TESTFILES_DIR}
362 for pkg in ${APP_TESTFILES_LIST}
363 do
364 cp -f ${pkg} ${SNAPSHOTS_TESTFILES_DIR}
365 done
366fi
367
368cd ${WORK_DIR}
369
370# Step 3: Set environment
371echo ""
372echo "Set environment..."
373echo ""
374
375check ()
376{
377 if [ $? -eq 0 ]
378 then
379 echo "PASS"
380 else
381 echo "FAIL"
382 exit 1
383 fi
384}
385
386echo ""
387echo "---------------------------------"
388echo "Create the Dirnames on target"
389
390if [ ! -d /etc/rpm/sysinfo ]
391then
392 mkdir -p /etc/rpm/sysinfo
393fi
394
395cat > /etc/rpm/sysinfo/Dirnames << EOF
396/etc/opt/lsb
397/home/tet/LSB.tools
398/opt/lsb-tet3-lite/lib/ksh
399/opt/lsb-tet3-lite/lib/perl
400/opt/lsb-tet3-lite/lib/posix_sh
401/opt/lsb-tet3-lite/lib/tet3
402/opt/lsb-tet3-lite/lib/xpg3sh
403/opt/lsb/appbat/lib/python2.4/site-packages/qm
404/opt/lsb/appbat/lib/python2.4/site-packages/qm/external
405/opt/lsb/appbat/lib/python2.4/site-packages/qm/external/DocumentTemplate
406/opt/lsb/appbat/lib/python2.4/site-packages/qm/test
407/opt/lsb/appbat/lib/python2.4/site-packages/qm/test/classes
408/opt/lsb/appbat/lib/python2.4/site-packages/qm/test/web
409/opt/lsb/test/doc
410/opt/lsb/test/lib
411/opt/lsb/test/qm/diagnostics
412/opt/lsb/test/qm/doc
413/opt/lsb/test/qm/doc/test/html
414/opt/lsb/test/qm/doc/test/print
415/opt/lsb/test/qm/dtml
416/opt/lsb/test/qm/dtml/test
417/opt/lsb/test/qm/messages/test
418/opt/lsb/test/qm/tutorial/test/tdb
419/opt/lsb/test/qm/tutorial/test/tdb/QMTest
420/opt/lsb/test/qm/web
421/opt/lsb/test/qm/web/images
422/opt/lsb/test/qm/web/stylesheets
423/opt/lsb/test/qm/xml
424/opt/lsb/test/share
425/usr/share/doc/lsb-runtime-test
426/var/opt/lsb
427/opt/lsb/test/desktop
428/opt/lsb/test/desktop/fontconfig
429/opt/lsb/test/desktop/freetype
430/opt/lsb/test/desktop/gtkvts
431/opt/lsb/test/desktop/libpng
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500432/opt/lsb/test/desktop/xft
433/opt/lsb/test/desktop/xml
434/opt/lsb/test/desktop/xrender
435
436
437EOF
438
439if [ -f /etc/rpm/sysinfo/Dirnames ]
440then
441 echo "Success to creat Dirnames file"
442else
443 echo "Fail to creat Dirnames file"
444fi
445
446[ -x /sbin/ldconfig ] && {
447echo ""
448echo "---------------------------------"
449echo "Update cache"
450/sbin/ldconfig
451check;
452}
453
454# Check loop device
455if [ ! -b /dev/loop0 ]
456then
457 insmod /lib/modules/`uname -r`/kernel/drivers/block/loop.ko
458 if [ $? != 0 ];then
459 echo "Insmod loop.ko failed."
460 fi
461fi
462
463# Resolve localhost
464LOCALHOST=`hostname`
465if ! `grep -F -q "$LOCALHOST" /etc/hosts`; then
466 echo "127.0.0.1 $LOCALHOST" >> /etc/hosts
467fi
468
469# Workaround to add part of locales for LSB test
470localedef -i de_DE -f ISO-8859-1 de_DE
471localedef -i de_DE -f ISO-8859-15 de_DE.ISO-8859-15
472localedef -i de_DE -f UTF-8 de_DE.UTF-8
473localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro
474localedef -i en_HK -f ISO-8859-1 en_HK
475localedef -i en_PH -f ISO-8859-1 en_PH
476localedef -i en_US -f ISO-8859-15 en_US.ISO-8859-15
477localedef -i en_US -f ISO-8859-1 en_US.ISO-8859-1
478localedef -i en_US -f ISO-8859-1 en_US
479localedef -i en_US -f UTF-8 en_US.UTF-8
480localedef -i en_US -f ISO-8859-1 en_US.ISO8859-1
481localedef -i es_MX -f ISO-8859-1 es_MX
482localedef -i fr_FR -f ISO-8859-1 fr_FR
483localedef -i it_IT -f ISO-8859-1 it_IT
484localedef -i ja_JP -f EUC-JP ja_JP.eucjp
485localedef -i se_NO -f UTF-8 se_NO.UTF-8
486localedef -i ta_IN -f UTF-8 ta_IN
487localedef -i es_ES -f ISO-8859-1 es_ES
488localedef -i fr_FR@euro -f ISO-8859-1 fr_FR@euro
489localedef -i is_IS -f UTF-8 is_IS.UTF-8
490localedef -i zh_TW -f BIG5 zh_TW.BIG5
491localedef -i en_US -f ISO-8859-15 en_US.ISO-8859-15
492
493echo ""
494echo "Installation done!"
495echo ""
496
497# Step 4: Start LSB test
498if [ -x ${LSB_START_CMD} ]
499then
500 ${LSB_START_CMD}
501fi
502
503echo "---------------------------------"
504echo "Run all the certification version of LSB Tests"
505echo "---------------------------------"
506
507LSB_DIST_CHECKER="/opt/lsb/test/manager/utils/dist-checker.pl"
508SESSION="${WORK_DIR}/session"
509if [ ! -e ${SESSION} ]
510then
511 echo "Error: Could not find session file."
512 echo "You must run LSB test from webbrower."
513 exit 1
514fi
515
516if [ -x ${LSB_DIST_CHECKER} ]
517then
518 ${LSB_DIST_CHECKER} -v2 -f ${SESSION}
519 check
520fi
521
522echo ""
523echo "LSB test complete. Please check the log file in /var/opt/lsb/test/manager/results/"
524echo ""
525