diff options
| author | Laurentiu Palcu <laurentiu.palcu@intel.com> | 2012-08-17 13:38:11 +0300 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-08-17 13:06:42 +0100 |
| commit | 3ba29d41e6e00cc6bedfcb2d5157db54b6bcfda0 (patch) | |
| tree | e2102ddc9147c5a13b6c14c3b7007251297e0f15 | |
| parent | 21049ec9644510a81aba748ad81fb6a73a711f21 (diff) | |
| download | poky-3ba29d41e6e00cc6bedfcb2d5157db54b6bcfda0.tar.gz | |
adt-installer: add support for relocatable SDK
Since we made the SDK relocatable, we have to add this functionality to
adt-installer too.
(From OE-Core rev: 0fa784c261050c632b7237ba3d43a148ab71b0ca)
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
3 files changed, 108 insertions, 21 deletions
diff --git a/meta/recipes-devtools/installer/adt-installer/adt_installer b/meta/recipes-devtools/installer/adt-installer/adt_installer index 1a53eb9c54..2d252b72ad 100755 --- a/meta/recipes-devtools/installer/adt-installer/adt_installer +++ b/meta/recipes-devtools/installer/adt-installer/adt_installer | |||
| @@ -332,6 +332,17 @@ if [ -f "$YOCTOADT_INSTALL_LOG_FILE" ]; then | |||
| 332 | rm $YOCTOADT_INSTALL_LOG_FILE | 332 | rm $YOCTOADT_INSTALL_LOG_FILE |
| 333 | fi | 333 | fi |
| 334 | 334 | ||
| 335 | echo -n "Please enter the install location (default: $DEFAULT_INSTALL_FOLDER): " | ||
| 336 | read INSTALL_FOLDER | ||
| 337 | |||
| 338 | if [ "$INSTALL_FOLDER" = "" ]; then | ||
| 339 | INSTALL_FOLDER=$DEFAULT_INSTALL_FOLDER | ||
| 340 | fi | ||
| 341 | |||
| 342 | eval INSTALL_FOLDER=$INSTALL_FOLDER | ||
| 343 | export INSTALL_FOLDER=$(readlink -m $INSTALL_FOLDER) | ||
| 344 | |||
| 345 | clear | ||
| 335 | 346 | ||
| 336 | usage | 347 | usage |
| 337 | 348 | ||
diff --git a/meta/recipes-devtools/installer/adt-installer/scripts/adt_installer_internal b/meta/recipes-devtools/installer/adt-installer/scripts/adt_installer_internal index 6201095117..a540c0d8ff 100755 --- a/meta/recipes-devtools/installer/adt-installer/scripts/adt_installer_internal +++ b/meta/recipes-devtools/installer/adt-installer/scripts/adt_installer_internal | |||
| @@ -50,8 +50,8 @@ install_native_sdk() | |||
| 50 | 50 | ||
| 51 | echo_info "\nStart installing selected native ADT for archs: $YOCTOADT_TARGETS..." | 51 | echo_info "\nStart installing selected native ADT for archs: $YOCTOADT_TARGETS..." |
| 52 | 52 | ||
| 53 | # where the packages are installed. Currently only / is supported | 53 | # where the packages are installed. |
| 54 | NATIVE_INSTALL_DIR="/" | 54 | NATIVE_INSTALL_DIR=$INSTALL_FOLDER |
| 55 | 55 | ||
| 56 | if [ -d "$INSTALL_FOLDER" ]; then | 56 | if [ -d "$INSTALL_FOLDER" ]; then |
| 57 | echo_info "\nNative ADT installation directory \"$INSTALL_FOLDER\" already exists! Continue installation will override its contents!" | 57 | echo_info "\nNative ADT installation directory \"$INSTALL_FOLDER\" already exists! Continue installation will override its contents!" |
| @@ -59,28 +59,51 @@ if [ -d "$INSTALL_FOLDER" ]; then | |||
| 59 | fi | 59 | fi |
| 60 | 60 | ||
| 61 | #Now begin to install native sdk and extract qemu rootfs which needs privilege rights | 61 | #Now begin to install native sdk and extract qemu rootfs which needs privilege rights |
| 62 | echo_info "#######################################################################" | 62 | #depending on the install location |
| 63 | echo_info "Please note from this point on installation requires sudo password ..." | 63 | username=$(id -nu) |
| 64 | echo_info "#######################################################################" | 64 | |
| 65 | username='id -nu' | 65 | # find the owner of the parent |
| 66 | dir=$NATIVE_INSTALL_DIR | ||
| 67 | while [ 1 ]; do | ||
| 68 | if [ -d $dir ]; then | ||
| 69 | owner=$(stat -c %U $dir) | ||
| 70 | break | ||
| 71 | else | ||
| 72 | dir=$(dirname $dir) | ||
| 73 | fi | ||
| 74 | done | ||
| 75 | |||
| 76 | if [ "$owner" = "$username" ]; then | ||
| 77 | SUDO="" | ||
| 78 | else | ||
| 79 | echo_info "#######################################################################" | ||
| 80 | echo_info "Please note from this point on installation requires sudo password ..." | ||
| 81 | echo_info "#######################################################################" | ||
| 82 | SUDO=sudo | ||
| 83 | fi | ||
| 84 | |||
| 66 | #we need to make this directory firstly since opkg need to use it. | 85 | #we need to make this directory firstly since opkg need to use it. |
| 67 | OPKG_LOCK_DIR="$NATIVE_INSTALL_DIR/$OPKG_LIBDIR/opkg" | 86 | OPKG_LOCK_DIR="$NATIVE_INSTALL_DIR/$OPKG_LIBDIR/opkg" |
| 68 | if [ ! -d "$OPKG_LOCK_DIR" ]; then | 87 | if [ ! -d "$OPKG_LOCK_DIR" ]; then |
| 69 | sudo mkdir -p $OPKG_LOCK_DIR | 88 | $SUDO mkdir -p $OPKG_LOCK_DIR |
| 70 | echo_info "Successfully create directory $OPKG_LOCK_DIR. " | 89 | echo_info "Successfully create directory $OPKG_LOCK_DIR. " |
| 71 | #if user delete /opt/xxx, while dangling folders there, report error | 90 | #if user delete /opt/xxx, while dangling folders there, report error |
| 72 | elif [ ! -d "$INSTALL_FOLDER" ]; then | 91 | elif [ ! -d "$INSTALL_FOLDER" ]; then |
| 73 | echo_info "\nDangling opkg cache folder $OPKG_LOCK_DIR detected. Continue installation will remove the folder!" | 92 | echo_info "\nDangling opkg cache folder $OPKG_LOCK_DIR detected. Continue installation will remove the folder!" |
| 74 | confirm_install $1 | 93 | confirm_install $1 |
| 75 | sudo rm -rf $OPKG_LOCK_DIR | 94 | $SUDO rm -rf $OPKG_LOCK_DIR |
| 76 | sudo mkdir -p $OPKG_LOCK_DIR | 95 | $SUDO mkdir -p $OPKG_LOCK_DIR |
| 77 | #if user are updating installing, just let him/her go, give her/him prompt | 96 | #if user are updating installing, just let him/her go, give her/him prompt |
| 78 | else | 97 | else |
| 79 | echo_info "ADT has already been installed. Will update its contents..." | 98 | echo_info "ADT has already been installed. Will update its contents..." |
| 80 | fi | 99 | fi |
| 81 | 100 | ||
| 82 | #first update repository | 101 | #first update repository |
| 83 | OPKG_CMD="sudo -E $LOCAL_OPKG_LOC/bin/opkg-cl" | 102 | if [ "x$SUDO" = "x" ]; then |
| 103 | OPKG_CMD="$LOCAL_OPKG_LOC/bin/opkg-cl" | ||
| 104 | else | ||
| 105 | OPKG_CMD="sudo -E $LOCAL_OPKG_LOC/bin/opkg-cl" | ||
| 106 | fi | ||
| 84 | 107 | ||
| 85 | echo_info "Updating opkg..." | 108 | echo_info "Updating opkg..." |
| 86 | $OPKG_CMD -f $OPKG_CONFIG_FILE -o $NATIVE_INSTALL_DIR update &>> $YOCTOADT_INSTALL_LOG_FILE | 109 | $OPKG_CMD -f $OPKG_CONFIG_FILE -o $NATIVE_INSTALL_DIR update &>> $YOCTOADT_INSTALL_LOG_FILE |
| @@ -117,13 +140,6 @@ for native_target_type in $YOCTOADT_TARGETS; do | |||
| 117 | 140 | ||
| 118 | done | 141 | done |
| 119 | 142 | ||
| 120 | # Link the ld.so.cache file into the hosts filesystem | ||
| 121 | if [ ! -f "$OECORE_NATIVE_SYSROOT/etc/ld.so.cache" ]; then | ||
| 122 | echo_info "Link the ld.so.cache file into the host filesystem" | ||
| 123 | sudo ln -s /etc/ld.so.cache $OECORE_NATIVE_SYSROOT/etc/ld.so.cache | ||
| 124 | check_result | ||
| 125 | fi | ||
| 126 | |||
| 127 | if [ "$YOCTOADT_QEMU" == "Y" ] || [ "$YOCTOADT_QEMU" = "y" ]; then | 143 | if [ "$YOCTOADT_QEMU" == "Y" ] || [ "$YOCTOADT_QEMU" = "y" ]; then |
| 128 | echo_info "\nInstalling qemu native ..." | 144 | echo_info "\nInstalling qemu native ..." |
| 129 | $OPKG_INSTALL_NATIVE_CMD qemu-nativesdk &>> $YOCTOADT_INSTALL_LOG_FILE | 145 | $OPKG_INSTALL_NATIVE_CMD qemu-nativesdk &>> $YOCTOADT_INSTALL_LOG_FILE |
| @@ -138,6 +154,65 @@ if [ "$YOCTOADT_NFS_UTIL" == "Y" ] || [ "$YOCTOADT_NFS_UTIL" == "y" ]; then | |||
| 138 | check_result | 154 | check_result |
| 139 | fi | 155 | fi |
| 140 | 156 | ||
| 157 | # Lose the ./opt/${DISTRO}/${SDK_VERSION} part, we don't really need to keep | ||
| 158 | # the entire directory structure. We could patch opkg to do that but it's far | ||
| 159 | # simpler to do that here and achieve the same result. | ||
| 160 | # This is done in two steps: | ||
| 161 | # Step 1: copy ./opt/${DISTRO}/${SDK_VERSION} contents to $NATIVE_INSTALL_DIR. | ||
| 162 | # We cannot use move if $NATIVE_INSTALL_DIR is not empty (for example: contains | ||
| 163 | # another SDK) | ||
| 164 | $SUDO cp -r $NATIVE_INSTALL_DIR/$DEFAULT_INSTALL_FOLDER/* $NATIVE_INSTALL_DIR | ||
| 165 | |||
| 166 | # delete the source directory now | ||
| 167 | $SUDO rm -rf $NATIVE_INSTALL_DIR/$DEFAULT_INSTALL_FOLDER/* | ||
| 168 | |||
| 169 | # Step 2: Delete the ./opt/${DISTRO}/${SDK_VERSION} directories too, they should be empty | ||
| 170 | dir=$NATIVE_INSTALL_DIR/$DEFAULT_INSTALL_FOLDER | ||
| 171 | while [ "$dir" != "$NATIVE_INSTALL_DIR" ]; do | ||
| 172 | # if the user chose / as the install folder, then we should leave /opt in place | ||
| 173 | if [ "$dir" = "/opt" ]; then | ||
| 174 | break | ||
| 175 | fi | ||
| 176 | |||
| 177 | # try to delete the directory, only if it's empty | ||
| 178 | $SUDO rmdir $dir | ||
| 179 | if [ $? -ne 0 ]; then | ||
| 180 | break | ||
| 181 | fi | ||
| 182 | |||
| 183 | # go to the next directory | ||
| 184 | dir=$(dirname $dir) | ||
| 185 | done | ||
| 186 | |||
| 187 | # Link the ld.so.cache file into the hosts filesystem | ||
| 188 | if [ ! -f "$OECORE_NATIVE_SYSROOT/etc/ld.so.cache" ]; then | ||
| 189 | echo_info "Link the ld.so.cache file into the host filesystem" | ||
| 190 | $SUDO ln -s /etc/ld.so.cache $OECORE_NATIVE_SYSROOT/etc/ld.so.cache | ||
| 191 | check_result | ||
| 192 | fi | ||
| 193 | |||
| 194 | # relocate binaries | ||
| 195 | echo_info "\nRelocating binaries ..." | ||
| 196 | escaped_sdkpath=$(echo $DEFAULT_INSTALL_FOLDER |sed -e "s:[\+\.]:\\\\\\\\\0:g") | ||
| 197 | |||
| 198 | # We don't change the script in-place since we may want the user to re-run | ||
| 199 | # adt-installer script | ||
| 200 | $SUDO sed -e "s:##DEFAULT_INSTALL_DIR##:$escaped_sdkpath:" scripts/relocate_sdk.py > scripts/relocate_sdk_tmp.py | ||
| 201 | $SUDO chmod +x scripts/relocate_sdk_tmp.py | ||
| 202 | |||
| 203 | dl_path=$(find $OECORE_NATIVE_SYSROOT/lib -name "ld-linux*") | ||
| 204 | executable_files=$(find $OECORE_NATIVE_SYSROOT -type f -perm +111) | ||
| 205 | |||
| 206 | $SUDO scripts/relocate_sdk_tmp.py $INSTALL_FOLDER $dl_path $executable_files | ||
| 207 | check_result | ||
| 208 | |||
| 209 | # replace /opt/${DISTRO}/${SDK_VERSION} with the install folder in all configs | ||
| 210 | env_setup_script=$(find $NATIVE_INSTALL_DIR -name "environment-setup-*") | ||
| 211 | $SUDO sed -i -e "s:$DEFAULT_INSTALL_FOLDER:$NATIVE_INSTALL_DIR:g" $env_setup_script | ||
| 212 | |||
| 213 | find $OECORE_NATIVE_SYSROOT -type f -exec file '{}' \;|grep ":.*ASCII.*text"|cut -d':' -f1|\ | ||
| 214 | xargs $SUDO sed -i -e "s:$DEFAULT_INSTALL_FOLDER:$NATIVE_INSTALL_DIR:g" | ||
| 215 | |||
| 141 | echo_info "\nSuccessfully installed selected native ADT!" | 216 | echo_info "\nSuccessfully installed selected native ADT!" |
| 142 | } | 217 | } |
| 143 | 218 | ||
| @@ -180,7 +255,7 @@ else | |||
| 180 | fi | 255 | fi |
| 181 | 256 | ||
| 182 | if [ ! -z "$env_filename" ]; then | 257 | if [ ! -z "$env_filename" ]; then |
| 183 | sudo sed -i -e "s%##SDKTARGETSYSROOT##%$target_sysroot%g" $env_filename | 258 | $SUDO sed -i -e "s%##SDKTARGETSYSROOT##%$target_sysroot%g" $env_filename |
| 184 | else | 259 | else |
| 185 | echo_info "[ADT_INST] Error: Failed to find environment script for arch: $1" | 260 | echo_info "[ADT_INST] Error: Failed to find environment script for arch: $1" |
| 186 | return 1 | 261 | return 1 |
diff --git a/meta/recipes-devtools/installer/adt-installer_1.0.bb b/meta/recipes-devtools/installer/adt-installer_1.0.bb index e1edf2f97f..becdef6274 100644 --- a/meta/recipes-devtools/installer/adt-installer_1.0.bb +++ b/meta/recipes-devtools/installer/adt-installer_1.0.bb | |||
| @@ -30,7 +30,7 @@ ALLOW_EMPTY = "1" | |||
| 30 | 30 | ||
| 31 | PACKAGES = "" | 31 | PACKAGES = "" |
| 32 | 32 | ||
| 33 | PR = "r9" | 33 | PR = "r10" |
| 34 | 34 | ||
| 35 | ADT_DEPLOY = "${TMPDIR}/deploy/sdk/" | 35 | ADT_DEPLOY = "${TMPDIR}/deploy/sdk/" |
| 36 | ADT_DIR = "${WORKDIR}/adt-installer/" | 36 | ADT_DIR = "${WORKDIR}/adt-installer/" |
| @@ -69,8 +69,9 @@ fakeroot do_populate_adt () { | |||
| 69 | cp adt_installer ${ADT_DIR} | 69 | cp adt_installer ${ADT_DIR} |
| 70 | cp adt_installer.conf ${ADT_DIR} | 70 | cp adt_installer.conf ${ADT_DIR} |
| 71 | sed -i -e 's#YOCTOADT_VERSION#${SDK_VERSION}#' ${ADT_DIR}/adt_installer.conf | 71 | sed -i -e 's#YOCTOADT_VERSION#${SDK_VERSION}#' ${ADT_DIR}/adt_installer.conf |
| 72 | echo 'SDK_VENDOR=${SDK_VENDOR}' >> ${ADT_DIR}/scripts/data_define | 72 | echo 'SDK_VENDOR=${SDK_VENDOR}' >> ${ADT_DIR}/scripts/data_define |
| 73 | echo 'INSTALL_FOLDER=${SDKPATH}' >> ${ADT_DIR}/scripts/data_define | 73 | echo 'DEFAULT_INSTALL_FOLDER=${SDKPATH}' >> ${ADT_DIR}/scripts/data_define |
| 74 | cp ${COREBASE}/scripts/relocate_sdk.py ${ADT_DIR}/scripts/ | ||
| 74 | tar cfj adt_installer.tar.bz2 adt-installer | 75 | tar cfj adt_installer.tar.bz2 adt-installer |
| 75 | cp ${WORKDIR}/adt_installer.tar.bz2 ${ADT_DEPLOY} | 76 | cp ${WORKDIR}/adt_installer.tar.bz2 ${ADT_DEPLOY} |
| 76 | } | 77 | } |
