summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/lsb/lsbtest/LSB_Test.sh
blob: ab79985b1b8c5e3272c134ed17e1201d877fdb8e (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

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight .nv { color: #f8f8f2 } /* Name.Variable */
.highlight .ow { color: #f92672 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
.highlight .sa { color: #e6db74 } /* Literal.String.Affix */
.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
.highlight .sc { color: #e6db74 } /* Literal.String.Char */
.highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */
.highlight .sd { color: #e6db74 } /* Literal.String.Doc */
.highlight .s2 { color: #e6db74 } /* Literal.String.Double */
.highlight .se { color: #ae81ff } /* Literal.String.Escape */
.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */
.highlight .si { color: #e6db74 } /* Literal.String.Interpol */
.highlight .sx { color: #e6db74 } /* Literal.String.Other */
.highlight .sr { color: #e6db74 } /* Literal.String.Regex */
.highlight .s1 { color: #e6db74 } /* Literal.String.Single */
.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */
.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #a6e22e } /* Name.Function.Magic */
.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */
.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */
.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */
.highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */
.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */
}
@media (prefers-color-scheme: light) {
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
}
Creative Commons


Attribution-NonCommercial-ShareAlike 2.0

CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM ITS USE.
License

THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.

BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.

1. Definitions

"Collective Work" means a work, such as a periodical issue, anthology or encyclopedia, in which the Work in its entirety in unmodified form, along with a number of other contributions, constituting separate and independent works in themselves, are assembled into a collective whole. A work that constitutes a Collective Work will not be considered a Derivative Work (as defined below) for the purposes of this License.
"Derivative Work" means a work based upon the Work or upon the Work and other pre-existing works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which the Work may be recast, transformed, or adapted, except that a work that constitutes a Collective Work will not be considered a Derivative Work for the purpose of this License. For the avoidance of doubt, where the Work is a musical composition or sound recording, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered a Derivative Work for the purpose of this License.
"Licensor" means the individual or entity that offers the Work under the terms of this License.
"Original Author" means the individual or entity who created the Work.
"Work" means the copyrightable work of authorship offered under the terms of this License.
"You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
"License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, Noncommercial, ShareAlike.
2. Fair Use Rights. Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use, first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other applicable laws.

3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:

to reproduce the Work, to incorporate the Work into one or more Collective Works, and to reproduce the Work as incorporated in the Collective Works;
to create and reproduce Derivative Works;
to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission the Work including as incorporated in Collective Works;
to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission Derivative Works;
The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. All rights not expressly granted by Licensor are hereby reserved, including but not limited to the rights set forth in Sections 4(e) and 4(f).

4. Restrictions.The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:

You may distribute, publicly display, publicly perform, or publicly digitally perform the Work only under the terms of this License, and You must include a copy of, or the Uniform Resource Identifier for, this License with every copy or phonorecord of the Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Work that alter or restrict the terms of this License or the recipients` exercise of the rights granted hereunder. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Work itself to be made subject to the terms of this License. If You create a Collective Work, upon notice from any Licensor You must, to the extent practicable, remove from the Collective Work any reference to such Licensor or the Original Author, as requested. If You create a Derivative Work, upon notice from any Licensor You must, to the extent practicable, remove from the Derivative Work any reference to such Licensor or the Original Author, as requested.
You may distribute, publicly display, publicly perform, or publicly digitally perform a Derivative Work only under the terms of this License, a later version of this License with the same License Elements as this License, or a Creative Commons iCommons license that contains the same License Elements as this License (e.g. Attribution-NonCommercial-ShareAlike 2.0 Japan). You must include a copy of, or the Uniform Resource Identifier for, this License or other license specified in the previous sentence with every copy or phonorecord of each Derivative Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Derivative Works that alter or restrict the terms of this License or the recipients` exercise of the rights granted hereunder, and You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Derivative Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Derivative
#!/bin/bash

# Copyright (C) 2012 Wind River Systems, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA


WORK_DIR="/opt/lsb-test"

if [ `id -u` -ne 0 ]
then
	cat << EOF
	In order to install and run LSB testsuite, you need administrator privileges.
	You are currently running this script as an unprivileged user.

EOF
	exit 1
fi

ARCH=`uname -m`
if [ ${ARCH} != "i686" ] && [ ${ARCH} != "x86_64" ] && [ ${ARCH} != "ppc" ] && [ ${ARCH} != "ppc64" ]
then
	echo "Error: Unsupported architecture"
	exit 1
fi

which rpm
if [ $? -ne 0 ]
then
	echo "No rpm command found"
	exit 1
fi

RET=0

cd ${WORK_DIR} || exit 1
# Step 1: Download the LSB Packages
echo ""
echo "Download LSB packages..."
echo ""

if [ ! -e ./packages_list ]
then
	echo "Error: Could not find packages list" >&2
	exit 1
fi

. ./packages_list

PACKAGES_DIR="/var/opt/lsb/test/manager/packages/ftp.linuxfoundation.org/pub/lsb"

BASE_PACKAGES_DIR="${PACKAGES_DIR}/base/${LSB_RELEASE}/binary"
RUNTIME_BASE_PACKAGES_DIR="${PACKAGES_DIR}/test_suites/released-all/binary/runtime"
RUNTIME_PACKAGES_DIR="${PACKAGES_DIR}/test_suites/${LSB_RELEASE}/binary/runtime"
APP_PACKAGES_DIR="${PACKAGES_DIR}/app-battery/${LSB_RELEASE}/${LSB_ARCH}"
APP_TESTFILES_DIR="${PACKAGES_DIR}/app-battery/tests"
SNAPSHOTS_TESTFILES_DIR="${PACKAGES_DIR}/snapshots/appbat/tests"

if [ ! -d ${PACKAGES_DIR} ]
then
	mkdir -p ${PACKAGES_DIR}
fi

if [ ! -d ${BASE_PACKAGES_DIR} ]
then
	mkdir -p ${BASE_PACKAGES_DIR}
fi

if [ ! -d ${RUNTIME_BASE_PACKAGES_DIR} ]
then
	mkdir -p ${RUNTIME_BASE_PACKAGES_DIR}
fi

if [ ! -d ${RUNTIME_PACKAGES_DIR} ]
then
	mkdir -p ${RUNTIME_PACKAGES_DIR}
fi

if [ ! -d ${APP_PACKAGES_DIR} ]
then
	mkdir -p ${APP_PACKAGES_DIR}
fi

if [ ! -d ${APP_TESTFILES_DIR} ]
then
	mkdir -p ${APP_TESTFILES_DIR}
fi

# Official download server list. You can replace them with your own server.
SERVER_IPADDR="140.211.169.23"
SERVER_NAME="ftp.linuxfoundation.org"

if ! `grep -F -q "${SERVER_NAME}" /etc/hosts`; then
	echo "${SERVER_IPADDR}	${SERVER_NAME}	${SERVER_NAME}" >> /etc/hosts
fi

#ping -c 5 ${SERVER_NAME}
#if [ $? -ne 0 ]
#then
#	echo "The server: ${SERVER_NAME} is unreachable"
#	exit 1
#fi

SERVER1="\
	http://${SERVER_NAME}/pub/lsb/base/${LSB_RELEASE}/binary"
SERVER2="\
	http://${SERVER_NAME}/pub/lsb/test_suites/released-all/binary/runtime"
SERVER3="\
	http://${SERVER_NAME}/pub/lsb/test_suites/${LSB_RELEASE}/binary/runtime"
SERVER4="\
	http://${SERVER_NAME}/pub/lsb/app-battery/${LSB_RELEASE}/${LSB_ARCH}"
SERVER5="\
	http://${SERVER_NAME}/pub/lsb/app-battery/tests"

# We using "curl" as a download tool, "wget" is an alternative.
CURL=`which curl`
WGET=`which wget`
if [ ! -z ${CURL} ]
then
	DOWNLOAD_CMD="${CURL} -R -L -f --retry 3 --retry-delay 4 --connect-timeout 180 --compressed -C - -o"
elif [ ! -z ${WGET} ]
then
	DOWNLOAD_CMD="${WGET} -c -t 5 -O"
else
	echo "Can not find a download tool, please install curl or wget."
	exit 1
fi

cd ${BASE_PACKAGES_DIR}
for pkg in ${BASE_PACKAGES_LIST}; do
	if [ ! -f ${pkg} ]
	then
		#${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER1}/${pkg} > /dev/null 2>&1
		${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER1}/${pkg}
		if [ $? -eq 0 ]
		then
			mv -f ${pkg}".#part" ${pkg}
			echo "Download ${pkg} successfully."
		else
			echo "Download ${pkg} failed."
			RET=1
		fi
	fi
done

cd ${RUNTIME_BASE_PACKAGES_DIR}
for pkg in ${RUNTIME_BASE_PACKAGES_LIST}; do
	if [ ! -f ${pkg} ]
	then
		#${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER2}/${pkg} > /dev/null 2>&1
		${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER2}/${pkg}
		if [ $? -eq 0 ]
		then
			mv -f ${pkg}".#part" ${pkg}
			echo "Download ${pkg} successfully."
		else
			echo "Download ${pkg} failed."
			RET=1
		fi
	fi
done

cd ${RUNTIME_PACKAGES_DIR}
for pkg in ${RUNTIME_PACKAGES_LIST}; do
	if [ ! -f ${pkg} ]
	then
		#${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER3}/${pkg} > /dev/null 2>&1
		${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER3}/${pkg}
		if [ $? -eq 0 ]
		then
			mv -f ${pkg}".#part" ${pkg}
			echo "Download ${pkg} successfully."
		else
			echo "Download ${pkg} failed."
			RET=1
		fi
	fi
done

cd ${APP_PACKAGES_DIR}
for pkg in ${APP_PACKAGES_LIST}; do
	if [ ! -f ${pkg} ]
	then
		#${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER4}/${pkg} > /dev/null 2>&1
		${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER4}/${pkg}
		if [ $? -eq 0 ]
		then
			mv -f ${pkg}".#part" ${pkg}
			echo "Download ${pkg} successfully."
		else
			echo "Download ${pkg} failed."
			RET=1
		fi
	fi
done

cd ${APP_TESTFILES_DIR}
for pkg in ${APP_TESTFILES_LIST}; do
	if [ ! -f ${pkg} ]
	then
		#${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER5}/${pkg} > /dev/null 2>&1
		${DOWNLOAD_CMD} ${pkg}".#part" ${SERVER5}/${pkg}
		if [ $? -eq 0 ]
		then
			mv -f ${pkg}".#part" ${pkg}
			echo "Download ${pkg} successfully."
		else
			echo "Download ${pkg} failed."
			RET=1
		fi
	fi
done

if [ ${RET} -ne 0 ]
then
	echo "Download some packages failed. Please download them again."
	exit 1
fi

# Step 2: Install the LSB Packages
echo ""
echo "Install LSB packages..."
echo ""

# Kill lighttpd
ps aux | grep "lighttpd" | grep -v -q "grep"
if [ $? -eq 0 ]
then
	killall lighttpd >/dev/null 2>&1
fi

# Start avahi-daemon
ps aux | grep "avahi-daemon" | grep -v -q "grep"
if [ $? -ne 0 ]
then
	/etc/init.d/avahi-daemon start >/dev/null 2>&1
fi

LSB_START_CMD="/opt/lsb/test/manager/bin/dist-checker-start.pl"
LSB_STOP_CMD="/opt/lsb/test/manager/bin/dist-checker-stop.pl"

PLATFORM_FILE="/etc/rpm/platform"

RPM_INSTALL_CMD="rpm --quiet --nodeps --replacepkgs --nosignature -i"
RPM_INSTALL_CMD_NOSCRIPTS="rpm --quiet --nodeps --replacepkgs --noscripts --nosignature -i"

# If the lsb has been started, stop it first.
if [ -x ${LSB_STOP_CMD} ]
then
	${LSB_STOP_CMD}
fi

if [ ! -d /etc/rpm ]
then
	mkdir -p /etc/rpm
fi

if [ ! -f ${PLATFORM_FILE} ]
then
	touch ${PLATFORM_FILE}
fi

if ! `grep -F -q "noarch-suse" ${PLATFORM_FILE}`; then
	if [ ${ARCH} = i686 ];then
		echo "i486-suse" >> ${PLATFORM_FILE}
		echo "i486-noarch" >> ${PLATFORM_FILE}
		echo "i486-pc" >> ${PLATFORM_FILE}
		echo "noarch-suse" >> ${PLATFORM_FILE}
	elif [ ${ARCH} = x86_64 ]; then
		echo "i486-suse" >> ${PLATFORM_FILE}
		echo "i486-noarch" >> ${PLATFORM_FILE}
		echo "i486-pc" >> ${PLATFORM_FILE}
		echo "i486-.*-linux.*" >> ${PLATFORM_FILE}
		echo "noarch-suse" >> ${PLATFORM_FILE}
		echo "${ARCH}-suse" >> ${PLATFORM_FILE}
		echo "${ARCH}-noarch" >> ${PLATFORM_FILE}
		echo "${ARCH}-pc" >> ${PLATFORM_FILE}
	else
		echo "${ARCH}-suse" >> ${PLATFORM_FILE}
		echo "${ARCH}-noarch" >> ${PLATFORM_FILE}
		echo "${ARCH}-pc" >> ${PLATFORM_FILE}
		echo "noarch-suse" >> ${PLATFORM_FILE}
	fi
fi

if [ -d ${BASE_PACKAGES_DIR} ]
then
	cd ${BASE_PACKAGES_DIR}
	for pkg in ${BASE_PACKAGES_LIST}
	do
		rpm --quiet -q ${pkg%\.*}
		if [ $? -ne 0 ]; then
			$RPM_INSTALL_CMD ${pkg}
		fi
	done
fi

if [ -d ${RUNTIME_BASE_PACKAGES_DIR} ]
then
	cd ${RUNTIME_BASE_PACKAGES_DIR}
	for pkg in ${RUNTIME_BASE_PACKAGES_LIST}
	do
		rpm --quiet -q ${pkg%\.*}
		if [ $? -ne 0 ]; then
			$RPM_INSTALL_CMD ${pkg}
		fi
	done
fi

if [ -d ${RUNTIME_PACKAGES_DIR} ]
then
	cd ${RUNTIME_PACKAGES_DIR}
	for pkg in ${RUNTIME_PACKAGES_LIST}
	do
		rpm --quiet -q ${pkg%\.*}
		if [ $? -ne 0 ]; then
			$RPM_INSTALL_CMD ${pkg}
		fi
	done
fi

if [ -d ${APP_PACKAGES_DIR} ]
then
	cd ${APP_PACKAGES_DIR}
	for pkg in ${APP_PACKAGES_LIST}
	do
		echo "${pkg}" | grep -q "apache\|xpdf"
		if [ $? -eq 0 ]
		then
			rpm --quiet -q ${pkg%\.*}
			if [ $? -ne 0 ]; then
				$RPM_INSTALL_CMD_NOSCRIPTS ${pkg}
			fi
		else
			rpm --quiet -q ${pkg%\.*}
			if [ $? -ne 0 ]; then
				$RPM_INSTALL_CMD ${pkg}
			fi
		fi
	done
fi

if [ ! -d ${SNAPSHOTS_TESTFILES_DIR} ]
then
	mkdir -p ${SNAPSHOTS_TESTFILES_DIR}
fi

if [ -d ${APP_TESTFILES_DIR} ]
then
	cd ${APP_TESTFILES_DIR}
	for pkg in ${APP_TESTFILES_LIST}
	do
		cp -f ${pkg} ${SNAPSHOTS_TESTFILES_DIR}
	done
fi

cd ${WORK_DIR}

# Step 3: Set environment
echo ""
echo "Set environment..."
echo ""

check ()
{
	if [ $? -eq 0 ]
	then
		echo "PASS"
	else 
		echo "FAIL"
		exit 1
	fi
}

echo ""
echo "---------------------------------"
echo "Create the Dirnames on target"

if [ ! -d /etc/rpm/sysinfo ]
then
	mkdir -p /etc/rpm/sysinfo
fi

cat > /etc/rpm/sysinfo/Dirnames << EOF
/etc/opt/lsb
/home/tet/LSB.tools
/opt/lsb-tet3-lite/lib/ksh
/opt/lsb-tet3-lite/lib/perl
/opt/lsb-tet3-lite/lib/posix_sh
/opt/lsb-tet3-lite/lib/tet3
/opt/lsb-tet3-lite/lib/xpg3sh
/opt/lsb/appbat/lib/python2.4/site-packages/qm
/opt/lsb/appbat/lib/python2.4/site-packages/qm/external
/opt/lsb/appbat/lib/python2.4/site-packages/qm/external/DocumentTemplate
/opt/lsb/appbat/lib/python2.4/site-packages/qm/test
/opt/lsb/appbat/lib/python2.4/site-packages/qm/test/classes
/opt/lsb/appbat/lib/python2.4/site-packages/qm/test/web
/opt/lsb/test/doc
/opt/lsb/test/lib
/opt/lsb/test/qm/diagnostics
/opt/lsb/test/qm/doc
/opt/lsb/test/qm/doc/test/html
/opt/lsb/test/qm/doc/test/print
/opt/lsb/test/qm/dtml
/opt/lsb/test/qm/dtml/test
/opt/lsb/test/qm/messages/test
/opt/lsb/test/qm/tutorial/test/tdb
/opt/lsb/test/qm/tutorial/test/tdb/QMTest
/opt/lsb/test/qm/web
/opt/lsb/test/qm/web/images
/opt/lsb/test/qm/web/stylesheets
/opt/lsb/test/qm/xml
/opt/lsb/test/share
/usr/share/doc/lsb-runtime-test
/var/opt/lsb
/opt/lsb/test/desktop
/opt/lsb/test/desktop/fontconfig
/opt/lsb/test/desktop/freetype
/opt/lsb/test/desktop/gtkvts
/opt/lsb/test/desktop/libpng
/opt/lsb/test/desktop/qt3
/opt/lsb/test/desktop/xft
/opt/lsb/test/desktop/xml
/opt/lsb/test/desktop/xrender


EOF

if [ -f /etc/rpm/sysinfo/Dirnames ]
then
	echo "Success to creat Dirnames file"
else 
	echo "Fail to creat Dirnames file"
fi

[ -x /sbin/ldconfig ] && {
echo ""
echo "---------------------------------"
echo "Update cache"
/sbin/ldconfig
check;
}

# Check loop device
if [ ! -b /dev/loop0 ]
then
	insmod /lib/modules/`uname -r`/kernel/drivers/block/loop.ko
	if [ $? != 0 ];then
		echo "Insmod loop.ko failed."
	fi
fi

# Resolve localhost
LOCALHOST=`hostname`
if ! `grep -F -q "$LOCALHOST" /etc/hosts`; then
	echo "127.0.0.1	$LOCALHOST" >> /etc/hosts
fi

# Workaround to add part of locales for LSB test
localedef -i de_DE -f ISO-8859-1 de_DE
localedef -i de_DE -f ISO-8859-15 de_DE.ISO-8859-15
localedef -i de_DE -f UTF-8 de_DE.UTF-8
localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro
localedef -i en_HK -f ISO-8859-1 en_HK
localedef -i en_PH -f ISO-8859-1 en_PH
localedef -i en_US -f ISO-8859-15 en_US.ISO-8859-15
localedef -i en_US -f ISO-8859-1 en_US.ISO-8859-1
localedef -i en_US -f ISO-8859-1 en_US
localedef -i en_US -f UTF-8 en_US.UTF-8
localedef -i en_US -f ISO-8859-1 en_US.ISO8859-1
localedef -i es_MX -f ISO-8859-1 es_MX
localedef -i fr_FR -f ISO-8859-1 fr_FR
localedef -i it_IT -f ISO-8859-1 it_IT
localedef -i ja_JP -f EUC-JP ja_JP.eucjp
localedef -i se_NO -f UTF-8 se_NO.UTF-8
localedef -i ta_IN -f UTF-8 ta_IN
localedef -i es_ES -f ISO-8859-1 es_ES
localedef -i fr_FR@euro -f ISO-8859-1 fr_FR@euro
localedef -i is_IS -f UTF-8 is_IS.UTF-8
localedef -i zh_TW -f BIG5 zh_TW.BIG5
localedef -i en_US -f ISO-8859-15 en_US.ISO-8859-15

echo ""
echo "Installation done!"
echo ""

# Step 4: Start LSB test
if [ -x ${LSB_START_CMD} ]
then
	${LSB_START_CMD}
fi

echo "---------------------------------"
echo "Run all the certification version of LSB Tests"
echo "---------------------------------"

LSB_DIST_CHECKER="/opt/lsb/test/manager/utils/dist-checker.pl"
SESSION="${WORK_DIR}/session"
if [ ! -e ${SESSION} ]
then
	echo "Error: Could not find session file."
	echo "You must run LSB test from webbrower."
	exit 1
fi

if [ -x ${LSB_DIST_CHECKER} ]
then
	${LSB_DIST_CHECKER} -v2 -f ${SESSION}
	check
fi

echo ""
echo "LSB test complete. Please check the log file in /var/opt/lsb/test/manager/results/"
echo ""