summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurentiu Palcu <laurentiu.palcu@intel.com>2013-05-21 14:17:19 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-06-11 15:38:04 +0100
commitb11f8183074857be5a5920f093b4298884eec805 (patch)
tree5ebfb0091cfeeda7993b92f322978eaba5c8a01a
parentfdb5c12240ff5e8e279a088dee632a308d233838 (diff)
downloadpoky-b11f8183074857be5a5920f093b4298884eec805.tar.gz
rootfs_*.bbclass: add some helper functions
This patch adds the following helper functions: * delayed_postinsts - outputs the list of delayed postinstalls; * save_postinsts - this will save the delayed postinstalls for ipk/deb in /etc/(ipk|deb)_postinsts; * rootfs_remove_packages - removes packages from an image; Additionaly, this patch will remove a piece of code in rootfs_ipk_do_rootfs which will be moved to image.bbclass and used for all backends; [YOCTO #4484] (From OE-Core rev: 928df79cd3964f775c4c6e4283ef84b8882f9328) Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/rootfs_deb.bbclass23
-rw-r--r--meta/classes/rootfs_ipk.bbclass39
-rw-r--r--meta/classes/rootfs_rpm.bbclass27
3 files changed, 64 insertions, 25 deletions
diff --git a/meta/classes/rootfs_deb.bbclass b/meta/classes/rootfs_deb.bbclass
index e642cf3852..edd1037f87 100644
--- a/meta/classes/rootfs_deb.bbclass
+++ b/meta/classes/rootfs_deb.bbclass
@@ -85,7 +85,7 @@ fakeroot rootfs_deb_do_rootfs () {
85 ${ROOTFS_POSTPROCESS_COMMAND} 85 ${ROOTFS_POSTPROCESS_COMMAND}
86 86
87 if ${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "true", "false" ,d)}; then 87 if ${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "true", "false" ,d)}; then
88 if grep Status:.install.ok.unpacked ${IMAGE_ROOTFS}/var/lib/dpkg/status; then 88 if [ -n "$(delayed_postinsts)" ]; then
89 bberror "Some packages could not be configured offline and rootfs is read-only." 89 bberror "Some packages could not be configured offline and rootfs is read-only."
90 exit 1 90 exit 1
91 fi 91 fi
@@ -94,9 +94,22 @@ fakeroot rootfs_deb_do_rootfs () {
94 log_check rootfs 94 log_check rootfs
95} 95}
96 96
97rootfs_deb_do_rootfs[vardeps] += "delayed_postinsts"
98
99delayed_postinsts () {
100 cat ${IMAGE_ROOTFS}/var/lib/dpkg/status|grep -e "^Package:" -e "^Status:"|sed -ne 'N;s/Package: \(.*\)\nStatus:.*unpacked/\1/p'
101}
102
103save_postinsts () {
104 for p in $(delayed_postinsts); do
105 install -d ${IMAGE_ROOTFS}${sysconfdir}/deb-postinsts
106 cp ${IMAGE_ROOTFS}/var/lib/dpkg/info/$p.postinst ${IMAGE_ROOTFS}${sysconfdir}/deb-postinsts/$p
107 done
108}
109
97remove_packaging_data_files() { 110remove_packaging_data_files() {
98 rm -rf ${IMAGE_ROOTFS}${opkglibdir} 111 rm -rf ${IMAGE_ROOTFS}${opkglibdir}
99 rm -rf ${IMAGE_ROOTFS}/usr/dpkg/ 112 rm -rf ${IMAGE_ROOTFS}/var/lib/dpkg/
100} 113}
101 114
102rootfs_install_packages() { 115rootfs_install_packages() {
@@ -105,3 +118,9 @@ rootfs_install_packages() {
105 # Mark all packages installed 118 # Mark all packages installed
106 sed -i -e "s/Status: install ok unpacked/Status: install ok installed/;" $INSTALL_ROOTFS_DEB/var/lib/dpkg/status 119 sed -i -e "s/Status: install ok unpacked/Status: install ok installed/;" $INSTALL_ROOTFS_DEB/var/lib/dpkg/status
107} 120}
121
122rootfs_remove_packages() {
123 # for some reason, --root doesn't really work here... We use --admindir&--instdir instead.
124 ${STAGING_BINDIR_NATIVE}/dpkg --admindir=${IMAGE_ROOTFS}/var/lib/dpkg --instdir=${IMAGE_ROOTFS} -r --force-depends $@
125}
126
diff --git a/meta/classes/rootfs_ipk.bbclass b/meta/classes/rootfs_ipk.bbclass
index 3e1f9590fc..1403422ca7 100644
--- a/meta/classes/rootfs_ipk.bbclass
+++ b/meta/classes/rootfs_ipk.bbclass
@@ -91,36 +91,29 @@ fakeroot rootfs_ipk_do_rootfs () {
91 ${ROOTFS_POSTPROCESS_COMMAND} 91 ${ROOTFS_POSTPROCESS_COMMAND}
92 92
93 if ${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "true", "false" ,d)}; then 93 if ${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "true", "false" ,d)}; then
94 if grep Status:.install.ok.unpacked ${STATUS}; then 94 if [ -n "$(delayed_postinsts)" ]; then
95 bberror "Some packages could not be configured offline and rootfs is read-only." 95 bberror "Some packages could not be configured offline and rootfs is read-only."
96 exit 1 96 exit 1
97 fi 97 fi
98 fi 98 fi
99 99
100 rm -f ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/lists/* 100 rm -f ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/lists/*
101 if ${@base_contains("IMAGE_FEATURES", "package-management", "false", "true", d)}; then
102 if ! grep Status:.install.ok.unpacked ${STATUS}; then
103 # All packages were successfully configured.
104 # update-rc.d, base-passwd, run-postinsts are no further use, remove them now
105 remove_run_postinsts=false
106 if [ -e ${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts ]; then
107 remove_run_postinsts=true
108 fi
109 opkg-cl ${OPKG_ARGS} --force-depends remove update-rc.d base-passwd ${ROOTFS_BOOTSTRAP_INSTALL} || true
110
111 # Need to remove rc.d files for run-postinsts by hand since opkg won't
112 # call postrm scripts in offline root mode.
113 if $remove_run_postinsts; then
114 update-rc.d -f -r ${IMAGE_ROOTFS} run-postinsts remove
115 fi
116
117 # Also delete the status files
118 remove_packaging_data_files
119 fi
120 fi
121 log_check rootfs 101 log_check rootfs
122} 102}
123 103
104rootfs_ipk_do_rootfs[vardeps] += "delayed_postinsts"
105
106delayed_postinsts () {
107 cat ${STATUS}|grep -e "^Package:" -e "^Status:"|sed -ne 'N;s/Package: \(.*\)\nStatus:.*unpacked/\1/p'
108}
109
110save_postinsts () {
111 for p in $(delayed_postinsts); do
112 install -d ${IMAGE_ROOTFS}${sysconfdir}/ipk-postinsts
113 cp ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/info/$p.postinst ${IMAGE_ROOTFS}${sysconfdir}/ipk-postinsts/$p
114 done
115}
116
124rootfs_ipk_write_manifest() { 117rootfs_ipk_write_manifest() {
125 manifest=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.manifest 118 manifest=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.manifest
126 cp ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/status $manifest 119 cp ${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/status $manifest
@@ -145,6 +138,10 @@ rootfs_install_packages() {
145 opkg-cl ${OPKG_ARGS} install `cat $1` 138 opkg-cl ${OPKG_ARGS} install `cat $1`
146} 139}
147 140
141rootfs_remove_packages() {
142 opkg-cl ${OPKG_ARGS} --force-depends remove $@
143}
144
148ipk_insert_feed_uris () { 145ipk_insert_feed_uris () {
149 146
150 echo "Building from feeds activated!" 147 echo "Building from feeds activated!"
diff --git a/meta/classes/rootfs_rpm.bbclass b/meta/classes/rootfs_rpm.bbclass
index d373dab408..4194c5621c 100644
--- a/meta/classes/rootfs_rpm.bbclass
+++ b/meta/classes/rootfs_rpm.bbclass
@@ -114,8 +114,8 @@ fakeroot rootfs_rpm_do_rootfs () {
114 ${ROOTFS_POSTPROCESS_COMMAND} 114 ${ROOTFS_POSTPROCESS_COMMAND}
115 115
116 if ${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "true", "false" ,d)}; then 116 if ${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "true", "false" ,d)}; then
117 if [ -d ${IMAGE_ROOTFS}/etc/rpm-postinsts ] ; then 117 if [ -d ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts ] ; then
118 if [ "`ls -A ${IMAGE_ROOTFS}/etc/rpm-postinsts`" != "" ] ; then 118 if [ "`ls -A ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts`" != "" ] ; then
119 bberror "Some packages could not be configured offline and rootfs is read-only." 119 bberror "Some packages could not be configured offline and rootfs is read-only."
120 exit 1 120 exit 1
121 fi 121 fi
@@ -135,6 +135,20 @@ fakeroot rootfs_rpm_do_rootfs () {
135 log_check rootfs 135 log_check rootfs
136} 136}
137 137
138rootfs_rpm_do_rootfs[vardeps] += "delayed_postinsts"
139
140delayed_postinsts() {
141 if [ -d ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts ]; then
142 ls ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts
143 fi
144}
145
146save_postinsts() {
147 # this is just a stub. For RPM, the failed postinstalls are already saved in
148 # /etc/rpm-postinsts
149 true
150}
151
138remove_packaging_data_files() { 152remove_packaging_data_files() {
139 # Save the rpmlib for increment rpm image generation 153 # Save the rpmlib for increment rpm image generation
140 t="${T}/saved_rpmlib/var/lib" 154 t="${T}/saved_rpmlib/var/lib"
@@ -165,6 +179,15 @@ rootfs_install_packages() {
165 package_install_internal_rpm 179 package_install_internal_rpm
166} 180}
167 181
182rootfs_remove_packages() {
183 rpm -e --nodeps --root=${IMAGE_ROOTFS} --dbpath=/var/lib/rpm\
184 --define='_cross_scriptlet_wrapper ${WORKDIR}/scriptlet_wrapper'\
185 --define='_tmppath /install/tmp' $@
186
187 # remove temp directory
188 rm -rf ${IMAGE_ROOTFS}/install
189}
190
168python () { 191python () {
169 if d.getVar('BUILD_IMAGES_FROM_FEEDS', True): 192 if d.getVar('BUILD_IMAGES_FROM_FEEDS', True):
170 flags = d.getVarFlag('do_rootfs', 'recrdeptask') 193 flags = d.getVarFlag('do_rootfs', 'recrdeptask')