Hacks to reduce PokyLinux build time

PokyLinux is a very powerful build tool for embedded Linux platform. We have struggled in the past to cross compile various components to make our embedded Linux device usable. PokyLinux provides just the same. All you need to do is configure the components you want to build and it fetches them from all our the places, patches them, configures them, builds the required dependencies and in the end just gives you a filesystem which you can install on your device and ready to go.

The main drawback however we encountered with PokyLinux was the time it takes to build. Leaving aside the download time, the build time itself was quite huge. I tried to look at the individual components taking unnecessary or redundant dependency and wasting time building that. Hence came the following list of quick patches which can significantly reduce your build time.

dbus-glib

Package dbus-glib has a dependency on dbus-glib-native. If we examine its recipe file we find that there are two files dbus-glib-bindings.h and dbus-glib-introspenct.xml that are needed by dbus-glib which dbus-glib-native provides. dbus-glib-native itself has a dependency on glib-2.0-native. glib-2.0-native cannot be set in ASSUME_PROVIDED because then the build of dbus-glib-native fails. And glib-2.0 is a huge package. It takes considerable amount of time to compile it. Hence the solution is to patch dbus-glib with the extra files needed and avoid the unnecessary build. This makes build of glib-2.0-native and dbus-glib-native (both i686 packages) unnecessary.

Index: packages/dbus/dbus-glib_0.74.bb
===================================================================
— packages/dbus/dbus-glib_0.74.bb
+++ packages/dbus/dbus-glib_0.74.bb (working copy)
@@ -3,11 +3,13 @@
HOMEPAGE = “http://www.freedesktop.org/Software/dbus”
DESCRIPTION = “message bus system for applications to talk to one another”
LICENSE = “GPL”
-DEPENDS = “expat glib-2.0 virtual/libintl dbus-glib-native dbus”
+# removed dependency on dbus-glib-native
+DEPENDS = “expat glib-2.0 virtual/libintl dbus”

SRC_URI = “http://dbus.freedesktop.org/releases/dbus-glib/dbus-glib-${PV}.tar.gz \
file://no-examples.patch;patch=1 \
– file://no-introspect.patch;patch=1″
+ file://no-introspect.patch;patch=1\
+ file://dbus-glib-files.patch;patch=1”

inherit autotools pkgconfig gettext

@@ -15,8 +17,8 @@
FILES_${PN}-dev += “${libdir}/dbus-1.0/include ${bindir}/dbus-glib-tool”

– do_configure_prepend() {
– install -m 0644 ${STAGING_DATADIR_NATIVE}/dbus/dbus-bus-introspect.xml ${S}/tools/
– install -m 0644 ${STAGING_DATADIR_NATIVE}/dbus/dbus-glib-bindings.h ${S}/tools/
– }

