diff options
author | Randy Witt <randy.e.witt@linux.intel.com> | 2015-07-16 13:34:21 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-07-20 10:40:40 +0100 |
commit | 2563aa55281c60c877d8a298b6884ee7da550234 (patch) | |
tree | 46b239e6fac44e050c7741db7c871ffb5c95b169 | |
parent | 873b8edd4100aa6a0d21e2bea20fbe7539de041a (diff) | |
download | poky-2563aa55281c60c877d8a298b6884ee7da550234.tar.gz |
extensible sdk: Error when trying to install as root.
Since the extensible sdk uses bitbake, which can't run as root, the sdk
shouldn't be installed as root.
Previously it would error out late into setup when bitbake errored
saying not to run bitbake as root.
Now the script errors with a message saying the extensible sdk can't be
installed as root.
[Yocto #7545]
(From OE-Core rev: 309e8f4e536148056223f50637ed291c48d148ca)
Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/populate_sdk_base.bbclass | 12 | ||||
-rw-r--r-- | meta/classes/populate_sdk_ext.bbclass | 11 | ||||
-rw-r--r-- | meta/files/toolchain-shar-extract.sh | 7 |
3 files changed, 28 insertions, 2 deletions
diff --git a/meta/classes/populate_sdk_base.bbclass b/meta/classes/populate_sdk_base.bbclass index 398e943a46..a9e9bd71d2 100644 --- a/meta/classes/populate_sdk_base.bbclass +++ b/meta/classes/populate_sdk_base.bbclass | |||
@@ -51,6 +51,7 @@ PID = "${@os.getpid()}" | |||
51 | EXCLUDE_FROM_WORLD = "1" | 51 | EXCLUDE_FROM_WORLD = "1" |
52 | 52 | ||
53 | SDK_PACKAGING_FUNC ?= "create_shar" | 53 | SDK_PACKAGING_FUNC ?= "create_shar" |
54 | SDK_PRE_INSTALL_COMMAND ?= "" | ||
54 | SDK_POST_INSTALL_COMMAND ?= "" | 55 | SDK_POST_INSTALL_COMMAND ?= "" |
55 | SDK_RELOCATE_AFTER_INSTALL ?= "1" | 56 | SDK_RELOCATE_AFTER_INSTALL ?= "1" |
56 | 57 | ||
@@ -134,15 +135,21 @@ fakeroot create_shar() { | |||
134 | # copy in the template shar extractor script | 135 | # copy in the template shar extractor script |
135 | cp ${COREBASE}/meta/files/toolchain-shar-extract.sh ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh | 136 | cp ${COREBASE}/meta/files/toolchain-shar-extract.sh ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh |
136 | 137 | ||
137 | rm -f ${T}/post_install_command | 138 | rm -f ${T}/pre_install_command ${T}/post_install_command |
138 | 139 | ||
139 | if [ ${SDK_RELOCATE_AFTER_INSTALL} -eq 1 ] ; then | 140 | if [ ${SDK_RELOCATE_AFTER_INSTALL} -eq 1 ] ; then |
140 | cp ${COREBASE}/meta/files/toolchain-shar-relocate.sh ${T}/post_install_command | 141 | cp ${COREBASE}/meta/files/toolchain-shar-relocate.sh ${T}/post_install_command |
141 | fi | 142 | fi |
143 | cat << "EOF" >> ${T}/pre_install_command | ||
144 | ${SDK_PRE_INSTALL_COMMAND} | ||
145 | EOF | ||
146 | |||
142 | cat << "EOF" >> ${T}/post_install_command | 147 | cat << "EOF" >> ${T}/post_install_command |
143 | ${SDK_POST_INSTALL_COMMAND} | 148 | ${SDK_POST_INSTALL_COMMAND} |
144 | EOF | 149 | EOF |
145 | sed -i -e '/@SDK_POST_INSTALL_COMMAND@/r ${T}/post_install_command' ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh | 150 | sed -i -e '/@SDK_PRE_INSTALL_COMMAND@/r ${T}/pre_install_command' \ |
151 | -e '/@SDK_POST_INSTALL_COMMAND@/r ${T}/post_install_command' \ | ||
152 | ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh | ||
146 | 153 | ||
147 | # substitute variables | 154 | # substitute variables |
148 | sed -i -e 's#@SDK_ARCH@#${SDK_ARCH}#g' \ | 155 | sed -i -e 's#@SDK_ARCH@#${SDK_ARCH}#g' \ |
@@ -151,6 +158,7 @@ EOF | |||
151 | -e 's#@REAL_MULTIMACH_TARGET_SYS@#${REAL_MULTIMACH_TARGET_SYS}#g' \ | 158 | -e 's#@REAL_MULTIMACH_TARGET_SYS@#${REAL_MULTIMACH_TARGET_SYS}#g' \ |
152 | -e 's#@SDK_TITLE@#${SDK_TITLE}#g' \ | 159 | -e 's#@SDK_TITLE@#${SDK_TITLE}#g' \ |
153 | -e 's#@SDK_VERSION@#${SDK_VERSION}#g' \ | 160 | -e 's#@SDK_VERSION@#${SDK_VERSION}#g' \ |
161 | -e '/@SDK_PRE_INSTALL_COMMAND@/d' \ | ||
154 | -e '/@SDK_POST_INSTALL_COMMAND@/d' \ | 162 | -e '/@SDK_POST_INSTALL_COMMAND@/d' \ |
155 | ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh | 163 | ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh |
156 | 164 | ||
diff --git a/meta/classes/populate_sdk_ext.bbclass b/meta/classes/populate_sdk_ext.bbclass index 8a80a563f0..b28413b8f5 100644 --- a/meta/classes/populate_sdk_ext.bbclass +++ b/meta/classes/populate_sdk_ext.bbclass | |||
@@ -173,6 +173,17 @@ install_tools() { | |||
173 | install ${SDK_DEPLOY}/${BUILD_ARCH}-nativesdk-libc.tar.bz2 ${SDK_OUTPUT}/${SDKPATH} | 173 | install ${SDK_DEPLOY}/${BUILD_ARCH}-nativesdk-libc.tar.bz2 ${SDK_OUTPUT}/${SDKPATH} |
174 | } | 174 | } |
175 | 175 | ||
176 | # Since bitbake won't run as root it doesn't make sense to try and install | ||
177 | # the extensible sdk as root. | ||
178 | sdk_ext_preinst() { | ||
179 | if [ "`id -u`" = "0" ]; then | ||
180 | echo "ERROR: The extensible sdk cannot be installed as root." | ||
181 | exit 1 | ||
182 | fi | ||
183 | SDK_EXTENSIBLE="1" | ||
184 | } | ||
185 | SDK_PRE_INSTALL_COMMAND_task-populate-sdk-ext = "${sdk_ext_preinst}" | ||
186 | |||
176 | # FIXME this preparation should be done as part of the SDK construction | 187 | # FIXME this preparation should be done as part of the SDK construction |
177 | sdk_ext_postinst() { | 188 | sdk_ext_postinst() { |
178 | printf "\nExtracting buildtools...\n" | 189 | printf "\nExtracting buildtools...\n" |
diff --git a/meta/files/toolchain-shar-extract.sh b/meta/files/toolchain-shar-extract.sh index 8cb8783f97..0a33ee8f5d 100644 --- a/meta/files/toolchain-shar-extract.sh +++ b/meta/files/toolchain-shar-extract.sh | |||
@@ -71,6 +71,8 @@ if [ $verbose = 1 ] ; then | |||
71 | set -x | 71 | set -x |
72 | fi | 72 | fi |
73 | 73 | ||
74 | @SDK_PRE_INSTALL_COMMAND@ | ||
75 | |||
74 | if [ "$target_sdk_dir" = "" ]; then | 76 | if [ "$target_sdk_dir" = "" ]; then |
75 | read -e -p "Enter target directory for SDK (default: $DEFAULT_INSTALL_DIR): " target_sdk_dir | 77 | read -e -p "Enter target directory for SDK (default: $DEFAULT_INSTALL_DIR): " target_sdk_dir |
76 | [ "$target_sdk_dir" = "" ] && target_sdk_dir=$DEFAULT_INSTALL_DIR | 78 | [ "$target_sdk_dir" = "" ] && target_sdk_dir=$DEFAULT_INSTALL_DIR |
@@ -116,6 +118,11 @@ mkdir -p $target_sdk_dir >/dev/null 2>&1 | |||
116 | 118 | ||
117 | # if don't have the right to access dir, gain by sudo | 119 | # if don't have the right to access dir, gain by sudo |
118 | if [ ! -x $target_sdk_dir -o ! -w $target_sdk_dir -o ! -r $target_sdk_dir ]; then | 120 | if [ ! -x $target_sdk_dir -o ! -w $target_sdk_dir -o ! -r $target_sdk_dir ]; then |
121 | if [ "$SDK_EXTENSIBLE" = "1" ]; then | ||
122 | echo "Unable to access \"$target_sdk_dir\"." | ||
123 | exit 1 | ||
124 | fi | ||
125 | |||
119 | SUDO_EXEC=$(which "sudo") | 126 | SUDO_EXEC=$(which "sudo") |
120 | if [ -z $SUDO_EXEC ]; then | 127 | if [ -z $SUDO_EXEC ]; then |
121 | echo "No command 'sudo' found, please install sudo first. Abort!" | 128 | echo "No command 'sudo' found, please install sudo first. Abort!" |