aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/installer/adt-installer/scripts/adt_installer_internal
blob: 0fd9e47e98e896b70dbf096fadbfbc7809e673b6 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#!/bin/bash

# Yocto ADT Installer
#
# Copyright 2010-2011 by Intel Corp.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy 
# of this software and associated documentation files (the "Software"), to deal 
# in the Software without restriction, including without limitation the rights 
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
# copies of the Software, and to permit persons to whom the Software is 
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in 
# all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
# THE SOFTWARE.

parse_config()
{
  INST_ARCH=`uname -m`

  case $INST_ARCH in 
  i[3-6]86)
    OPKG_CONFIG_FILE=$YOCTOADT_OPKG_CONF_FILE_32
    POKY_NATIVE_SYSROOT="$INSTALL_FOLDER/sysroots/$INST_ARCH-pokysdk-linux/"
    ;;
  x86_64)
    OPKG_CONFIG_FILE=$YOCTOADT_OPKG_CONF_FILE_64
    POKY_NATIVE_SYSROOT="$INSTALL_FOLDER/sysroots/x86_64-pokysdk-linux/"
    ;;
  *)
    echo_info "[ADT_INST] Error: Installation Machine is not supported!"
    exit -1
    ;;
  esac
}


#let us install a qemu-native firstly
#installation step 2
install_native_sdk()
{

echo_info "\nStart installing selected native ADT for archs: $YOCTOADT_TARGETS..."

# where the packages are installed. Currently only / is supported
NATIVE_INSTALL_DIR="/"

if [ -d "$INSTALL_FOLDER" ]; then
  echo_info "\nNative ADT installation directory \"$INSTALL_FOLDER\" already exists! Continue installation will override its contents!"
  confirm_install $1
fi

#Now begin to install native sdk and extract qemu rootfs which needs privilege rights
echo_info "#######################################################################"
echo_info "Please note from this point on installation requires sudo password ..."
echo_info "#######################################################################"
username='id -nu'
#we need to make this directory firstly since opkg need to use it.
OPKG_LOCK_DIR="$NATIVE_INSTALL_DIR/$OPKG_LIBDIR/opkg"
if [ ! -d "$OPKG_LOCK_DIR" ]; then
  sudo mkdir -p $OPKG_LOCK_DIR
  echo_info "Successfully create directory $OPKG_LOCK_DIR. "
#if user delete /opt/poky, while dangling folders there, report error
elif [ ! -d "$INSTALL_FOLDER" ]; then
  echo_info "\nDangling opkg cache folder $OPKG_LOCK_DIR detected. Continue installation will remove the folder!"
  confirm_install $1
  sudo rm -rf $OPKG_LOCK_DIR
  sudo mkdir -p $OPKG_LOCK_DIR
#if user are updating installing, just let him/her go, give her/him prompt
else
  echo_info "ADT has already been installed. Will update its contents..."
fi

#first update repository
OPKG_CMD="sudo -E $LOCAL_OPKG_LOC/bin/opkg-cl"

echo_info "Updating opkg..."
$OPKG_CMD -f $OPKG_CONFIG_FILE -o $NATIVE_INSTALL_DIR update &>> $YOCTOADT_INSTALL_LOG_FILE
echo_info "opkg update process ended..."
check_result

#install below must sdk-host packages
OPKG_INSTALL_CMD="$OPKG_CMD "
OPKG_INSTALL_NATIVE_CMD="$OPKG_INSTALL_CMD  -f $OPKG_CONFIG_FILE -o $NATIVE_INSTALL_DIR install"

echo_info "Installing pseudo nativesdk ...\n"
$OPKG_INSTALL_NATIVE_CMD pseudo-nativesdk &>> $YOCTOADT_INSTALL_LOG_FILE
check_result
echo_info "Installing opkg nativesdk ...\n"
$OPKG_INSTALL_NATIVE_CMD opkg-nativesdk &>> $YOCTOADT_INSTALL_LOG_FILE
check_result
echo_info "Installing pkgconfig nativesdk ...\n"
$OPKG_INSTALL_NATIVE_CMD pkgconfig-nativesdk &>> $YOCTOADT_INSTALL_LOG_FILE
check_result
echo_info "Installing libtool nativesdk ...\n"
$OPKG_INSTALL_NATIVE_CMD libtool-nativesdk &>> $YOCTOADT_INSTALL_LOG_FILE
check_result

for native_target_type in $YOCTOADT_TARGETS; do
  native_target_type=`echo "$native_target_type" | sed -e 's/x86_64/x86-64/' -e 's/ppc/powerpc/'  -e 's/x86$/i586/'`
  echo_info "Installing cross toolchain for $native_target_type ..."
  echo_info "Installing binutils for $native_target_type ..."
  $OPKG_INSTALL_NATIVE_CMD binutils-cross-canadian-$native_target_type &>> $YOCTOADT_INSTALL_LOG_FILE
  check_result
  echo_info "Installing gcc for $native_target_type ..."
  $OPKG_INSTALL_NATIVE_CMD gcc-cross-canadian-$native_target_type &>> $YOCTOADT_INSTALL_LOG_FILE
  check_result
  echo_info "Installing gdb for $native_target_type ..."
  $OPKG_INSTALL_NATIVE_CMD gdb-cross-canadian-$native_target_type &>> $YOCTOADT_INSTALL_LOG_FILE
  check_result

  echo_info "Installing envrionement file for $native_target_type ..."
  $OPKG_INSTALL_NATIVE_CMD meta-environment-$native_target_type &>> $YOCTOADT_INSTALL_LOG_FILE
  check_result

done

# Link the ld.so.cache file into the hosts filesystem
if [ ! -f "$POKY_NATIVE_SYSROOT/etc/ld.so.cache" ]; then 
echo_info "Link the ld.so.cache file into the host filesystem"
sudo ln -s /etc/ld.so.cache $POKY_NATIVE_SYSROOT/etc/ld.so.cache
check_result
fi

if [ "$YOCTOADT_QEMU" == "Y" ] || [ "$YOCTOADT_QEMU" = "y" ]; then
  echo_info "\nInstalling qemu native ..."
  $OPKG_INSTALL_NATIVE_CMD qemu-nativesdk &>> $YOCTOADT_INSTALL_LOG_FILE
  check_result
  $OPKG_INSTALL_NATIVE_CMD qemu-helper-nativesdk &>> $YOCTOADT_INSTALL_LOG_FILE
  check_result
fi

if [ "$YOCTOADT_NFS_UTIL" == "Y" ] || [ "$YOCTOADT_NFS_UTIL" == "y" ]; then
  echo_info "\nInstalling unfs ..."
  $OPKG_INSTALL_NATIVE_CMD unfs-server-nativesdk &>> $YOCTOADT_INSTALL_LOG_FILE
  check_result
fi

echo_info "\nSuccessfully installed selected native ADT!"
}

