summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2011-12-28 17:16:11 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-01-11 10:36:22 +0000
commit9d1823b2a0193b3c20fa30f0a118b4ee80a20027 (patch)
tree9121080b49eabb7cb29db155de82f2e6a1e45445 /meta
parent489cde8eb0e19ef6fe8078148199eaf5b52631ae (diff)
downloadpoky-9d1823b2a0193b3c20fa30f0a118b4ee80a20027.tar.gz
Incremental rpm image generation
Incremental rpm image generation, the rootfs would be totally removed and re-created in the second generation by default, but with INC_RPM_IMAGE_GEN = "1", the rpm based rootfs would be kept, and will do update(remove/add some pkgs) on it. NOTE: This is not suggested when you want to create a productive rootfs For example: 1) Add the follow config option to a conf file: INC_RPM_IMAGE_GEN = "1" 2) bitbake core-image-sato modify a package bitbake core-image-sato The rootfs would not be totally removed and re-created in the second generation, it would be simply updated based on the "package". Implatation: 1) Figure out the pkg which need to be removed or re-installed, then use 'rpm -e to remove the old one. Use the rpm's BUILDTIME to determine which pkg has been rebuilt. 2) Figure out the pkg which is newly added, and use 'rpm -U' to install it. This only for the rpm based rootfs, the deb and ipk based rootfs would be done later. [YOCTO #1651] (From OE-Core rev: 575ba3c9e153a1d8ac228a99a03ca2df5fbca151) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/image.bbclass11
-rw-r--r--meta/classes/package_rpm.bbclass73
-rw-r--r--meta/classes/rootfs_rpm.bbclass6
3 files changed, 77 insertions, 13 deletions
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 295b653c97..3034725ac2 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -134,15 +134,22 @@ do_rootfs[umask] = 022
134 134
135fakeroot do_rootfs () { 135fakeroot do_rootfs () {
136 #set -x 136 #set -x
137 rm -rf ${IMAGE_ROOTFS} 137 # When use the rpm incremental image generation, don't remove the rootfs
138 if [ "${INC_RPM_IMAGE_GEN}" != "1" -o "${IMAGE_PKGTYPE}" != "rpm" ]; then
139 rm -rf ${IMAGE_ROOTFS}
140 fi
138 rm -rf ${MULTILIB_TEMP_ROOTFS} 141 rm -rf ${MULTILIB_TEMP_ROOTFS}
139 mkdir -p ${IMAGE_ROOTFS} 142 mkdir -p ${IMAGE_ROOTFS}
140 mkdir -p ${DEPLOY_DIR_IMAGE} 143 mkdir -p ${DEPLOY_DIR_IMAGE}
141 144
142 cp ${COREBASE}/meta/files/deploydir_readme.txt ${DEPLOY_DIR_IMAGE}/README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt 145 cp ${COREBASE}/meta/files/deploydir_readme.txt ${DEPLOY_DIR_IMAGE}/README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt
143 146
144 if [ "${USE_DEVFS}" != "1" ]; then 147 # If "${IMAGE_ROOTFS}/dev" exists, then the device had been made by
148 # the previous build
149 if [ "${USE_DEVFS}" != "1" -a ! -r "${IMAGE_ROOTFS}/dev" ]; then
145 for devtable in ${@get_devtable_list(d)}; do 150 for devtable in ${@get_devtable_list(d)}; do
151 # Always return ture since there maybe already one when use the
152 # incremental image generation
146 makedevs -r ${IMAGE_ROOTFS} -D $devtable 153 makedevs -r ${IMAGE_ROOTFS} -D $devtable
147 done 154 done
148 fi 155 fi
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index d03dc3f883..2d92efe272 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -147,6 +147,67 @@ resolve_package_rpm () {
147 echo $pkg_name 147 echo $pkg_name
148} 148}
149 149
150# rpm common command and options
151rpm_common_comand () {
152
153 local target_rootfs="${INSTALL_ROOTFS_RPM}"
154 local extra_args="$@"
155
156 ${RPM} --root ${target_rootfs} \
157 --predefine "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
158 --predefine "_rpmrc_platform_path ${target_rootfs}/etc/rpm/platform" \
159 -D "_var ${localstatedir}" \
160 -D "_dbpath ${rpmlibdir}" \
161 --noparentdirs --nolinktos \
162 -D "__dbi_txn create nofsync private" \
163 -D "_cross_scriptlet_wrapper ${WORKDIR}/scriptlet_wrapper" $extra_args
164}
165
166# install or remove the pkg
167rpm_update_pkg () {
168
169 local target_rootfs="${INSTALL_ROOTFS_RPM}"
170
171 # Save the rpm's build time for incremental image generation, and the file
172 # would be moved to ${T}
173 rm -f ${target_rootfs}/install/total_solution_bt.manifest
174 for i in `cat ${target_rootfs}/install/total_solution.manifest`; do
175 # Use "rpm" rather than "${RPM}" here, since we don't need the
176 # '--dbpath' option
177 echo "$i `rpm -qp --qf '%{BUILDTIME}\n' $i`" >> \
178 ${target_rootfs}/install/total_solution_bt.manifest
179 done
180
181 # Only install the different pkgs if incremental image generation is set
182 if [ "${INC_RPM_IMAGE_GEN}" = "1" -a -f ${T}/total_solution_bt.manifest -a \
183 "${IMAGE_PKGTYPE}" = "rpm" ]; then
184 cur_list="${target_rootfs}/install/total_solution_bt.manifest"
185 pre_list="${T}/total_solution_bt.manifest"
186 sort -u $cur_list -o $cur_list
187 sort -u $pre_list -o $pre_list
188 comm -1 -3 $cur_list $pre_list | sed 's#.*/\(.*\)\.rpm .*#\1#' > \
189 ${target_rootfs}/install/remove.manifest
190 comm -2 -3 $cur_list $pre_list | awk '{print $1}' > \
191 ${target_rootfs}/install/incremental.manifest
192
193 # Attempt to remove unwanted pkgs, the scripts(pre, post, etc.) has not
194 # been run by now, so don't have to run them(preun, postun, etc.) when
195 # erase the pkg
196 if [ -s ${target_rootfs}/install/remove.manifest ]; then
197 rpm_common_comand --noscripts --nodeps \
198 -e `cat ${target_rootfs}/install/remove.manifest`
199 fi
200
201 # Attempt to install the incremental pkgs
202 rpm_common_comand --nodeps --replacefiles --replacepkgs \
203 -Uvh ${target_rootfs}/install/incremental.manifest
204 else
205 # Attempt to install
206 rpm_common_comand --replacepkgs \
207 -Uhv ${target_rootfs}/install/total_solution.manifest
208 fi
209}
210
150# 211#
151# install a bunch of packages using rpm 212# install a bunch of packages using rpm
152# the following shell variables needs to be set before calling this func: 213# the following shell variables needs to be set before calling this func:
@@ -406,16 +467,8 @@ EOF
406 467
407 chmod 0755 ${WORKDIR}/scriptlet_wrapper 468 chmod 0755 ${WORKDIR}/scriptlet_wrapper
408 469
409 # Attempt install 470 rpm_update_pkg
410 ${RPM} --root ${target_rootfs} \ 471
411 --predefine "_rpmds_sysinfo_path ${target_rootfs}/etc/rpm/sysinfo" \
412 --predefine "_rpmrc_platform_path ${target_rootfs}/etc/rpm/platform" \
413 -D "_var ${localstatedir}" \
414 -D "_dbpath ${rpmlibdir}" \
415 --noparentdirs --nolinktos --replacepkgs \
416 -D "__dbi_txn create nofsync private" \
417 -D "_cross_scriptlet_wrapper ${WORKDIR}/scriptlet_wrapper" \
418 -Uhv ${target_rootfs}/install/total_solution.manifest
419} 472}
420 473
421python write_specfile () { 474python write_specfile () {
diff --git a/meta/classes/rootfs_rpm.bbclass b/meta/classes/rootfs_rpm.bbclass
index 999b8a6c86..48133f080b 100644
--- a/meta/classes/rootfs_rpm.bbclass
+++ b/meta/classes/rootfs_rpm.bbclass
@@ -201,11 +201,15 @@ rootfs_check_package_exists() {
201} 201}
202 202
203rootfs_install_packages() { 203rootfs_install_packages() {
204 # The pkg to be installed here is not controlled by the
205 # package_install_internal_rpm, so it may have already been
206 # installed(e.g, installed in the first time when generate the
207 # rootfs), use '--replacepkgs' to always install them
204 for pkg in $@; do 208 for pkg in $@; do
205 ${RPM} --root ${IMAGE_ROOTFS} -D "_dbpath ${rpmlibdir}" \ 209 ${RPM} --root ${IMAGE_ROOTFS} -D "_dbpath ${rpmlibdir}" \
206 -D "__dbi_txn create nofsync private" \ 210 -D "__dbi_txn create nofsync private" \
207 --noscripts --notriggers --noparentdirs --nolinktos \ 211 --noscripts --notriggers --noparentdirs --nolinktos \
208 -Uhv $pkg || true 212 --replacepkgs -Uhv $pkg || true
209 done 213 done
210} 214}
211 215