diff options
author | Laurentiu Palcu <laurentiu.palcu@intel.com> | 2013-02-12 18:12:37 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-02-13 16:52:28 +0000 |
commit | 6cca7efa6f7b61523913eace3f44ca2235d4e9ac (patch) | |
tree | c92fabaac094678c998376529a251285585a3e88 | |
parent | 7306dbea6d5ea95624f89bb247b742392be20046 (diff) | |
download | poky-6cca7efa6f7b61523913eace3f44ca2235d4e9ac.tar.gz |
image.bbclass: add fall-back functionality when running intercepts
If an intercept script fails, it would be helpful to fall-back to
running the postinstall on target's first boot. In order to achieve
that, the postinstalls that install a host intercept hook will have to
return 1, so that the postinstall is marked as unpacked only. If the
intercept hook fails, then we're ok, the postinstalls will be run on
target anyway. If it succeeds, then mark the packages as installed.
This logic was chosen mainly because of rpm backend which saves the
failed postinstalls in /etc/rpm-postinsts. Hence, in order to mark the
packages as installed, all we have to do is delete the scriptlets from
there.
(From OE-Core rev: ed8ac4ee43132ae974794038821f7ca5465ae556)
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/image.bbclass | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index 84ddc3872f..dd78acb7be 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass | |||
@@ -194,13 +194,41 @@ run_intercept_scriptlets () { | |||
194 | cd ${WORKDIR}/intercept_scripts | 194 | cd ${WORKDIR}/intercept_scripts |
195 | echo "Running intercept scripts:" | 195 | echo "Running intercept scripts:" |
196 | for script in *; do | 196 | for script in *; do |
197 | if [ "$script" = "*" ]; then break; fi | 197 | [ "$script" = "*" ] && break |
198 | [ "$script" = "postinst_intercept" ] || [ ! -x "$script" ] && continue | ||
198 | echo "> Executing $script" | 199 | echo "> Executing $script" |
199 | chmod +x $script | 200 | ./$script || (echo "WARNING: intercept script \"$script\" failed, falling back to running postinstalls at first boot" && continue) |
200 | ./$script | 201 | # |
201 | if [ $? -ne 0 ]; then | 202 | # If we got here, than the intercept was successful. Next, we must |
202 | echo "ERROR: intercept script \"$script\" failed!" | 203 | # mark the postinstalls as "installed". For rpm is a little bit |
203 | fi | 204 | # different, we just have to delete the saved postinstalls from |
205 | # /etc/rpm-postinsts | ||
206 | # | ||
207 | pkgs="$(cat ./$script|grep "^##PKGS"|cut -d':' -f2)" || continue | ||
208 | case ${IMAGE_PKGTYPE} in | ||
209 | "rpm") | ||
210 | for pi in ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts/*; do | ||
211 | pkg_name="$(cat $pi|sed -n -e "s/^.*postinst_intercept $script \([^ ]*\).*/\1/p")" | ||
212 | if [ -n "$pkg_name" -a -n "$(echo "$pkgs"|grep " $pkg_name ")" ]; then | ||
213 | rm $pi | ||
214 | fi | ||
215 | done | ||
216 | # move to the next intercept script | ||
217 | continue | ||
218 | ;; | ||
219 | "ipk") | ||
220 | status_file="${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/status" | ||
221 | ;; | ||
222 | "deb") | ||
223 | status_file="${IMAGE_ROOTFS}/var/lib/dpkg/status" | ||
224 | ;; | ||
225 | esac | ||
226 | # the next piece of code is run only for ipk/dpkg | ||
227 | sed_expr="" | ||
228 | for p in $pkgs; do | ||
229 | sed_expr="$sed_expr -e \"/^Package: ${p}$/,/^Status: install.* unpacked$/ {s/unpacked/installed/}\"" | ||
230 | done | ||
231 | eval sed -i $sed_expr $status_file | ||
204 | done | 232 | done |
205 | fi | 233 | fi |
206 | } | 234 | } |
@@ -223,6 +251,9 @@ fakeroot do_rootfs () { | |||
223 | 251 | ||
224 | cp ${COREBASE}/meta/files/deploydir_readme.txt ${DEPLOY_DIR_IMAGE}/README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt || true | 252 | cp ${COREBASE}/meta/files/deploydir_readme.txt ${DEPLOY_DIR_IMAGE}/README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt || true |
225 | 253 | ||
254 | # copy the intercept scripts | ||
255 | cp ${COREBASE}/scripts/postinst-intercepts/* ${WORKDIR}/intercept_scripts/ | ||
256 | |||
226 | # If "${IMAGE_ROOTFS}/dev" exists, then the device had been made by | 257 | # If "${IMAGE_ROOTFS}/dev" exists, then the device had been made by |
227 | # the previous build | 258 | # the previous build |
228 | if [ "${USE_DEVFS}" != "1" -a ! -r "${IMAGE_ROOTFS}/dev" ]; then | 259 | if [ "${USE_DEVFS}" != "1" -a ! -r "${IMAGE_ROOTFS}/dev" ]; then |