{"id":604,"date":"2014-06-27T12:00:02","date_gmt":"2014-06-27T10:00:02","guid":{"rendered":"http:\/\/www.thelins.se\/johan\/blog\/?p=604"},"modified":"2014-06-30T08:20:48","modified_gmt":"2014-06-30T06:20:48","slug":"yocto-part-iv-going-on-a-diet","status":"publish","type":"post","link":"https:\/\/www.thelins.se\/johan\/blog\/2014\/06\/yocto-part-iv-going-on-a-diet\/","title":{"rendered":"Yocto part IV &#8211; going on a diet"},"content":{"rendered":"<p>This time we will start looking at how we can reduce the image size of the diet-image. Before we start, lets do a super-quick recap of the first three installments (<a href=\"https:\/\/www.thelins.se\/johan\/blog\/2014\/06\/yocto-part-i-baseline-boot-time\/\">i<\/a>, <a href=\"https:\/\/www.thelins.se\/johan\/blog\/2014\/06\/yocto-part-ii-baseline-image-size\/\">ii<\/a>, <a href=\"https:\/\/www.thelins.se\/johan\/blog\/2014\/06\/yocto-part-iii-a-custom-meta-layer\/\">iii<\/a>):<\/p>\n<p>Start by creating and populating a project area:<\/p>\n<p><code>mkdir minimal<br \/>\ncd minimal\/<br \/>\ngit clone git:\/\/git.yoctoproject.org\/poky<br \/>\ncd poky\/<br \/>\ngit checkout -b daisy origin\/daisy<br \/>\nsource oe-init-build-env minimal-qemu<br \/>\ncd ..<br \/>\ngit clone https:\/\/github.com\/e8johan\/meta-diet.git<br \/>\ncd minimal-qemu\/<br \/>\nvim conf\/local.conf<\/code><\/p>\n<p>Add the following lines at the end of conf\/local.conf.<\/p>\n<p><code>DISTRO_FEATURES_append = \" systemd\"<br \/>\nVIRTUAL-RUNTIME_init_manager = \"systemd\"<br \/>\nDISTRO_FEATURES_BACKFILL_CONSIDERED = \"sysvinit\"<br \/>\nVIRTUAL-RUNTIME_initscripts = \"\"<\/code><\/p>\n<p><code>INHERIT += \"buildhistory\"<br \/>\nBUILDHISTORY_COMMIT = \"1\"<\/code><\/p>\n<p>Add the meta-diet layer to BBLAYERS in conf\/bblayer.conf, and build the image.<\/p>\n<p><code>bitbake diet-image<\/code><\/p>\n<p>And now, lets get back to business.<\/p>\n<p>Today, I will demonstrate how to modify an existing package through a <a href=\"http:\/\/www.yoctoproject.org\/docs\/1.6\/dev-manual\/dev-manual.html#using-bbappend-files\">bbappend<\/a>&nbsp;file, but first, some background.<\/p>\n<p>Back in <a href=\"https:\/\/www.thelins.se\/johan\/blog\/2014\/06\/yocto-part-ii-baseline-image-size\/\">part ii<\/a>, I presented a list of the packages included on the image. Something that surprised me was the inclusion of libx11-6 and libxcb. Both associated with the X windowing system which the image does not include. Using the depents.dot file, I found that the source of this dependency was the dbus package. To be more exact, this line from meta\/recipes-core\/dbus\/dbus.inc:<\/p>\n<p><code>PACKAGECONFIG[x11] = \"--with-x --enable-x11-autolaunch,--without-x --disable-x11-autolaunch, virtual\/libx11 libsm\"<br \/>\n<\/code><\/p>\n<p>The nice thing about <a href=\"http:\/\/www.yoctoproject.org\/docs\/current\/ref-manual\/ref-manual.html#var-PACKAGECONFIG\">PACKAGECONFIG<\/a> lines like the one above, is that they contain two halves &#8211; one to use if the feature is enabled, and one to use if the feature is disabled. So, what we need to do, is to ensure that PACKAGECONFIG does not include &#8220;x11&#8221;. I prefer to do this using a bbappend file.<\/p>\n<p>A bbappend file is used to override, or append, configuration options to an existing bb file, i.e. a package recipe. At the time of writing, the d-bus package is named dbus_1.6.18.bb, so the corresponding append file is named dbus_1.6.18.bbappend. I put it in the recipes-core\/dbus subdirectory, inside the meta-diet layer.<\/p>\n<p>As we want to remove the dependency on X11, I create an append file with the following line:<\/p>\n<p><code>PACKAGECONFIG_remove = \"x11\"<\/code><\/p>\n<p>The file is available from the <a href=\"https:\/\/github.com\/e8johan\/meta-diet\">meta-diet layer on github<\/a>. Use the tag part-iv to get the right version.<\/p>\n<p>Building the image again, we can see that the libx11-6 and libxcb references are gone from the installed-package-sizes.txt build statistics file:<\/p>\n<p><code> 8637 KiB systemd<br \/>\n4487 KiB udev-hwdb<br \/>\n3042 KiB libc6<br \/>\n1221 KiB e2fsprogs-e2fsck<br \/>\n1153 KiB shadow<br \/>\n789 KiB dbus-1<br \/>\n547 KiB kmod<br \/>\n532 KiB busybox<br \/>\n398 KiB udev<br \/>\n349 KiB libkmod2<br \/>\n297 KiB libext2fs2<br \/>\n296 KiB libdbus-1-3<br \/>\n261 KiB libmount1<br \/>\n249 KiB udev-utils<br \/>\n241 KiB libblkid1<br \/>\n233 KiB systemd-analyze<br \/>\n161 KiB liblzma5<br \/>\n159 KiB libexpat1<br \/>\n110 KiB v86d<br \/>\n94 KiB util-linux-fsck<br \/>\n86 KiB libz1<br \/>\n83 KiB libgcc1<br \/>\n36 KiB systemd-binfmt<br \/>\n32 KiB kernel-module-uvesafb<br \/>\n31 KiB util-linux-mount<br \/>\n31 KiB libwrap0<br \/>\n30 KiB libacl1<br \/>\n29 KiB util-linux-agetty<br \/>\n27 KiB libe2p2<br \/>\n23 KiB netbase<br \/>\n20 KiB kernel-3.14.0-yocto-standard<br \/>\n16 KiB libattr1<br \/>\n15 KiB libcap2<br \/>\n14 KiB libuuid1<br \/>\n11 KiB kernel-module-binfmt-misc<br \/>\n10 KiB libcom-err2<br \/>\n5 KiB update-rc.d<br \/>\n4 KiB update-alternatives-opkg<br \/>\n4 KiB base-files<br \/>\n3 KiB busybox-udhcpc<br \/>\n2 KiB shadow-securetty<br \/>\n2 KiB run-postinsts<br \/>\n1 KiB systemd-serialgetty<br \/>\n1 KiB busybox-syslog<br \/>\n0 KiB systemd-compat-units<br \/>\n0 KiB packagegroup-core-boot<br \/>\n0 KiB base-passwd<\/code><\/p>\n<p>Comparing this to the previous list, we just shaved off&nbsp;1423 KiB. Lets call that a success for today, and we will have a good look at udev next time.<\/p>\n<p><em>Update! Thanks Erik, for telling me about the *_remove. I only knew about *_append. Also, fixed the quotation marks in the snippet for enabling build history. Again, well spotted by Erik.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This time we will start looking at how we can reduce the image size of the diet-image. Before we start, lets do a super-quick recap of the first three installments (i, ii, iii): Start by creating and populating a project area: mkdir minimal cd minimal\/ git clone git:\/\/git.yoctoproject.org\/poky cd poky\/ git checkout -b daisy origin\/daisy &hellip; <a href=\"https:\/\/www.thelins.se\/johan\/blog\/2014\/06\/yocto-part-iv-going-on-a-diet\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Yocto part IV &#8211; going on a diet<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-604","post","type-post","status-publish","format-standard","hentry","category-yocto"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/604","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/comments?post=604"}],"version-history":[{"count":12,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/604\/revisions"}],"predecessor-version":[{"id":629,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/604\/revisions\/629"}],"wp:attachment":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/media?parent=604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/categories?post=604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/tags?post=604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}