diff options
author | Laurentiu Palcu <laurentiu.palcu@intel.com> | 2012-07-31 11:49:36 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-08-02 15:28:39 +0100 |
commit | 44df019842bc83cdcf559ac64b989ab3c5febd6a (patch) | |
tree | f651220c9d1b10a504bbdd77b6dbed59f528ba39 /meta/classes | |
parent | 749b8a52c68500cca546d705b7ac81905c1fe0e7 (diff) | |
download | poky-44df019842bc83cdcf559ac64b989ab3c5febd6a.tar.gz |
populate_sdk_base.bbclass: create self-extracting archive
In order for the SDK to be relocatable, the user would need to call a
setup script to change the binaries acordingly. Having an auto-extracting
archive has the advantage of being more user friendly and the user does
not have to call the setup script separately after extracting the SDK.
It is called automatically.
(From OE-Core rev: d4e976849da845d595db7029d8089946ae16d982)
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/populate_sdk_base.bbclass | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/meta/classes/populate_sdk_base.bbclass b/meta/classes/populate_sdk_base.bbclass index 55ec684a41..0d1974141b 100644 --- a/meta/classes/populate_sdk_base.bbclass +++ b/meta/classes/populate_sdk_base.bbclass | |||
@@ -55,6 +55,8 @@ fakeroot python do_populate_sdk() { | |||
55 | bb.build.exec_func("create_sdk_files", localdata) | 55 | bb.build.exec_func("create_sdk_files", localdata) |
56 | 56 | ||
57 | bb.build.exec_func("tar_sdk", d) | 57 | bb.build.exec_func("tar_sdk", d) |
58 | |||
59 | bb.build.exec_func("create_shar", d) | ||
58 | } | 60 | } |
59 | 61 | ||
60 | fakeroot populate_sdk_image() { | 62 | fakeroot populate_sdk_image() { |
@@ -94,6 +96,13 @@ fakeroot create_sdk_files() { | |||
94 | 96 | ||
95 | # Add version information | 97 | # Add version information |
96 | toolchain_create_sdk_version ${SDK_OUTPUT}/${SDKPATH}/version-${REAL_MULTIMACH_TARGET_SYS} | 98 | toolchain_create_sdk_version ${SDK_OUTPUT}/${SDKPATH}/version-${REAL_MULTIMACH_TARGET_SYS} |
99 | |||
100 | cp ${COREBASE}/scripts/relocate_sdk.py ${SDK_OUTPUT}/${SDKPATH}/ | ||
101 | |||
102 | # Replace the ##DEFAULT_INSTALL_DIR## with the correct pattern. | ||
103 | # Escape special characters like '+' and '.' in the SDKPATH | ||
104 | escaped_sdkpath=$(echo ${SDKPATH} |sed -e "s:[\+\.]:\\\\\\\\\0:g") | ||
105 | sed -i -e "s:##DEFAULT_INSTALL_DIR##:$escaped_sdkpath:" ${SDK_OUTPUT}/${SDKPATH}/relocate_sdk.py | ||
97 | } | 106 | } |
98 | 107 | ||
99 | fakeroot tar_sdk() { | 108 | fakeroot tar_sdk() { |
@@ -103,6 +112,83 @@ fakeroot tar_sdk() { | |||
103 | tar --owner=root --group=root -cj --file=${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.tar.bz2 . | 112 | tar --owner=root --group=root -cj --file=${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.tar.bz2 . |
104 | } | 113 | } |
105 | 114 | ||
115 | fakeroot create_shar() { | ||
116 | cat << "EOF" > ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh | ||
117 | #!/bin/bash | ||
118 | |||
119 | DEFAULT_INSTALL_DIR="${SDKPATH}" | ||
120 | |||
121 | echo -n "Enter target directory for Poky SDK (default: $DEFAULT_INSTALL_DIR): " | ||
122 | read target_sdk_dir | ||
123 | |||
124 | if [ "$target_sdk_dir" = "" ]; then | ||
125 | target_sdk_dir=$DEFAULT_INSTALL_DIR | ||
126 | fi | ||
127 | |||
128 | eval target_sdk_dir=$target_sdk_dir | ||
129 | target_sdk_dir=$(readlink -m $target_sdk_dir) | ||
130 | |||
131 | echo -n "You are about to install Poky SDK to \"$target_sdk_dir\". Proceed[Y/n]?" | ||
132 | read answer | ||
133 | |||
134 | if [ "$answer" = "" ]; then | ||
135 | answer="y" | ||
136 | fi | ||
137 | |||
138 | if [ "$answer" != "Y" -a "$answer" != "y" ]; then | ||
139 | echo "Installation aborted!" | ||
140 | exit 1 | ||
141 | fi | ||
142 | |||
143 | mkdir -p $target_sdk_dir >/dev/null 2>&1 | ||
144 | if [ $? -ne 0 ]; then | ||
145 | echo "Error: Unable to create target directory. Do you have permissions?" | ||
146 | exit 1 | ||
147 | fi | ||
148 | |||
149 | payload_offset=$(($(grep -na -m1 "^MARKER:$" $(basename $0)|cut -d':' -f1) + 1)) | ||
150 | |||
151 | echo -n "Extracting SDK..." | ||
152 | tail -n +$payload_offset $(basename $0) | tar xj --strip-components=4 -C $target_sdk_dir | ||
153 | echo "done" | ||
154 | |||
155 | echo -n "Setting it up..." | ||
156 | # fix environment paths | ||
157 | env_setup_script=$(find $target_sdk_dir -name "environment-setup*") | ||
158 | sed -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:g" -i $env_setup_script | ||
159 | |||
160 | # fix dynamic loader paths in all ELF SDK binaries | ||
161 | native_sysroot=$(cat $env_setup_script |grep OECORE_NATIVE_SYSROOT|cut -d'=' -f2|tr -d '"') | ||
162 | dl_path=$(find $native_sysroot/lib -name "ld-linux*") | ||
163 | executable_files=$(find $native_sysroot -type f -perm +111) | ||
164 | ${env_setup_script%/*}/relocate_sdk.py $target_sdk_dir $dl_path $executable_files | ||
165 | if [ $? -ne 0 ]; then | ||
166 | echo "SDK could not be set up. Relocate script failed. Abort!" | ||
167 | exit 1 | ||
168 | fi | ||
169 | |||
170 | # replace ${SDKPATH} with the new prefix in all text files: configs/scripts/etc | ||
171 | find $native_sysroot -type f -exec file '{}' \;|grep text|cut -d':' -f1|xargs sed -i -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:g" | ||
172 | |||
173 | echo done | ||
174 | |||
175 | # delete the relocating script, so that user is forced to re-run the installer | ||
176 | # if he/she wants another location for the sdk | ||
177 | rm ${env_setup_script%/*}/relocate_sdk.py | ||
178 | |||
179 | echo "SDK has been successfully set up and is ready to be used." | ||
180 | |||
181 | exit 0 | ||
182 | |||
183 | MARKER: | ||
184 | EOF | ||
185 | # append the SDK tarball | ||
186 | cat ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.tar.bz2 >> ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh | ||
187 | |||
188 | # delete the old tarball, we don't need it anymore | ||
189 | rm ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.tar.bz2 | ||
190 | } | ||
191 | |||
106 | populate_sdk_log_check() { | 192 | populate_sdk_log_check() { |
107 | for target in $* | 193 | for target in $* |
108 | do | 194 | do |