summaryrefslogtreecommitdiffstats
path: root/meta/classes/image.bbclass
diff options
context:
space:
mode:
authorLaurentiu Palcu <laurentiu.palcu@intel.com>2013-12-18 18:02:18 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-02-11 11:53:38 +0000
commit7fc9bdaeed5aa3f2dd8b83a660eb97797bd2fcf4 (patch)
treefe2f2286820d9b484e721a323e8c8eacc1af39b9 /meta/classes/image.bbclass
parent85cc53a5a09e4076a0940c938374e6be8795db80 (diff)
downloadpoky-7fc9bdaeed5aa3f2dd8b83a660eb97797bd2fcf4.tar.gz
Activate the new python rootfs/image creation routines
This commit will: * remove old bash code common to all backends; * create a new do_rootfs() python function that will use the new rootfs/image creation routines; * allow creation of dpkg based images; * fail for rpm/opkg (not implemented yet); (From OE-Core rev: a83144bac8d67704ff66f5dc0fc56f5b63979694) 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.bbclass262
1 files changed, 11 insertions, 251 deletions
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 37b761ba44..0b35c719fd 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -151,32 +151,11 @@ python () {
151 d.appendVarFlag('do_bundle_initramfs', 'depends', " %s:do_rootfs" % initramfs_image) 151 d.appendVarFlag('do_bundle_initramfs', 'depends', " %s:do_rootfs" % initramfs_image)
152} 152}
153 153
154#
155# Get a list of files containing device tables to create.
156# * IMAGE_DEVICE_TABLE is the old name to an absolute path to a device table file
157# * IMAGE_DEVICE_TABLES is a new name for a file, or list of files, seached
158# for in the BBPATH
159# If neither are specified then the default name of files/device_table-minimal.txt
160# is searched for in the BBPATH (same as the old version.)
161#
162def get_devtable_list(d):
163 devtable = d.getVar('IMAGE_DEVICE_TABLE', True)
164 if devtable != None:
165 return devtable
166 str = ""
167 devtables = d.getVar('IMAGE_DEVICE_TABLES', True)
168 if devtables == None:
169 devtables = 'files/device_table-minimal.txt'
170 for devtable in devtables.split():
171 str += " %s" % bb.utils.which(d.getVar('BBPATH', True), devtable)
172 return str
173
174IMAGE_CLASSES ?= "image_types" 154IMAGE_CLASSES ?= "image_types"
175inherit ${IMAGE_CLASSES} 155inherit ${IMAGE_CLASSES}
176 156
177IMAGE_POSTPROCESS_COMMAND ?= "" 157IMAGE_POSTPROCESS_COMMAND ?= ""
178MACHINE_POSTPROCESS_COMMAND ?= "" 158MACHINE_POSTPROCESS_COMMAND ?= ""
179ROOTFS_POSTPROCESS_COMMAND_prepend = "run_intercept_scriptlets; "
180# Allow dropbear/openssh to accept logins from accounts with an empty password string if debug-tweaks is enabled 159# Allow dropbear/openssh to accept logins from accounts with an empty password string if debug-tweaks is enabled
181ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "debug-tweaks", "ssh_allow_empty_password; ", "",d)}' 160ROOTFS_POSTPROCESS_COMMAND += '${@base_contains("IMAGE_FEATURES", "debug-tweaks", "ssh_allow_empty_password; ", "",d)}'
182# Enable postinst logging if debug-tweaks is enabled 161# Enable postinst logging if debug-tweaks is enabled
@@ -197,7 +176,7 @@ LINGUAS_INSTALL ?= "${@" ".join(map(lambda s: "locale-base-%s" % s, d.getVar('IM
197 176
198PSEUDO_PASSWD = "${IMAGE_ROOTFS}" 177PSEUDO_PASSWD = "${IMAGE_ROOTFS}"
199 178
200do_rootfs[dirs] = "${TOPDIR} ${WORKDIR}/intercept_scripts" 179do_rootfs[dirs] = "${TOPDIR}"
201do_rootfs[lockfiles] += "${IMAGE_ROOTFS}.lock" 180do_rootfs[lockfiles] += "${IMAGE_ROOTFS}.lock"
202do_rootfs[cleandirs] += "${S} ${WORKDIR}/intercept_scripts" 181do_rootfs[cleandirs] += "${S} ${WORKDIR}/intercept_scripts"
203 182
@@ -205,63 +184,6 @@ do_rootfs[cleandirs] += "${S} ${WORKDIR}/intercept_scripts"
205# task, so that we have a single fakeroot context for the whole process. 184# task, so that we have a single fakeroot context for the whole process.
206do_rootfs[umask] = "022" 185do_rootfs[umask] = "022"
207 186
208
209run_intercept_scriptlets () {
210 if [ -d ${WORKDIR}/intercept_scripts ]; then
211 cd ${WORKDIR}/intercept_scripts
212 echo "Running intercept scripts:"
213 for script in *; do
214 [ "$script" = "*" ] && break
215 [ "$script" = "postinst_intercept" ] || [ ! -x "$script" ] && continue
216 echo "> Executing $script"
217 ./$script && continue
218 echo "WARNING: intercept script \"$script\" failed, falling back to running postinstalls at first boot"
219 #
220 # If we got here, than the intercept has failed. Next, we must
221 # mark the postinstalls as "unpacked". For rpm is a little bit
222 # different, we just have to save the package postinstalls in
223 # /etc/rpm-postinsts
224 #
225 pkgs="$(cat ./$script|grep "^##PKGS"|cut -d':' -f2)" || continue
226 case ${IMAGE_PKGTYPE} in
227 "rpm")
228 [ -d ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts/ ] || mkdir ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts/
229 v_expr=$(echo ${MULTILIB_GLOBAL_VARIANTS}|tr ' ' '|')
230 for p in $pkgs; do
231 # remove any multilib prefix from the package name (RPM
232 # does not use it like this)
233 new_p=$(echo $p | sed -r "s/^($v_expr)-//")
234
235 # extract the postinstall scriptlet from rpm package and
236 # save it in /etc/rpm-postinsts
237 echo " * postponing $new_p"
238 rpm -q --scripts --root=${IMAGE_ROOTFS} --dbpath=/var/lib/rpm $new_p |\
239 sed -n -e '/^postinstall scriptlet (using .*):$/,/^.* scriptlet (using .*):$/ {/.*/p}' |\
240 sed -e 's/postinstall scriptlet (using \(.*\)):$/#!\1/' -e '/^.* scriptlet (using .*):$/d'\
241 > ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts/$new_p
242 chmod +x ${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts/$new_p
243 done
244 # move to the next intercept script
245 continue
246 ;;
247 "ipk")
248 status_file="${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/status"
249 ;;
250 "deb")
251 status_file="${IMAGE_ROOTFS}/var/lib/dpkg/status"
252 ;;
253 esac
254 # the next piece of code is run only for ipk/dpkg
255 sed_expr=""
256 for p in $pkgs; do
257 echo " * postponing $p"
258 sed_expr="$sed_expr -e \"/^Package: ${p}$/,/^Status: install.* installed$/ {s/installed/unpacked/}\""
259 done
260 eval sed -i $sed_expr $status_file
261 done
262 fi
263}
264
265# A hook function to support read-only-rootfs IMAGE_FEATURES 187# A hook function to support read-only-rootfs IMAGE_FEATURES
266# Currently, it only supports sysvinit system. 188# Currently, it only supports sysvinit system.
267read_only_rootfs_hook () { 189read_only_rootfs_hook () {
@@ -328,72 +250,19 @@ python rootfs_runtime_mapping() {
328} 250}
329do_rootfs[prefuncs] += "rootfs_runtime_mapping" 251do_rootfs[prefuncs] += "rootfs_runtime_mapping"
330 252
331fakeroot do_rootfs () { 253fakeroot python do_rootfs () {
332 #set -x 254 from oe.rootfs import create_rootfs
333 # When use the rpm incremental image generation, don't remove the rootfs 255 from oe.image import create_image
334 if [ "${INC_RPM_IMAGE_GEN}" != "1" -o "${IMAGE_PKGTYPE}" != "rpm" ]; then 256 from oe.manifest import create_manifest
335 rm -rf ${IMAGE_ROOTFS}
336 elif [ -d ${T}/saved_rpmlib/var/lib/rpm ]; then
337 # Move the rpmlib back
338 if [ ! -d ${IMAGE_ROOTFS}/var/lib/rpm ]; then
339 mkdir -p ${IMAGE_ROOTFS}/var/lib/
340 mv ${T}/saved_rpmlib/var/lib/rpm ${IMAGE_ROOTFS}/var/lib/
341 fi
342 fi
343 rm -rf ${MULTILIB_TEMP_ROOTFS}
344 mkdir -p ${IMAGE_ROOTFS}
345 mkdir -p ${DEPLOY_DIR_IMAGE}
346
347 cp ${COREBASE}/meta/files/deploydir_readme.txt ${DEPLOY_DIR_IMAGE}/README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt || true
348
349 # copy the intercept scripts
350 cp ${COREBASE}/scripts/postinst-intercepts/* ${WORKDIR}/intercept_scripts/
351
352 rootfs_${IMAGE_PKGTYPE}_do_rootfs
353
354 if [ "${USE_DEVFS}" != "1" ]; then
355 for devtable in ${@get_devtable_list(d)}; do
356 # Always return ture since there maybe already one when use the
357 # incremental image generation
358 makedevs -r ${IMAGE_ROOTFS} -D $devtable
359 done
360 fi
361
362 # remove unneeded packages/files from the final image
363 rootfs_uninstall_unneeded
364
365 insert_feed_uris
366 257
367 if [ "x${LDCONFIGDEPEND}" != "x" ]; then 258 # generate the initial manifest
368 # Run ldconfig on the image to create a valid cache 259 create_manifest(d)
369 # (new format for cross arch compatibility)
370 echo executing: ldconfig -r ${IMAGE_ROOTFS} -c new -v
371 ldconfig -r ${IMAGE_ROOTFS} -c new -v
372 fi
373
374 # (re)create kernel modules dependencies
375 # This part is done by kernel-module-* postinstall scripts but if image do
376 # not contains modules at all there are few moments in boot sequence with
377 # "unable to open modules.dep" message.
378 if [ -e ${STAGING_KERNEL_DIR}/kernel-abiversion ]; then
379 KERNEL_VERSION=`cat ${STAGING_KERNEL_DIR}/kernel-abiversion`
380 260
381 mkdir -p ${IMAGE_ROOTFS}/lib/modules/$KERNEL_VERSION 261 # generate rootfs
382 depmodwrapper -a -b ${IMAGE_ROOTFS} $KERNEL_VERSION 262 create_rootfs(d)
383 fi
384 263
385 ${IMAGE_PREPROCESS_COMMAND} 264 # generate final images
386 265 create_image(d)
387 ${@get_imagecmds(d)}
388
389 ${IMAGE_POSTPROCESS_COMMAND}
390
391 ${MACHINE_POSTPROCESS_COMMAND}
392
393 if [ -n "${IMAGE_LINK_NAME}" -a -f "${IMAGE_MANIFEST}" ]; then
394 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.manifest
395 ln -s ${IMAGE_NAME}.rootfs.manifest ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.manifest
396 fi
397} 266}
398 267
399insert_feed_uris () { 268insert_feed_uris () {
@@ -414,23 +283,6 @@ insert_feed_uris () {
414 done 283 done
415} 284}
416 285
417log_check() {
418 for target in $*
419 do
420 lf_path="`dirname ${BB_LOGFILE}`/log.do_$target.${PID}"
421
422 echo "log_check: Using $lf_path as logfile"
423
424 if test -e "$lf_path"
425 then
426 ${IMAGE_PKGTYPE}_log_check $target $lf_path
427 else
428 echo "Cannot find logfile [$lf_path]"
429 fi
430 echo "Logfile is clean"
431 done
432}
433
434MULTILIBRE_ALLOW_REP =. "${base_bindir}|${base_sbindir}|${bindir}|${sbindir}|${libexecdir}|" 286MULTILIBRE_ALLOW_REP =. "${base_bindir}|${base_sbindir}|${bindir}|${sbindir}|${libexecdir}|"
435MULTILIB_CHECK_FILE = "${WORKDIR}/multilib_check.py" 287MULTILIB_CHECK_FILE = "${WORKDIR}/multilib_check.py"
436MULTILIB_TEMP_ROOTFS = "${WORKDIR}/multilib" 288MULTILIB_TEMP_ROOTFS = "${WORKDIR}/multilib"
@@ -473,98 +325,6 @@ multilib_sanity_check() {
473 echo $@ | python ${MULTILIB_CHECK_FILE} 325 echo $@ | python ${MULTILIB_CHECK_FILE}
474} 326}
475 327
476get_split_linguas() {
477 for translation in ${IMAGE_LINGUAS}; do
478 translation_split=$(echo ${translation} | awk -F '-' '{print $1}')
479 echo ${translation}
480 echo ${translation_split}
481 done | sort | uniq
482}
483
484rootfs_install_complementary() {
485 # Install complementary packages based upon the list of currently installed packages
486 # e.g. locales, *-dev, *-dbg, etc. This will only attempt to install these packages,
487 # if they don't exist then no error will occur.
488 # Note: every backend needs to call this function explicitly after the normal
489 # package installation
490
491 # Get list of installed packages
492 list_installed_packages arch > ${WORKDIR}/installed_pkgs.txt
493
494 # Apply the globs to all the packages currently installed
495 if [ -n "$1" -a "$1" = "populate_sdk" ] ; then
496 GLOBS="${SDKIMAGE_INSTALL_COMPLEMENTARY}"
497 elif [ -n "$1" ]; then
498 GLOBS="$@"
499 else
500 GLOBS="${IMAGE_INSTALL_COMPLEMENTARY}"
501 # Add locales
502 SPLIT_LINGUAS=`get_split_linguas`
503 PACKAGES_TO_INSTALL=""
504 for lang in $SPLIT_LINGUAS ; do
505 GLOBS="$GLOBS *-locale-$lang"
506 done
507 fi
508
509 if [ "$GLOBS" != "" ] ; then
510 # Use the magic script to do all the work for us :)
511 : > ${WORKDIR}/complementary_pkgs.txt
512 oe-pkgdata-util glob ${PKGDATA_DIR} ${WORKDIR}/installed_pkgs.txt "$GLOBS" >> ${WORKDIR}/complementary_pkgs.txt
513
514 # Install the packages, if any
515 sed -i '/^$/d' ${WORKDIR}/complementary_pkgs.txt
516 if [ -s ${WORKDIR}/complementary_pkgs.txt ]; then
517 echo "Installing complementary packages"
518 rootfs_install_packages ${WORKDIR}/complementary_pkgs.txt
519 fi
520 fi
521
522 # Workaround for broken shell function dependencies
523 if false ; then
524 get_split_linguas
525 fi
526}
527
528rootfs_uninstall_unneeded () {
529 if ${@base_contains("IMAGE_FEATURES", "package-management", "false", "true", d)}; then
530 if [ -z "$(delayed_postinsts)" ]; then
531 # All packages were successfully configured.
532 # update-rc.d, base-passwd, run-postinsts are no further use, remove them now
533 remove_run_postinsts=false
534 if [ -e ${IMAGE_ROOTFS}${sbindir}/run-postinsts ]; then
535 remove_run_postinsts=true
536 fi
537
538 # Remove package only if it's installed
539 pkgs_to_remove="update-rc.d base-passwd update-alternatives shadow ${ROOTFS_BOOTSTRAP_INSTALL}"
540 for pkg in $pkgs_to_remove; do
541 # regexp for pkg, to be used in grep and sed
542 pkg_regexp="^`echo $pkg | sed 's/\./\\\./'` "
543 if grep -q "$pkg_regexp" ${WORKDIR}/installed_pkgs.txt; then
544 rootfs_uninstall_packages $pkg
545 sed -i "/$pkg_regexp/d" ${WORKDIR}/installed_pkgs.txt
546 fi
547 done
548
549 # Need to remove rc.d files for run-postinsts by hand since opkg won't
550 # call postrm scripts in offline root mode.
551 if $remove_run_postinsts; then
552 update-rc.d -f -r ${IMAGE_ROOTFS} run-postinsts remove
553 fi
554 else
555 # Some packages were not successfully configured, save them only
556 # if we have run-postinsts script present. Otherwise, they're
557 # useless
558 if [ -e ${IMAGE_ROOTFS}${sbindir}/run-postinsts ]; then
559 save_postinsts
560 fi
561 fi
562
563 # Since no package manager is present in the image the metadata is not needed
564 remove_packaging_data_files
565 fi
566}
567
568# This function is intended to disallow empty root password if 'debug-tweaks' is not in IMAGE_FEATURES. 328# This function is intended to disallow empty root password if 'debug-tweaks' is not in IMAGE_FEATURES.
569zap_empty_root_password () { 329zap_empty_root_password () {
570 if [ -e ${IMAGE_ROOTFS}/etc/shadow ]; then 330 if [ -e ${IMAGE_ROOTFS}/etc/shadow ]; then