summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/installer/adt-installer/scripts/adt_installer_internal
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/installer/adt-installer/scripts/adt_installer_internal')
-rwxr-xr-xmeta/recipes-devtools/installer/adt-installer/scripts/adt_installer_internal300
1 files changed, 300 insertions, 0 deletions
diff --git a/meta/recipes-devtools/installer/adt-installer/scripts/adt_installer_internal b/meta/recipes-devtools/installer/adt-installer/scripts/adt_installer_internal
new file mode 100755
index 0000000000..2eb13a9044
--- /dev/null
+++ b/meta/recipes-devtools/installer/adt-installer/scripts/adt_installer_internal
@@ -0,0 +1,300 @@
1#!/bin/bash
2
3# Yocto ADT Installer
4#
5# Copyright 2010-2011 by Intel Corp.
6#
7# Permission is hereby granted, free of charge, to any person obtaining a copy
8# of this software and associated documentation files (the "Software"), to deal
9# in the Software without restriction, including without limitation the rights
10# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11# copies of the Software, and to permit persons to whom the Software is
12# furnished to do so, subject to the following conditions:
13
14# The above copyright notice and this permission notice shall be included in
15# all copies or substantial portions of the Software.
16
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23# THE SOFTWARE.
24
25parse_config()
26{
27 INST_ARCH=`uname -m`
28
29 case $INST_ARCH in
30 i[3-6]86)
31 OPKG_CONFIG_FILE=$YOCTOADT_OPKG_CONF_FILE_32
32 OECORE_NATIVE_SYSROOT="$INSTALL_FOLDER/sysroots/$INST_ARCH$SDK_VENDOR-linux/"
33 ;;
34 x86_64)
35 OPKG_CONFIG_FILE=$YOCTOADT_OPKG_CONF_FILE_64
36 OECORE_NATIVE_SYSROOT="$INSTALL_FOLDER/sysroots/x86_64$SDK_VENDOR-linux/"
37 ;;
38 *)
39 echo_info "[ADT_INST] Error: Installation Machine is not supported!"
40 exit -1
41 ;;
42 esac
43}
44
45get_sudo_app()
46{
47 username=$(id -nu)
48
49 # find the owner of the parent
50 dir=$1
51 while [ 1 ]; do
52 if [ -d $dir ]; then
53 owner=$(stat -c %U $dir)
54 break
55 else
56 dir=$(dirname $dir)
57 fi
58 done
59
60 if [ "$owner" = "$username" ]; then
61 true
62 else
63 echo sudo
64 fi
65}
66
67
68#let us install a qemu-native firstly
69#installation step 2
70install_native_sdk()
71{
72
73echo_info "\nStart installing selected native ADT for archs: $YOCTOADT_TARGETS..."
74
75# where the packages are installed.
76NATIVE_INSTALL_DIR=$INSTALL_FOLDER
77
78if [ -d "$INSTALL_FOLDER" ]; then
79 echo_info "\nNative ADT installation directory \"$INSTALL_FOLDER\" already exists! Continue installation will override its contents!"
80 confirm_install $1
81fi
82
83#Now begin to install native sdk and extract qemu rootfs which needs privilege rights
84#depending on the install location
85SUDO=$(get_sudo_app $NATIVE_INSTALL_DIR)
86if [ -n "$SUDO" ]; then
87 echo_info "#######################################################################"
88 echo_info "Please note from this point on installation requires sudo password ..."
89 echo_info "#######################################################################"
90fi
91
92#we need to make this directory firstly since opkg need to use it.
93OPKG_LOCK_DIR="$NATIVE_INSTALL_DIR/$OPKG_LIBDIR/opkg"
94if [ ! -d "$OPKG_LOCK_DIR" ]; then
95 $SUDO mkdir -p $OPKG_LOCK_DIR
96 echo_info "Successfully create directory $OPKG_LOCK_DIR. "
97#if user delete /opt/xxx, while dangling folders there, report error
98elif [ ! -d "$INSTALL_FOLDER" ]; then
99 echo_info "\nDangling opkg cache folder $OPKG_LOCK_DIR detected. Continue installation will remove the folder!"
100 confirm_install $1
101 $SUDO rm -rf $OPKG_LOCK_DIR
102 $SUDO mkdir -p $OPKG_LOCK_DIR
103#if user are updating installing, just let him/her go, give her/him prompt
104else
105 echo_info "ADT has already been installed. Will update its contents..."
106fi
107
108#first update repository
109if [ "x$SUDO" = "x" ]; then
110 OPKG_CMD="$LOCAL_OPKG_LOC/bin/opkg-cl"
111else
112 OPKG_CMD="sudo -E $LOCAL_OPKG_LOC/bin/opkg-cl"
113fi
114
115echo_info "Updating opkg..."
116$OPKG_CMD -f $OPKG_CONFIG_FILE -o $NATIVE_INSTALL_DIR update &>> $YOCTOADT_INSTALL_LOG_FILE
117echo_info "opkg update process ended..."
118check_result
119
120#install below must sdk-host packages
121OPKG_INSTALL_CMD="$OPKG_CMD "
122OPKG_INSTALL_NATIVE_CMD="$OPKG_INSTALL_CMD --force-overwrite -f $OPKG_CONFIG_FILE -o $NATIVE_INSTALL_DIR install"
123
124BASE_HOSTSDK_PKGNAMES="pseudo opkg pkgconfig libtool autoconf automake"
125for pkg in $BASE_HOSTSDK_PKGNAMES; do
126 echo_info "Installing ${pkg} nativesdk ...\n"
127 $OPKG_INSTALL_NATIVE_CMD nativesdk-${pkg} &>> $YOCTOADT_INSTALL_LOG_FILE
128 check_result
129done
130
131for target_type in $YOCTOADT_TARGETS; do
132 machine_var="\$YOCTOADT_TARGET_MACHINE_$target_type"
133 machine=`eval echo $machine_var`
134 echo_info "Installing cross canadian packages for $machine ..."
135 $OPKG_INSTALL_NATIVE_CMD packagegroup-cross-canadian-$machine &>> $YOCTOADT_INSTALL_LOG_FILE
136 check_result
137done
138
139if [ "$YOCTOADT_QEMU" == "Y" ] || [ "$YOCTOADT_QEMU" = "y" ]; then
140 echo_info "\nInstalling qemu native ..."
141 $OPKG_INSTALL_NATIVE_CMD nativesdk-qemu &>> $YOCTOADT_INSTALL_LOG_FILE
142 check_result
143 $OPKG_INSTALL_NATIVE_CMD nativesdk-qemu-helper &>> $YOCTOADT_INSTALL_LOG_FILE
144 check_result
145fi
146
147if [ "$YOCTOADT_NFS_UTIL" == "Y" ] || [ "$YOCTOADT_NFS_UTIL" == "y" ]; then
148 echo_info "\nInstalling unfs ..."
149 $OPKG_INSTALL_NATIVE_CMD nativesdk-unfs-server &>> $YOCTOADT_INSTALL_LOG_FILE
150 check_result
151fi
152
153# Lose the ./opt/${DISTRO}/${SDK_VERSION} part, we don't really need to keep
154# the entire directory structure. We could patch opkg to do that but it's far
155# simpler to do that here and achieve the same result.
156# This is done in two steps:
157if [ -d $NATIVE_INSTALL_DIR/$DEFAULT_INSTALL_FOLDER ]; then
158 # Step 1: copy ./opt/${DISTRO}/${SDK_VERSION} contents to $NATIVE_INSTALL_DIR.
159 # We cannot use move if $NATIVE_INSTALL_DIR is not empty (for example: contains
160 # another SDK)
161 $SUDO cp -r $NATIVE_INSTALL_DIR/$DEFAULT_INSTALL_FOLDER/* $NATIVE_INSTALL_DIR
162
163 # delete the source directory now
164 $SUDO rm -rf $NATIVE_INSTALL_DIR/$DEFAULT_INSTALL_FOLDER/*
165
166 # Step 2: Delete the ./opt/${DISTRO}/${SDK_VERSION} directories too, they should be empty
167 dir=$NATIVE_INSTALL_DIR/$DEFAULT_INSTALL_FOLDER
168 while [ "$dir" != "$NATIVE_INSTALL_DIR" ]; do
169 # if the user chose / as the install folder, then we should leave /opt in place
170 if [ "$dir" = "/opt" ]; then
171 break
172 fi
173
174 # try to delete the directory, only if it's empty
175 $SUDO rmdir $dir
176 if [ $? -ne 0 ]; then
177 break
178 fi
179
180 # go to the next directory
181 dir=$(dirname $dir)
182 done
183fi
184
185# Link the ld.so.cache file into the hosts filesystem
186if [ ! -f "$OECORE_NATIVE_SYSROOT/etc/ld.so.cache" ]; then
187echo_info "Link the ld.so.cache file into the host filesystem"
188$SUDO ln -s /etc/ld.so.cache $OECORE_NATIVE_SYSROOT/etc/ld.so.cache
189check_result
190fi
191
192# relocate binaries
193echo_info "\nRelocating binaries ..."
194escaped_sdkpath=$(echo $DEFAULT_INSTALL_FOLDER |sed -e "s:[\+\.]:\\\\\\\\\0:g")
195
196# We don't change the script in-place since we may want the user to re-run
197# adt-installer script
198sed -e "s:##DEFAULT_INSTALL_DIR##:$escaped_sdkpath:" scripts/relocate_sdk.py > scripts/relocate_sdk_tmp.py
199chmod +x scripts/relocate_sdk_tmp.py
200
201dl_path=$(find $OECORE_NATIVE_SYSROOT/lib -name "ld-linux*")
202executable_files=$(find $OECORE_NATIVE_SYSROOT -type f -perm /111)
203
204$SUDO scripts/relocate_sdk_tmp.py $INSTALL_FOLDER $dl_path $executable_files
205check_result
206
207# replace /opt/${DISTRO}/${SDK_VERSION} with the install folder in all configs
208env_setup_script=$(find $NATIVE_INSTALL_DIR/ -name "environment-setup-*")
209$SUDO sed -i -e "s:$DEFAULT_INSTALL_FOLDER:$NATIVE_INSTALL_DIR:g" $env_setup_script
210
211find $OECORE_NATIVE_SYSROOT -type f -exec file '{}' \; | grep ":.*\(ASCII\|script\|source\).*text" | \
212 cut -d':' -f1 | xargs $SUDO sed -i -e "s:$DEFAULT_INSTALL_FOLDER:$NATIVE_INSTALL_DIR:g"
213
214# change all symlinks pointing to /opt/${DISTRO}/${SDK_VERSION}
215for l in $(find $NATIVE_INSTALL_DIR -type l); do
216 $SUDO ln -sfn $(readlink $l|sed -e "s:$DEFAULT_INSTALL_FOLDER:$NATIVE_INSTALL_DIR:") $l
217done
218
219# find out all perl scripts in $OECORE_NATIVE_SYSROOT and modify them
220# replacing the host perl with SDK perl.
221for perl_script in $($SUDO grep -m 1 "^#!.*perl" -rl $OECORE_NATIVE_SYSROOT); do
222 $SUDO sed -i -e "s:^#! */usr/bin/perl.*:#! /usr/bin/env perl:g" -e \
223 "s: /usr/bin/perl: /usr/bin/env perl:g" $perl_script
224done
225
226echo_info "\nSuccessfully installed selected native ADT!"
227}
228
229#Need three input params, $1 -- arch_type(arm powerpc x86 mips) #2 -- user installation type
230#customer or scilent
231
232install_target()
233{
234
235# rootfs extraction directory
236target_sysroot_var="\$YOCTOADT_TARGET_SYSROOT_LOC_$1"
237target_sysroot=`eval echo $target_sysroot_var`
238
239if [ "$target_sysroot" == "" ]; then
240 return 0
241else
242 target_sysroot=`readlink -m $target_sysroot`
243fi
244
245target_sysroot_image_var="\$YOCTOADT_TARGET_SYSROOT_IMAGE_$1"
246target_sysroot_image=`eval echo $target_sysroot_image_var`
247if [ "$target_sysroot_image" == "" ]; then
248 echo_info "[ADT_INST] Error: YOCTOADT_TARGET_SYSROOT_IMAGE_$1 selection is empty, failed to create target sysroot!"
249 return 1
250fi
251
252echo_info "Installing target sysroot for arch: $1, rootfs type: $target_sysroot_image, location: $target_sysroot"
253
254target_machine_var="\$YOCTOADT_TARGET_MACHINE_$1"
255target_machine=`eval echo $target_machine_var`
256sysroot_image_name="core-image-$target_sysroot_image-$target_machine.tar.bz2"
257 #echo_info "Extracting rootfs: $sysroot_image_name, using pseudo..."
258
259# sudo password might be needed to install the target sysroot
260SUDO=$(get_sudo_app $target_sysroot)
261
262$SUDO scripts/extract_rootfs $sysroot_image_name $target_sysroot $OECORE_NATIVE_SYSROOT $user_inst_type
263check_result
264
265echo_info "Updating environment script with target sysroot location."
266if [ "$1" == "x86" ]; then
267 env_filename=`ls $INSTALL_FOLDER/environment-setup-i586*`
268else
269 env_filename=`ls $INSTALL_FOLDER/environment-setup-$1*`
270fi
271
272if [ ! -z "$env_filename" ]; then
273 SUDO=$(get_sudo_app $INSTALL_FOLDER)
274 $SUDO sed -i -e "s%##SDKTARGETSYSROOT##%$target_sysroot%g" $env_filename
275else
276 echo_info "[ADT_INST] Error: Failed to find environment script for arch: $1"
277 return 1
278fi
279
280
281}
282
283
284#Main part
285. scripts/data_define
286. scripts/util
287
288parse_config
289
290#secondly we will start to install native tools
291user_inst_type=$1
292install_native_sdk $user_inst_type
293check_result
294
295for arch_type in $YOCTOADT_SUPPORTED_TARGETS; do
296 install_target $arch_type
297 check_result
298done
299
300