summaryrefslogtreecommitdiffstats
path: root/meta-openembedded/meta-initramfs
diff options
context:
space:
mode:
authorDave Cobbley <david.j.cobbley@linux.intel.com>2018-08-14 10:05:37 -0700
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-08-22 21:26:31 -0400
commiteb8dc40360f0cfef56fb6947cc817a547d6d9bc6 (patch)
treede291a73dc37168da6370e2cf16c347d1eba9df8 /meta-openembedded/meta-initramfs
parent9c3cf826d853102535ead04cebc2d6023eff3032 (diff)
downloadtalos-openbmc-eb8dc40360f0cfef56fb6947cc817a547d6d9bc6.tar.gz
talos-openbmc-eb8dc40360f0cfef56fb6947cc817a547d6d9bc6.zip
[Subtree] Removing import-layers directory
As part of the move to subtrees, need to bring all the import layers content to the top level. Change-Id: I4a163d10898cbc6e11c27f776f60e1a470049d8f Signed-off-by: Dave Cobbley <david.j.cobbley@linux.intel.com> Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'meta-openembedded/meta-initramfs')
-rw-r--r--meta-openembedded/meta-initramfs/COPYING.MIT17
-rw-r--r--meta-openembedded/meta-initramfs/README36
-rw-r--r--meta-openembedded/meta-initramfs/classes/klibc.bbclass16
-rw-r--r--meta-openembedded/meta-initramfs/conf/layer.conf23
-rw-r--r--meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-debug-image.bb22
-rw-r--r--meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-image.bb28
-rw-r--r--meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-klibc-image.bb12
-rw-r--r--meta-openembedded/meta-initramfs/recipes-bsp/initrdscripts/files/init-debug.sh31
-rw-r--r--meta-openembedded/meta-initramfs/recipes-bsp/initrdscripts/initramfs-debug_1.0.bb14
-rw-r--r--meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg/icon.xpm43
-rw-r--r--meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg_0.2.bb60
-rw-r--r--meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot_git.bb64
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut/0001-util.h-include-sys-reg.h-when-libc-glibc.patch33
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut_git.bb69
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/0001-Add-another-variable-LIBS-to-provides-libraries-from.patch26
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/0002-include-paths.h-for-_PATH_MOUNTED.patch25
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/grubby-rename-grub2-editenv-to-grub-editenv.patch69
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/run-ptest3
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby_8.40.bb40
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klcc-cross_2.0.4.bb34
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch87
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Kbuild.klibc-Add-path-to-compiler-headers-via-isyste.patch28
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Kbuild.klibc-Use-print-libgcc-file-name-instead-of-p.patch28
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-always-use-bfd-linker.patch28
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-arm-Do-not-set-a-fallback-march-and-mtune.patch29
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch29
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch30
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch27
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/armv4-fix-v4bx.patch26
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch22
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-config-eabi.patch24
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-linux-libc-dev.patch29
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/staging.patch151
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/use-env-for-perl.patch25
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-static-utils_2.0.4.bb12
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils.inc60
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils_2.0.4.bb14
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc.inc74
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc_2.0.4.bb24
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0001-Makefile-build-ubi-utils-only.patch87
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0002-common.mk-for-klibc-CC-is-klcc.patch27
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0003-libubi.c-add-klibc-specific-fixes-for-ioctl.patch76
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0004-Restore-compatibility-to-dietlibc-klibc-musl-libc-af.patch88
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0005-common.h-more-workarounds-for-klibc-compatibility.patch52
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0006-libiniparser-remove-unused-function-needing-float.patch85
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch64
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0008-ubi-utils-ubiformat.c-convert-to-integer-arithmetic.patch44
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0009-Eliminate-warnings-about-implicit-non-const-casting-.patch48
-rw-r--r--meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_1.5.2.bb51
-rw-r--r--meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/0001-Adjust-the-order-of-headers-to-fix-build-for-musl.patch30
-rw-r--r--meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/arm_crashdump.patch12
-rw-r--r--meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/cflags_static.patch11
-rw-r--r--meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/fix-out-of-tree-build.patch54
-rw-r--r--meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/ifdown_errno.patch11
-rw-r--r--meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/kexec-elf-rel.patch61
-rw-r--r--meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/kexec-syscall.patch44
-rw-r--r--meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/ppc__lshrdi3.patch18
-rw-r--r--meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/purgatory_flags.patch21
-rw-r--r--meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/purgatory_string.patch9
-rw-r--r--meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/sha256.patch13
-rw-r--r--meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/sysconf_nrprocessors.patch13
-rw-r--r--meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/x86_basename.patch14
-rw-r--r--meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/x86_kexec_test.patch13
-rw-r--r--meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/x86_sys_io.patch21
-rw-r--r--meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/x86_vfscanf.patch27
-rw-r--r--meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc_2.0.2.bb69
66 files changed, 2475 insertions, 0 deletions
diff --git a/meta-openembedded/meta-initramfs/COPYING.MIT b/meta-openembedded/meta-initramfs/COPYING.MIT
new file mode 100644
index 000000000..fb950dc69
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/COPYING.MIT
@@ -0,0 +1,17 @@
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/meta-openembedded/meta-initramfs/README b/meta-openembedded/meta-initramfs/README
new file mode 100644
index 000000000..718538312
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/README
@@ -0,0 +1,36 @@
+meta-initramfs
+==============
+
+This layer contains the metadata necessary to build the klibc library and
+utilities (shared and static) plus other tools useful for the creation of
+small-sized initramfs.
+
+
+Dependencies
+------------
+
+This layer depends on:
+
+URI: git://github.com/openembedded/oe-core.git
+branch: master
+revision: HEAD
+
+
+Maintenance
+-----------
+
+Send patches / pull requests to openembedded-devel@lists.openembedded.org
+with '[meta-initramfs]' in the subject.
+
+When sending single patches, please using something like:
+'git send-email -M -1 --to openembedded-devel@lists.openembedded.org --subject-prefix=meta-initramfs][PATCH'
+
+Interm layer maintainer: Armin Kuster <akuster808@gmail.com>
+
+
+License
+-------
+
+All metadata is MIT licensed unless otherwise stated. Source code included
+in tree for individual recipes is under the LICENSE stated in each recipe
+(.bb file) unless otherwise stated.
diff --git a/meta-openembedded/meta-initramfs/classes/klibc.bbclass b/meta-openembedded/meta-initramfs/classes/klibc.bbclass
new file mode 100644
index 000000000..b7b72b728
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/classes/klibc.bbclass
@@ -0,0 +1,16 @@
+# klcc-cross depends on klibc
+DEPENDS =+ "klcc-cross"
+
+# Default for klcc is to build static binaries.
+# Set CC = "${TARGET_PREFIX}klcc -shared" to build the dynamic version.
+CC_forcevariable = "${TARGET_PREFIX}klcc ${TOOLCHAIN_OPTIONS}"
+CC_forcevariable_armv4_linux-gnueabi = "${TARGET_PREFIX}klcc ${TOOLCHAIN_OPTIONS} -march=armv4 -mthumb-interwork"
+CC_append_armv7ve = " ${@' -mfloat-abi=${TUNE_CCARGS_MFLOAT}' if (d.getVar('TUNE_CCARGS_MFLOAT') != '') else ''}"
+CC_append_armv7a = " ${@' -mfloat-abi=${TUNE_CCARGS_MFLOAT}' if (d.getVar('TUNE_CCARGS_MFLOAT') != '') else ''}"
+
+CPP_forcevariable = "${CC} -E"
+
+# klcc uses own optimizations by default. See klcc(1) man file.
+export CFLAGS="${TUNE_CCARGS}"
+export CPPFLAGS="${TUNE_CCARGS}"
+export LDFLAGS="${TUNE_CCARGS}"
diff --git a/meta-openembedded/meta-initramfs/conf/layer.conf b/meta-openembedded/meta-initramfs/conf/layer.conf
new file mode 100644
index 000000000..97afc9374
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/conf/layer.conf
@@ -0,0 +1,23 @@
+# Layer configuration for meta-initramfs layer
+
+# We have a conf and classes directory, append to BBPATH
+BBPATH .= ":${LAYERDIR}"
+
+# We have a recipes directory, add to BBFILES
+BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"
+
+BBFILE_COLLECTIONS += "meta-initramfs"
+BBFILE_PATTERN_meta-initramfs := "^${LAYERDIR}/"
+
+# Define the priority for recipes (.bb files) from this layer,
+# choosing carefully how this layer interacts with all of the
+# other layers.
+
+BBFILE_PRIORITY_meta-initramfs = "8"
+LAYERDEPENDS_meta-initramfs = "core"
+
+LAYERSERIES_COMPAT_meta-initramfs = "sumo"
+
+SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS += " \
+ dracut->virtual/kernel \
+"
diff --git a/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-debug-image.bb b/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-debug-image.bb
new file mode 100644
index 000000000..be7350ade
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-debug-image.bb
@@ -0,0 +1,22 @@
+# Simple initramfs image. Mostly used for live images.
+DESCRIPTION = "Small image capable of booting a device. The kernel includes \
+the Minimal RAM-based Initial Root Filesystem (initramfs), which one can use \
+to check the hardware efficiently."
+
+PACKAGE_INSTALL = "initramfs-debug busybox base-passwd ${ROOTFS_BOOTSTRAP_INSTALL}"
+
+# Do not pollute the initrd image with rootfs features
+IMAGE_FEATURES = ""
+
+export IMAGE_BASENAME = "initramfs-debug-image"
+IMAGE_LINGUAS = ""
+
+LICENSE = "MIT"
+
+IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}"
+inherit core-image
+
+IMAGE_ROOTFS_SIZE = "8192"
+IMAGE_ROOTFS_EXTRA_SPACE = "0"
+
+BAD_RECOMMENDATIONS += "busybox-syslog"
diff --git a/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-image.bb b/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-image.bb
new file mode 100644
index 000000000..2573eb481
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-image.bb
@@ -0,0 +1,28 @@
+SUMMARY = "Initramfs image for kexecboot kernel"
+DESCRIPTION = "This image provides kexecboot (linux as bootloader) and helpers."
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+inherit image
+
+IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}"
+
+# avoid circular dependencies
+EXTRA_IMAGEDEPENDS = ""
+KERNELDEPMODDEPEND = ""
+
+# We really need just kexecboot, kexec and ubiattach
+IMAGE_INSTALL = "kexecboot kexec mtd-utils-ubifs"
+
+# Do not pollute the initrd image with rootfs features
+IMAGE_FEATURES = ""
+
+IMAGE_LINGUAS = ""
+
+FEED_DEPLOYDIR_BASE_URI = ""
+LDCONFIGDEPEND = ""
+IMAGE_ROOTFS_EXTRA_SPACE = "0"
+
+# disable runtime dependency on run-postinsts -> update-rc.d
+ROOTFS_BOOTSTRAP_INSTALL = ""
+
diff --git a/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-klibc-image.bb b/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-klibc-image.bb
new file mode 100644
index 000000000..3a8d9f743
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-bsp/images/initramfs-kexecboot-klibc-image.bb
@@ -0,0 +1,12 @@
+require initramfs-kexecboot-image.bb
+
+SUMMARY = "Initramfs image for kexecboot kernel (klibc-static binaries)"
+
+# We really need just kexecboot, kexec and ubiattach
+# statically compiled against klibc
+IMAGE_INSTALL = "kexecboot-klibc kexec-klibc ubiattach-klibc"
+
+python () {
+ if d.getVar('TARGET_ARCH') == "nios2":
+ raise bb.parse.SkipRecipe("'nios2' not supported arch")
+}
diff --git a/meta-openembedded/meta-initramfs/recipes-bsp/initrdscripts/files/init-debug.sh b/meta-openembedded/meta-initramfs/recipes-bsp/initrdscripts/files/init-debug.sh
new file mode 100644
index 000000000..7edbd70cb
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-bsp/initrdscripts/files/init-debug.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+
+do_mount_fs() {
+ grep -q "$1" /proc/filesystems || return
+ test -d "$2" || mkdir -p "$2"
+ mount -t "$1" "$1" "$2"
+}
+
+do_mknod() {
+ test -e "$1" || mknod "$1" "$2" "$3" "$4"
+}
+
+mkdir -p /proc
+mount -t proc proc /proc
+
+do_mount_fs sysfs /sys
+do_mount_fs debugfs /sys/kernel/debug
+do_mount_fs devtmpfs /dev
+do_mount_fs devpts /dev/pts
+do_mount_fs tmpfs /dev/shm
+
+mkdir -p /run
+mkdir -p /var/run
+
+do_mknod /dev/console c 5 1
+do_mknod /dev/null c 1 3
+do_mknod /dev/zero c 1 5
+
+exec sh </dev/console >/dev/console 2>/dev/console
diff --git a/meta-openembedded/meta-initramfs/recipes-bsp/initrdscripts/initramfs-debug_1.0.bb b/meta-openembedded/meta-initramfs/recipes-bsp/initrdscripts/initramfs-debug_1.0.bb
new file mode 100644
index 000000000..667690f88
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-bsp/initrdscripts/initramfs-debug_1.0.bb
@@ -0,0 +1,14 @@
+SUMMARY = "Extremely basic live image init script"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+SRC_URI = "file://init-debug.sh"
+
+S = "${WORKDIR}"
+
+do_install() {
+ install -m 0755 ${WORKDIR}/init-debug.sh ${D}/init
+}
+
+inherit allarch
+
+FILES_${PN} += " /init "
diff --git a/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg/icon.xpm b/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg/icon.xpm
new file mode 100644
index 000000000..6e6fd776d
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg/icon.xpm
@@ -0,0 +1,43 @@
+/* XPM */
+static char * icon_xpm[] = {
+"32 32 8 1",
+" c None",
+". c #D6DBDE",
+"+ c #9BA6AE",
+"@ c #60727D",
+"# c #B8BFC5",
+"$ c #A9E8F6",
+"% c #12BCE4",
+"& c #57D2EC",
+" ",
+" ",
+" ",
+" .++@@@@++. ",
+" +@@@@@@@@@@@@+ ",
+" #@@@@@@@@@@@@@@@@# ",
+" +@@@@@@@@@@@@@@@@@@+ ",
+" .@@@@@@@@++##+@@@@@@@@@. ",
+" @@@@@@@. .@@@@@@@ ",
+" +@@@@@+ $$$$ #@@@@@+ ",
+" #@@@@@. $%%%%%%%%$ .@@@@@# ",
+" @@@@@. &%%%%%%%%%%& .@@@@@ ",
+" #@@@@+ %%%%%%%%%%%%%% +@@@@# ",
+" @@@@@ &%%%%%%%%%%%%%%& @@@@@ ",
+".@@@@. $%%%%%& $%%%%%& .@@@@.",
+"+@@@@ %%%%% $%%%%%& @@@@+",
+"+@@@+ %%%%$ $%%%%%& $$ +@@@+",
+"@@@@+ $%%%% $%%%%%& $%$ +@@@@",
+"@@@@# &%%%& &%%%%& $%%& #@@@@",
+"@@@@. &%%%& %%%%& $%%%& .@@@@",
+"@@@@# $%%%& &%%& &%%%$ #@@@@",
+"+@@@+ $%%%% %%%%$ +@@@+",
+"+@@@@ %%%%& &%%%% @@@@+",
+"#@@@@ &%%%%& &%%%%& @@@@#",
+" @@@@+ %%%%%%&$$&%%%%%% +@@@@ ",
+" +@@@@. $%%%%%%%%%%%%%%$ .@@@@+ ",
+" .@@@@@ $%%%%%%%%%%%%$ @@@@@. ",
+" #++++. &%%%%%%%%& .++++# ",
+" $&&%%&&$ ",
+" ",
+" ",
+" "};
diff --git a/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg_0.2.bb b/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg_0.2.bb
new file mode 100644
index 000000000..804ec3235
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot-cfg_0.2.bb
@@ -0,0 +1,60 @@
+SUMMARY = "Configuration files for kexecboot"
+DESCRIPTION = "Default icon and boot.cfg for kexecboot linux-as-bootloader."
+SECTION = "base"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+SRC_URI = "file://icon.xpm"
+
+S = "${WORKDIR}"
+
+do_install_prepend () {
+echo '# /boot/boot.cfg - KEXECBOOT configuration file.
+#
+# First kernel stanza.
+# Show this label in kexecboot menu.
+#
+LABEL=${KEXECBOOT_LABEL}
+#
+# Specify full kernel path on target.
+KERNEL=/boot/${KERNEL_IMAGETYPE}
+#
+# Append this tags to the kernel cmdline.
+APPEND=${CMDLINE} ${CMDLINE_DEBUG}
+#
+# Specify optional initrd/initramfs.
+# INITRD=/boot/initramfs.cpio.gz
+#
+# Specify full path for a custom icon for the menu-item.
+# If not set, use device-icons as default (NAND, SD, CF, ...).
+# ICON=/boot/icon.xpm
+#
+# Priority of item in kexecboot menu.
+# Items with highest priority will be shown at top of menu.
+# Default: 0 (lowest, ordered by device ordering)
+# PRIORITY=10
+#
+#
+# Second kernel stanza.
+# LABEL=${KEXECBOOT_LABEL}-test
+# KERNEL=/boot/${KERNEL_IMAGETYPE}-test
+# APPEND=${CMDLINE}
+#' > ${S}/boot.cfg
+}
+do_install () {
+ install -d ${D}/boot
+ install -m 0644 boot.cfg ${D}/boot/boot.cfg
+ install -m 0644 icon.xpm ${D}/boot/icon.xpm
+}
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+FILES_${PN} += "/boot/*"
+
+CMDLINE ?= ""
+CMDLINE_DEBUG ?= "quiet"
+
+INHIBIT_DEFAULT_DEPS = "1"
+
+# Note: for qvga the label is currently limited to about 24 chars
+KEXECBOOT_LABEL ?= "${@d.getVar('DISTRO') or d.getVar('DISTRO_VERSION')}-${MACHINE}"
diff --git a/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot_git.bb b/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot_git.bb
new file mode 100644
index 000000000..9f5dad7c6
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-bsp/kexecboot/kexecboot_git.bb
@@ -0,0 +1,64 @@
+###########################
+# Configure options:
+#
+# --enable-static-linking compile kexecboot as static executable [default=no]
+# --enable-fbui support framebuffer menu [default=yes]
+# --enable-fbui-width limit FB UI width to specified value [default=no]
+# --enable-fbui-height limit FB UI height to specified value [default=no]
+# --enable-textui support console text user interface [default=no]
+# --enable-cfgfiles support config files [default=yes]
+# --enable-icons support custom icons (depends on fbui) [default=yes]
+# --enable-zaurus compile Sharp Zaurus specific code [default=no]
+# --enable-zimage compile with zImage support [default=yes]
+# --enable-uimage compile with uImage support [default=no]
+# --enable-machine-kernel look for machine-specific zImage kernel [default=no]
+# --enable-devices-recreating
+# enable devices re-creating [default=yes]
+# --enable-debug enable debug output [default=no]
+# --enable-host-debug allow for non-destructive executing of kexecboot on
+# host system [default=no]
+# --enable-numkeys enable menu item selection by keys [0-9] [default=yes]
+# --enable-bg-buffer enable buffer for pre-drawed FB GUI background
+#
+# --enable-timeout allow to boot 1st kernel after timeout in seconds
+# [default=no]
+# --enable-delay specify delay before device scanning, allowing
+# initialization of old CF/SD cards [default=1]
+# --enable-bpp enable support of specified bpp modes
+# (all,32,24,18,16,4,2,1) [default=all]
+# --enable-evdev-rate change evdev (keyboard/mouse) repeat rate
+# in milliseconds e.g. "1000,250" [default=no]
+# --with-kexec-binary look for kexec binary at path
+# [default="/usr/sbin/kexec"]
+##########################
+SUMMARY = "kexecboot linux-as-bootloader"
+DESCRIPTION = "kexecboot is a graphical linux-as-bootloader implementation based on kexec."
+HOMEPAGE = "http://kexecboot.org"
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f"
+PV = "0.6+git${SRCPV}"
+S = "${WORKDIR}/git"
+SRC_URI = "git://github.com/kexecboot/kexecboot.git"
+SRCREV = "4c4f127e79ac5b8d6b6e2fbb938ccbf12b04c531"
+inherit autotools
+
+EXTRA_OECONF = "--enable-textui --enable-delay=2 --enable-evdev-rate=1000,250"
+
+do_install () {
+ install -d ${D}${bindir}
+ install -m 0755 kexecboot ${D}${bindir}
+ install -d ${D}/proc
+ install -d ${D}/mnt
+ install -d ${D}/dev
+ install -d ${D}/sys
+}
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+FILES_${PN} += " ${bindir}/kexecboot /init /proc /mnt /dev /sys"
+
+pkg_postinst_${PN} () {
+ ln -sf ${bindir}/kexecboot $D/init
+}
+
+BBCLASSEXTEND = "klibc"
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut/0001-util.h-include-sys-reg.h-when-libc-glibc.patch b/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut/0001-util.h-include-sys-reg.h-when-libc-glibc.patch
new file mode 100644
index 000000000..32714038b
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut/0001-util.h-include-sys-reg.h-when-libc-glibc.patch
@@ -0,0 +1,33 @@
+From 06011ce55b1e892e863568a73d64eebc6389544f Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 13 Jul 2017 17:14:05 -0700
+Subject: [PATCH] util.h: include <sys/reg.h> when libc != glibc
+
+For musl libc it is required to include <sys/reg.h> to
+have __WORDSIZE defined to e.g. 32 for arm*-musl.
+
+Taken from void-linux
+https://github.com/voidlinux/void-packages/blob/master/srcpkgs/dracut/patches/musl-__wordsize.patch
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ install/util.h | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/install/util.h b/install/util.h
+index 2ad3254d..062626ec 100644
+--- a/install/util.h
++++ b/install/util.h
+@@ -36,6 +36,9 @@
+ #include <sys/stat.h>
+ #include <dirent.h>
+ #include <sys/resource.h>
++#if !defined(__GLIBC__)
++#include <sys/reg.h>
++#endif
+
+ #include "macro.h"
+
+--
+2.13.2
+
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut_git.bb b/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut_git.bb
new file mode 100644
index 000000000..ccf9f6ab1
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/dracut/dracut_git.bb
@@ -0,0 +1,69 @@
+SUMMARY = "Initramfs generator using udev"
+HOMEPAGE = "https://dracut.wiki.kernel.org/index.php/Main_Page"
+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 = "046+git${SRCREV}"
+
+# v046 tag
+SRCREV = "a0799ffb554487a370c2a1adafaedd2021b6dc8c"
+SRC_URI = "git://git.kernel.org/pub/scm/boot/dracut/dracut.git;protocol=http \
+ file://0001-util.h-include-sys-reg.h-when-libc-glibc.patch \
+ "
+
+DEPENDS += "kmod"
+DEPENDS_append_libc-musl = " fts"
+
+inherit bash-completion pkgconfig
+
+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.filter('DISTRO_FEATURES', 'systemd', d)}"
+PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_unitdir}/system/,,,systemd"
+
+EXTRA_OEMAKE += 'libdir=${prefix}/lib LDLIBS="${LDLIBS}"'
+
+LDLIBS_append_libc-musl = " -lfts"
+
+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/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/0001-Add-another-variable-LIBS-to-provides-libraries-from.patch b/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/0001-Add-another-variable-LIBS-to-provides-libraries-from.patch
new file mode 100644
index 000000000..1b1a993a0
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/0001-Add-another-variable-LIBS-to-provides-libraries-from.patch
@@ -0,0 +1,26 @@
+From 22afaa21b4b258082be591e54c99e1ba6fbd7748 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sat, 15 Jul 2017 10:19:22 -0700
+Subject: [PATCH 1/2] Add another variable LIBS to provides libraries from env
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index ac14404..92a8e73 100644
+--- a/Makefile
++++ b/Makefile
+@@ -27,7 +27,7 @@ RPM_OPT_FLAGS ?= -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector
+ CFLAGS += $(RPM_OPT_FLAGS) -std=gnu99 -Wall -Werror -Wno-error=unused-function -Wno-unused-function -ggdb
+ LDFLAGS :=
+
+-grubby_LIBS = -lblkid -lpopt
++grubby_LIBS = -lblkid -lpopt ${LIBS}
+
+ all: grubby
+
+--
+2.13.3
+
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/0002-include-paths.h-for-_PATH_MOUNTED.patch b/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/0002-include-paths.h-for-_PATH_MOUNTED.patch
new file mode 100644
index 000000000..de8133a3a
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/0002-include-paths.h-for-_PATH_MOUNTED.patch
@@ -0,0 +1,25 @@
+From 8f844ac7f44b8dc428d06cd6958c5f32d383d01c Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sat, 15 Jul 2017 10:19:50 -0700
+Subject: [PATCH 2/2] include paths.h for _PATH_MOUNTED
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ grubby.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/grubby.c b/grubby.c
+index 47a1a15..59f74a9 100644
+--- a/grubby.c
++++ b/grubby.c
+@@ -34,6 +34,7 @@
+ #include <libgen.h>
+ #include <execinfo.h>
+ #include <signal.h>
++#include <paths.h>
+ #include <blkid/blkid.h>
+
+ #include "log.h"
+--
+2.13.3
+
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/grubby-rename-grub2-editenv-to-grub-editenv.patch b/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/grubby-rename-grub2-editenv-to-grub-editenv.patch
new file mode 100644
index 000000000..d936249be
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/grubby-rename-grub2-editenv-to-grub-editenv.patch
@@ -0,0 +1,69 @@
+From 0841706a5b5280e501c8e392c70c466c5fbcf0aa Mon Sep 17 00:00:00 2001
+From: Jackie Huang <jackie.huang@windriver.com>
+Date: Tue, 4 Aug 2015 23:54:41 -0700
+Subject: [PATCH] rename grub2-editenv to grub-editenv
+
+We don't use the name grub2-editenv for grub2.
+
+Upstream-Status: Inappropriate
+
+Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
+---
+ grubby.c | 4 ++--
+ test.sh | 6 +++---
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/grubby.c b/grubby.c
+index d4ebb86..47a1a15 100644
+--- a/grubby.c
++++ b/grubby.c
+@@ -290,7 +290,7 @@ static char *grub2GetEnv(struct configFileInfo *info, char *name)
+ char *s = NULL;
+ char *ret = NULL;
+ char *envFile = info->envFile ? info->envFile : "/boot/grub2/grubenv";
+- int rc = asprintf(&s, "grub2-editenv %s list | grep '^%s='", envFile, name);
++ int rc = asprintf(&s, "grub-editenv %s list | grep '^%s='", envFile, name);
+
+ if (rc < 0)
+ return NULL;
+@@ -361,7 +361,7 @@ static int grub2SetEnv(struct configFileInfo *info, char *name, char *value)
+ if (!value)
+ return -1;
+
+- rc = asprintf(&s, "grub2-editenv %s set '%s=%s'", envFile, name, value);
++ rc = asprintf(&s, "grub-editenv %s set '%s=%s'", envFile, name, value);
+ free(value);
+ if (rc <0)
+ return -1;
+diff --git a/test.sh b/test.sh
+index 6379698..f738388 100755
+--- a/test.sh
++++ b/test.sh
+@@ -574,7 +574,7 @@ if [ "$testgrub2" == "y" ]; then
+ --title='title' --initrd=/boot/new-initrd --boot-filesystem=/boot/ \
+ --copy-default
+ commandTest "saved_default output" \
+- "grub2-editenv test/grub2-support_files/env_temp list" \
++ "grub-editenv test/grub2-support_files/env_temp list" \
+ "saved_entry=Linux, with Fedora 2.6.38.8-32.fc15.x86_64"
+
+ testing="GRUB2 add kernel with default=saved_entry and a terrible title"
+@@ -587,13 +587,13 @@ if [ "$testgrub2" == "y" ]; then
+ testing="GRUB2 set default with default=saved_entry and a terrible name"
+ grub2Test grub2.9 add/g2-1.9 --env grubenv.1 --set-default-index=0
+ commandTest "saved_default output" \
+- "grub2-editenv test/grub2-support_files/env_temp list" \
++ "grub-editenv test/grub2-support_files/env_temp list" \
+ 'saved_entry=Fedora (3.10.3-300.fc19.x86_64) 19 (Schrödinger’s Cat)'
+
+ testing="GRUB2 set default with default=saved_entry"
+ grub2Test grub2.8 add/g2-1.8 --env grubenv.1 --set-default-index=0
+ commandTest "saved_default output" \
+- "grub2-editenv test/grub2-support_files/env_temp list" \
++ "grub-editenv test/grub2-support_files/env_temp list" \
+ "saved_entry=title"
+
+ testing="GRUB2 --default-index with default=saved_entry"
+--
+2.3.5
+
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/run-ptest b/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/run-ptest
new file mode 100644
index 000000000..b06ac5946
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby/run-ptest
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+./test.sh -v
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby_8.40.bb b/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby_8.40.bb
new file mode 100644
index 000000000..dc3a70bb5
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/grubby/grubby_8.40.bb
@@ -0,0 +1,40 @@
+SUMMARY = "A command line tool for updating and displaying info about boot loaders"
+DESCRIPTION = "grubby is a command line tool for updating and displaying information \
+about the configuration files for the grub, lilo, elilo (ia64), yaboot (powerpc) and \
+zipl (s390) boot loaders. It is primarily designed to be used from scripts which install \
+new kernels and need to find information about the current boot environment. \
+"
+HOMEPAGE = "https://github.com/rhboot/grubby"
+LICENSE = "GPLv2+"
+
+LIC_FILES_CHKSUM = "file://COPYING;md5=892f569a555ba9c07a568a7c0c4fa63a"
+
+DEPENDS = "popt util-linux"
+DEPENDS_append_libc-musl = " libexecinfo"
+
+S = "${WORKDIR}/git"
+SRCREV = "79c5cfa02c567efdc5bb18cdd584789e2e35aa23"
+SRC_URI = "git://github.com/rhboot/grubby.git;protocol=https; \
+ file://grubby-rename-grub2-editenv-to-grub-editenv.patch \
+ file://run-ptest \
+ file://0001-Add-another-variable-LIBS-to-provides-libraries-from.patch \
+ file://0002-include-paths.h-for-_PATH_MOUNTED.patch \
+ "
+
+RDEPENDS_${PN} += "dracut"
+
+inherit autotools-brokensep ptest
+
+EXTRA_OEMAKE = "-e 'CC=${CC}' 'LDFLAGS=${LDFLAGS}' LIBS='${LIBS}'"
+
+LIBS_libc-musl = "-lexecinfo"
+LIBS ?= ""
+do_install_ptest() {
+ install -d ${D}${PTEST_PATH}
+ cp -r ${S}/test ${S}/test.sh ${D}${PTEST_PATH}
+ sed -i 's|./grubby|grubby|' ${D}${PTEST_PATH}/test.sh
+}
+
+RDEPENDS_${PN}-ptest = "util-linux-getopt bash"
+
+COMPATIBLE_HOST = '(x86_64.*|i.86.*)-(linux|freebsd.*)'
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klcc-cross_2.0.4.bb b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klcc-cross_2.0.4.bb
new file mode 100644
index 000000000..b285b2e8b
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klcc-cross_2.0.4.bb
@@ -0,0 +1,34 @@
+SUMMARY = "The klcc crosscompiler for klibc"
+
+require klibc.inc
+DEPENDS = "klibc"
+
+# no packaging for this crossscript
+PACKAGES = ""
+inherit nopackages
+
+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
+ # Turn the horribly encoded paths into something which sstate can transform using its ususal
+ # magic by removing all the crazy escaping.
+ sed -i -e "2i \$TARGETSYSROOT = '${STAGING_DIR_TARGET}';" \
+ -e "2i \$NATIVESYSROOT = '${STAGING_DIR_NATIVE}';" \
+ -e 's#${@d.getVar("STAGING_DIR_NATIVE", True).replace("/", "\\\\/").replace("-", "\\\\-").replace(".", "\\\\.")}#${NATIVESYSROOT}#g;' \
+ -e 's#${@d.getVar("STAGING_DIR_TARGET", True).replace("/", "\\\\/").replace("-", "\\\\-").replace(".", "\\\\.")}#${TARGETSYSROOT}#g' \
+ ${D}${bindir_crossscripts}/${TARGET_PREFIX}klcc
+}
+
+SYSROOT_DIRS += "${bindir_crossscripts}"
+SSTATE_SCAN_FILES += "*-klcc"
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch
new file mode 100644
index 000000000..e7a0cce83
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch
@@ -0,0 +1,87 @@
+From 57e3a60b23891905733bfea7a1cb78c2377cc524 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 9 Jul 2017 15:17:29 -0700
+Subject: [PATCH] Define in_* structs for non-glibc system libs
+
+These defines and structs are required to be coming from
+userspace netinet/in.h, which is being overridden in klibc
+however, libc-compat.h from kernel is only written keeping
+glibc in mind, and does not provide adequate guards for musl
+to infer that these structs should be defined in linux/in.h
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+---
+ usr/include/net/if.h | 11 +++++++++++
+ usr/include/netinet/in.h | 36 ++++++++++++++++++++++++++++++++++++
+ 2 files changed, 47 insertions(+)
+
+diff --git a/usr/include/net/if.h b/usr/include/net/if.h
+index 116a176..6246b12 100644
+--- a/usr/include/net/if.h
++++ b/usr/include/net/if.h
+@@ -1,6 +1,17 @@
+ #ifndef _NET_IF_H
+ #define _NET_IF_H
+
++#ifndef __GLIBC__
++#include <linux/libc-compat.h>
++#undef __UAPI_DEF_IF_IFREQ
++#define __UAPI_DEF_IF_IFREQ 1
++#undef __UAPI_DEF_IF_IFNAMSIZ
++#define __UAPI_DEF_IF_IFNAMSIZ 1
++#undef __UAPI_DEF_IF_IFMAP
++#define __UAPI_DEF_IF_IFMAP 1
++#undef __UAPI_DEF_IF_NET_DEVICE_FLAGS
++#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1
++#endif
+ #include <sys/socket.h>
+ #include <sys/types.h>
+ #include <linux/if.h>
+diff --git a/usr/include/netinet/in.h b/usr/include/netinet/in.h
+index 2952bb2..0c95bc9 100644
+--- a/usr/include/netinet/in.h
++++ b/usr/include/netinet/in.h
+@@ -5,6 +5,42 @@
+ #ifndef _NETINET_IN_H
+ #define _NETINET_IN_H
+
++#ifndef __GLIBC__
++#include <linux/libc-compat.h>
++
++#undef __UAPI_DEF_IN_ADDR
++#undef __UAPI_DEF_IN_IPPROTO
++#undef __UAPI_DEF_IN_PKTINFO
++#undef __UAPI_DEF_IP_MREQ
++#undef __UAPI_DEF_SOCKADDR_IN
++#undef __UAPI_DEF_IN_CLASS
++#undef __UAPI_DEF_IN6_ADDR
++#undef __UAPI_DEF_IN6_ADDR_ALT
++#undef __UAPI_DEF_SOCKADDR_IN6
++#undef __UAPI_DEF_IPV6_MREQ
++#undef __UAPI_DEF_IPPROTO_V6
++#undef __UAPI_DEF_IPV6_OPTIONS
++#undef __UAPI_DEF_IN6_PKTINFO
++#undef __UAPI_DEF_IP6_MTUINFO
++#undef __UAPI_DEF_IF_IFREQ
++
++#define __UAPI_DEF_IN_ADDR 1
++#define __UAPI_DEF_IN_IPPROTO 1
++#define __UAPI_DEF_IN_PKTINFO 1
++#define __UAPI_DEF_IP_MREQ 1
++#define __UAPI_DEF_SOCKADDR_IN 1
++#define __UAPI_DEF_IN_CLASS 1
++#define __UAPI_DEF_IN6_ADDR 1
++#define __UAPI_DEF_IN6_ADDR_ALT 1
++#define __UAPI_DEF_SOCKADDR_IN6 1
++#define __UAPI_DEF_IPV6_MREQ 1
++#define __UAPI_DEF_IPPROTO_V6 1
++#define __UAPI_DEF_IPV6_OPTIONS 1
++#define __UAPI_DEF_IN6_PKTINFO 1
++#define __UAPI_DEF_IP6_MTUINFO 1
++#define __UAPI_DEF_IF_IFREQ 1
++#endif
++
+ #include <klibc/extern.h>
+ #include <stdint.h>
+ #include <endian.h> /* Must be included *before* <linux/in.h> */
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Kbuild.klibc-Add-path-to-compiler-headers-via-isyste.patch b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Kbuild.klibc-Add-path-to-compiler-headers-via-isyste.patch
new file mode 100644
index 000000000..181dcfb6d
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Kbuild.klibc-Add-path-to-compiler-headers-via-isyste.patch
@@ -0,0 +1,28 @@
+From 4b4147b76518d31a88fb2c58cdbf2236e159a25c Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Fri, 8 Sep 2017 23:10:54 -0700
+Subject: [PATCH] Kbuild.klibc: Add path to compiler headers via -isystem
+
+We need to include this path so it can find compiler headers e.g.
+stdarg.h which is called from wrapper stdarg.h using include_next
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+---
+ scripts/Kbuild.klibc | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc
+index 101f86f..1d5cdc4 100644
+--- a/scripts/Kbuild.klibc
++++ b/scripts/Kbuild.klibc
+@@ -105,7 +105,8 @@ KLIBCOBJCOPY := $(OBJCOPY)
+ KLIBCOBJDUMP := $(OBJDUMP)
+
+ # klibc include paths
+-KLIBCCPPFLAGS := -nostdinc -iwithprefix include \
++KLIBCCPPFLAGS := -nostdinc -iwithprefix include \
++ -isystem $(shell $(CC) -print-file-name=include) \
+ -I$(KLIBCINC)/arch/$(KLIBCARCHDIR) \
+ -I$(KLIBCINC)/bits$(KLIBCBITSIZE) \
+ -I$(KLIBCOBJ)/../include \
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Kbuild.klibc-Use-print-libgcc-file-name-instead-of-p.patch b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Kbuild.klibc-Use-print-libgcc-file-name-instead-of-p.patch
new file mode 100644
index 000000000..1ba05a811
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Kbuild.klibc-Use-print-libgcc-file-name-instead-of-p.patch
@@ -0,0 +1,28 @@
+From b6185401fc3daa7fa8ba2b84db3e4da3b94a9867 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 26 Jul 2017 16:13:16 -0700
+Subject: [PATCH] Kbuild.klibc: Use -print-libgcc-file-name instead of
+ --print-libgcc
+
+-print-libgcc-file-name works with clang and gcc unlike --print-libgcc
+which is gcc specific
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+---
+ scripts/Kbuild.klibc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc
+index f500d53..101f86f 100644
+--- a/scripts/Kbuild.klibc
++++ b/scripts/Kbuild.klibc
+@@ -128,7 +128,7 @@ KLIBCCFLAGS += $(KLIBCCPPFLAGS) $(KLIBCREQFLAGS) $(KLIBCARCHREQFLAGS) \
+ KLIBCAFLAGS += -D__ASSEMBLY__ $(KLIBCCFLAGS)
+ KLIBCSTRIPFLAGS += --strip-all -R .comment -R .note
+
+-KLIBCLIBGCC_DEF := $(shell $(KLIBCCC) $(KLIBCCFLAGS) --print-libgcc)
++KLIBCLIBGCC_DEF := $(shell $(KLIBCCC) $(KLIBCCFLAGS) -print-libgcc-file-name)
+ KLIBCLIBGCC ?= $(KLIBCLIBGCC_DEF)
+ KLIBCCRT0 := $(KLIBCOBJ)/arch/$(KLIBCARCHDIR)/crt0.o
+ KLIBCLIBC := $(KLIBCOBJ)/libc.a
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-always-use-bfd-linker.patch b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-always-use-bfd-linker.patch
new file mode 100644
index 000000000..de04d691f
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-always-use-bfd-linker.patch
@@ -0,0 +1,28 @@
+From 63ab5102d6ef362a597941e62470bf19e6f1652b Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Tue, 11 Jul 2017 08:09:52 -0700
+Subject: [PATCH] always use bfd linker
+
+its possible that distros choose to default to gold linker
+therefore explicitly asking for bfd linker would fix the
+linking issues on such distros
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+---
+ Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index dc10fc5..40647be 100644
+--- a/Makefile
++++ b/Makefile
+@@ -20,7 +20,7 @@ include $(srctree)/scripts/Kbuild.include
+ KLIBCROSS ?= $(CROSS_COMPILE)
+ export KLIBCROSS
+ export CC := $(KLIBCROSS)gcc
+-export LD := $(KLIBCROSS)ld
++export LD := $(KLIBCROSS)ld.bfd
+ export AR := $(KLIBCROSS)ar
+ export RANLIB := $(KLIBCROSS)ranlib
+ export STRIP := $(KLIBCROSS)strip
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-arm-Do-not-set-a-fallback-march-and-mtune.patch b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-arm-Do-not-set-a-fallback-march-and-mtune.patch
new file mode 100644
index 000000000..fcf4f891a
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-arm-Do-not-set-a-fallback-march-and-mtune.patch
@@ -0,0 +1,29 @@
+From ebd2b0e414c98467156b961abb470b5d07f37ea8 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Fri, 29 Sep 2017 23:11:53 -0700
+Subject: [PATCH] arm: Do not set a fallback march and mtune
+
+In OE we pass the options explicitly, there is
+no need to set it inside the makefiles, we will
+need to compute values for CPU_ARCH and CPU_TUNE
+which is a bit harder in OE
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+---
+ usr/klibc/arch/arm/MCONFIG | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/usr/klibc/arch/arm/MCONFIG b/usr/klibc/arch/arm/MCONFIG
+index 303c6ac..48d2685 100644
+--- a/usr/klibc/arch/arm/MCONFIG
++++ b/usr/klibc/arch/arm/MCONFIG
+@@ -10,7 +10,7 @@
+ CPU_ARCH ?= armv4
+ CPU_TUNE ?= strongarm
+
+-KLIBCOPTFLAGS += -Os -march=$(CPU_ARCH) -mtune=$(CPU_TUNE)
++KLIBCOPTFLAGS += -Os
+ KLIBCBITSIZE = 32
+ KLIBCREQFLAGS += -fno-exceptions
+ KLIBCSTRIPFLAGS += -R .ARM.exidx
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch
new file mode 100644
index 000000000..46a23987f
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch
@@ -0,0 +1,29 @@
+From 8beffe501c1ac5b35d62004735c4157c74183901 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 9 Jul 2017 13:51:25 -0700
+Subject: [PATCH] dash: Specify format string in fmtstr()
+
+Fixes build with hardening flags
+
+usr/dash/jobs.c:429:3: error: format not a string literal and no format arguments [-Werror=format-security]
+ col = fmtstr(s, 32, strsignal(st));
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+---
+ usr/dash/jobs.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/usr/dash/jobs.c b/usr/dash/jobs.c
+index 009bbfe..299bcac 100644
+--- a/usr/dash/jobs.c
++++ b/usr/dash/jobs.c
+@@ -426,7 +426,7 @@ sprint_status(char *s, int status, int sigonly)
+ goto out;
+ #endif
+ }
+- col = fmtstr(s, 32, strsignal(st));
++ col = fmtstr(s, 32, "%s", strsignal(st));
+ #ifdef WCOREDUMP
+ if (WCOREDUMP(status)) {
+ col += fmtstr(s + col, 16, " (core dumped)");
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch
new file mode 100644
index 000000000..04c97fc5e
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch
@@ -0,0 +1,30 @@
+From d966d52d1e569cbc2293d841285e2b8941f28c61 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 9 Jul 2017 15:56:28 -0700
+Subject: [PATCH] include linux/sysinfo.h directly
+
+This is done to avoid the kernel header linux/kernel.h to use
+__GLIBC__ define to decide on if libc implements sysinfo() API
+or not. Kernel headers should be independent of such assumptions
+but until its done in right place, change the local header
+override to avoid this assumption
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+---
+ usr/include/sys/sysinfo.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/usr/include/sys/sysinfo.h b/usr/include/sys/sysinfo.h
+index dba68dc..d145c0b 100644
+--- a/usr/include/sys/sysinfo.h
++++ b/usr/include/sys/sysinfo.h
+@@ -5,7 +5,7 @@
+ #ifndef _SYS_SYSINFO_H
+ #define _SYS_SYSINFO_H
+
+-#include <linux/kernel.h>
++#include <linux/sysinfo.h>
+
+ extern int sysinfo(struct sysinfo *info);
+
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch
new file mode 100644
index 000000000..3bc081d4e
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch
@@ -0,0 +1,27 @@
+From cf97079009ba48d10e52052b2eab7461ea4dd09b Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Mon, 10 Jul 2017 20:42:50 -0700
+Subject: [PATCH] mkfifo: Implement mkfifo
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+---
+ usr/utils/mkfifo.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/usr/utils/mkfifo.c b/usr/utils/mkfifo.c
+index 5a758b2..f1f577e 100644
+--- a/usr/utils/mkfifo.c
++++ b/usr/utils/mkfifo.c
+@@ -26,6 +26,11 @@ static int make_fifo(char *dir)
+ return 0;
+ }
+
++int mkfifo (const char *__p, mode_t __m)
++{
++ return mknod(__p, (__m & ~S_IFMT) | S_IFIFO, (dev_t) 0);
++}
++
+ int main(int argc, char *argv[])
+ {
+ int c, ret = 0;
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/armv4-fix-v4bx.patch b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/armv4-fix-v4bx.patch
new file mode 100644
index 000000000..e84235306
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/armv4-fix-v4bx.patch
@@ -0,0 +1,26 @@
+From d2fb484d995221277cce7abddcd7dfa0e8bceec3 Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Fri, 11 Jan 2013 17:26:40 +0000
+Subject: [PATCH] klibc_2.0.2: apply FIX_V4BX patch for armv4 targets only
+
+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>
+
+---
+ usr/klibc/arch/arm/MCONFIG | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/usr/klibc/arch/arm/MCONFIG b/usr/klibc/arch/arm/MCONFIG
+index 53bc1dc..303c6ac 100644
+--- a/usr/klibc/arch/arm/MCONFIG
++++ b/usr/klibc/arch/arm/MCONFIG
+@@ -29,6 +29,7 @@ else
+ 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/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch
new file mode 100644
index 000000000..5f47d3f20
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klcc-consider-sysroot.patch
@@ -0,0 +1,22 @@
+From 0cb26cf2d25d36c1fdcc4f1635e4329436ed866a Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Fri, 19 Sep 2014 23:09:29 +0200
+
+---
+ klcc/klcc.in | 3 +++
+ 1 file changed, 3 insertions(+)
+
+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/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-config-eabi.patch b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-config-eabi.patch
new file mode 100644
index 000000000..f28cd5423
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-config-eabi.patch
@@ -0,0 +1,24 @@
+From 1118cc971917abe19ddb029aa80417f6fd6bb343 Mon Sep 17 00:00:00 2001
+From: Thomas Kunze <thommycheck@gmx.de>
+Date: Sat, 6 Aug 2011 05:30:14 +0000
+Subject: [PATCH] klibc: initial commit of version 1.5.24
+
+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>
+
+---
+ defconfig | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/defconfig b/defconfig
+index 04b98e9..0cb23d0 100644
+--- a/defconfig
++++ b/defconfig
+@@ -6,4 +6,4 @@ CONFIG_KLIBC_ZLIB=y
+ CONFIG_REGPARM=y
+ # ARM options
+ # CONFIG_KLIBC_THUMB is not set
+-# CONFIG_AEABI is not set
++CONFIG_AEABI=y
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-linux-libc-dev.patch b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-linux-libc-dev.patch
new file mode 100644
index 000000000..a5563b740
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/klibc-linux-libc-dev.patch
@@ -0,0 +1,29 @@
+From 1be2bc41f915922102a3ba671b54c2df6f0052e6 Mon Sep 17 00:00:00 2001
+From: Ben Hutchings <ben@decadent.org.uk>
+Date: Sun, 14 Mar 2010 18:41:56 +0000
+Subject: [PATCH] klibc_1.5.26: now build against linux-libc-headers
+
+commit 43adf69062254fb4f8d4d11fb5fe36a60ae25d5a
+
+ Taken from debian "Fix klibc Debian specific build trouble"
+ Adapted for klibc_2.0.2
+
+---
+ scripts/Kbuild.install | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/scripts/Kbuild.install b/scripts/Kbuild.install
+index 8af5697..d32a8a5 100644
+--- a/scripts/Kbuild.install
++++ b/scripts/Kbuild.install
+@@ -95,7 +95,9 @@ header:
+ $(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,go-w $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
+ $(Q)$(install-data) $(srctree)/klcc/klcc.1 $(INSTALLROOT)$(mandir)/man1/$(KCROSS)klcc.1
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/staging.patch b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/staging.patch
new file mode 100644
index 000000000..5c7a6625b
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/staging.patch
@@ -0,0 +1,151 @@
+From 1892079b827cf8f8316305b6d6e0985db82441a2 Mon Sep 17 00:00:00 2001
+From: Thomas Kunze <thommycheck@gmx.de>
+Date: Sat, 6 Aug 2011 05:30:14 +0000
+Subject: [PATCH] klibc: initial commit of version 1.5.24
+
+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>
+
+---
+ scripts/Kbuild.install | 4 ----
+ usr/dash/Kbuild | 2 --
+ usr/gzip/Kbuild | 2 --
+ usr/kinit/Kbuild | 2 --
+ usr/kinit/fstype/Kbuild | 2 --
+ usr/kinit/ipconfig/Kbuild | 2 --
+ usr/kinit/nfsmount/Kbuild | 2 --
+ usr/kinit/resume/Kbuild | 2 --
+ usr/kinit/run-init/Kbuild | 2 --
+ usr/klibc/Kbuild | 2 --
+ usr/utils/Kbuild | 2 --
+ 11 files changed, 24 deletions(-)
+
+diff --git a/scripts/Kbuild.install b/scripts/Kbuild.install
+index d32a8a5..fda699d 100644
+--- a/scripts/Kbuild.install
++++ b/scripts/Kbuild.install
+@@ -88,19 +88,15 @@ else
+ 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
+ $(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
+diff --git a/usr/dash/Kbuild b/usr/dash/Kbuild
+index 3a98c1f..1a6920a 100644
+--- a/usr/dash/Kbuild
++++ b/usr/dash/Kbuild
+@@ -92,5 +92,3 @@ $(obj)/syntax.c: $(obj)/mksyntax
+ $(obj)/syntax.h: $(obj)/syntax.c
+ $(Q):
+
+-# Targets to install
+-install-y := sh.shared
+diff --git a/usr/gzip/Kbuild b/usr/gzip/Kbuild
+index 9bbf0a4..c497d02 100644
+--- a/usr/gzip/Kbuild
++++ b/usr/gzip/Kbuild
+@@ -21,5 +21,3 @@ $(obj)/gunzip $(obj)/zcat: $(obj)/gzip
+ # Cleaning
+ targets := gzip gzip.g gunzip zcat
+
+-# Targets to install
+-install-y := gzip gunzip zcat
+diff --git a/usr/kinit/Kbuild b/usr/kinit/Kbuild
+index 5320127..f7fdccd 100644
+--- a/usr/kinit/Kbuild
++++ b/usr/kinit/Kbuild
+@@ -33,5 +33,3 @@ targets += kinit kinit.g kinit.shared kinit.shared.g
+ subdir- := fstype ipconfig nfsmount resume run-init
+
+
+-# install binary
+-install-y := kinit kinit.shared
+diff --git a/usr/kinit/fstype/Kbuild b/usr/kinit/fstype/Kbuild
+index 9b20db1..367611d 100644
+--- a/usr/kinit/fstype/Kbuild
++++ b/usr/kinit/fstype/Kbuild
+@@ -21,5 +21,3 @@ shared/fstype-y := $(objs)
+ # Cleaning
+ clean-dirs := static shared
+
+-# install binary
+-install-y := $(shared-y)
+diff --git a/usr/kinit/ipconfig/Kbuild b/usr/kinit/ipconfig/Kbuild
+index 7f8d181..eb1d472 100644
+--- a/usr/kinit/ipconfig/Kbuild
++++ b/usr/kinit/ipconfig/Kbuild
+@@ -27,5 +27,3 @@ shared/ipconfig-y := $(objs)
+ # Cleaning
+ clean-dirs := static shared
+
+-# install binary
+-install-y := $(shared-y)
+diff --git a/usr/kinit/nfsmount/Kbuild b/usr/kinit/nfsmount/Kbuild
+index 461e6f3..ba31708 100644
+--- a/usr/kinit/nfsmount/Kbuild
++++ b/usr/kinit/nfsmount/Kbuild
+@@ -23,5 +23,3 @@ dummypmap-y := dummypmap_test.o
+
+ clean-dirs := static shared
+
+-# Install binary
+-install-y := $(shared-y)
+diff --git a/usr/kinit/resume/Kbuild b/usr/kinit/resume/Kbuild
+index 034195d..c1342e1 100644
+--- a/usr/kinit/resume/Kbuild
++++ b/usr/kinit/resume/Kbuild
+@@ -26,5 +26,3 @@ shared/resume-lib := ../lib.a
+ # Cleaning
+ clean-dirs := static shared
+
+-# install binary
+-install-y := $(shared-y)
+diff --git a/usr/kinit/run-init/Kbuild b/usr/kinit/run-init/Kbuild
+index f7832b7..c153b0a 100644
+--- a/usr/kinit/run-init/Kbuild
++++ b/usr/kinit/run-init/Kbuild
+@@ -30,5 +30,3 @@ shared/run-init-lib := ../lib.a
+ # Cleaning
+ clean-dirs := static shared
+
+-# install binary
+-install-y := $(shared-y)
+diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
+index eba6add..98caf2e 100644
+--- a/usr/klibc/Kbuild
++++ b/usr/klibc/Kbuild
+@@ -185,5 +185,3 @@ install-rule:
+ $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)lib))
+ $(Q)$(install-lib) $(obj)/klibc-$(SOLIBHASH).so \
+ $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)lib
+- $(Q)$(install-lib) $(obj)/klibc-$(SOLIBHASH).so \
+- $(INSTALLROOT)$(SHLIBDIR)
+diff --git a/usr/utils/Kbuild b/usr/utils/Kbuild
+index 05aa794..67d9486 100644
+--- a/usr/utils/Kbuild
++++ b/usr/utils/Kbuild
+@@ -72,5 +72,3 @@ $(obj)/shared/reboot $(obj)/shared/poweroff: $(obj)/shared/halt
+ # 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/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/use-env-for-perl.patch b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/use-env-for-perl.patch
new file mode 100644
index 000000000..eac128cc0
--- /dev/null
+++ b/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/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-static-utils_2.0.4.bb b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-static-utils_2.0.4.bb
new file mode 100644
index 000000000..c835fd647
--- /dev/null
+++ b/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/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils.inc b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils.inc
new file mode 100644
index 000000000..7df33d64e
--- /dev/null
+++ b/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 = "${@oe.utils.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/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils_2.0.4.bb b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc-utils_2.0.4.bb
new file mode 100644
index 000000000..06e71cb7b
--- /dev/null
+++ b/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/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc.inc b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc.inc
new file mode 100644
index 000000000..30294b19a
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc.inc
@@ -0,0 +1,74 @@
+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 \
+ ${ARMPATCHES} \
+ file://klibc-linux-libc-dev.patch \
+ file://staging.patch \
+ file://klcc-consider-sysroot.patch \
+ file://0001-dash-Specify-format-string-in-fmtstr.patch \
+ file://0001-Define-in_-structs-for-non-glibc-system-libs.patch \
+ file://0001-include-linux-sysinfo.h-directly.patch \
+ file://0001-mkfifo-Implement-mkfifo.patch \
+ file://0001-always-use-bfd-linker.patch \
+ file://0001-Kbuild.klibc-Use-print-libgcc-file-name-instead-of-p.patch \
+ file://0001-Kbuild.klibc-Add-path-to-compiler-headers-via-isyste.patch \
+ file://0001-arm-Do-not-set-a-fallback-march-and-mtune.patch \
+"
+
+ARMPATCHES ?= ""
+
+ARMPATCHES_arm = "file://klibc-config-eabi.patch \
+ file://armv4-fix-v4bx.patch \
+ "
+
+
+S = "${WORKDIR}/git"
+
+PARALLEL_MAKE = ""
+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}' \
+ 'INSTALLDIR=${libdir}/klibc' \
+ 'SHLIBDIR=${libdir}' \
+ '${KLIBCTHUMB}' \
+ 'KLIBCOPTFLAGS=${TUNE_CCARGS} -Os' \
+ V=1 \
+ "
+
+export FIX_ARMV4_EABI_BX = "${FIX_V4BX}"
+KLIBCTHUMB = "${@['CONFIG_KLIBC_THUMB=n', 'CONFIG_KLIBC_THUMB=y'][(d.getVar('ARM_INSTRUCTION_SET') == 'thumb')]}"
+
+do_configure () {
+ ln -sf "${STAGING_DIR_TARGET}${exec_prefix}" linux
+}
+
+do_compile_prepend_toolchain-clang() {
+ sed -i -e 's#$(KLIBCROSS)gcc#$(KLIBCROSS)clang#g' ${S}/Makefile
+}
+
+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})"
+
+SECURITY_CFLAGS = "-fno-PIE -no-pie"
+SECURITY_LDFLAGS = "-no-pie"
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc_2.0.4.bb b/meta-openembedded/meta-initramfs/recipes-devtools/klibc/klibc_2.0.4.bb
new file mode 100644
index 000000000..bc80f382f
--- /dev/null
+++ b/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/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0001-Makefile-build-ubi-utils-only.patch b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0001-Makefile-build-ubi-utils-only.patch
new file mode 100644
index 000000000..6ac2cca9d
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0001-Makefile-build-ubi-utils-only.patch
@@ -0,0 +1,87 @@
+From 1c989e4c36d0bf76ab444f984bc73b98eeacd03f 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/9] 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 | 26 ++------------------------
+ 1 file changed, 2 insertions(+), 24 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 3ce8587..8b79f71 100644
+--- a/Makefile
++++ b/Makefile
+@@ -16,28 +16,11 @@ 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 mtdpart \
+- 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
+-
+-TARGETS = $(BINS)
+-TARGETS += lib/libmtd.a
+-TARGETS += ubi-utils/libubi.a
++BINS = $(addprefix ubi-utils/,$(UBI_BINS))
+
+ OBJDEPS = $(BUILDDIR)/include/version.h
+
+@@ -61,12 +44,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 +71,6 @@ LDLIBS_mkfs.jffs2 = -lz $(LZOLDLIBS)
+ LDFLAGS_jffs2reader = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
+ LDLIBS_jffs2reader = -lz $(LZOLDLIBS)
+
+-$(foreach v,$(MTD_BINS),$(eval $(call mkdep,,$(v))))
+-
+ #
+ # Common libmtd
+ #
+--
+2.7.4
+
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0002-common.mk-for-klibc-CC-is-klcc.patch b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0002-common.mk-for-klibc-CC-is-klcc.patch
new file mode 100644
index 000000000..c23d11f0b
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0002-common.mk-for-klibc-CC-is-klcc.patch
@@ -0,0 +1,27 @@
+From 89c76bbe82a2029a25b0654eb0a1d0b22d6e6877 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/9] common.mk: for klibc $(CC) is klcc
+
+Do not hardcode: assign the value to the variable if it is not already defined.
+
+Upstream-Status: Submitted
+
+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..126d11a 100644
+--- a/common.mk
++++ b/common.mk
+@@ -1,4 +1,4 @@
+-CC := $(CROSS)gcc
++CC ?= $(CROSS)gcc
+ AR := $(CROSS)ar
+ RANLIB := $(CROSS)ranlib
+
+--
+2.7.4
+
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0003-libubi.c-add-klibc-specific-fixes-for-ioctl.patch b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0003-libubi.c-add-klibc-specific-fixes-for-ioctl.patch
new file mode 100644
index 000000000..9ad4a5b99
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0003-libubi.c-add-klibc-specific-fixes-for-ioctl.patch
@@ -0,0 +1,76 @@
+From fecbb7056d621a30f7106e67f5fe209763571b70 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/9] 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: Accepted
+
+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 97c0434..2b49833 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)
+--
+2.7.4
+
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0004-Restore-compatibility-to-dietlibc-klibc-musl-libc-af.patch b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0004-Restore-compatibility-to-dietlibc-klibc-musl-libc-af.patch
new file mode 100644
index 000000000..2f31fb4a2
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0004-Restore-compatibility-to-dietlibc-klibc-musl-libc-af.patch
@@ -0,0 +1,88 @@
+From b668cb75cb7e72ff92055209130d4cd4b3cacbdb 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/9] Restore compatibility to dietlibc, klibc, musl libc after
+ commit 4f1b108
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+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: Submitted
+
+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 fb0ca83..5a20964 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"
+
+@@ -67,6 +69,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
+@@ -74,6 +91,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 { \
+--
+2.7.4
+
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0005-common.h-more-workarounds-for-klibc-compatibility.patch b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0005-common.h-more-workarounds-for-klibc-compatibility.patch
new file mode 100644
index 000000000..8309a7271
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0005-common.h-more-workarounds-for-klibc-compatibility.patch
@@ -0,0 +1,52 @@
+From 5d4a66b502003ef385dab31a17012246407e7364 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/9] 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: Submitted
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ include/common.h | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/include/common.h b/include/common.h
+index 5a20964..2f51e1c 100644
+--- a/include/common.h
++++ b/include/common.h
+@@ -161,15 +161,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;
+--
+2.7.4
+
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0006-libiniparser-remove-unused-function-needing-float.patch b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0006-libiniparser-remove-unused-function-needing-float.patch
new file mode 100644
index 000000000..d046f9505
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0006-libiniparser-remove-unused-function-needing-float.patch
@@ -0,0 +1,85 @@
+From 2af30e9b2988111e45ed6ea6af55e49ec7cb1cb1 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/9] 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: Accepted
+
+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
+--
+2.7.4
+
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch
new file mode 100644
index 000000000..36b012f90
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch
@@ -0,0 +1,64 @@
+From 41e7c76b0853bf5241b38b8167dfd57c27fef1eb Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Sun, 28 Jan 2018 21:47:59 +0100
+Subject: [PATCH 7/9] mtd-utils: common.c: convert to integer arithmetic
+
+We use floating point just to print out KiB, MiB, GiB.
+Avoid that to be klibc friendly.
+
+Fixes compilation for aarch64 against klibc:
+
+error: '-mgeneral-regs-only' is incompatible with floating-point argument
+| printf("%s%.1f GiB", p, (double)bytes / (1024 * 1024 * 1024));
+etc.
+
+Note:
+* In the KiB case, we could apparently multiply by 100 before dividing
+ without risking overflow. This code simply avoids multiplications.
+
+Upstream-Status: Submitted
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ ubi-utils/ubiutils-common.c | 18 ++++++++++++------
+ 1 file changed, 12 insertions(+), 6 deletions(-)
+
+diff --git a/ubi-utils/ubiutils-common.c b/ubi-utils/ubiutils-common.c
+index 6609a6b..0ded2a4 100644
+--- a/ubi-utils/ubiutils-common.c
++++ b/ubi-utils/ubiutils-common.c
+@@ -107,6 +107,9 @@ long long ubiutils_get_bytes(const char *str)
+ void ubiutils_print_bytes(long long bytes, int bracket)
+ {
+ const char *p;
++ int GiB = 1024 * 1024 * 1024;
++ int MiB = 1024 * 1024;
++ int KiB = 1024;
+
+ if (bracket)
+ p = " (";
+@@ -115,12 +118,15 @@ void ubiutils_print_bytes(long long bytes, int bracket)
+
+ printf("%lld bytes", bytes);
+
+- if (bytes > 1024 * 1024 * 1024)
+- printf("%s%.1f GiB", p, (double)bytes / (1024 * 1024 * 1024));
+- else if (bytes > 1024 * 1024)
+- printf("%s%.1f MiB", p, (double)bytes / (1024 * 1024));
+- else if (bytes > 1024 && bytes != 0)
+- printf("%s%.1f KiB", p, (double)bytes / 1024);
++ if (bytes > GiB)
++ printf("%s%lld.%lld GiB", p,
++ bytes / GiB, bytes % GiB / (GiB / 10));
++ else if (bytes > MiB)
++ printf("%s%lld.%lld MiB", p,
++ bytes / MiB, bytes % MiB / (MiB / 10));
++ else if (bytes > KiB && bytes != 0)
++ printf("%s%lld.%lld KiB", p,
++ bytes / KiB, bytes % KiB / (KiB / 10));
+ else
+ return;
+
+--
+2.7.4
+
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0008-ubi-utils-ubiformat.c-convert-to-integer-arithmetic.patch b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0008-ubi-utils-ubiformat.c-convert-to-integer-arithmetic.patch
new file mode 100644
index 000000000..5bd05742c
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0008-ubi-utils-ubiformat.c-convert-to-integer-arithmetic.patch
@@ -0,0 +1,44 @@
+From e6f1a85c0a3df24fe3ca9a520dc697105e75a80c Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Sat, 27 Jan 2018 09:39:26 +0100
+Subject: [PATCH 8/9] ubi-utils: ubiformat.c: convert to integer arithmetic
+
+Do not cast percent to double, it is just used as upper limit.
+Avoid floating point to fix compilation for aarch64 against klibc:
+
+error: '-mgeneral-regs-only' is incompatible with floating-point code
+| int percent = ((double)si->ok_cnt)/si->good_cnt * 100;
+| ^~~~~~~
+
+Notes:
+* The checks in the code above this line ensure that si->good_cnt is not 0.
+
+* The code assumes si->good_cnt * 100 will not overflow, then we can use
+ (si->ok_cnt * 100) safely because the former is bigger.
+
+* The truncated result does not affect the logic:
+ i.e. a value of 49.9 is truncated to 49 and is still <50.
+
+Upstream-Status: Submitted
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ ubi-utils/ubiformat.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/ubi-utils/ubiformat.c b/ubi-utils/ubiformat.c
+index 21409ca..d93164a 100644
+--- a/ubi-utils/ubiformat.c
++++ b/ubi-utils/ubiformat.c
+@@ -843,7 +843,7 @@ int main(int argc, char * const argv[])
+ }
+
+ if (!args.override_ec && si->empty_cnt < si->good_cnt) {
+- int percent = ((double)si->ok_cnt)/si->good_cnt * 100;
++ int percent = (si->ok_cnt * 100) / si->good_cnt;
+
+ /*
+ * Make sure the majority of eraseblocks have valid
+--
+2.7.4
+
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0009-Eliminate-warnings-about-implicit-non-const-casting-.patch b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0009-Eliminate-warnings-about-implicit-non-const-casting-.patch
new file mode 100644
index 000000000..658246add
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0009-Eliminate-warnings-about-implicit-non-const-casting-.patch
@@ -0,0 +1,48 @@
+From 2229f3b9fd4bad47794c28e558ad273173cea73d Mon Sep 17 00:00:00 2001
+From: Andrea Adami <andrea.adami@gmail.com>
+Date: Sat, 27 Jan 2018 09:52:46 +0100
+Subject: [PATCH 9/9] Eliminate warnings about implicit non-const casting in
+ libmtd
+
+The mtd_get_dev_info1 function reads (among other things) name and type
+string into coresponding struct mtd_dev_info fields.
+
+The struct mtd_dev_info has the string fields marked const, requiring
+them to be cast to non-const version during initialization.
+
+This cast was previously omitted from the dev_read_data calls,
+triggering warnings during compilation.
+
+Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+
+Upstream-Status: Backport
+
+Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
+---
+ lib/libmtd.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/libmtd.c b/lib/libmtd.c
+index 60b4782..5f0bcbc 100644
+--- a/lib/libmtd.c
++++ b/lib/libmtd.c
+@@ -746,13 +746,13 @@ int mtd_get_dev_info1(libmtd_t desc, int mtd_num, struct mtd_dev_info *mtd)
+ if (dev_get_major(lib, mtd_num, &mtd->major, &mtd->minor))
+ return -1;
+
+- ret = dev_read_data(lib->mtd_name, mtd_num, &mtd->name,
++ ret = dev_read_data(lib->mtd_name, mtd_num, (char *)&mtd->name,
+ MTD_NAME_MAX + 1);
+ if (ret < 0)
+ return -1;
+ ((char *)mtd->name)[ret - 1] = '\0';
+
+- ret = dev_read_data(lib->mtd_type, mtd_num, &mtd->type_str,
++ ret = dev_read_data(lib->mtd_type, mtd_num, (char *)&mtd->type_str,
+ MTD_TYPE_MAX + 1);
+ if (ret < 0)
+ return -1;
+--
+2.7.4
+
diff --git a/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_1.5.2.bb b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_1.5.2.bb
new file mode 100644
index 000000000..abb0d4b84
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_1.5.2.bb
@@ -0,0 +1,51 @@
+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
+
+SRCREV = "aea36417067dade75192bafa03af70b6eb2677b1"
+SRC_URI = "git://git.infradead.org/mtd-utils.git \
+ file://0001-Makefile-build-ubi-utils-only.patch \
+ file://0002-common.mk-for-klibc-CC-is-klcc.patch \
+ file://0003-libubi.c-add-klibc-specific-fixes-for-ioctl.patch \
+ file://0004-Restore-compatibility-to-dietlibc-klibc-musl-libc-af.patch \
+ file://0005-common.h-more-workarounds-for-klibc-compatibility.patch \
+ file://0006-libiniparser-remove-unused-function-needing-float.patch \
+ file://0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch \
+ file://0008-ubi-utils-ubiformat.c-convert-to-integer-arithmetic.patch \
+ file://0009-Eliminate-warnings-about-implicit-non-const-casting-.patch \
+ "
+
+S = "${WORKDIR}/git/"
+
+EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}include -DWITHOUT_XATTR' 'BUILDDIR=${S}'"
+
+do_install () {
+ oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} INCLUDEDIR=${includedir}
+}
+
+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"
diff --git a/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/0001-Adjust-the-order-of-headers-to-fix-build-for-musl.patch b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/0001-Adjust-the-order-of-headers-to-fix-build-for-musl.patch
new file mode 100644
index 000000000..a7600b301
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/0001-Adjust-the-order-of-headers-to-fix-build-for-musl.patch
@@ -0,0 +1,30 @@
+From 86b962e7c0de43b20b6210d059e4855ce87078bc Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 13 Jul 2017 16:20:08 -0700
+Subject: [PATCH] Adjust the order of headers to fix build for musl
+
+Fixes
+kexec/ifdown.c:33:16: error: storage size of 'ifc' isn't known
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ kexec/ifdown.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/kexec/ifdown.c b/kexec/ifdown.c
+index 2215798..e13f777 100644
+--- a/kexec/ifdown.c
++++ b/kexec/ifdown.c
+@@ -16,8 +16,8 @@ char *v_ifdown = "@(#)ifdown.c 1.11 02-Jun-1998 miquels@cistron.nl";
+ #include <sys/time.h>
+ #include <errno.h>
+
+-#include <net/if.h>
+ #include <netinet/in.h>
++#include <net/if.h>
+
+ #define MAX_IFS 64
+
+--
+2.13.2
+
diff --git a/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/arm_crashdump.patch b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/arm_crashdump.patch
new file mode 100644
index 000000000..0ff61e543
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/arm_crashdump.patch
@@ -0,0 +1,12 @@
+--- a/kexec/arch/arm/crashdump-arm.c
++++ b/kexec/arch/arm/crashdump-arm.c
+@@ -20,7 +20,7 @@
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+-#include <elf.h>
++#include "../../../include/elf.h"
+ #include <errno.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+
diff --git a/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/cflags_static.patch b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/cflags_static.patch
new file mode 100644
index 000000000..35100a3b4
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/cflags_static.patch
@@ -0,0 +1,11 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -46,7 +46,7 @@
+ # where necessary.
+ CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/include -I$(srcdir)/util_lib/include \
+ -Iinclude/
+-CFLAGS = @CFLAGS@ -fno-strict-aliasing -Wall -Wstrict-prototypes
++CFLAGS = @CFLAGS@ -static -fno-strict-aliasing -Wall -Wstrict-prototypes
+ PURGATORY_EXTRA_CFLAGS = @PURGATORY_EXTRA_CFLAGS@
+ ASFLAGS = @ASFLAGS@
+ LDFLAGS = @LDFLAGS@
diff --git a/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/fix-out-of-tree-build.patch b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/fix-out-of-tree-build.patch
new file mode 100644
index 000000000..ccbb24d0d
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/fix-out-of-tree-build.patch
@@ -0,0 +1,54 @@
+From 37737527725e465833be649101c4a6f8352c5d5e Mon Sep 17 00:00:00 2001
+From: Tyler Hall <tylerwhall@gmail.com>
+Date: Tue, 7 Feb 2012 18:50:05 -0500
+Subject: Fix out-of-tree build
+
+Use automatic variables for prerequisites when copying man pages and
+include a makefile relative to $(srcdir).
+
+Backported to 2.0.2-klibc
+
+Signed-off-by: Tyler Hall <tylerwhall@gmail.com>
+Signed-off-by: Simon Horman <horms@verge.net.au>
+
+diff --git a/kdump/Makefile b/kdump/Makefile
+index 1e2b72c..5dfa928 100644
+--- a/kdump/Makefile
++++ b/kdump/Makefile
+@@ -22,7 +22,7 @@ $(KDUMP): $(KDUMP_OBJS)
+
+ $(KDUMP_MANPAGE): kdump/kdump.8
+ $(MKDIR) -p $(MANDIR)/man8
+- cp kdump/kdump.8 $(KDUMP_MANPAGE)
++ cp $^ $(KDUMP_MANPAGE)
+ echo::
+ @echo "KDUMP_SRCS $(KDUMP_SRCS)"
+ @echo "KDUMP_DEPS $(KDUMP_DEPS)"
+diff --git a/kexec/Makefile b/kexec/Makefile
+index 2137cab..8c815b5 100644
+--- a/kexec/Makefile
++++ b/kexec/Makefile
+@@ -82,7 +82,7 @@ $(KEXEC): CPPFLAGS+=-I$(srcdir)/kexec/arch/$(ARCH)/include
+
+ $(KEXEC_MANPAGE): kexec/kexec.8
+ @$(MKDIR) -p $(MANDIR)/man8
+- cp kexec/kexec.8 $(KEXEC_MANPAGE)
++ cp $^ $(KEXEC_MANPAGE)
+ echo::
+ @echo "KEXEC_SRCS $(KEXEC_SRCS)"
+ @echo "KEXEC_DEPS $(KEXEC_DEPS)"
+diff --git a/kexec/arch/ppc/Makefile b/kexec/arch/ppc/Makefile
+index 3dba7cf..41242a5 100644
+--- a/kexec/arch/ppc/Makefile
++++ b/kexec/arch/ppc/Makefile
+@@ -1,7 +1,7 @@
+ #
+ # kexec ppc (linux booting linux)
+ #
+-include kexec/arch/ppc/libfdt/Makefile.libfdt
++include $(srcdir)/kexec/arch/ppc/libfdt/Makefile.libfdt
+
+ ppc_KEXEC_SRCS = kexec/arch/ppc/kexec-ppc.c
+ ppc_KEXEC_SRCS += kexec/arch/ppc/kexec-elf-ppc.c
+
+
diff --git a/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/ifdown_errno.patch b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/ifdown_errno.patch
new file mode 100644
index 000000000..7f8cddd35
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/ifdown_errno.patch
@@ -0,0 +1,11 @@
+--- a/kexec/ifdown.c
++++ b/kexec/ifdown.c
+@@ -14,7 +14,7 @@
+ #include <sys/ioctl.h>
+ #include <sys/socket.h>
+ #include <sys/time.h>
+-#include <sys/errno.h>
++#include <errno.h>
+
+ #include <net/if.h>
+ #include <netinet/in.h>
diff --git a/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/kexec-elf-rel.patch b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/kexec-elf-rel.patch
new file mode 100644
index 000000000..c666afcac
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/kexec-elf-rel.patch
@@ -0,0 +1,61 @@
+--- a/kexec/kexec-elf-rel.c
++++ b/kexec/kexec-elf-rel.c
+@@ -4,7 +4,7 @@
+ #include <stdio.h>
+ #include <errno.h>
+ #include <stdlib.h>
+-#include "elf.h"
++#include "../include/elf.h"
+ #include <boot/elf_boot.h>
+ #include "kexec.h"
+ #include "kexec-elf.h"
+
+--- a/kexec/arch/arm/kexec-elf-rel-arm.c
++++ b/kexec/arch/arm/kexec-elf-rel-arm.c
+@@ -1,5 +1,5 @@
+ #include <stdio.h>
+-#include <elf.h>
++#include "../../../include/elf.h"
+ #include "../../kexec.h"
+ #include "../../kexec-elf.h"
+
+
+--- a/kexec/arch/i386/kexec-elf-rel-x86.c
++++ b/kexec/arch/i386/kexec-elf-rel-x86.c
+@@ -1,5 +1,5 @@
+ #include <stdio.h>
+-#include <elf.h>
++#include "../../../include/elf.h"
+ #include "../../kexec.h"
+ #include "../../kexec-elf.h"
+
+
+--- a/kexec/arch/ppc/kexec-elf-rel-ppc.c
++++ b/kexec/arch/ppc/kexec-elf-rel-ppc.c
+@@ -1,5 +1,5 @@
+ #include <stdio.h>
+-#include <elf.h>
++#include "../../../include/elf.h"
+ #include "../../kexec.h"
+ #include "../../kexec-elf.h"
+
+
+--- a/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
++++ b/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
+@@ -1,5 +1,5 @@
+ #include <stdio.h>
+-#include <elf.h>
++#include "../../../include/elf.h"
+ #include <string.h>
+ #include "../../kexec.h"
+ #include "../../kexec-elf.h"
+
+--- a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
++++ b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
+@@ -1,5 +1,5 @@
+ #include <stdio.h>
+-#include <elf.h>
++#include "../../../include/elf.h"
+ #include "../../kexec.h"
+ #include "../../kexec-elf.h"
+
diff --git a/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/kexec-syscall.patch b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/kexec-syscall.patch
new file mode 100644
index 000000000..081de1bb5
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/kexec-syscall.patch
@@ -0,0 +1,44 @@
+--- a/kexec/kexec-syscall.h
++++ b/kexec/kexec-syscall.h
+@@ -2,7 +2,7 @@
+ #define KEXEC_SYSCALL_H
+
+ #define __LIBRARY__
+-#include <syscall.h>
++/*#include <syscall.h>*/
+ #include <sys/syscall.h>
+ #include <unistd.h>
+
+@@ -23,6 +23,7 @@
+ #define LINUX_REBOOT_CMD_KEXEC 0x45584543
+
+ #ifndef __NR_kexec_load
++/*
+ #ifdef __i386__
+ #define __NR_kexec_load 283
+ #endif
+@@ -61,19 +62,21 @@
+ #ifndef __NR_kexec_load
+ #error Unknown processor architecture. Needs a kexec_load syscall number.
+ #endif
++*/
+ #endif /*ifndef __NR_kexec_load*/
+
+ struct kexec_segment;
+-
++/*
+ static inline long kexec_load(void *entry, unsigned long nr_segments,
+ struct kexec_segment *segments, unsigned long flags)
+ {
+ return (long) syscall(__NR_kexec_load, entry, nr_segments, segments, flags);
+ }
+-
++*/
+ static inline long kexec_reboot(void)
+ {
+- return (long) syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_KEXEC, 0);
++ //return (long) syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_KEXEC, 0);
++ return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_KEXEC, 0);
+ }
+
+
diff --git a/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/ppc__lshrdi3.patch b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/ppc__lshrdi3.patch
new file mode 100644
index 000000000..56cdfb08d
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/ppc__lshrdi3.patch
@@ -0,0 +1,18 @@
+--- a/purgatory/arch/ppc/crt.S
++++ b/purgatory/arch/ppc/crt.S
+@@ -249,6 +249,7 @@
+ *
+ */
+
++/* already defined in misc.S
+ _GLOBAL(__lshrdi3)
+ subfic 6,5,32
+ srw 4,4,5 # LSW = count > 31 ? 0 : LSW >> count
+@@ -259,5 +260,7 @@
+ srw 3,3,5 # MSW = MSW >> count
+ or 4,4,7 # LSW |= t2
+ blr
++*/
++
+ #endif
+ #endif
diff --git a/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/purgatory_flags.patch b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/purgatory_flags.patch
new file mode 100644
index 000000000..41fc1168f
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/purgatory_flags.patch
@@ -0,0 +1,21 @@
+--- a/purgatory/Makefile
++++ b/purgatory/Makefile
+@@ -47,7 +47,7 @@
+ $(PURGATORY): CC=$(TARGET_CC)
+ $(PURGATORY): CFLAGS+=$(PURGATORY_EXTRA_CFLAGS) \
+ $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
+- -Os -fno-builtin -ffreestanding
++ -Os -fno-builtin -ffreestanding -nostdinc
+
+ $(PURGATORY): CPPFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
+ -I$(srcdir)/purgatory/include \
+@@ -61,7 +61,8 @@
+
+ $(PURGATORY): $(PURGATORY_OBJS)
+ $(MKDIR) -p $(@D)
+- $(CC) $(LDFLAGS) -o $@ $^
++# $(CC) $(LDFLAGS) -o $@ $^
++ $(LD) $(LDFLAGS) -o $@ $^
+
+ # $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) --no-undefined -e purgatory_start -r -o $@ $(PURGATORY_OBJS) $(UTIL_LIB)
+
diff --git a/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/purgatory_string.patch b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/purgatory_string.patch
new file mode 100644
index 000000000..5710561b1
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/purgatory_string.patch
@@ -0,0 +1,9 @@
+--- a/purgatory/string.c
++++ b/purgatory/string.c
+@@ -1,5 +1,5 @@
+ #include <stddef.h>
+-#include <string.h>
++/* #include <string.h> */
+
+ size_t strnlen(const char *s, size_t max)
+ {
diff --git a/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/sha256.patch b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/sha256.patch
new file mode 100644
index 000000000..85bf7aa4f
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/sha256.patch
@@ -0,0 +1,13 @@
+--- a/util_lib/include/sha256.h
++++ b/util_lib/include/sha256.h
+@@ -1,7 +1,8 @@
+ #ifndef SHA256_H
+ #define SHA256_H
+
+-#include <sys/types.h>
++//#include <sys/types.h>
++#include <stddef.h>
+ #include <stdint.h>
+
+ typedef struct
+
diff --git a/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/sysconf_nrprocessors.patch b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/sysconf_nrprocessors.patch
new file mode 100644
index 000000000..04a97e6bc
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/sysconf_nrprocessors.patch
@@ -0,0 +1,13 @@
+--- a/kexec/crashdump-elf.c
++++ b/kexec/crashdump-elf.c
+@@ -47,7 +47,8 @@
+ if (xen_present())
+ nr_cpus = xen_get_nr_phys_cpus();
+ else
+- nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
++ /*nr_cpus = sysconf(_SC_NPROCESSORS_CONF);*/
++ nr_cpus = 1;
+
+ if (nr_cpus < 0) {
+ return -1;
+
diff --git a/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/x86_basename.patch b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/x86_basename.patch
new file mode 100644
index 000000000..77a1c01a1
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/x86_basename.patch
@@ -0,0 +1,14 @@
+--- a/kexec/arch/i386/x86-linux-setup.c
++++ b/kexec/arch/i386/x86-linux-setup.c
+@@ -280,9 +280,9 @@ static int add_edd_entry(struct x86_linu
+ memset(edd_info, 0, sizeof(struct edd_info));
+
+ /* extract the device number */
+- if (sscanf(basename(sysfs_name), "int13_dev%hhx", &devnum) != 1) {
++ if (sscanf(strrchr(sysfs_name,'/') + 1, "int13_dev%hhx", &devnum) != 1) {
+ fprintf(stderr, "Invalid format of int13_dev dir "
+- "entry: %s\n", basename(sysfs_name));
++ "entry: %s\n", strrchr(sysfs_name,'/') + 1);
+ return -1;
+ }
+
diff --git a/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/x86_kexec_test.patch b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/x86_kexec_test.patch
new file mode 100644
index 000000000..9500bd604
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/x86_kexec_test.patch
@@ -0,0 +1,13 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -106,8 +106,8 @@
+
+ MAN_PAGES:= kexec/kexec.8
+ MAN_PAGES+= kdump/kdump.8
+-BINARIES_i386:= $(SBINDIR)/kexec $(PKGLIBDIR)/kexec_test
+-BINARIES_x86_64:=$(SBINDIR)/kexec $(PKGLIBDIR)/kexec_test
++BINARIES_i386:= $(SBINDIR)/kexec
++BINARIES_x86_64:=$(SBINDIR)/kexec
+ BINARIES:=$(SBINDIR)/kexec $(SBINDIR)/kdump $(BINARIES_$(ARCH))
+
+ TARGETS:=$(BINARIES) $(MAN_PAGES)
diff --git a/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/x86_sys_io.patch b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/x86_sys_io.patch
new file mode 100644
index 000000000..a497c9a63
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/x86_sys_io.patch
@@ -0,0 +1,21 @@
+--- a/purgatory/arch/i386/pic.c
++++ b/purgatory/arch/i386/pic.c
+@@ -16,7 +16,7 @@
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+-#include <sys/io.h>
++#include "include/arch/io.h"
+ #include <purgatory.h>
+ #include "purgatory-x86.h"
+
+
+--- a/purgatory/arch/i386/vga.c
++++ b/purgatory/arch/i386/vga.c
+@@ -1,4 +1,4 @@
+-#include <sys/io.h>
++#include "include/arch/io.h"
+ #include <purgatory.h>
+ #include "purgatory-x86.h"
+
+
diff --git a/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/x86_vfscanf.patch b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/x86_vfscanf.patch
new file mode 100644
index 000000000..cad695154
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc-2.0.2/x86_vfscanf.patch
@@ -0,0 +1,27 @@
+--- a/kexec/arch/i386/x86-linux-setup.c
++++ b/kexec/arch/i386/x86-linux-setup.c
+@@ -176,6 +176,8 @@ static int file_scanf(const char *dir, c
+ FILE *fp;
+ int retno;
+ char filename[PATH_MAX];
++ long line_size = MAX_LINE;
++ char *line;
+
+ snprintf(filename, PATH_MAX, "%s/%s", dir, file);
+ filename[PATH_MAX-1] = 0;
+@@ -186,7 +188,14 @@ static int file_scanf(const char *dir, c
+ }
+
+ va_start(argptr, scanf_line);
+- retno = vfscanf(fp, scanf_line, argptr);
++
++ line = xmalloc(sizeof(line) * line_size);
++ while(fgets(line, sizeof(line), fp) != NULL ) {
++ line_size += MAX_LINE;
++ line = xrealloc(line,line_size);
++ }
++ retno = vsscanf(line, scanf_line, argptr);
++
+ va_end(argptr);
+
+ fclose(fp);
diff --git a/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc_2.0.2.bb b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc_2.0.2.bb
new file mode 100644
index 000000000..2e2703382
--- /dev/null
+++ b/meta-openembedded/meta-initramfs/recipes-kernel/kexec/kexec-tools-klibc_2.0.2.bb
@@ -0,0 +1,69 @@
+# the binaries are statically linked against klibc
+SUMMARY = "Kexec tools, statically compiled against klibc"
+AUTHOR = "Eric Biederman"
+HOMEPAGE = "http://kernel.org/pub/linux/utils/kernel/kexec/"
+SECTION = "kernel/userland"
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://COPYING;md5=ea5bed2f60d357618ca161ad539f7c0a \
+ file://kexec/kexec.c;beginline=1;endline=20;md5=af10f6ae4a8715965e648aa687ad3e09"
+DEPENDS = "zlib xz"
+
+PR = "r1"
+
+inherit klibc autotools
+
+FILESPATH =. "${FILE_DIRNAME}/kexec-tools-${PV}:"
+
+SRC_URI = "${KERNELORG_MIRROR}/linux/utils/kernel/kexec/kexec-tools-${PV}.tar.gz"
+
+SRC_URI += " \
+ file://kexec-elf-rel.patch \
+ file://kexec-syscall.patch \
+ file://cflags_static.patch \
+ file://ifdown_errno.patch \
+ file://purgatory_flags.patch \
+ file://purgatory_string.patch \
+ file://sha256.patch \
+ file://sysconf_nrprocessors.patch \
+ file://fix-out-of-tree-build.patch \
+ file://0001-Adjust-the-order-of-headers-to-fix-build-for-musl.patch \
+ "
+
+SRC_URI[md5sum] = "92eff93b097475b7767f8c98df84408a"
+SRC_URI[sha256sum] = "09e180ff36dee087182cdc939ba6c6917b6adbb5fc12d589f31fd3659b6471f2"
+
+SRC_URI_append_arm = " file://arm_crashdump.patch"
+SRC_URI_append_powerpc = " file://ppc__lshrdi3.patch"
+SRC_URI_append_x86 = " file://x86_sys_io.patch file://x86_basename.patch file://x86_vfscanf.patch file://x86_kexec_test.patch"
+SRC_URI_append_x86-64 = " file://x86_sys_io.patch file://x86_basename.patch file://x86_vfscanf.patch file://x86_kexec_test.patch"
+
+S = "${WORKDIR}/kexec-tools-${PV}"
+
+EXTRA_OECONF += "--without-zlib --without-lzma --without-xen"
+
+CFLAGS += "-I${STAGING_DIR_HOST}${libdir}/klibc/include -I${STAGING_DIR_HOST}${libdir}/klibc/include/bits32"
+CFLAGS_x86-64 += "-I${STAGING_DIR_HOST}${libdir}/klibc/include -I${STAGING_DIR_HOST}${libdir}/klibc/include/bits64"
+
+do_compile_prepend() {
+ # Remove the prepackaged config.h from the source tree as it overrides
+ # the same file generated by configure and placed in the build tree
+ rm -f ${S}/include/config.h
+
+ # Remove the '*.d' file to make sure the recompile is OK
+ for dep in `find ${B} -type f -name '*.d'`; do
+ dep_no_d="`echo $dep | sed 's#.d$##'`"
+ # Remove file.d when there is a file.o
+ if [ -f "$dep_no_d.o" ]; then
+ rm -f $dep
+ fi
+ done
+}
+
+PACKAGES =+ "kexec-klibc kdump-klibc"
+
+FILES_kexec-klibc = "${sbindir}/kexec"
+FILES_kdump-klibc = "${sbindir}/kdump"
+
+INSANE_SKIP_${PN} = "arch"
+
+COMPATIBLE_HOST = '(x86_64.*|i.86.*|arm.*|aarch64.*|powerpc.*|mips.*)-(linux|freebsd.*)'
OpenPOWER on IntegriCloud