do_stage () {

dbus

In one of the build sequence, dbus was failing to build. The reason was that the sm library that dbus needs was not yet compiled. The issue was that the dependency on dbus was only on libx11 and not on sm. Adding the dependency fixed the problem.

Index: packages/dbus/dbus.inc
===================================================================
— packages/dbus/dbus.inc
+++ packages/dbus/dbus.inc (working copy)
@@ -3,7 +3,7 @@
HOMEPAGE = “http://dbus.freedesktop.org”
DESCRIPTION = “Message bus system for applications to talk to one another”
LICENSE = “GPL”
-DEPENDS = “expat glib-2.0 virtual/libintl virtual/libx11”
+DEPENDS = “expat glib-2.0 virtual/libintl virtual/libx11 libsm”

DEFAULT_PREFERENCE = “-1”

apt-native

apt-native was a tricky issue. We cannot rely on host apt as it uses the host database and needs super user permissions for running. If we go ahead using it inspite of this reason there is a possibility of it corrupting host installed packages. This will render your PC useless. Hence we cannot put this in ASSUME_PROVIDED. But we can definitely get rid of some of its dependencies.

One such dependency is curl. curl is needed for fetching the code which has https uri. We do not use the apt in poky to download a package, hence this feature is anyway redundant. Building curl also as part of the dependency is totally useless. Hence we removed building of modules which uses curl in apt. This required editing the modules/makefile to remove hppts related module from being built.

Index: packages/apt/apt-native.inc
===================================================================
— packages/apt/apt-native.inc
+++ packages/apt/apt-native.inc (working copy)
@@ -1,12 +1,14 @@
require apt.inc
inherit native

-DEPENDS = “dpkg-native curl-native db-native”
+DEPENDS = “dpkg-native db-native”
FILESDIR = “${@os.path.dirname(bb.data.getVar(‘FILE’,d,1))}/apt-${PV}”
PACKAGES = “”
USE_NLS = “no”

SRC_URI += “file://db_linking_hack.patch;patch=1”
+SRC_URI += “file://apt-remove-https.patch;patch=1”

python do_stage () {
bb.build.exec_func(‘do_stage_base’, d)

Index: packages/apt/files/apt-remove-https.patch
===================================================================
— packages/apt/files/apt-remove-https.patch
+++ packages/apt/files/apt-remove-https.patch
@@ -0,0 +1,21 @@
+Index: apt-0.7.3/methods/makefile
+===================================================================
+— apt-0.7.3.orig/methods/makefile 2008-05-24 13:07:49.000000000 +0530
++++ apt-0.7.3/methods/makefile 2008-05-24 13:08:08.000000000 +0530
+@@ -53,11 +53,11 @@
+ include $(PROGRAM_H)
+
+ # The https method
+-PROGRAM=https
+-SLIBS = -lapt-pkg -lcurl
+-LIB_MAKES = apt-pkg/makefile
+-SOURCE = https.cc
+-include $(PROGRAM_H)
++#PROGRAM=https
++#SLIBS = -lapt-pkg -lcurl
++#LIB_MAKES = apt-pkg/makefile
++#SOURCE = https.cc
++#include $(PROGRAM_H)
+
+ # The ftp method
+ PROGRAM=ftp

apt using db2

apt uses libdb4.2. Hence it tries to put db-native as a dependency. But db-native can be installed on the host (libdb4.2). But that does not help with the build of apt. And hence an application called apt-ftparchive fails to build. That is ok since apt is anyway installed on host and apt-ftparchive of host can be used when needed. But to complete the build this application has to be removed from installation.

Index: packages/apt/apt-native.inc
===================================================================
— packages/apt/apt-native.inc
+++ packages/apt/apt-native.inc (working copy)
@@ -1,12 +1,14 @@
require apt.inc
inherit native

-DEPENDS = “dpkg-native curl-native db-native”
+#DEPENDS = “dpkg-native curl-native db-native”
+DEPENDS = “dpkg-native”
FILESDIR = “${@os.path.dirname(bb.data.getVar(‘FILE’,d,1))}/apt-${PV}”
PACKAGES = “”

@@ -37,7 +39,7 @@
install -m 0755 bin/apt-get ${bindir}/
install -m 0755 bin/apt-config ${bindir}/
install -m 0755 bin/apt-cache ${bindir}/
– install -m 0755 bin/apt-ftparchive ${bindir}/
+ #install -m 0755 bin/apt-ftparchive ${bindir}/
install -m 0755 bin/apt-sortpkgs ${bindir}/
install -m 0755 bin/apt-extracttemplates ${bindir}/

gconf-dbus

gconf-dbus has dependency on intltool-native. When i removed this dependency (or rather made it part of ASSUME_PROVIDED) the configuration step of the build failed. This failed because the staging directory did not have intltool.m4 provided by intltool package. Hence i added an extra line in configure_prepend to copy this file from /usr/share/aclocal.

Index: packages/gnome/gconf-dbus_svn.bb
===================================================================
— packages/gnome/gconf-dbus_svn.bb
+++ packages/gnome/gconf-dbus_svn.bb (working copy)
@@ -1,5 +1,6 @@
SECTION = “x11/utils”
-DEPENDS = “intltool-native virtual/libintl glib-2.0 dbus dbus-glib libxml2 popt gtk-doc-native”
+DEPENDS = “virtual/libintl glib-2.0 dbus dbus-glib libxml2 popt gtk-doc-native”
DESCRIPTION = “Settings daemon using DBUS for communication.”
LICENSE = “GPL”
PROVIDES = “gconf”
@@ -22,6 +23,7 @@

do_configure_prepend() {
+ cp /usr/share/aclocal/intltool.m4 ${STAGING_DATADIR}/aclocal/
touch gtk-doc.make
}

fontconfig

This one was quite ridiculous. fontconfig had a dependency on both freetype as well as freetype-native. For the build of fontconfig for some reason it was taking the freetype-native’s header files instead of freetype (arm) header file. After i changed this dependency i could remove freetype-native from fontconfig’s dependency

Index: packages/fontconfig/fontconfig_2.4.2.bb
===================================================================
— packages/fontconfig/fontconfig_2.4.2.bb
+++ packages/fontconfig/fontconfig_2.4.2.bb (working copy)
@@ -1,7 +1,8 @@
SECTION = “libs”
LICENSE = “BSD”
DESCRIPTION = “A library for configuring and customizing font access.”
-DEPENDS = “expat freetype freetype-native zlib”
+DEPENDS = “expat freetype zlib”

SRC_URI = “http://fontconfig.org/release/fontconfig-${PV}.tar.gz”

@@ -44,7 +45,8 @@
for i in ${S}/fontconfig/*.h; do install -m 0644 $i ${STAGING_INCDIR}/fontconfig/; done
}

-BUILD_CFLAGS += ” -I${STAGING_INCDIR_NATIVE}/freetype2″
+BUILD_CFLAGS += ” -I${STAGING_INCDIR}/freetype2″

do_configure_append () {
sed -i ‘s|LDFLAGS =.*|LDFLAGS =|’ fc-case/Makefile

xserver using xcalibrate

xcalibrate’s source is not present in the tar.gz format. Instead it is present as git. Hence there is a dependency on either host having git or git-native being built. Both are quite redundant. Moreover xcalibrate is needed by xserver. But our xserver actually uses tslib and hence there is no need to build xcalibrate.

Index: packages/xserver-mbx/xserver-kdrive_1.3.0.0.bb
===================================================================
— packages/xserver-mbx/xserver-kdrive_1.3.0.0.bb
+++ packages/xserver-mbx/xserver-kdrive_1.3.0.0.bb (working copy)
@@ -1,6 +1,7 @@
require xserver-kdrive.inc

-DEPENDS += “libxkbfile libxcalibrate”
+# removed xcalibrate dependecy
+DEPENDS += “libxkbfile ”

PE = “1”
PR = “r18″
@@ -17,9 +18,7 @@
file://optional-xkb.patch;patch=1 \
file://enable-epson.patch;patch=1 \
file://enable-tslib.patch;patch=1 \
– file://enable-xcalibrate.patch;patch=1 \
file://hide-cursor-and-ppm-root.patch;patch=1 \
– file://xcalibrate_coords.patch;patch=1 \
file://scheduler.patch;patch=1”

S = “${WORKDIR}/xorg-server-${PV}”
Index: packages/xserver-mbx/xserver-kdrive.inc
===================================================================
— packages/xserver-mbx/xserver-kdrive.inc
+++ packages/xserver-mbx/xserver-kdrive.inc (working copy)
@@ -98,7 +98,7 @@
–disable-xevie –disable-xprint –disable-xtrap \
–disable-dmx \
–with-default-font-path=built-ins \
– –enable-tslib –enable-xcalibrate \
+ –enable-tslib \
ac_cv_file__usr_share_X11_sgml_defs_ent=no”

do_configure_prepend() {

One Response to Hacks to reduce PokyLinux build time

  1. Paul Cooper says:

    Interesting article – please file bugs for these issues, and / or send patches to the Poky mailing list, and we can get them fixed for everyone. Also in the development version of Poky we have staged packaging which should make compilation times significantly faster.

Leave a comment