#Need three input params, $1 -- arch_type(arm powerpc x86 mips) #2 -- user installation type
#customer or scilent

install_target()
{

# rootfs extraction directory
target_sysroot_var="\$YOCTOADT_TARGET_SYSROOT_LOC_$1"
target_sysroot=`eval echo $target_sysroot_var`

if [ "$target_sysroot" == "" ]; then
  return 0
fi

target_sysroot_image_var="\$YOCTOADT_TARGET_SYSROOT_IMAGE_$1"
target_sysroot_image=`eval echo $target_sysroot_image_var`
if [ "$target_sysroot_image" == "" ]; then
  echo_info "[ADT_INST] Error: YOCTOADT_TARGET_SYSROOT_IMAGE_$1 selection is empty, failed to create target sysroot!"
  return 1
fi

echo_info "Installing target sysroot for arch: $1, rootfs type: $target_sysroot_image, location: $target_sysroot"


qemu_type=`echo "$1" | sed -e 's/x86_64/x86-64/'`
sysroot_image_name="core-image-$target_sysroot_image-qemu$qemu_type.tar.bz2"
    #echo_info "Extracting rootfs: $sysroot_image_name, using pseudo..."

scripts/extract_rootfs $sysroot_image_name $target_sysroot $POKY_NATIVE_SYSROOT $user_inst_type
check_result

echo_info "Updating environment script with target sysroot location."
if [ "$1" == "x86"  ]; then
  env_filename=`ls $INSTALL_FOLDER/environment-setup-i586*`
else
  env_filename=`ls $INSTALL_FOLDER/environment-setup-$1*`
fi

if [ ! -z "$env_filename" ]; then
  sudo sed -i -e "s%##SDKTARGETSYSROOT##%$target_sysroot%g" $env_filename
else
  echo_info "[ADT_INST] Error: Failed to find environment script for arch: $1"
  return 1 
fi


}


#Main part
. scripts/data_define
. scripts/util

parse_config

#secondly we will start to install native tools
user_inst_type=$1
install_native_sdk $user_inst_type
check_result

for arch_type in $YOCTOADT_SUPPORTED_TARGETS; do
  install_target $arch_type
  check_result
done