summaryrefslogtreecommitdiffstats
path: root/meta
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
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')
-rw-r--r--meta/classes/image.bbclass262
-rw-r--r--meta/classes/image_types.bbclass113
-rw-r--r--meta/classes/package_deb.bbclass146
-rw-r--r--meta/classes/rootfs_deb.bbclass115
4 files changed, 11 insertions, 625 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
diff --git a/meta/classes/image_types.bbclass b/meta/classes/image_types.bbclass
index 48675b8794..393bfa82eb 100644
--- a/meta/classes/image_types.bbclass
+++ b/meta/classes/image_types.bbclass
@@ -1,122 +1,9 @@
1def get_imagecmds(d):
2 cmds = "\n"
3 old_overrides = d.getVar('OVERRIDES', 0)
4
5 alltypes = d.getVar('IMAGE_FSTYPES', True).split()
6 types = []
7 ctypes = d.getVar('COMPRESSIONTYPES', True).split()
8 cimages = {}
9
10 # Image type b depends on a having been generated first
11 def addtypedepends(a, b):
12 if a in alltypes:
13 alltypes.remove(a)
14 if b not in alltypes:
15 alltypes.append(b)
16 alltypes.append(a)
17
18 # The elf image depends on the cpio.gz image already having
19 # been created, so we add that explicit ordering here.
20 addtypedepends("elf", "cpio.gz")
21
22 # jffs2 sumtool'd images need jffs2
23 addtypedepends("sum.jffs2", "jffs2")
24
25 # Filter out all the compressed images from alltypes
26 for type in alltypes:
27 basetype = None
28 for ctype in ctypes:
29 if type.endswith("." + ctype):
30 basetype = type[:-len("." + ctype)]
31 if basetype not in types:
32 types.append(basetype)
33 if basetype not in cimages:
34 cimages[basetype] = []
35 if ctype not in cimages[basetype]:
36 cimages[basetype].append(ctype)
37 break
38 if not basetype and type not in types:
39 types.append(type)
40
41 # Live and VMDK images will be processed via inheriting
42 # bbclass and does not get processed here.
43 # vmdk depend on live images also depend on ext3 so ensure its present
44 # Note: we need to ensure ext3 is in alltypes, otherwise, subimages may
45 # not contain ext3 and the .rootfs.ext3 file won't be created.
46 if "vmdk" in types:
47 if "ext3" not in types:
48 types.append("ext3")
49 if "ext3" not in alltypes:
50 alltypes.append("ext3")
51 types.remove("vmdk")
52 if "live" in types or "iso" in types or "hddimg" in types:
53 if "ext3" not in types:
54 types.append("ext3")
55 if "ext3" not in alltypes:
56 alltypes.append("ext3")
57 if "live" in types:
58 types.remove("live")
59 if "iso" in types:
60 types.remove("iso")
61 if "hddimg" in types:
62 types.remove("hddimg")
63
64 if d.getVar('IMAGE_LINK_NAME', True):
65 if d.getVar('RM_OLD_IMAGE', True) == "1":
66 # Remove the old image
67 cmds += "\trm -f `find ${DEPLOY_DIR_IMAGE} -maxdepth 1 -type l -name ${IMAGE_LINK_NAME}'.*' -exec readlink -f {} \;`"
68 # Remove the symlink
69 cmds += "\n\trm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.*"
70
71 for type in types:
72 ccmd = []
73 subimages = []
74 localdata = bb.data.createCopy(d)
75 localdata.setVar('OVERRIDES', '%s:%s' % (type, old_overrides))
76 bb.data.update_data(localdata)
77 localdata.setVar('type', type)
78 if type in cimages:
79 for ctype in cimages[type]:
80 ccmd.append("\t" + localdata.getVar("COMPRESS_CMD_" + ctype, True))
81 subimages.append(type + "." + ctype)
82 if type not in alltypes:
83 ccmd.append(localdata.expand("\trm ${IMAGE_NAME}.rootfs.${type}"))
84 else:
85 subimages.append(type)
86 localdata.setVar('ccmd', "\n".join(ccmd))
87 localdata.setVar('subimages', " ".join(subimages))
88 cmd = localdata.getVar("IMAGE_CMD", True)
89 localdata.setVar('cmd', cmd)
90 cmds += "\n" + localdata.getVar("runimagecmd", True)
91 return cmds
92 1
93# The default aligment of the size of the rootfs is set to 1KiB. In case 2# The default aligment of the size of the rootfs is set to 1KiB. In case
94# you're using the SD card emulation of a QEMU system simulator you may 3# you're using the SD card emulation of a QEMU system simulator you may
95# set this value to 2048 (2MiB alignment). 4# set this value to 2048 (2MiB alignment).
96IMAGE_ROOTFS_ALIGNMENT ?= "1" 5IMAGE_ROOTFS_ALIGNMENT ?= "1"
97 6
98runimagecmd () {
99 # Image generation code for image type ${type}
100 # The base_size gets calculated:
101 # - initial size determined by `du -ks` of the IMAGE_ROOTFS
102 # - then multiplied by the IMAGE_OVERHEAD_FACTOR
103 # - tested against IMAGE_ROOTFS_SIZE
104 # - round up ROOTFS_SIZE to IMAGE_ROOTFS_ALIGNMENT
105 ROOTFS_SIZE=`du -ks ${IMAGE_ROOTFS} | awk '{base_size = $1 * ${IMAGE_OVERHEAD_FACTOR}; base_size = ((base_size > ${IMAGE_ROOTFS_SIZE} ? base_size : ${IMAGE_ROOTFS_SIZE}) + ${IMAGE_ROOTFS_EXTRA_SPACE}); if (base_size != int(base_size)) base_size = int(base_size + 1); base_size = base_size + ${IMAGE_ROOTFS_ALIGNMENT} - 1; base_size -= base_size % ${IMAGE_ROOTFS_ALIGNMENT}; print base_size }'`
106 ${cmd}
107 # Now create the needed compressed versions
108 cd ${DEPLOY_DIR_IMAGE}/
109 ${ccmd}
110 # And create the symlinks
111 if [ -n "${IMAGE_LINK_NAME}" ]; then
112 for type in ${subimages}; do
113 if [ -e ${IMAGE_NAME}.rootfs.$type ]; then
114 ln -s ${IMAGE_NAME}.rootfs.$type ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.$type
115 fi
116 done
117 fi
118}
119
120def imagetypes_getdepends(d): 7def imagetypes_getdepends(d):
121 def adddep(depstr, deps): 8 def adddep(depstr, deps):
122 for i in (depstr or "").split(): 9 for i in (depstr or "").split():
diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass
index 5d316aa8b2..bf9739e099 100644
--- a/meta/classes/package_deb.bbclass
+++ b/meta/classes/package_deb.bbclass
@@ -15,38 +15,6 @@ APTCONF_TARGET = "${WORKDIR}"
15APT_ARGS = "${@['', '--no-install-recommends'][d.getVar("NO_RECOMMENDATIONS", True) == "1"]}" 15APT_ARGS = "${@['', '--no-install-recommends'][d.getVar("NO_RECOMMENDATIONS", True) == "1"]}"
16 16
17# 17#
18# Update the Packages index files in ${DEPLOY_DIR_DEB}
19#
20package_update_index_deb () {
21
22 local debarchs=""
23
24 if [ ! -z "${DEPLOY_KEEP_PACKAGES}" ]; then
25 return
26 fi
27
28 for arch in ${PACKAGE_ARCHS} ${SDK_PACKAGE_ARCHS}; do
29 if [ -e ${DEPLOY_DIR_DEB}/$arch ]; then
30 debarchs="$debarchs $arch"
31 fi
32 done
33
34 found=0
35 for arch in $debarchs; do
36 if [ ! -d ${DEPLOY_DIR_DEB}/$arch ]; then
37 continue;
38 fi
39 cd ${DEPLOY_DIR_DEB}/$arch
40 dpkg-scanpackages . | gzip > Packages.gz
41 echo "Label: $arch" > Release
42 found=1
43 done
44 if [ "$found" != "1" ]; then
45 bbfatal "There are no packages in ${DEPLOY_DIR_DEB}!"
46 fi
47}
48
49#
50# install a bunch of packages using apt 18# install a bunch of packages using apt
51# the following shell variables needs to be set before calling this func: 19# the following shell variables needs to be set before calling this func:
52# INSTALL_ROOTFS_DEB - install root dir 20# INSTALL_ROOTFS_DEB - install root dir
@@ -57,120 +25,6 @@ package_update_index_deb () {
57# INSTALL_PACKAGES_LINGUAS_DEB - additional packages for uclibc 25# INSTALL_PACKAGES_LINGUAS_DEB - additional packages for uclibc
58# INSTALL_TASK_DEB - task name 26# INSTALL_TASK_DEB - task name
59 27
60package_install_internal_deb () {
61
62 local target_rootfs="${INSTALL_ROOTFS_DEB}"
63 local dpkg_arch="${INSTALL_BASEARCH_DEB}"
64 local archs="${INSTALL_ARCHS_DEB}"
65 local package_to_install="${INSTALL_PACKAGES_NORMAL_DEB}"
66 local package_attemptonly="${INSTALL_PACKAGES_ATTEMPTONLY_DEB}"
67 local package_linguas="${INSTALL_PACKAGES_LINGUAS_DEB}"
68 local task="${INSTALL_TASK_DEB}"
69
70 mkdir -p ${APTCONF_TARGET}/apt
71 rm -f ${APTCONF_TARGET}/apt/sources.list.rev
72 rm -f ${APTCONF_TARGET}/apt/preferences
73
74 priority=1
75 for arch in $archs; do
76 if [ ! -d ${DEPLOY_DIR_DEB}/$arch ]; then
77 continue;
78 fi
79
80 echo "deb file:${DEPLOY_DIR_DEB}/$arch/ ./" >> ${APTCONF_TARGET}/apt/sources.list.rev
81 (echo "Package: *"
82 echo "Pin: release l=$arch"
83 echo "Pin-Priority: $(expr 800 + $priority)"
84 echo) >> ${APTCONF_TARGET}/apt/preferences
85 priority=$(expr $priority + 5)
86 done
87
88 for pkg in ${PACKAGE_EXCLUDE}; do
89 (echo "Package: $pkg"
90 echo "Pin: release *"
91 echo "Pin-Priority: -1"
92 echo) >> ${APTCONF_TARGET}/apt/preferences
93 done
94
95 tac ${APTCONF_TARGET}/apt/sources.list.rev > ${APTCONF_TARGET}/apt/sources.list
96
97 # The params in deb package control don't allow character `_', so
98 # change the arch's `_' to `-' in it.
99 dpkg_arch=`echo ${dpkg_arch} | sed 's/_/-/g'`
100 cat "${STAGING_ETCDIR_NATIVE}/apt/apt.conf.sample" \
101 | sed -e "s#Architecture \".*\";#Architecture \"${dpkg_arch}\";#" \
102 | sed -e "s:#ROOTFS#:${target_rootfs}:g" \
103 | sed -e "s:#APTCONF#:${APTCONF_TARGET}/apt:g" \
104 > "${APTCONF_TARGET}/apt/apt.conf"
105
106 export APT_CONFIG="${APTCONF_TARGET}/apt/apt.conf"
107
108 mkdir -p ${target_rootfs}/var/lib/dpkg/info
109 mkdir -p ${target_rootfs}/var/lib/dpkg/updates
110
111 > ${target_rootfs}/var/lib/dpkg/status
112 > ${target_rootfs}/var/lib/dpkg/available
113
114 apt-get update
115
116 if [ ! -z "${package_linguas}" ]; then
117 for i in ${package_linguas}; do
118 apt-get ${APT_ARGS} install $i --force-yes --allow-unauthenticated
119 if [ $? -ne 0 ]; then
120 exit 1
121 fi
122 done
123 fi
124
125 # normal install
126 if [ ! -z "${package_to_install}" ]; then
127 apt-get ${APT_ARGS} install ${package_to_install} --force-yes --allow-unauthenticated
128 if [ $? -ne 0 ]; then
129 exit 1
130 fi
131
132 # Attempt to correct the probable broken dependencies in place.
133 apt-get ${APT_ARGS} -f install
134 if [ $? -ne 0 ]; then
135 exit 1
136 fi
137 fi
138
139 rm -f `dirname ${BB_LOGFILE}`/log.do_${task}-attemptonly.${PID}
140 if [ ! -z "${package_attemptonly}" ]; then
141 for i in ${package_attemptonly}; do
142 apt-get ${APT_ARGS} install $i --force-yes --allow-unauthenticated >> `dirname ${BB_LOGFILE}`/log.do_${task}-attemptonly.${PID} 2>&1 || true
143 done
144 fi
145
146 find ${target_rootfs} -name \*.dpkg-new | for i in `cat`; do
147 mv $i `echo $i | sed -e's,\.dpkg-new$,,'`
148 done
149
150 # Mark all packages installed
151 sed -i -e "s/Status: install ok unpacked/Status: install ok installed/;" ${target_rootfs}/var/lib/dpkg/status
152}
153
154deb_log_check() {
155 target="$1"
156 lf_path="$2"
157
158 lf_txt="`cat $lf_path`"
159 for keyword_die in "^E:"
160 do
161 if (echo "$lf_txt" | grep -v log_check | grep "$keyword_die") >/dev/null 2>&1
162 then
163 echo "log_check: There were error messages in the logfile"
164 printf "log_check: Matched keyword: [$keyword_die]\n\n"
165 echo "$lf_txt" | grep -v log_check | grep -C 5 -i "$keyword_die"
166 echo ""
167 do_exit=1
168 fi
169 done
170 test "$do_exit" = 1 && exit 1
171 true
172}
173
174python do_package_deb () { 28python do_package_deb () {
175 import re, copy 29 import re, copy
176 import textwrap 30 import textwrap
diff --git a/meta/classes/rootfs_deb.bbclass b/meta/classes/rootfs_deb.bbclass
index bcfa95003c..728ea0e2d1 100644
--- a/meta/classes/rootfs_deb.bbclass
+++ b/meta/classes/rootfs_deb.bbclass
@@ -21,118 +21,3 @@ DEB_POSTPROCESS_COMMANDS = ""
21 21
22opkglibdir = "${localstatedir}/lib/opkg" 22opkglibdir = "${localstatedir}/lib/opkg"
23 23
24deb_package_setflag() {
25 sed -i -e "/^Package: $2\$/{n; s/Status: install ok .*/Status: install ok $1/;}" ${IMAGE_ROOTFS}/var/lib/dpkg/status
26}
27
28deb_package_getflag() {
29 cat ${IMAGE_ROOTFS}/var/lib/dpkg/status | sed -n -e "/^Package: $2\$/{n; s/Status: install ok .*/$1/; p}"
30}
31
32fakeroot rootfs_deb_do_rootfs () {
33 set +e
34
35 mkdir -p ${IMAGE_ROOTFS}/var/lib/dpkg/alternatives
36
37 # update index
38 package_update_index_deb
39
40 #install packages
41 export INSTALL_ROOTFS_DEB="${IMAGE_ROOTFS}"
42 export INSTALL_BASEARCH_DEB="${DPKG_ARCH}"
43 export INSTALL_ARCHS_DEB="${PACKAGE_ARCHS}"
44 export INSTALL_PACKAGES_NORMAL_DEB="${PACKAGE_INSTALL}"
45 export INSTALL_PACKAGES_ATTEMPTONLY_DEB="${PACKAGE_INSTALL_ATTEMPTONLY}"
46 export INSTALL_PACKAGES_LINGUAS_DEB="${LINGUAS_INSTALL}"
47 export INSTALL_TASK_DEB="rootfs"
48
49 package_install_internal_deb
50 ${DEB_POSTPROCESS_COMMANDS}
51
52 rootfs_install_complementary
53
54 export D=${IMAGE_ROOTFS}
55 export OFFLINE_ROOT=${IMAGE_ROOTFS}
56 export IPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
57 export OPKG_OFFLINE_ROOT=${IMAGE_ROOTFS}
58 export INTERCEPT_DIR=${WORKDIR}/intercept_scripts
59 export NATIVE_ROOT=${STAGING_DIR_NATIVE}
60
61 # Attempt to run preinsts
62 # Mark packages with preinst failures as unpacked
63 for i in ${IMAGE_ROOTFS}/var/lib/dpkg/info/*.preinst; do
64 if [ -f $i ] && ! sh $i; then
65 deb_package_setflag unpacked `basename $i .preinst`
66 fi
67 done
68
69 # Attempt to run postinsts
70 # Mark packages with postinst failures as unpacked
71 for i in ${IMAGE_ROOTFS}/var/lib/dpkg/info/*.postinst; do
72 if [ -f $i ] && ! sh $i configure; then
73 deb_package_setflag unpacked `basename $i .postinst`
74 fi
75 done
76
77 set -e
78
79 install -d ${IMAGE_ROOTFS}/${sysconfdir}
80 echo ${BUILDNAME} > ${IMAGE_ROOTFS}/${sysconfdir}/version
81
82 # Hacks to allow opkg's update-alternatives and opkg to coexist for now
83 mkdir -p ${IMAGE_ROOTFS}${opkglibdir}
84 if [ -e ${IMAGE_ROOTFS}/var/lib/dpkg/alternatives ]; then
85 rmdir ${IMAGE_ROOTFS}/var/lib/dpkg/alternatives
86 fi
87 ln -s ${opkglibdir}/alternatives ${IMAGE_ROOTFS}/var/lib/dpkg/alternatives
88 ln -s /var/lib/dpkg/info ${IMAGE_ROOTFS}${opkglibdir}/info
89 ln -s /var/lib/dpkg/status ${IMAGE_ROOTFS}${opkglibdir}/status
90
91 ${ROOTFS_POSTPROCESS_COMMAND}
92
93 if ${@base_contains("IMAGE_FEATURES", "read-only-rootfs", "true", "false" ,d)}; then
94 delayed_postinsts="$(delayed_postinsts)"
95 if [ -n "$delayed_postinsts" ]; then
96 bberror "The following packages could not be configured offline and rootfs is read-only: $delayed_postinsts"
97 exit 1
98 fi
99 fi
100
101 log_check rootfs
102}
103
104rootfs_deb_do_rootfs[vardeps] += "delayed_postinsts"
105
106delayed_postinsts () {
107 cat ${IMAGE_ROOTFS}/var/lib/dpkg/status|grep -e "^Package:" -e "^Status:"|sed -ne 'N;s/Package: \(.*\)\nStatus:.*unpacked/\1/p'
108}
109
110save_postinsts () {
111 # Scripts need to be ordered when executed, this ensures numeric order
112 # If we ever run into needing more the 899 scripts, we'll have to
113 # change num to start with 1000.
114 num=100
115 for p in $(delayed_postinsts); do
116 install -d ${IMAGE_ROOTFS}${sysconfdir}/deb-postinsts
117 cp ${IMAGE_ROOTFS}/var/lib/dpkg/info/$p.postinst ${IMAGE_ROOTFS}${sysconfdir}/deb-postinsts/$num-$p
118 num=`echo \$((num+1))`
119 done
120}
121
122remove_packaging_data_files() {
123 rm -rf ${IMAGE_ROOTFS}${opkglibdir}
124 rm -rf ${IMAGE_ROOTFS}/var/lib/dpkg/
125}
126
127rootfs_install_packages() {
128 ${STAGING_BINDIR_NATIVE}/apt-get ${APT_ARGS} install `cat $1` --force-yes --allow-unauthenticated
129
130 # Mark all packages installed
131 sed -i -e "s/Status: install ok unpacked/Status: install ok installed/;" $INSTALL_ROOTFS_DEB/var/lib/dpkg/status
132}
133
134rootfs_uninstall_packages() {
135 # for some reason, --root doesn't really work here... We use --admindir&--instdir instead.
136 ${STAGING_BINDIR_NATIVE}/dpkg --admindir=${IMAGE_ROOTFS}/var/lib/dpkg --instdir=${IMAGE_ROOTFS} -r --force-depends $@
137}
138