Squashed 'import-layers/meta-openembedded/' content from commit 247b126

Change-Id: I40827e9ce5fba63f1cca2a0be44976ae8383b4c0
git-subtree-dir: import-layers/meta-openembedded
git-subtree-split: 247b1267bbe95719cd4877d2d3cfbaf2a2f4865a
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut_git.bb b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut_git.bb
new file mode 100644
index 0000000..c978263
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut_git.bb
@@ -0,0 +1,61 @@
+SUMMARY = "Initramfs generator using udev"
+DESCRIPTION = "Dracut is an event driven initramfs infrastructure. dracut (the tool) is used to create an initramfs image by copying tools and files from an installed system and combining it with the dracut framework, usually found in /usr/lib/dracut/modules.d."
+
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
+
+PE = "1"
+PV = "044+git${SRCREV}"
+
+# v044 tag
+SRCREV = "1bc3e733f96033a508841e97fe08da7a12851782"
+SRC_URI = "git://git.kernel.org/pub/scm/boot/dracut/dracut.git;protocol=http"
+
+inherit bash-completion
+
+S = "${WORKDIR}/git"
+
+EXTRA_OECONF = "--prefix=${prefix} \
+                --libdir=${prefix}/lib \
+                --datadir=${datadir} \
+                --sysconfdir=${sysconfdir} \
+                --sbindir=${sbindir} \
+                --disable-documentation \
+                --bindir=${bindir} \
+                --includedir=${includedir} \
+                --localstatedir=${localstatedir} \
+               "
+
+# RDEPEND on systemd optionally
+PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}"
+PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_unitdir}/system/,,,systemd"
+
+EXTRA_OEMAKE += 'libdir=${prefix}/lib'
+
+do_configure() {
+    ./configure ${EXTRA_OECONF}
+}
+
+do_install() {
+    oe_runmake install DESTDIR=${D}
+    # Its Makefile uses cp -arx to install modules.d, so fix the owner
+    # to root:root
+    chown -R root:root ${D}/${prefix}/lib/dracut/modules.d
+}
+
+FILES_${PN} += "${prefix}/lib/kernel \
+                ${prefix}/lib/dracut \
+                ${systemd_unitdir} \
+               "
+FILES_${PN}-dbg += "${prefix}/lib/dracut/.debug"
+
+CONFFILES_${PN} += "${sysconfdir}/dracut.conf"
+
+RDEPENDS_${PN} = "findutils cpio util-linux-blkid util-linux-getopt util-linux bash ldd"
+
+# This could be optimized a bit, but let's avoid non-booting systems :)
+RRECOMMENDS_${PN} = " \
+                     kernel-modules \
+                     busybox \
+                     coreutils \ 
+                    "
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klcc-cross_2.0.4.bb b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klcc-cross_2.0.4.bb
new file mode 100644
index 0000000..2f4afce
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klcc-cross_2.0.4.bb
@@ -0,0 +1,40 @@
+SUMMARY = "The klcc crosscompiler for klibc"
+
+require klibc.inc
+DEPENDS = "klibc"
+
+FILESPATH =. "${FILE_DIRNAME}/klibc-${PV}:"
+
+SRC_URI += "file://use-env-for-perl.patch"
+
+# disable task already run in klibc recipe
+do_configure[noexec] = "1"
+
+do_compile() {
+    oe_runmake 'INSTALLDIR=${STAGING_DIR_TARGET}${libdir}/klibc' klcc
+}
+
+do_install() {
+    install -d ${D}${bindir_crossscripts}/
+    install -m 0755 klcc/klcc ${D}${bindir_crossscripts}/${TARGET_PREFIX}klcc
+    # Insert an unencoded path as a comment to trigger the sstate renaming functions
+    sed -i '2i #${STAGING_DIR_TARGET}' ${D}${bindir_crossscripts}/${TARGET_PREFIX}klcc
+}
+
+SYSROOT_PREPROCESS_FUNCS += "klcc_sysroot_preprocess"
+
+klcc_sysroot_preprocess () {
+       sysroot_stage_dir ${D}${bindir_crossscripts} ${SYSROOT_DESTDIR}${bindir_crossscripts}
+}
+
+deltask do_package
+deltask do_packagedata
+deltask do_package_write_ipk
+deltask do_package_write_rpm
+deltask do_package_write_deb
+deltask do_package_write_tar
+
+SSTATE_SCAN_FILES = "*"
+EXTRA_STAGING_FIXMES = "MANGLEDSTAGINGDIRTARGET MANGLEDSTAGINGDIR"
+MANGLEDSTAGINGDIR = "${@d.getVar("STAGING_DIR", True).replace("/", "\\\\/").replace("-", "\\\\-")}"
+MANGLEDSTAGINGDIRTARGET = "${@d.getVar("STAGING_DIR_TARGET", True).replace("/", "\\\\/").replace("-", "\\\\-")}"
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/armv4-fix-v4bx.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/armv4-fix-v4bx.patch
new file mode 100644
index 0000000..6bb384b
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/armv4-fix-v4bx.patch
@@ -0,0 +1,15 @@
+Status: not applicable upstream, in OE/Yocto we use $(FIX_V4BX)
+which is "" in case of armv5 or thumbs.
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+--- a/usr/klibc/arch/arm/MCONFIG	2013-01-09 01:12:02.000000000 +0100
++++ b/usr/klibc/arch/arm/MCONFIG	2013-01-08 23:45:59.000000000 +0100
+@@ -29,6 +29,7 @@
+ KLIBCSHAREDFLAGS = -Ttext 0x01800200
+ ifeq ($(CONFIG_AEABI),y)
+ KLIBCREQFLAGS += -mabi=aapcs-linux -mno-thumb-interwork
++KLIBCLDFLAGS += $(FIX_ARMV4_EABI_BX)
+ else
+ KLIBCREQFLAGS += -mabi=apcs-gnu -mno-thumb-interwork
+ endif
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch
new file mode 100644
index 0000000..9bc4835
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch
@@ -0,0 +1,14 @@
+diff --git a/klcc/klcc.in b/klcc/klcc.in
+index 43d0984..61e9385 100644
+--- a/klcc/klcc.in
++++ b/klcc/klcc.in
+@@ -204,6 +204,9 @@ while ( defined($a = shift(@ARGV)) ) {
+ 	# Libraries
+ 	push(@libs, $a);
+ 	push(@libs, shift(@ARGV)) if ( $2 eq '' );
++    } elsif ( $a =~ /^--([sysroot=])(.*)$/ ) {
++	# Override gcc encoded sysroot
++	push(@ccopt, $a);
+     } else {
+ 	die "$0: unknown option: $a\n";
+     }
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-config-eabi.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-config-eabi.patch
new file mode 100644
index 0000000..316c80a
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-config-eabi.patch
@@ -0,0 +1,14 @@
+Patch was imported from the OpenEmbedded git server
+(git://git.openembedded.org/openembedded)
+as of commit id b6764cf32ec93547531130dca364fb95e1c495f4
+Signed-off-by: Thomas Kunze <thommycheck@gmx.de>
+
+diff -Nur klibc-1.5/defconfig klibc-1.5p/defconfig
+--- klibc-1.5/defconfig	2007-03-04 02:52:10.000000000 +0100
++++ klibc-1.5p/defconfig	2008-02-08 19:24:22.337127756 +0100
+@@ -5,4 +5,4 @@
+ CONFIG_REGPARM=y
+ # ARM options
+ # CONFIG_KLIBC_THUMB is not set
+-# CONFIG_AEABI is not set
++CONFIG_AEABI=y
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-linux-libc-dev.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-linux-libc-dev.patch
new file mode 100644
index 0000000..2043064
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-linux-libc-dev.patch
@@ -0,0 +1,22 @@
+commit 43adf69062254fb4f8d4d11fb5fe36a60ae25d5a
+Author: Ben Hutchings <ben@decadent.org.uk>
+Date:   Sun Mar 14 18:41:56 2010 +0000
+
+    Taken from debian "Fix klibc Debian specific build trouble"
+    Adapted for klibc_2.0.2
+
+Index: klibc-2.0~rc2/scripts/Kbuild.install
+===================================================================
+--- klibc-2.0~rc2.orig/scripts/Kbuild.install	2012-02-11 18:50:21.000000000 +0000
++++ klibc-2.0~rc2/scripts/Kbuild.install	2012-02-11 19:04:52.000000000 +0000
+@@ -95,7 +95,9 @@
+ 	$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
+ 	$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)lib
+ 	$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)bin
+-	$(Q)$(MAKE) -C $(KLIBCKERNELSRC) ARCH=$(KLIBCARCH) INSTALL_HDR_PATH=$(INSTALLROOT)$(INSTALLDIR)/$(KCROSS) headers_install
++	$(Q)for x in ../../../include/asm ../../../include/asm-generic ../../../include/linux ../../../include/mtd; do \
++		ln -sf $${x} $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/ || exit; \
++	done
+ 	$(Q)cp -rf usr/include/. $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/.
+ 	$(Q)chmod -R a+rX $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
+ 	$(Q)$(install-data) $(srctree)/klcc/klcc.1 $(INSTALLROOT)$(mandir)/man1/$(KCROSS)klcc.1
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/staging.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/staging.patch
new file mode 100644
index 0000000..c01c712
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/staging.patch
@@ -0,0 +1,144 @@
+Patch was imported from the OpenEmbedded git server
+(git://git.openembedded.org/openembedded)
+as of commit id eefb99a313bbcc8f34c8b32bf0c5aa2dd2580735
+Signed-off-by: Thomas Kunze <thommycheck@gmx.de>
+
+Minor edits following upstream changes
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+
+Index: klibc-1.5.24/scripts/Kbuild.install
+===================================================================
+--- a/scripts/Kbuild.install	2011-07-27 15:50:53.000000000 +0200
++++ b/scripts/Kbuild.install	2011-08-01 00:03:03.000000000 +0200
+@@ -88,13 +88,10 @@
+ header:
+ 	$(Q)echo "  INSTALL headers + man pages to $(INSTALLROOT)$(INSTALLDIR)"
+ 	$(Q)mkdir -p $(INSTALLROOT)$(bindir)
+-	$(Q)mkdir -p $(INSTALLROOT)$(mandir)/man1
+-	$(Q)mkdir -p $(INSTALLROOT)$(SHLIBDIR)
+ 	$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)
+ 	$(Q)-rm -rf $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
+ 	$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
+ 	$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)lib
+-	$(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)bin
+ 	$(Q)for x in ../../../include/asm ../../../include/asm-generic ../../../include/linux ../../../include/mtd; do \
+ 		ln -sf $${x} $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/ || exit; \
+ 	done
+@@ -103,7 +100,6 @@
+ 	done
+ 	$(Q)cp -rf usr/include/. $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/.
+ 	$(Q)chmod -R a+rX,go-w $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
+-	$(Q)$(install-data) $(srctree)/klcc/klcc.1 $(INSTALLROOT)$(mandir)/man1/$(KCROSS)klcc.1
+ 	$(Q)$(install-bin) $(objtree)/klcc/$(KCROSS)klcc $(INSTALLROOT)$(bindir)
+ 
+ footer: header
+
+Index: klibc-1.5.24/usr/dash/Kbuild
+===================================================================
+--- a/usr/dash/Kbuild	2011-07-27 15:50:53.000000000 +0200
++++ b/usr/dash/Kbuild	2011-08-01 00:07:56.000000000 +0200
+@@ -92,5 +92,3 @@
+ $(obj)/syntax.h: $(obj)/syntax.c
+ 	$(Q):
+ 
+-# Targets to install
+-install-y := sh.shared
+
+Index: klibc-1.5.24/usr/gzip/Kbuild
+===================================================================
+--- a/usr/gzip/Kbuild	2011-07-27 15:50:53.000000000 +0200
++++ b/usr/gzip/Kbuild	2011-08-01 00:06:39.000000000 +0200
+@@ -21,5 +21,3 @@
+ # Cleaning
+ targets := gzip gzip.g gunzip zcat
+ 
+-# Targets to install
+-install-y := gzip gunzip zcat
+
+Index: klibc-1.5.24/usr/kinit/fstype/Kbuild
+===================================================================
+--- a/usr/kinit/fstype/Kbuild	2011-07-27 15:50:53.000000000 +0200
++++ b/usr/kinit/fstype/Kbuild	2011-08-01 00:09:12.000000000 +0200
+@@ -21,5 +21,3 @@
+ # Cleaning
+ clean-dirs := static shared
+ 
+-# install binary
+-install-y := $(shared-y)
+
+Index: klibc-1.5.24/usr/kinit/ipconfig/Kbuild
+===================================================================
+--- a/usr/kinit/ipconfig/Kbuild	2011-07-27 15:50:53.000000000 +0200
++++ b/usr/kinit/ipconfig/Kbuild	2011-08-01 00:10:52.000000000 +0200
+@@ -27,5 +27,3 @@
+ # Cleaning
+ clean-dirs := static shared
+ 
+-# install binary
+-install-y := $(shared-y)
+
+Index: klibc-1.5.24/usr/kinit/Kbuild
+===================================================================
+--- a/usr/kinit/Kbuild	2011-07-27 15:50:53.000000000 +0200
++++ b/usr/kinit/Kbuild	2011-08-01 00:20:18.000000000 +0200
+@@ -33,5 +33,3 @@
+ subdir- := fstype ipconfig nfsmount resume run-init
+ 
+ 
+-# install binary
+-install-y := kinit kinit.shared
+
+Index: klibc-1.5.24/usr/kinit/nfsmount/Kbuild
+===================================================================
+--- a/usr/kinit/nfsmount/Kbuild	2011-07-27 15:50:53.000000000 +0200
++++ b/usr/kinit/nfsmount/Kbuild	2011-08-01 00:12:52.000000000 +0200
+@@ -23,5 +23,3 @@
+ 
+ clean-dirs := static shared
+ 
+-# Install binary
+-install-y := $(shared-y)
+
+Index: klibc-1.5.24/usr/kinit/resume/Kbuild
+===================================================================
+--- a/usr/kinit/resume/Kbuild	2011-07-27 15:50:53.000000000 +0200
++++ b/usr/kinit/resume/Kbuild	2011-08-01 00:13:51.000000000 +0200
+@@ -26,5 +26,3 @@
+ # Cleaning
+ clean-dirs := static shared
+ 
+-# install binary
+-install-y := $(shared-y)
+
+Index: klibc-1.5.24/usr/kinit/run-init/Kbuild
+===================================================================
+--- a/usr/kinit/run-init/Kbuild	2011-07-27 15:50:53.000000000 +0200
++++ b/usr/kinit/run-init/Kbuild	2011-08-01 00:14:41.000000000 +0200
+@@ -25,5 +25,3 @@
+ # Cleaning
+ clean-dirs := static shared
+ 
+-# install binary
+-install-y := $(shared-y)
+
+Index: klibc-1.5.24/usr/klibc/Kbuild
+===================================================================
+--- a/usr/klibc/Kbuild	2011-07-27 15:50:53.000000000 +0200
++++ b/usr/klibc/Kbuild	2011-08-01 00:18:11.000000000 +0200
+@@ -177,5 +177,3 @@
+ 	          $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)lib))
+ 	$(Q)$(install-lib) $(obj)/klibc-$(SOLIBHASH).so \
+ 	                      $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)lib
+-	$(Q)$(install-lib) $(obj)/klibc-$(SOLIBHASH).so \
+-	                      $(INSTALLROOT)$(SHLIBDIR)
+
+Index: klibc-1.5.24/usr/utils/Kbuild
+===================================================================
+--- a/usr/utils/Kbuild	2011-07-27 15:50:53.000000000 +0200
++++ b/usr/utils/Kbuild	2011-08-01 00:19:13.000000000 +0200
+@@ -72,5 +72,3 @@
+ # Clean deletes the static and shared dir
+ clean-dirs := static shared
+ 
+-# install only install the shared binaries
+-install-y := $(shared-y) shared/reboot shared/poweroff
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/use-env-for-perl.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/use-env-for-perl.patch
new file mode 100644
index 0000000..eac128c
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/use-env-for-perl.patch
@@ -0,0 +1,25 @@
+Patch was imported from the OpenEmbedded git server
+(git://git.openembedded.org/openembedded)
+as of commit id 676cbb54d42c89a4832871064cfcb7ee2ad372ee
+
+klcc-cross: Add patch to use /usr/bin/env perl
+Certain configurations (such as autobuilders) may build in very
+deep paths (that are longer than the #! mechanism allows) which
+makes it unsafe to use the direct path for perl.  In our case we know
+that /usr/bin/env perl will always return ours (if it has been built).
+
+Signed-off-by: Tom Rini <tom_rini@mentor.com>
+
+Index: klibc-1.5.20/klcc/makeklcc.pl
+===================================================================
+--- a/klcc/makeklcc.pl
++++ b/klcc/makeklcc.pl
+@@ -26,7 +26,7 @@ sub pathsearch($) {
+     return undef;
+ }
+ 
+-print "#!${perlpath}\n";
++print "#!/usr/bin/env perl\n";
+ 
+ open(KLIBCCONF, "< $klibcconf\0")
+     or die "$0: cannot open $klibcconf: $!\n";
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-static-utils_2.0.4.bb b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-static-utils_2.0.4.bb
new file mode 100644
index 0000000..c835fd6
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-static-utils_2.0.4.bb
@@ -0,0 +1,12 @@
+SUMMARY = "klibc utils for initramfs statically compiled"
+
+FILESPATH =. "${FILE_DIRNAME}/klibc-${PV}:"
+
+PACKAGES = "${PN}"
+FILES_${PN} = ""
+
+KLIBC_UTILS_VARIANT = "static"
+KLIBC_UTILS_PKGNAME = "klibc-static-utils"
+
+require klibc-utils.inc
+require klibc.inc
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils.inc b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils.inc
new file mode 100644
index 0000000..9014f52
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils.inc
@@ -0,0 +1,60 @@
+do_install() {
+    install -d ${D}${base_bindir}
+    install -d ${D}${base_sbindir}
+    # debian packages kinit + kinit.shared but only sh.shared
+    if [ "${KLIBC_UTILS_VARIANT}" = "shared" ]; then
+        install -m 755 usr/kinit/kinit ${D}${base_bindir}/kinit
+        install -m 755 usr/kinit/kinit.shared ${D}${base_bindir}/kinit.shared
+        install -m 755 usr/dash/sh.shared ${D}${base_bindir}/sh.shared
+    else
+        install -m 755 usr/dash/sh ${D}${base_bindir}/sh
+        install -m 755 usr/kinit/kinit ${D}${base_bindir}/kinit
+    fi
+    install -m 755 usr/gzip/gzip ${D}${base_bindir}
+    install -m 755 usr/kinit/fstype/${KLIBC_UTILS_VARIANT}/fstype ${D}${base_bindir}
+    install -m 755 usr/kinit/ipconfig/${KLIBC_UTILS_VARIANT}/ipconfig ${D}${base_bindir}
+    install -m 755 usr/kinit/nfsmount/${KLIBC_UTILS_VARIANT}/nfsmount ${D}${base_bindir}
+    install -m 755 usr/kinit/resume/${KLIBC_UTILS_VARIANT}/resume ${D}${base_bindir}
+    install -m 755 usr/kinit/run-init/${KLIBC_UTILS_VARIANT}/run-init ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/cat ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/chroot ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/cpio ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/dd ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/dmesg ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/false ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/halt ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/kill ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/ln ${D}${base_bindir}
+    # losetup goes in ${base_sbindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/losetup ${D}${base_sbindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/ls ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/minips ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/mkdir ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/mkfifo ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/mknod ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/mount ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/mv ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/nuke ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/pivot_root ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/poweroff ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/readlink ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/reboot ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/sleep ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/sync ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/true ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/umount ${D}${base_bindir}
+    install -m 755 usr/utils/${KLIBC_UTILS_VARIANT}/uname ${D}${base_bindir}
+    ln -s gzip ${D}${base_bindir}/gunzip
+    ln -s gzip ${D}${base_bindir}/zcat
+}
+
+EXTRA_KLIBC_DEPS = "${@base_conditional('KLIBC_UTILS_VARIANT', 'shared', '${THIS_LIBKLIBC}', '', d)}"
+
+PACKAGES_DYNAMIC += "^${KLIBC_UTILS_PKGNAME}-.*"
+
+python populate_packages_prepend () {
+    base_bin_dir = d.expand('${base_bindir}')
+    do_split_packages(d, base_bin_dir, '(.*)', '${KLIBC_UTILS_PKGNAME}-%s', 'Klibc util for %s', extra_depends='${EXTRA_KLIBC_DEPS}', allow_links=True, allow_dirs=True)
+    base_sbin_dir = d.expand('${base_sbindir}')
+    do_split_packages(d, base_sbin_dir, '(.*)', '${KLIBC_UTILS_PKGNAME}-%s', 'Klibc util for %s', extra_depends='${EXTRA_KLIBC_DEPS}', allow_dirs=True)
+}
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils_2.0.4.bb b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils_2.0.4.bb
new file mode 100644
index 0000000..06e71cb
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils_2.0.4.bb
@@ -0,0 +1,14 @@
+SUMMARY = "klibc utils for initramfs"
+
+FILESPATH =. "${FILE_DIRNAME}/klibc-${PV}:"
+
+PACKAGES = "${PN}"
+FILES_${PN} = ""
+
+KLIBC_UTILS_VARIANT = "shared"
+KLIBC_UTILS_PKGNAME = "klibc-utils"
+
+require klibc-utils.inc
+require klibc.inc
+
+DEPENDS = "klibc"
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc.inc b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc.inc
new file mode 100644
index 0000000..65ee868
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc.inc
@@ -0,0 +1,51 @@
+DESCRIPTION = "klibc is intended to be a minimalistic libc subset for \
+use with initramfs.  It is deliberately written for small size, \
+minimal entaglement, and portability, not speed."
+SECTION = "libs"
+LICENSE = "BSD-3-Clause & GPL-2.0 & MIT & Zlib"
+LIC_FILES_CHKSUM = "file://usr/klibc/LICENSE;md5=d75181f10e998c21eb147f6d2e43ce8b"
+DEPENDS = "linux-libc-headers perl-native"
+SRCREV = "4d19974d7020488f63651244e1f9f51727c3f66c"
+
+SRC_URI = "git://git.kernel.org/pub/scm/libs/klibc/klibc.git"
+SRC_URI_append_linux-gnueabi = " file://klibc-config-eabi.patch \
+                                 file://armv4-fix-v4bx.patch \
+                                 "
+SRC_URI_append_linux-uclibceabi = " file://klibc-config-eabi.patch \
+                                    file://armv4-fix-v4bx.patch \
+                                    "
+SRC_URI += "file://klibc-linux-libc-dev.patch \
+            file://staging.patch \
+            file://klcc-consider-sysroot.patch \
+            "
+
+S = "${WORKDIR}/git"
+
+EXTRA_OEMAKE = "'KLIBCARCH=${KLIBC_ARCH}' \
+                'CROSS_COMPILE=${TARGET_PREFIX}' \
+                'KLIBCKERNELSRC=${STAGING_DIR_TARGET}${exec_prefix}' \
+                'KLIBCLIBGCC=${STAGING_DIR_TARGET}${libdir}/${TARGET_SYS}/*/libgcc.a' \
+                'prefix=${exec_prefix}' \
+                'INSTALLROOT=${D}' \
+                'SHLIBDIR=${libdir}' \
+                "
+
+export FIX_ARMV4_EABI_BX = "${FIX_V4BX}"
+
+do_configure () {
+    ln -sf "${STAGING_DIR_TARGET}${exec_prefix}" linux
+}
+
+INHIBIT_PACKAGE_STRIP = "1"
+INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
+INSANE_SKIP_${PN} = "already-stripped"
+INSANE_SKIP_libklibc-dev = "dev-elf"
+KLIBC_ARCH = "${TARGET_ARCH}"
+KLIBC_ARCH_aarch64 = "arm64"
+KLIBC_ARCH_armeb = "arm"
+KLIBC_ARCH_mipsel = "mips"
+KLIBC_ARCH_x86 = "i386"
+KLIBC_ARCH_x86-64 = "x86_64"
+KLIBC_ARCH_powerpc = "ppc"
+KLIBC_ARCH_powerpc64 = "ppc64"
+THIS_LIBKLIBC = "libklibc (= ${PV}-${PR})"
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc_2.0.4.bb b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc_2.0.4.bb
new file mode 100644
index 0000000..bc80f38
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc_2.0.4.bb
@@ -0,0 +1,24 @@
+SUMMARY = "klibc, a small C library for use with initramfs"
+
+do_install() {
+    oe_runmake install
+    # the crosscompiler is packaged by klcc-cross
+    # remove klcc
+    rm ${D}${bindir}/klcc
+    # remove now empty dir
+    rmdir ${D}${bindir}
+    install -d ${D}${libdir}
+    install -m 755 usr/klibc/klibc-*.so ${D}${libdir}
+    (cd  ${D}${libdir}; ln -s klibc-*.so klibc.so)
+}
+
+PACKAGES = "libklibc libklibc-staticdev libklibc-dev"
+
+FILES_libklibc = "${libdir}/klibc-*.so"
+FILES_libklibc-staticdev = "${libdir}/klibc/lib/libc.a"
+FILES_libklibc-dev = "${libdir}/klibc.so \
+                      ${libdir}/klibc/lib/* \
+                      ${libdir}/klibc/include/* \
+                      "
+
+require klibc.inc
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0001-Makefile-only-build-ubi-utils.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0001-Makefile-only-build-ubi-utils.patch
new file mode 100644
index 0000000..9d5e4eb
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0001-Makefile-only-build-ubi-utils.patch
@@ -0,0 +1,87 @@
+From c4e6bd9378645d577e9d9f85da85f1438afe7c50 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Sun, 29 Jun 2014 00:32:29 +0200
+Subject: [PATCH 1/6] Makefile: build ubi-utils only
+
+We build all the static ubi-utils but actually only ubiattach is needed in
+a minimalistic initramfs for the mount of ubi volumes.
+
+More fixes are needed in order to build the full mtd-utils.
+The first issue is:
+
+| mkfs.jffs2.c:64:20: fatal error: libgen.h: No such file or directory
+|  #include <libgen.h>
+
+Removing the include then the second error is:
+
+| mkfs.jffs2.c:1570:22: error: '_SC_PAGESIZE' undeclared
+| (first use in this function)
+|   page_size = sysconf(_SC_PAGESIZE);
+
+Upstream-Status: Inappropriate [embedded specific]
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ Makefile | 24 ++----------------------
+ 1 file changed, 2 insertions(+), 22 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index eade234..2275865 100644
+--- a/Makefile
++++ b/Makefile
+@@ -16,28 +16,13 @@ endif
+ 
+ TESTS = tests
+ 
+-MTD_BINS = \
+-	ftl_format flash_erase nanddump doc_loadbios \
+-	ftl_check mkfs.jffs2 flash_lock flash_unlock \
+-	flash_otp_info flash_otp_dump flash_otp_lock flash_otp_write \
+-	mtd_debug flashcp nandwrite nandtest \
+-	jffs2dump \
+-	nftldump nftl_format docfdisk \
+-	rfddump rfdformat \
+-	serve_image recv_image \
+-	sumtool jffs2reader
+ UBI_BINS = \
+ 	ubiupdatevol ubimkvol ubirmvol ubicrc32 ubinfo ubiattach \
+ 	ubidetach ubinize ubiformat ubirename mtdinfo ubirsvol ubiblock
+ 
+-BINS = $(MTD_BINS)
+-BINS += mkfs.ubifs/mkfs.ubifs
+-BINS += $(addprefix ubi-utils/,$(UBI_BINS))
+-SCRIPTS = flash_eraseall
++BINS = $(addprefix ubi-utils/,$(UBI_BINS))
+ 
+ TARGETS = $(BINS)
+-TARGETS += lib/libmtd.a
+-TARGETS += ubi-utils/libubi.a
+ 
+ OBJDEPS = $(BUILDDIR)/include/version.h
+ 
+@@ -61,12 +46,9 @@ endif
+ 	rm -f $(BUILDDIR)/include/version.h
+ 	$(MAKE) -C $(TESTS) clean
+ 
+-install:: $(addprefix $(BUILDDIR)/,${BINS}) ${SCRIPTS}
++install:: $(addprefix $(BUILDDIR)/,${BINS})
+ 	mkdir -p ${DESTDIR}/${SBINDIR}
+ 	install -m 0755 $^ ${DESTDIR}/${SBINDIR}/
+-	mkdir -p ${DESTDIR}/${MANDIR}/man1
+-	install -m 0644 mkfs.jffs2.1 ${DESTDIR}/${MANDIR}/man1/
+-	-gzip -9f ${DESTDIR}/${MANDIR}/man1/*.1
+ 
+ tests::
+ 	$(MAKE) -C $(TESTS)
+@@ -91,8 +73,6 @@ LDLIBS_mkfs.jffs2  = -lz $(LZOLDLIBS)
+ LDFLAGS_jffs2reader = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
+ LDLIBS_jffs2reader  = -lz $(LZOLDLIBS)
+ 
+-$(foreach v,$(MTD_BINS),$(eval $(call mkdep,,$(v))))
+-
+ #
+ # Common libmtd
+ #
+-- 
+1.9.1
+
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0002-common.mk-for-klibc-CC-is-klcc.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0002-common.mk-for-klibc-CC-is-klcc.patch
new file mode 100644
index 0000000..f46824b
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0002-common.mk-for-klibc-CC-is-klcc.patch
@@ -0,0 +1,27 @@
+From f3609c7c0450b4c31e1d4603fcf2cfb1ba46f994 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Sun, 29 Jun 2014 00:37:28 +0200
+Subject: [PATCH 2/6] common.mk: for klibc $(CC) is klcc
+
+Do not hardcode: assign the value to the variable if it is not already defined.
+
+Upstream-Status: Pending
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ common.mk | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/common.mk b/common.mk
+index ba87377..59c56df 100644
+--- a/common.mk
++++ b/common.mk
+@@ -1,4 +1,4 @@
+-CC := $(CROSS)gcc
++CC ?= $(CROSS)gcc
+ AR := $(CROSS)ar
+ RANLIB := $(CROSS)ranlib
+ 
+-- 
+1.9.1
+
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0003-libubi.c-add-klibc-specific-fixes.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0003-libubi.c-add-klibc-specific-fixes.patch
new file mode 100644
index 0000000..962b368
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0003-libubi.c-add-klibc-specific-fixes.patch
@@ -0,0 +1,76 @@
+From 72a39bb3290a79e76b0dbf59eef83ea2d9b577a1 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Sun, 29 Jun 2014 00:40:15 +0200
+Subject: [PATCH 3/6] libubi.c: add klibc specific fixes for ioctl
+
+First issue is that ioctl() in klibc doesn't expect a constant as arg3.
+Second issue is that arg3 in klibc ioctl() implementation is not optional.
+
+Fixes:
+
+| ubi-utils/libubi.c: In function 'do_attach':
+| ubi-utils/libubi.c:698:8: warning: passing argument 3 of 'ioctl' discards
+| 'const' qualifier from pointer target type
+|   ret = ioctl(fd, UBI_IOCATT, r);
+|         ^
+| In file included from ubi-utils/libubi.c:32:0:
+| .../lib/klibc/include/sys/ioctl.h:15:14: note: expected 'void *' but argument
+| is of type 'const struct ubi_attach_req *'
+|  __extern int ioctl(int, int, void *);
+|               ^
+
+| ubi-utils/libubi.c: In function 'ubi_vol_block_create':
+| ubi-utils/libubi.c:1118:9: error: too few arguments to function 'ioctl'
+|   return ioctl(fd, UBI_IOCVOLCRBLK);
+|          ^
+| In file included from ubi-utils/libubi.c:32:0:
+| .../lib/klibc/include/sys/ioctl.h:15:14: note: declared here
+|  __extern int ioctl(int, int, void *);
+|               ^
+| ubi-utils/libubi.c: In function 'ubi_vol_block_remove':
+| ubi-utils/libubi.c:1123:9: error: too few arguments to function 'ioctl'
+|   return ioctl(fd, UBI_IOCVOLRMBLK);
+|          ^
+| In file included from ubi-utils/libubi.c:32:0:
+| .../usr/lib/klibc/include/sys/ioctl.h:15:14: note: declared here
+|  __extern int ioctl(int, int, void *);
+|               ^
+
+Upstream-Status: Inappropriate [klibc specific]
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ ubi-utils/libubi.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/ubi-utils/libubi.c b/ubi-utils/libubi.c
+index 1e08b7d..491e525 100644
+--- a/ubi-utils/libubi.c
++++ b/ubi-utils/libubi.c
+@@ -687,7 +687,7 @@ void libubi_close(libubi_t desc)
+  * success and %-1 in case of failure. @r->ubi_num contains newly created UBI
+  * device number.
+  */
+-static int do_attach(const char *node, const struct ubi_attach_req *r)
++static int do_attach(const char *node, struct ubi_attach_req *r)
+ {
+ 	int fd, ret;
+ 
+@@ -1115,12 +1115,12 @@ int ubi_rsvol(libubi_t desc, const char *node, int vol_id, long long bytes)
+ 
+ int ubi_vol_block_create(int fd)
+ {
+-	return ioctl(fd, UBI_IOCVOLCRBLK);
++	return ioctl(fd, UBI_IOCVOLCRBLK, NULL);
+ }
+ 
+ int ubi_vol_block_remove(int fd)
+ {
+-	return ioctl(fd, UBI_IOCVOLRMBLK);
++	return ioctl(fd, UBI_IOCVOLRMBLK, NULL);
+ }
+ 
+ int ubi_update_start(libubi_t desc, int fd, long long bytes)
+-- 
+1.9.1
+
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0004-common.h-klibc-fixes-1.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0004-common.h-klibc-fixes-1.patch
new file mode 100644
index 0000000..fee1cbc
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0004-common.h-klibc-fixes-1.patch
@@ -0,0 +1,84 @@
+From e56767b9caa02e7c41803499c77dc939d5a7f64a Mon Sep 17 00:00:00 2001
+From: Thorsten Glaser <tg@mirbsd.org>
+Date: Fri, 20 Jun 2014 10:56:27 +0000
+Subject: [PATCH 4/6] Restore compatibility to dietlibc, klibc, musl libc after commit 4f1b108
+
+Each C library has their own way to define off_t, and the <features.h>
+header is nonstandard and specific to the GNU libc and those that clone
+it (uClibc). Fefe’s dietlibc uses different flags, and klibc always uses
+a 64-bit off_t (like the BSDs); musl libc cannot be recognised using cpp
+instructions, so we assume 64 bit there (and on unknown C libraries) and
+leave it to the user to submit a follow-up fix if we guess wrong. I also
+added a static assertion to verify the 64 bit guess is correct.
+
+It would be really better using a configure script for this instead.
+
+Fixes:
+|   CC      lib/libmtd.o
+| In file included from ubi-utils/ubiutils-common.c:35:0:
+| ./include/common.h:29:22: fatal error: features.h: No such file or directory
+|  #include <features.h>
+|                       ^
+| compilation terminated.
+
+Upstream-Status: Pending
+
+Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ include/common.h | 24 ++++++++++++++++++++++++
+ 1 file changed, 24 insertions(+)
+
+diff --git a/include/common.h b/include/common.h
+index 6895e5c..77f3f7d 100644
+--- a/include/common.h
++++ b/include/common.h
+@@ -26,7 +26,9 @@
+ #include <string.h>
+ #include <fcntl.h>
+ #include <errno.h>
++#if defined(__GLIBC__) || defined(__UCLIBC__)
+ #include <features.h>
++#endif
+ #include <inttypes.h>
+ #include "version.h"
+ 
+@@ -52,6 +54,21 @@ extern "C" {
+ #endif
+ 
+ /* define a print format specifier for off_t */
++#if defined(__KLIBC__)
++/* always 64 bit on klibc */
++#define PRIxoff_t PRIx64
++#define PRIdoff_t PRId64
++#elif defined(__dietlibc__)
++/* depends on compiler flags on dietlibc */
++#if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
++#define PRIxoff_t PRIx64
++#define PRIdoff_t PRId64
++#else
++#define PRIxoff_t "l"PRIx32
++#define PRIdoff_t "l"PRId32
++#endif
++#elif defined(__GLIBC__) || defined(__UCLIBC__)
++/* depends on compiler flags on glibc and uClibc */
+ #ifdef __USE_FILE_OFFSET64
+ #define PRIxoff_t PRIx64
+ #define PRIdoff_t PRId64
+@@ -59,6 +76,13 @@ extern "C" {
+ #define PRIxoff_t "l"PRIx32
+ #define PRIdoff_t "l"PRId32
+ #endif
++#else
++/* unknown libc or musl */
++#define PRIxoff_t PRIx64
++#define PRIdoff_t PRId64
++/* verify our guess of 64 bit is correct */
++static char __PRIxoff_t_static_assert[sizeof(off_t) == 8 ? 1 : -1];
++#endif
+ 
+ /* Verbose messages */
+ #define bareverbose(verbose, fmt, ...) do {                        \
+-- 
+1.9.1
+
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0005-common.h-klibc-fixes-2.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0005-common.h-klibc-fixes-2.patch
new file mode 100644
index 0000000..2e43d5d
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0005-common.h-klibc-fixes-2.patch
@@ -0,0 +1,61 @@
+From 8318852ef4f768bed31072aa7b57e11adc1f639c Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Sun, 29 Jun 2014 00:44:03 +0200
+Subject: [PATCH 5/6] common.h: more workarounds for klibc compatibility
+
+Patch is addressing two issues:
+* First,  Klibc doesn't have rpmatch().
+* Second, Klibc lacks getline()
+
+Fixes:
+|   LD      ubi-utils/ubiformat
+| .../git/ubi-utils/ubiformat.o: In function `prompt':
+| .../git/./include/common.h:157: undefined reference to `getline'
+| .../git/./include/common.h:164: undefined reference to `rpmatch'
+| .../git/./include/common.h:157: undefined reference to `getline'
+| .../git/./include/common.h:164: undefined reference to `rpmatch'
+
+Upstream-Status: Pending
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ include/common.h | 10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/include/common.h b/include/common.h
+index 77f3f7d..2cbee0f 100644
+--- a/include/common.h
++++ b/include/common.h
+@@ -126,7 +126,7 @@ static char __PRIxoff_t_static_assert[sizeof(off_t) == 8 ? 1 : -1];
+ 	fprintf(stderr, "%s: warning!: " fmt "\n", PROGRAM_NAME, ##__VA_ARGS__); \
+ } while(0)
+ 
+-#if defined(__UCLIBC__)
++#if defined(__UCLIBC__) || defined(__KLIBC__)
+ /* uClibc versions before 0.9.34 don't have rpmatch() */
+ #if __UCLIBC_MAJOR__ == 0 && \
+ 		(__UCLIBC_MINOR__ < 9 || \
+@@ -146,15 +146,17 @@ static inline int __rpmatch(const char *resp)
+  */
+ static inline bool prompt(const char *msg, bool def)
+ {
+-	char *line = NULL;
+-	size_t len;
++	char *line;
+ 	bool ret = def;
+ 
++	const int sizeof_line = 2;
++	line = malloc(sizeof_line);
++
+ 	do {
+ 		normsg_cont("%s (%c/%c) ", msg, def ? 'Y' : 'y', def ? 'n' : 'N');
+ 		fflush(stdout);
+ 
+-		while (getline(&line, &len, stdin) == -1) {
++		while (fgets(line, sizeof_line, stdin) == NULL) {
+ 			printf("failed to read prompt; assuming '%s'\n",
+ 				def ? "yes" : "no");
+ 			break;
+-- 
+1.9.1
+
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0006-libiniparser-remove-unused-function-needing-float.patch b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0006-libiniparser-remove-unused-function-needing-float.patch
new file mode 100644
index 0000000..043a89d
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc/0006-libiniparser-remove-unused-function-needing-float.patch
@@ -0,0 +1,85 @@
+From 72a04a9b9ed33c889d2e2b86f306c5be9f6cde35 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Sun, 29 Jun 2014 00:44:57 +0200
+Subject: [PATCH 6/6] libiniparser: remove unused function needing float
+
+Fixes:
+|   LD      ubi-utils/ubiformat
+| .../git/ubi-utils/libiniparser.a(libiniparser.o): In function
+| `  LD      ubi-utils/ubirename
+| iniparser_getdouble':
+| .../git/ubi-utils/libiniparser.c:336: undefined reference to `atof'
+
+Grep doesn't reveal any occurrence of iniparser_getdouble(), using atof() so
+remove it: floating-point is not supported in klibc
+
+Upstream-Status: Pending
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ ubi-utils/include/libiniparser.h | 15 ---------------
+ ubi-utils/libiniparser.c         | 22 ----------------------
+ 2 files changed, 37 deletions(-)
+
+diff --git a/ubi-utils/include/libiniparser.h b/ubi-utils/include/libiniparser.h
+index be3c667..abd77aa 100644
+--- a/ubi-utils/include/libiniparser.h
++++ b/ubi-utils/include/libiniparser.h
+@@ -158,21 +158,6 @@ int iniparser_getint(dictionary * d, const char * key, int notfound);
+ 
+ /*-------------------------------------------------------------------------*/
+ /**
+-  @brief    Get the string associated to a key, convert to a double
+-  @param    d Dictionary to search
+-  @param    key Key string to look for
+-  @param    notfound Value to return in case of error
+-  @return   double
+-
+-  This function queries a dictionary for a key. A key as read from an
+-  ini file is given as "section:key". If the key cannot be found,
+-  the notfound value is returned.
+- */
+-/*--------------------------------------------------------------------------*/
+-double iniparser_getdouble(dictionary * d, char * key, double notfound);
+-
+-/*-------------------------------------------------------------------------*/
+-/**
+   @brief    Get the string associated to a key, convert to a boolean
+   @param    d Dictionary to search
+   @param    key Key string to look for
+diff --git a/ubi-utils/libiniparser.c b/ubi-utils/libiniparser.c
+index 898f57f..ba70c08 100644
+--- a/ubi-utils/libiniparser.c
++++ b/ubi-utils/libiniparser.c
+@@ -316,28 +316,6 @@ int iniparser_getint(dictionary * d, const char * key, int notfound)
+ 
+ /*-------------------------------------------------------------------------*/
+ /**
+-  @brief    Get the string associated to a key, convert to a double
+-  @param    d Dictionary to search
+-  @param    key Key string to look for
+-  @param    notfound Value to return in case of error
+-  @return   double
+-
+-  This function queries a dictionary for a key. A key as read from an
+-  ini file is given as "section:key". If the key cannot be found,
+-  the notfound value is returned.
+- */
+-/*--------------------------------------------------------------------------*/
+-double iniparser_getdouble(dictionary * d, char * key, double notfound)
+-{
+-    char    *   str ;
+-
+-    str = iniparser_getstring(d, key, INI_INVALID_KEY);
+-    if (str==INI_INVALID_KEY) return notfound ;
+-    return atof(str);
+-}
+-
+-/*-------------------------------------------------------------------------*/
+-/**
+   @brief    Get the string associated to a key, convert to a boolean
+   @param    d Dictionary to search
+   @param    key Key string to look for
+-- 
+1.9.1
+
diff --git a/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_1.5.1.bb b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_1.5.1.bb
new file mode 100644
index 0000000..8ca1ca7
--- /dev/null
+++ b/import-layers/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_1.5.1.bb
@@ -0,0 +1,50 @@
+SUMMARY = "UBI utils statically compiled against klibc"
+DESCRIPTION = "Small sized tools from mtd-utils for use with initramfs."
+SECTION = "base"
+DEPENDS = "zlib lzo e2fsprogs util-linux"
+HOMEPAGE = "http://www.linux-mtd.infradead.org/"
+LICENSE = "GPLv2+"
+LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
+                    file://include/common.h;beginline=1;endline=17;md5=ba05b07912a44ea2bf81ce409380049c"
+
+inherit klibc
+
+SRC_URI = "git://git.infradead.org/mtd-utils.git;tag=b7455d847ab4f9eeeb6a729efc306bfda7bddc99 \
+             file://0001-Makefile-only-build-ubi-utils.patch \
+             file://0002-common.mk-for-klibc-CC-is-klcc.patch \
+             file://0003-libubi.c-add-klibc-specific-fixes.patch \
+             file://0004-common.h-klibc-fixes-1.patch \
+             file://0005-common.h-klibc-fixes-2.patch \
+             file://0006-libiniparser-remove-unused-function-needing-float.patch \
+             "
+
+S = "${WORKDIR}/git/"
+
+EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}include -DWITHOUT_XATTR' 'BUILDDIR=${S}'"
+
+do_install () {
+
+    install -d ${D}${sbindir}
+    oe_runmake DESTDIR="${D}" install
+
+}
+
+PACKAGES = "ubi-utils-klibc-dbg"
+
+PACKAGES =+ "mtdinfo-klibc ubiattach-klibc ubiblock-klibc ubicrc32-klibc ubidetach-klibc \
+             ubiformat-klibc ubimkvol-klibc ubinfo-klibc ubinize-klibc ubirename-klibc \
+             ubirmvol-klibc ubirsvol-klibc ubiupdatevol-klibc"
+
+FILES_mtdinfo-klibc = "${sbindir}/mtdinfo"
+FILES_ubiattach-klibc = "${sbindir}/ubiattach"
+FILES_ubiblock-klibc = "${sbindir}/ubiblock"
+FILES_ubicrc32-klibc = "${sbindir}/ubicrc32"
+FILES_ubidetach-klibc = "${sbindir}/ubidetach"
+FILES_ubiformat-klibc = "${sbindir}/ubiformat"
+FILES_ubimkvol-klibc = "${sbindir}/ubimkvol"
+FILES_ubinfo-klibc = "${sbindir}/ubinfo"
+FILES_ubinize-klibc = "${sbindir}/ubinize"
+FILES_ubirename-klibc = "${sbindir}/ubirename"
+FILES_ubirmvol-klibc = "${sbindir}/ubirmvol"
+FILES_ubirsvol-klibc = "${sbindir}/ubirsvol"
+FILES_ubiupdatevol-klibc = "${sbindir}/ubiupdatevol"