summaryrefslogtreecommitdiff
path: root/meta/classes/image.bbclass
diff options
context:
space:
mode:
authorLaurentiu Palcu <laurentiu.palcu@intel.com>2013-02-12 18:12:37 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-02-12 16:35:13 +0000
commited8ac4ee43132ae974794038821f7ca5465ae556 (patch)
treee58e338977557dcf898c502b031ff802546e90a5 /meta/classes/image.bbclass
parent0ef538d75c2f3921a2fcbe6ca1deed5525b276cc (diff)
downloadopenembedded-core-ed8ac4ee43132ae974794038821f7ca5465ae556.tar.gz
openembedded-core-ed8ac4ee43132ae974794038821f7ca5465ae556.tar.bz2
openembedded-core-ed8ac4ee43132ae974794038821f7ca5465ae556.zip
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. Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/image.bbclass')
-rw-r--r--meta/classes/image.bbclass43
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 () {
cd ${WORKDIR}/intercept_scripts
echo "Running intercept scripts:"
for script in *; do
- if [ "$script" = "*" ]; then break; fi
+ [ "$script" = "*" ] && break
+ [ "$script" = "postinst_intercept" ] || [ ! -x "$script" ] && continue
echo "> Executing $script"
- chmod +x $script
- ./$script
- if [ $? -ne 0 ]; then
- echo "ERROR: intercept script \"$script\" failed!"
- fi
+ ./$script || (echo "WARNING: intercept script \"$script\" failed, falling back to running postinstalls at first boot" && continue)
+ #
+ # If we got here, than the intercept was successful. Next, we must
+ # mark the postinstalls as "installed". For rpm is a little bit
+ # different, we just have to delete the saved postinstalls from
+ # /etc/rpm-postinsts
+ #
+ pkgs="$(cat ./$script|grep "^##PKGS"|cut -d':' -f2)" || continue
+ case ${IMAGE_PKGTYPE} in
+ "rpm")
+ for pi in ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts/*; do
+ pkg_name="$(cat $pi|sed -n -e "s/^.*postinst_intercept $script \([^ ]*\).*/\1/p")"
+ if [ -n "$pkg_name" -a -n "$(echo "$pkgs"|grep " $pkg_name ")" ]; then
+ rm $pi
+ fi
+ done
+ # move to the next intercept script
+ continue
+ ;;
+ "ipk")
+ status_file="${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/status"
+ ;;
+ "deb")
+ status_file="${IMAGE_ROOTFS}/var/lib/dpkg/status"
+ ;;
+ esac
+ # the next piece of code is run only for ipk/dpkg
+ sed_expr=""
+ for p in $pkgs; do
+ sed_expr="$sed_expr -e \"/^Package: ${p}$/,/^Status: install.* unpacked$/ {s/unpacked/installed/}\""
+ done
+ eval sed -i $sed_expr $status_file
done
fi
}
@@ -223,6 +251,9 @@ fakeroot do_rootfs () {
cp ${COREBASE}/meta/files/deploydir_readme.txt ${DEPLOY_DIR_IMAGE}/README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt || true
+ # copy the intercept scripts
+ cp ${COREBASE}/scripts/postinst-intercepts/* ${WORKDIR}/intercept_scripts/
+
# If "${IMAGE_ROOTFS}/dev" exists, then the device had been made by
# the previous build
if [ "${USE_DEVFS}" != "1" -a ! -r "${IMAGE_ROOTFS}/dev" ]; then