summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/installer/adt-installer/adt_installer
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/installer/adt-installer/adt_installer')
-rwxr-xr-xmeta/recipes-devtools/installer/adt-installer/adt_installer420
1 files changed, 420 insertions, 0 deletions
diff --git a/meta/recipes-devtools/installer/adt-installer/adt_installer b/meta/recipes-devtools/installer/adt-installer/adt_installer
new file mode 100755
index 0000000000..24db247910
--- /dev/null
+++ b/meta/recipes-devtools/installer/adt-installer/adt_installer
@@ -0,0 +1,420 @@
1#!/bin/bash
2# Yocto ADT Installer
3#
4# Copyright 2010-2011 by Intel Corp.
5#
6# Permission is hereby granted, free of charge, to any person obtaining a copy
7# of this software and associated documentation files (the "Software"), to deal
8# in the Software without restriction, including without limitation the rights
9# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10# copies of the Software, and to permit persons to whom the Software is
11# furnished to do so, subject to the following conditions:
12
13# The above copyright notice and this permission notice shall be included in
14# all copies or substantial portions of the Software.
15
16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22# THE SOFTWARE.
23
24
25usage ()
26{
27
28 INST_ARCH=`uname -m`
29 INST_OS=`uname -o| tr '[A-Z]' '[a-z]'`
30 INST_KR=`uname -r| tr '[A-Z]' '[a-z]'`
31
32 echo_info "#########################################################################"
33 echo_info "# Welcome to Yocto Application Developement Tools (ADT) Installer"
34 echo_info "# "
35 echo_info "# Host Machine:\t\t\t\t"$INST_ARCH
36 echo_info "# OS info:\t\t\t\t$INST_KR"
37 echo_info "# Yocto ADT version to be installed:\t$YOCTOADT_VERSION"
38 echo_info "# supported target architectures:\t$YOCTOADT_SUPPORTED_TARGETS"
39 echo_info "# supported target root_fs images:\t$YOCTOADT_SUPPORTED_ROOTFS"
40 echo_info "#########################################################################\n"
41
42 echo_info "Systemwide installation. Installation will occur under $INSTALL_FOLDER\n"
43 echo_info "############################################################################"
44 echo_info "# Your system installation configurations from adt_installer.conf"
45 echo_info "############################################################################"
46
47 echo_info "# Cross toolchains:\t\t$YOCTOADT_TARGETS"
48 echo_info "# Install Qemu:\t\t\t$YOCTOADT_QEMU"
49 echo_info "# Install NFS utilities:\t$YOCTOADT_NFS_UTIL"
50 #echo_info "# Install bitbake + UI:\t\t$YOCTOADT_BITBAKE"
51 #echo_info "# Install metadata:\t$YOCTOADT_METADATA"
52 #echo_info "############################################################################\n"
53
54 echo_info "\n##############################################################################"
55 echo_info "# Your rootfs image(s) and target sysroot selections from adt_installer.conf"
56 echo_info "##############################################################################"
57prompt=1
58for arch_type in $YOCTOADT_TARGETS; do
59 download_images $arch_type $prompt
60done
61 echo_info "############################################################################\n"
62 select_install_type
63}
64
65validate_config()
66{
67
68 for selected_arch_type in $YOCTOADT_TARGETS; do
69 found=0
70 select_machine_var="\$YOCTOADT_TARGET_MACHINE_$selected_arch_type"
71 select_machine=`eval echo $select_machine_var`
72 show_error_banner=0
73
74 for supported_arch_type in $YOCTOADT_SUPPORTED_TARGETS; do
75 if [ "$selected_arch_type" == "$supported_arch_type" ]; then
76 found=1
77 break
78 fi
79 done
80 if [ $found == 0 ]; then
81 echo_info "[ADT_INST] Error: YOCTADT_TARGETS in adt_installer.conf contains invalid entries: $YOCTOADT_TARGETS. Valid values are: $YOCTOADT_SUPPORTED_TARGETS"
82 show_error_banner=1
83 elif [ -z "$select_machine" ]; then
84 echo_info "[ADT_INST] Error: No MACHINE was defined for $selected_arch_type architecture! This is needed to install the toolchain and the correct environment settings."
85 echo_info "[ADT_INST] To do that, in adt-installer.conf, set the following variable: YOCTOADT_TARGET_MACHINE_$selected_arch_type"
86 show_error_banner=1
87 fi
88
89 if [ $show_error_banner == 1 ]; then
90 echo -e "\n#############################################################################"
91 echo -e "# Meet error(s) when installing Yocto ADT! Please check log file for details. "
92 echo -e "#############################################################################\n"
93 exit -1
94 fi
95 done
96
97 for arch_type in $YOCTOADT_SUPPORTED_TARGETS; do
98 #select_target_var="\$YOCTOADT_TARGET_$arch_type"
99 #select_target=`eval echo $select_target_var`
100
101 #if [ "$select_target" != "Y" ] || [ "$selected_target" != "y" ]; then
102 # continue;
103 #fi
104
105 target_sysroot_image_var="\$YOCTOADT_TARGET_SYSROOT_IMAGE_$arch_type"
106 target_sysroot_image=`eval echo $target_sysroot_image_var`
107
108
109 select_rootfs_var="\$YOCTOADT_ROOTFS_$arch_type"
110 select_rootfs=`eval echo $select_rootfs_var`
111
112 if [ "$select_rootfs" == "" ] && [ "$target_sysroot_image" == "" ]; then
113 continue;
114 fi
115
116 for image_type in $select_rootfs; do
117#validate rootfs type defined in YOCTOADT_ROOTFS_{ARCH} is valid and in YOCTOADT_SUPPORTED_ROOTFS
118 found=0
119 for supported_rootfs_type in $YOCTOADT_SUPPORTED_ROOTFS; do
120 if [ "$image_type" == "$supported_rootfs_type" ]; then
121 found=1
122 break
123 fi
124 done
125 if [ $found == 0 ]; then
126#the rootfs type listed for downloading is not valid
127 echo_info "[ADT_INST] Error: Selected YOCTOADT_ROOTFS_$arch_type value: $image_type, is not valid! Valid values are: $YOCTOADT_SUPPORTED_ROOTFS "
128 echo -e "\n#############################################################################"
129 echo -e "# Meet error(s) when installing Yocto ADT! Please check log file for details. "
130 echo -e "#############################################################################\n"
131 exit -1
132 fi
133 done
134
135 found=0
136 for image_type in $select_rootfs; do
137#validate that rootfs to be extracted must be in the item: YOCTOADT_ROOTFS_${ARCH}
138 if [ "$target_sysroot_image" == "$image_type" ]; then
139 found=1
140 break
141 fi
142 done
143# the rootfs image to be extracted is not selected
144 if [ $found == 0 ]; then
145 echo_info "[ADT_INST] Error: YOCTOADT_TARGET_SYSROOT_IMAGE_$arch_type selection: $target_sysroot_image is not included in YOCTOADT_ROOTFS_$arch_type selections: $select_rootfs"
146 echo -e "\n#############################################################################"
147 echo -e "# Meet error(s) when installing Yocto ADT! Please check log file for details. "
148 echo -e "#############################################################################\n"
149 exit -1
150 fi
151 done
152}
153
154
155#detect opkg installed or not, for installing sdk, we will use
156#this installed local opkg
157install_opkg()
158{
159if [ ! -x "$LOCAL_OPKG_LOC/bin/opkg-cl" ]; then
160 echo_info "OPKG is not setup, setting up opkg in local, which is required for installing yocto ADT...\n"
161
162 if [ -d $LOCAL_OPKG_LOC ]; then
163 echo_info "Deleting old OPKG folder, which doesn't contain executables... "
164 rm -rf $LOCAL_OPKG_LOC
165 fi
166
167 parent_folder=`pwd`
168 cd $LOCAL_OPKG_FOLDER
169 check_result
170
171 opkg_source_dir=`ls -d opkg-*`
172
173 if [ $opkg_source_dir == "" ]; then
174 echo_info "[ADT_INST] Error: OPKG source directory is not found!"
175 echo -e "\n#############################################################################"
176 echo -e "# Meet error(s) when installing Yocto ADT! Please check log file for details. "
177 echo -e "#############################################################################\n"
178 exit -1
179 fi
180
181 cd $opkg_source_dir
182 check_result
183
184 echo_info "Configure opkg ...\n"
185 autoreconf
186 ./configure --prefix=$parent_folder/$LOCAL_OPKG_LOC --with-opkglibdir=$OPKG_LIBDIR --enable-shared=no --disable-curl --disable-ssl-curl --disable-gpg --disable-shave >> $parent_folder/$YOCTOADT_INSTALL_LOG_FILE
187 check_result
188
189 echo_info "Make opkg ...\n"
190 make &>> $parent_folder/$YOCTOADT_INSTALL_LOG_FILE
191 check_result
192
193 echo_info "Make Install opkg ...\n"
194 make install &>> $parent_folder/$YOCTOADT_INSTALL_LOG_FILE
195 #if meet error when installing opkg, cancel the installation
196 check_result
197
198 cd $parent_folder
199 echo_info "Successfully installed OPKG.\n"
200fi
201}
202
203confirm_download()
204{
205#avoid repeated reminding
206if [ "$override_oldfile" == 1 ]; then
207 return $pre_result
208else
209 override_oldfile=1
210fi
211
212while true; do
213 #echo_info "[ADT_INST] Files [$1] already exists. If you continue downloading, old files will be overrided."
214 #echo_info "[ADT_INST] Further prompts will not be given if there're more existing files to be downloaded."
215 #echo_info "[ADT_INST] Do you want to continue downloading? Please enter Y/N:"
216 echo_info "\nFile [$1] already exists, which means you've downloaded the qemu kernel and rootfs file(s) before. If you choose continue downloading, old files will be overridden."
217 echo_info "[ADT_INST] Do you want to continue downloading? Please enter Y/N:"
218 read YOCTOADT_INSTALL
219 YOCTOADT_INSTALL=`tr '[a-z]' '[A-Z]'<<<"$YOCTOADT_INSTALL"`
220 if [ "$YOCTOADT_INSTALL" == "Y" ]; then
221 pre_result=0
222 return 0
223 elif [ "$YOCTOADT_INSTALL" == "N" ]; then
224 pre_result=1
225 return 1
226 fi
227done
228}
229
230download_file()
231{
232local filename=`echo ${1##*/}`
233if [ -f "$LOCAL_DOWNLOAD/$filename" ]; then
234 confirm_download $filename
235 result="$?"
236 if [ ! "$result" == "0" ]; then
237 return
238 else
239 echo "Removing old file [$1]"
240 rm -rf "$LOCAL_DOWNLOAD/$filename"
241 fi
242fi
243echo_info "Downloading file: $filename..."
244wget "$YOCTOADT_REPO/rootfs/$1" -P $LOCAL_DOWNLOAD --progress=bar:force 2>&1 | tee -a "$YOCTOADT_INSTALL_LOG_FILE"
245}
246
247
248
249#Need three input params:
250# $1 arch_type(arm powerpc x86 mips)
251# $2 machine(qemuarm beagleboard)
252# $3 rootfs_image_type (a list of sdk sato minimal lsb)
253get_image()
254{
255 local machine=$2
256
257 if [ "$1" == "x86" ] || [ "$1" == "x86_64" ]; then
258 kernel="bzImage-$machine.bin"
259 elif [ "$1" == "ppc" ] || [ "$1" == "mips" ]; then
260 kernel="vmlinux-$machine.bin"
261 else
262 kernel="zImage-$machine.bin"
263 fi
264
265 #echo_info "[ADT_INST] Downloading qemu kernel binary: $qemu_kernel"
266 download_file $machine/$kernel
267 check_result
268
269 for image_type in $select_rootfs; do
270 #echo_info "[ADT_INST] Downloading rootfs file: core-image-$image_type-$machine.tar.bz2"
271 filename="core-image-$image_type-$machine.tar.bz2"
272 download_file $machine/$filename
273 check_result
274 done
275}
276
277download_images()
278{
279 select_rootfs_var="\$YOCTOADT_ROOTFS_$1"
280 select_sysroot_image_var="\$YOCTOADT_TARGET_SYSROOT_IMAGE_$1"
281 select_sysroot_var="\$YOCTOADT_TARGET_SYSROOT_LOC_$1"
282 select_machine_var="\$YOCTOADT_TARGET_MACHINE_$1"
283 select_rootfs=`eval echo $select_rootfs_var`
284 select_sysroot_image=`eval echo $select_sysroot_image_var`
285 select_sysroot=`eval echo $select_sysroot_var`
286 select_machine=`eval echo $select_machine_var`
287
288 if [ -n "$select_sysroot" ]; then
289 select_sysroot=`readlink -m $select_sysroot`
290 fi
291
292 if [ "$select_rootfs" != "" ]; then
293 if [ $2 ]; then
294 #echo_info "\n############################################################################"
295 #echo_info "# To be downloaded rootfs image details defined in adt_installer.conf"
296 #echo_info "############################################################################"
297 echo_info "# Target architecture:\t\t$1"
298 echo_info "# Target machine:\t\t$select_machine"
299 echo_info "# Root_fs images:\t\t$select_rootfs"
300 echo_info "# Target sysroot image:\t\t$select_sysroot_image"
301 echo_info "# Target sysroot loc:\t\t$select_sysroot"
302 echo_info "\n"
303 #echo_info "############################################################################\n"
304 else
305 get_image $1 $select_machine $select_rootfs
306 fi
307 fi
308}
309
310
311
312
313#Main body of installer
314
315clear
316
317run_path=`dirname $0`
318cd $run_path
319
320if [ ! -f "scripts/util" ]; then
321 echo -e "[ADT_INST] Error: Script file: util, can't be found under: $run_path!"
322 echo -e "\n#############################################################################"
323 echo -e "# Meet error(s) when installing Yocto ADT! Please check log file for details. "
324 echo -e "#############################################################################\n"
325 exit -1
326fi
327
328if [ ! -f "scripts/adt_installer_internal" ]; then
329 echo -e "[ADT_INST] Error: Script file: adt_installer_internal, can't be found under: $run_path!"
330 echo -e "\n#############################################################################"
331 echo -e "# Meet error(s) when installing Yocto ADT! Please check log file for details. "
332 echo -e "#############################################################################\n"
333 exit -1
334fi
335
336config_file="adt_installer.conf"
337if [ ! -f "$config_file" ]; then
338 echo_info "[ADT_INST] Error: Installation configuration file: adt_installer.conf is not found!\n"
339 echo_info "\n##################################################################################"
340 echo_info "# Meet error(s) when installing Yocto ADT. Please check log file for details. "
341 echo_info "##################################################################################\n"
342 exit -1
343fi
344
345. scripts/data_define
346. scripts/util
347
348
349if [ -f "$YOCTOADT_INSTALL_LOG_FILE" ]; then
350 rm $YOCTOADT_INSTALL_LOG_FILE
351fi
352
353echo -n "Please enter the install location (default: $DEFAULT_INSTALL_FOLDER): "
354read INSTALL_FOLDER
355
356if [ "$INSTALL_FOLDER" = "" ]; then
357 INSTALL_FOLDER=$DEFAULT_INSTALL_FOLDER
358fi
359
360eval INSTALL_FOLDER=$(printf "%q" "$INSTALL_FOLDER")
361if [ -d "$INSTALL_FOLDER" ]; then
362 export INSTALL_FOLDER=$(cd "$INSTALL_FOLDER"; pwd)
363else
364 export INSTALL_FOLDER=$(readlink -m "$INSTALL_FOLDER")
365fi
366
367if [ -n "$(echo $INSTALL_FOLDER|grep ' ')" ]; then
368 echo "The target directory path ($INSTALL_FOLDER) contains spaces. Abort!"
369 exit 1
370fi
371
372clear
373
374usage
375
376user_inst_type="$?"
377
378validate_config
379check_result
380
381#check adt_repo exist
382wget --spider $YOCTOADT_REPO 2>&1 | tee -a "$YOCTOADT_INSTALL_LOG_FILE"
383if grep -q "404 Not Found" $YOCTOADT_INSTALL_LOG_FILE; then
384 echo -e "[ADT_INST] Error: YOCTOADT_REPO does not exist: $YOCTOADT_REPO"
385 echo -e "\n#############################################################################"
386 echo -e "# Meet error(s) when installing Yocto ADT! Please check log file for details. "
387 echo -e "#############################################################################\n"
388 exit -1
389fi
390
391#firstly we need to install opkg host
392install_opkg
393
394#Create folders for holding rootfs/qemu images
395if [ ! -d "$LOCAL_DOWNLOAD" ]; then
396 echo_info "Creating new images downloading folder: $LOCAL_DOWNLOAD ..."
397 mkdir -p $LOCAL_DOWNLOAD
398fi
399
400#downloading required qemu images/rootfs
401if [ "$user_inst_type" == "0" ]; then
402 override_oldfile=1
403else
404 override_oldfile=0
405fi
406
407for arch_type in $YOCTOADT_TARGETS; do
408 download_images $arch_type
409done
410
411scripts/adt_installer_internal $user_inst_type
412
413result="$?"
414#echo_info "\n############################################################"
415if [ "$result" == "0" ]; then
416 echo_info "\n############################################################"
417 echo_info "# Yocto ADT has been successfully installed."
418 echo_info "############################################################\n"
419fi
420