diff options
author | Mark Hatle <mark.hatle@windriver.com> | 2011-11-10 10:30:21 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-11-11 11:01:07 +0000 |
commit | ef1d61d711102b3417e83e56d4e2746f5b6a5db9 (patch) | |
tree | 11fd7e88d6e9cc6dcfad673211b6259436cbd84b /meta/classes/package_rpm.bbclass | |
parent | 298278257bdba9c684ae293351b1cf421b5b3e50 (diff) | |
download | poky-ef1d61d711102b3417e83e56d4e2746f5b6a5db9.tar.gz |
rootfs_rpm.bbclass: Enable pre and post install scripts
[YOCTO #1755]
We change the want the RPM rootfs install works to install pre and post install
scripts. The new method uses a script helper that is invoked by RPM outside
of the normal chroot.
The wrapper is dynamically generated prior to the install starting. It will
check the return code of the script. If the script fails, it will store a copy
to be executed on the first system boot. This is similar to the previous
mechanism.
In addition, a line of debug was added to the scripts as written by package_rpm
to list which package and which script for later debugging, if necessary.
(From OE-Core rev: 3e7120d6a9fd5e46214673d0a6e1085a7314ff42)
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/package_rpm.bbclass')
-rw-r--r-- | meta/classes/package_rpm.bbclass | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass index 2c5545c11d..2ace0537ac 100644 --- a/meta/classes/package_rpm.bbclass +++ b/meta/classes/package_rpm.bbclass | |||
@@ -382,13 +382,39 @@ package_install_internal_rpm () { | |||
382 | cat ${target_rootfs}/install/install_solution.manifest > ${target_rootfs}/install/total_solution.manifest | 382 | cat ${target_rootfs}/install/install_solution.manifest > ${target_rootfs}/install/total_solution.manifest |
383 | cat ${target_rootfs}/install/install_multilib_solution.manifest >> ${target_rootfs}/install/total_solution.manifest | 383 | cat ${target_rootfs}/install/install_multilib_solution.manifest >> ${target_rootfs}/install/total_solution.manifest |
384 | 384 | ||
385 | # Construct install scriptlet wrapper | ||
386 | cat << EOF > ${WORKDIR}/scriptlet_wrapper | ||
387 | #!/bin/bash | ||
388 | |||
389 | export PATH="${PATH}" | ||
390 | export D="${target_rootfs}" | ||
391 | export OFFLINE_ROOT="\$D" | ||
392 | export IPKG_OFFLINE_ROOT="\$D" | ||
393 | export OPKG_OFFLINE_ROOT="\$D" | ||
394 | |||
395 | \$2 \$1/\$3 \$4 | ||
396 | if [ \$? -ne 0 ]; then | ||
397 | mkdir -p \$1/etc/rpm-postinsts | ||
398 | num=100 | ||
399 | while [ -e \$1/etc/rpm-postinsts/\${num} ]; do num=\$((num + 1)); done | ||
400 | echo "#!\$2" > \$1/etc/rpm-postinsts/\${num} | ||
401 | echo "# Arg: \$4" >> \$1/etc/rpm-postinsts/\${num} | ||
402 | cat \$1/\$3 >> \$1/etc/rpm-postinsts/\${num} | ||
403 | chmod +x \$1/etc/rpm-postinsts/\${num} | ||
404 | fi | ||
405 | EOF | ||
406 | |||
407 | chmod 0755 ${WORKDIR}/scriptlet_wrapper | ||
408 | |||
385 | # Attempt install | 409 | # Attempt install |
386 | ${RPM} --root ${target_rootfs} \ | 410 | ${RPM} --root ${target_rootfs} \ |
387 | --predefine "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \ | 411 | --predefine "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \ |
388 | --predefine "_rpmrc_platform_path ${target_rootfs}/etc/rpm/platform" \ | 412 | --predefine "_rpmrc_platform_path ${target_rootfs}/etc/rpm/platform" \ |
413 | -D "_var ${localstatedir}" \ | ||
389 | -D "_dbpath ${rpmlibdir}" \ | 414 | -D "_dbpath ${rpmlibdir}" \ |
390 | --noscripts --notriggers --noparentdirs --nolinktos --replacepkgs \ | 415 | --noparentdirs --nolinktos --replacepkgs \ |
391 | -D "__dbi_txn create nofsync private" \ | 416 | -D "__dbi_txn create nofsync private" \ |
417 | -D "_cross_scriptlet_wrapper ${WORKDIR}/scriptlet_wrapper" \ | ||
392 | -Uhv ${target_rootfs}/install/total_solution.manifest | 418 | -Uhv ${target_rootfs}/install/total_solution.manifest |
393 | } | 419 | } |
394 | 420 | ||
@@ -685,6 +711,7 @@ python write_specfile () { | |||
685 | elif script == 'postrm': | 711 | elif script == 'postrm': |
686 | spec_scriptlets_bottom.append('%%postun -n %s' % splitname) | 712 | spec_scriptlets_bottom.append('%%postun -n %s' % splitname) |
687 | scriptvar = wrap_uninstall(scriptvar) | 713 | scriptvar = wrap_uninstall(scriptvar) |
714 | spec_scriptlets_bottom.append('# %s - %s' % (splitname, script)) | ||
688 | spec_scriptlets_bottom.append(scriptvar) | 715 | spec_scriptlets_bottom.append(scriptvar) |
689 | spec_scriptlets_bottom.append('') | 716 | spec_scriptlets_bottom.append('') |
690 | 717 | ||
@@ -762,19 +789,23 @@ python write_specfile () { | |||
762 | 789 | ||
763 | if srcpreinst: | 790 | if srcpreinst: |
764 | spec_scriptlets_top.append('%pre') | 791 | spec_scriptlets_top.append('%pre') |
792 | spec_scriptlets_top.append('# %s - preinst' % srcname) | ||
765 | spec_scriptlets_top.append(srcpreinst) | 793 | spec_scriptlets_top.append(srcpreinst) |
766 | spec_scriptlets_top.append('') | 794 | spec_scriptlets_top.append('') |
767 | if srcpostinst: | 795 | if srcpostinst: |
768 | spec_scriptlets_top.append('%post') | 796 | spec_scriptlets_top.append('%post') |
797 | spec_scriptlets_top.append('# %s - postinst' % srcname) | ||
769 | spec_scriptlets_top.append(srcpostinst) | 798 | spec_scriptlets_top.append(srcpostinst) |
770 | spec_scriptlets_top.append('') | 799 | spec_scriptlets_top.append('') |
771 | if srcprerm: | 800 | if srcprerm: |
772 | spec_scriptlets_top.append('%preun') | 801 | spec_scriptlets_top.append('%preun') |
802 | spec_scriptlets_top.append('# %s - prerm' % srcname) | ||
773 | scriptvar = wrap_uninstall(srcprerm) | 803 | scriptvar = wrap_uninstall(srcprerm) |
774 | spec_scriptlets_top.append(scriptvar) | 804 | spec_scriptlets_top.append(scriptvar) |
775 | spec_scriptlets_top.append('') | 805 | spec_scriptlets_top.append('') |
776 | if srcpostrm: | 806 | if srcpostrm: |
777 | spec_scriptlets_top.append('%postun') | 807 | spec_scriptlets_top.append('%postun') |
808 | spec_scriptlets_top.append('# %s - postrm' % srcname) | ||
778 | scriptvar = wrap_uninstall(srcpostrm) | 809 | scriptvar = wrap_uninstall(srcpostrm) |
779 | spec_scriptlets_top.append(scriptvar) | 810 | spec_scriptlets_top.append(scriptvar) |
780 | spec_scriptlets_top.append('') | 811 | spec_scriptlets_top.append('') |