diff --git a/packages/linux/package.mk b/packages/linux/package.mk
index 5e761064bb..fcd6381759 100644
--- a/packages/linux/package.mk
+++ b/packages/linux/package.mk
@@ -56,6 +56,10 @@ else
KERNEL_IMAGE="bzImage"
fi
+if [ "$BUILD_ANDROID_BOOTIMG" = "yes" ]; then
+ PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET mkbootimg:host"
+fi
+
post_patch() {
if [ -f $PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_NAME.$TARGET_ARCH.conf ]; then
KERNEL_CFG_FILE=$PROJECT_DIR/$PROJECT/$PKG_NAME/$PKG_NAME.$TARGET_ARCH.conf
@@ -70,7 +74,9 @@ post_patch() {
$PKG_BUILD/Makefile
cp $KERNEL_CFG_FILE $PKG_BUILD/.config
- sed -i -e "s|^CONFIG_INITRAMFS_SOURCE=.*$|CONFIG_INITRAMFS_SOURCE=\"$ROOT/$BUILD/image/initramfs.cpio\"|" $PKG_BUILD/.config
+ if [ ! "$BUILD_ANDROID_BOOTIMG" = "yes" ]; then
+ sed -i -e "s|^CONFIG_INITRAMFS_SOURCE=.*$|CONFIG_INITRAMFS_SOURCE=\"$ROOT/$BUILD/image/initramfs.cpio\"|" $PKG_BUILD/.config
+ fi
# set default hostname based on $DISTRONAME
sed -i -e "s|@DISTRONAME@|$DISTRONAME|g" $PKG_BUILD/.config
@@ -140,6 +146,12 @@ make_target() {
fi
LDFLAGS="" make $KERNEL_IMAGE $KERNEL_MAKE_EXTRACMD
+
+ if [ "$BUILD_ANDROID_BOOTIMG" = "yes" ]; then
+ LDFLAGS="" mkbootimg --kernel arch/arm/boot/$KERNEL_IMAGE --ramdisk $ROOT/$BUILD/image/initramfs.cpio \
+ --second "$ANDROID_BOOTIMG_SECOND" --output arch/arm/boot/boot.img
+ mv -f arch/arm/boot/boot.img arch/arm/boot/$KERNEL_IMAGE
+ fi
}
makeinstall_target() {
diff --git a/packages/tools/mkbootimg/package.mk b/packages/tools/mkbootimg/package.mk
new file mode 100644
index 0000000000..4291944f63
--- /dev/null
+++ b/packages/tools/mkbootimg/package.mk
@@ -0,0 +1,38 @@
+################################################################################
+# This file is part of OpenELEC - http://www.openelec.tv
+# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
+#
+# OpenELEC is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# OpenELEC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with OpenELEC. If not, see .
+################################################################################
+
+PKG_NAME="mkbootimg"
+PKG_VERSION="6668fc2"
+PKG_REV="1"
+PKG_ARCH="any"
+PKG_LICENSE="GPL"
+PKG_SITE="https://android.googlesource.com/platform/system/core/+/master/mkbootimg/"
+PKG_URL="$DISTRO_SRC/$PKG_NAME-$PKG_VERSION.tar.xz"
+PKG_DEPENDS_HOST=""
+PKG_PRIORITY="optional"
+PKG_SECTION="tools"
+PKG_SHORTDESC="mkbootimg: Creates kernel boot images for Android"
+PKG_LONGDESC="mkbootimg: Creates kernel boot images for Android"
+
+PKG_IS_ADDON="no"
+PKG_AUTORECONF="no"
+
+makeinstall_host() {
+ mkdir -p $SYSROOT_PREFIX/usr/include
+ cp mkbootimg $ROOT/$TOOLCHAIN/bin/
+}
diff --git a/tools/mkpkg/mkpkg_mkbootimg b/tools/mkpkg/mkpkg_mkbootimg
new file mode 100755
index 0000000000..d47206233b
--- /dev/null
+++ b/tools/mkpkg/mkpkg_mkbootimg
@@ -0,0 +1,41 @@
+#!/bin/sh
+################################################################################
+# This file is part of OpenELEC - http://www.openelec.tv
+# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
+#
+# OpenELEC is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# OpenELEC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with OpenELEC. If not, see .
+################################################################################
+
+echo "getting sources..."
+ if [ ! -d mkbootimg.git ]; then
+ git clone https://github.com/codesnake/mkbootimg.git mkbootimg.git
+ fi
+
+ cd mkbootimg.git
+ git pull
+ GIT_REV=`git log -n1 --format=%h`
+ cd ..
+
+echo "copying sources..."
+ rm -rf mkbootimg-$GIT_REV
+ cp -R mkbootimg.git mkbootimg-$GIT_REV
+
+echo "cleaning sources..."
+ rm -rf mkbootimg-$GIT_REV/.git
+
+echo "packing sources..."
+ tar cvJf mkbootimg-$GIT_REV.tar.xz mkbootimg-$GIT_REV
+
+echo "remove temporary sourcedir..."
+ rm -rf mkbootimg-$GIT_REV