summaryrefslogtreecommitdiffstats
path: root/scripts/create-lsb-image
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/create-lsb-image')
-rwxr-xr-xscripts/create-lsb-image228
1 files changed, 228 insertions, 0 deletions
diff --git a/scripts/create-lsb-image b/scripts/create-lsb-image
new file mode 100755
index 0000000000..94cb337678
--- /dev/null
+++ b/scripts/create-lsb-image
@@ -0,0 +1,228 @@
1#!/bin/bash
2#
3# Copyright (C) 2010-2011 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
19red='\E[31;40m'
20green='\E[32;40m'
21
22#Get current owner
23OWNER=`whoami`
24#Get group
25GROUP=`id -gn ${USER}`
26MACHINE_ARCH=`bitbake -e | sed -n 's/^MACHINE_ARCH=\"\(.*\)\"/\1/p'`
27DEPLOY_DIR_IMAGE=`bitbake -e | sed -n 's/^DEPLOY_DIR_IMAGE=\"\(.*\)\"/\1/p'`
28#Get value of varibale MACHINE_INE and DEPLOY_DIR_IMAGE
29LSB_IMAGE=poky-image-lsb-${MACHINE_ARCH}-test.ext3
30
31ECHO()
32{
33 echo -e "${green}$@"
34 tput sgr0
35}
36
37ERROR()
38{
39 echo -e "${red}$@"
40 tput sgr0
41 exit 1
42}
43
44exit_check()
45{
46 [ $? -ne 0 ] && exit $?
47}
48
49usage()
50{
51 ECHO "Usage: PC\$ create-lsb-image ARCH ROOTFS_IMAGE"
52 ECHO " ARCH: x86 or x86-64 or ppc32"
53 ECHO " ROOTFS_IMAGE: \
54Name of the rootfs image with suffix \"tar.bz2\""
55
56
57 ECHO ""
58 ECHO "Examples:"
59 ECHO " PC\$ creat-lsb-image \
60x86 poky-image-lsb-qemux86-20110317030443.rootfs.tar.bz2"
61 exit 1
62}
63
64#There should be two parameters to get machine type and name of image
65if [ $# -ne 2 ]; then
66 usage
67fi
68
69#Get list for lsb test suite
70case ${1} in
71"x86")
72 T_ARCH=ia32
73 P_ARCH=i486
74 COM_PACKAGE_LIST="lsb-dist-testkit-4.1.0-5.${T_ARCH}.tar.gz"
75 ;;
76"x86-64")
77 T_ARCH=amd64
78 P_ARCH=x86_64
79 MACHINE_ARCH=${MACHINE_ARCH/x86_64/x86-64}
80 COM_PACKAGE_LIST="lsb-dist-testkit-4.1.0-5.${P_ARCH}.tar.gz"
81 ;;
82"ppc32")
83 P_ARCH=ppc
84 T_ARCH=${ARCH}
85 COM_PACKAGE_LIST="lsb-dist-testkit-4.1.0-5.${T_ARCH}.tar.gz"
86 ;;
87*)
88 usage
89 ;;
90esac
91
92APP_PACKAGE_RPMLIST="lsb-apache-2.2.14-3.lsb4.${P_ARCH}.rpm \
93 lsb-tcl-8.5.7-6.lsb4.${P_ARCH}.rpm \
94 lsb-expect-5.43.0-11.lsb4.${P_ARCH}.rpm \
95 lsb-groff-1.20.1-5.lsb4.${P_ARCH}.rpm \
96 lsb-raptor-1.4.19-3.lsb4.${P_ARCH}.rpm \
97 lsb-xpdf-1.01-10.lsb4.${P_ARCH}.rpm \
98 lsb-samba-3.4.3-5.lsb4.${P_ARCH}.rpm \
99 lsb-rsync-3.0.6-3.lsb4.${P_ARCH}.rpm"
100
101APP_PACKAGE_SOURCELIST="expect-tests.tar \
102 tcl-tests.tar \
103 raptor-tests.tar \
104 test1.pdf \
105 test2.pdf"
106
107PACKAGE_LIST="${COM_PACKAGE_LIST} \
108 ${APP_PACKAGE_RPMLIST} \
109 ${APP_PACKAGE_SOURCELIST}"
110
111#Version for lsb test suite
112RELEASE=released-4.1.0
113#Tools of download packages
114WGET="wget -c -t 5"
115SERVER1="\
116http://ftp.linuxfoundation.org/pub/lsb/bundles/${RELEASE}/dist-testkit"
117SERVER2="\
118http://ftp.linux-foundation.org/pub/lsb/app-battery/${RELEASE}/${T_ARCH}"
119SERVER3="http://ftp.linuxfoundation.org/pub/lsb/snapshots/appbat/tests"
120
121
122#Function for downloading package from URL pointed
123download()
124{
125
126 for i in $@; do
127 ECHO " -->Downloading package \"${i}\""
128 PACKAGE_NAME=${i}
129 suffix=${PACKAGE_NAME##*.}
130 if [ "$suffix" = "gz" ];then
131 ${WGET} ${SERVER1}/${i}
132 elif [ "$suffix" = "rpm" ];then
133 ${WGET} ${SERVER2}/${i}
134 else
135 ${WGET} ${SERVER3}/${i}
136 fi
137 done
138}
139
140#Check lsb image
141[ ! -d $DEPLOY_DIR_IMAGE ] && ERROR "\
142Image directory does not exist: ${DEPLOY_DIR_IMAGE}"
143
144ECHO "Entering directory $DEPLOY_DIR_IMAGE"
145cd $DEPLOY_DIR_IMAGE
146
147if [ ! -f ${2} ]; then
148 ECHO "rootfs image \"${2}\" not found in ${DEPLOY_DIR_IMAGE}"
149 ECHO "Please copy \"${2}\" to \"${DEPLOY_DIR_IMAGE}\""
150 exit 1
151fi
152
153#Umount lsbtmp
154[ ! -d lsbtmp ] && mkdir lsbtmp
155
156#Download lsb test suite
157mkdir -p lsb-test-suite-${MACHINE_ARCH} || \
158ERROR "Couldn't find lsb test suite for ${MACHINE_ARCH}"
159cd lsb-test-suite-${MACHINE_ARCH}
160ECHO "Downloading lsb test suite, it would take some time..."
161download ${PACKAGE_LIST}
162
163cd ..
164
165#Creat lsb image
166if [ -f ${LSB_IMAGE} ];then
167 sudo umount lsbtmp > /dev/null 2>&1
168 ECHO "Removing old lsb image..."
169 /bin/rm ${LSB_IMAGE} > /dev/null 2>&1
170fi
171
172ECHO "Creating a 8GB file for the lsb image"
173dd if=/dev/zero of=${LSB_IMAGE} bs=1M count=8000 > /dev/null 2>&1
174exit_check
175
176ECHO "Formatting ext3 image..."
177mkfs.ext3 -q -F ${LSB_IMAGE} > /dev/null 2>&1
178tune2fs -j ${LSB_IMAGE} > /dev/null 2>&1
179
180
181ECHO "Generating final image"
182[ ! -d lsbtmp ] && mkdir lsbtmp
183
184
185#Install file system and lsb test suite to lsb image
186sudo mount -o loop ${LSB_IMAGE} lsbtmp
187exit_check
188
189ECHO " ->Installing rootfs..."
190sudo tar jpxf ${2} -C lsbtmp
191exit_check
192
193ECHO " ->Installing lsb test suite..."
194cd lsb-test-suite-${MACHINE_ARCH}
195if [ "${1}" = "x86-64" ]; then
196 sudo tar zpxf lsb-dist-testkit-4.1.0-5.${P_ARCH}.tar.gz -C ../lsbtmp
197else
198 sudo tar zpxf lsb-dist-testkit-4.1.0-5.${T_ARCH}.tar.gz -C ../lsbtmp
199fi
200exit_check
201
202sudo mkdir ../lsbtmp/lsb-Application
203sudo cp *.rpm *.tar *.pdf ../lsbtmp/lsb-Application
204exit_check
205cd ..
206
207if [ -f modules-*-${MACHINE_ARCH}.tgz ];then
208ECHO " ->Installing moudles of driver..."
209 sudo tar zpxf modules-*-${MACHINE_ARCH}.tgz -C lsbtmp/
210fi
211
212
213#Unmount lsbtmp
214sudo umount lsbtmp
215exit_check
216sudo rm -rf lsbtmp
217
218#Change file attribute
219sudo chown ${OWNER}:${GROUP} ${LSB_IMAGE}
220exit_check
221sudo chmod 755 ${LSB_IMAGE}
222exit_check
223
224#Set up link
225ln -sf ${LSB_IMAGE} poky-image-lsb-${MACHINE_ARCH}.ext3
226
227ECHO "The LSB test environment has been setup successfully."
228ECHO "Please run this image on platform ${MACHINE_ARCH}"