[Feature]add MT2731_MP2_MR2_SVN388 baseline version
Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-avbtool.bb b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-avbtool.bb
new file mode 100644
index 0000000..b4b5a95
--- /dev/null
+++ b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-avbtool.bb
@@ -0,0 +1,28 @@
+inherit deploy
+
+DESCRIPTION = "Android Verify Boot sign tool from Android external/avb"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+SRC_URI = " \
+ git://android.googlesource.com/platform/external/avb;protocol=https \
+ file://0001-security-boot-add-avbtool-support-hsm.patch \
+ file://tmp.patch \
+"
+SRCREV = "c68f082d910b674f9e5ecf05ebe77432dbbfe0b6"
+
+SRC_URI[sha256sum] = "833893127582352d05d925e36a2ba82d7837105ec8915cd82c7ba9abdddcf680"
+SRC_URI[md5sum] = "1935b6e637d9413cc48115e7602dec4f"
+S = "${WORKDIR}/git"
+
+do_compile () {
+}
+
+do_install () {
+}
+
+do_deploy () {
+ install -d ${DEPLOYDIR}
+ install -m 755 ${S}/avbtool -t ${DEPLOYDIR}
+}
+
+addtask deploy before do_build after do_compile
diff --git a/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-avbtool/0001-security-boot-add-avbtool-support-hsm.patch b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-avbtool/0001-security-boot-add-avbtool-support-hsm.patch
new file mode 100644
index 0000000..a4e96e1
--- /dev/null
+++ b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-avbtool/0001-security-boot-add-avbtool-support-hsm.patch
@@ -0,0 +1,64 @@
+From 92eac8dd843a5f00b837b6eff79c91a500ba85e3 Mon Sep 17 00:00:00 2001
+From: darrenchen <Darren.Chen@mediatek.com>
+Date: Fri, 16 Nov 2018 11:48:02 +0800
+Subject: [PATCH] security boot: add avbtool support hsm
+
+add avbtool support hsm
+modify signing_helper to signing_helper_with_files
+
+Test: OK
+
+Signed-off-by: Darren Chen <Darren.Chen@mediatek.com>
+CR-Id: AUTO00000778
+---
+ avbtool | 27 ++++++++++++++++-----------
+ 1 file changed, 16 insertions(+), 11 deletions(-)
+
+diff --git a/avbtool b/avbtool
+index 10ff39a..81f1f7b 100755
+--- a/avbtool
++++ b/avbtool
+@@ -420,24 +420,29 @@ def raw_sign(signing_helper, algorithm_name, signature_num_bytes, key_path,
+ """
+ p = None
+ if signing_helper is not None:
++ signing_file = tempfile.NamedTemporaryFile()
++ signing_file.write(str(raw_data_to_sign))
++ signing_file.flush()
+ p = subprocess.Popen(
+- [signing_helper, algorithm_name, key_path],
+- stdin=subprocess.PIPE,
+- stdout=subprocess.PIPE,
+- stderr=subprocess.PIPE)
++ [signing_helper, os.getenv("VERIFIED_KEY"), "none", "raw", signing_file.name])
++ retcode = p.wait()
++ if retcode != 0:
++ raise AvbError('Error signing')
++ signing_file.seek(0)
++ signature = bytearray(signing_file.read())
+ else:
+ p = subprocess.Popen(
+ ['openssl', 'rsautl', '-sign', '-inkey', key_path, '-raw'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+- (pout, perr) = p.communicate(str(raw_data_to_sign))
+- retcode = p.wait()
+- if retcode != 0:
+- raise AvbError('Error signing: {}'.format(perr))
+- signature = bytearray(pout)
+- if len(signature) != signature_num_bytes:
+- raise AvbError('Error signing: Invalid length of signature')
++ (pout, perr) = p.communicate(str(raw_data_to_sign))
++ retcode = p.wait()
++ if retcode != 0:
++ raise AvbError('Error signing')
++ signature = bytearray(pout)
++ if len(signature) != signature_num_bytes:
++ raise AvbError('Error signing: Invalid length of signature')
+ return signature
+
+
+--
+2.18.0
+
diff --git a/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-avbtool/tmp.patch b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-avbtool/tmp.patch
new file mode 100644
index 0000000..10a3e67
--- /dev/null
+++ b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-avbtool/tmp.patch
@@ -0,0 +1,18 @@
+diff --git a/avbtool b/avbtool
+index 81f1f7b..bcf447b 100755
+--- a/avbtool
++++ b/avbtool
+@@ -1576,7 +1576,12 @@ class AvbVBMetaHeader(object):
+ Exception: If the given data is malformed.
+ """
+ assert struct.calcsize(self.FORMAT_STRING) == self.SIZE
+-
++ if data:
++ if len(data)!=256:
++ print ('data length',len(data))
++ raise AvbError('data length is not 256.')
++ else:
++ print ('data length',len(data))
+ if data:
+ (self.magic, self.required_libavb_version_major,
+ self.required_libavb_version_minor,
diff --git a/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fastboot/disable-selinux-support.patch b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fastboot/disable-selinux-support.patch
new file mode 100644
index 0000000..738f575
--- /dev/null
+++ b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fastboot/disable-selinux-support.patch
@@ -0,0 +1,137 @@
+diff --git a/extras/ext4_utils/make_ext4fs.c b/extras/ext4_utils/make_ext4fs.c
+index b2d1426..94e92d6 100644
+--- a/extras/ext4_utils/make_ext4fs.c
++++ b/extras/ext4_utils/make_ext4fs.c
+@@ -59,9 +59,11 @@
+
+ #else
+
++#if 0
+ #include <selinux/selinux.h>
+ #include <selinux/label.h>
+ #include <selinux/android.h>
++#endif
+
+ #define O_BINARY 0
+
+@@ -178,6 +180,7 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
+ error("can't set android permissions - built without android support");
+ #endif
+ }
++#if 0
+ #ifndef USE_MINGW
+ if (sehnd) {
+ if (selabel_lookup(sehnd, &dentries[i].secon, dentries[i].path, stat.st_mode) < 0) {
+@@ -188,6 +191,7 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
+ printf("Labeling %s as %s\n", dentries[i].path, dentries[i].secon);
+ }
+ #endif
++#endif
+
+ if (S_ISREG(stat.st_mode)) {
+ dentries[i].file_type = EXT4_FT_REG_FILE;
+@@ -229,10 +233,12 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
+ dentries[0].file_type = EXT4_FT_DIR;
+ dentries[0].uid = 0;
+ dentries[0].gid = 0;
++#if 0
+ if (sehnd) {
+ if (selabel_lookup(sehnd, &dentries[0].secon, dentries[0].path, dentries[0].mode) < 0)
+ error("cannot lookup security context for %s", dentries[0].path);
+ }
++#endif
+ entries++;
+ dirs++;
+ }
+@@ -270,9 +276,11 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
+ dentries[i].mtime);
+ if (ret)
+ error("failed to set permissions on %s\n", dentries[i].path);
++#if 0
+ ret = inode_set_selinux(entry_inode, dentries[i].secon);
+ if (ret)
+ error("failed to set SELinux context on %s\n", dentries[i].path);
++#endif
+
+ free(dentries[i].path);
+ free(dentries[i].full_path);
+@@ -562,6 +570,7 @@ int make_ext4fs_internal(int fd, const char *_directory,
+ root_mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
+ inode_set_permissions(root_inode_num, root_mode, 0, 0, 0);
+
++#if 0
+ #ifndef USE_MINGW
+ if (sehnd) {
+ char *secontext = NULL;
+@@ -578,6 +587,7 @@ int make_ext4fs_internal(int fd, const char *_directory,
+ freecon(secontext);
+ }
+ #endif
++#endif
+
+ ext4_update_free();
+
+diff --git a/extras/ext4_utils/make_ext4fs_main.c b/extras/ext4_utils/make_ext4fs_main.c
+index b6c740d..ce31764 100644
+--- a/extras/ext4_utils/make_ext4fs_main.c
++++ b/extras/ext4_utils/make_ext4fs_main.c
+@@ -29,6 +29,7 @@
+ #include <private/android_filesystem_config.h>
+ #endif
+
++#if 0
+ #ifndef USE_MINGW
+ #include <selinux/selinux.h>
+ #include <selinux/label.h>
+@@ -36,6 +37,7 @@
+ #else
+ struct selabel_handle;
+ #endif
++#endif
+
+ #include "make_ext4fs.h"
+ #include "ext4_utils.h"
+@@ -72,9 +74,11 @@ int main(int argc, char **argv)
+ int exitcode;
+ int verbose = 0;
+ struct selabel_handle *sehnd = NULL;
++#if 0
+ #ifndef USE_MINGW
+ struct selinux_opt seopts[] = { { SELABEL_OPT_PATH, "" } };
+ #endif
++#endif
+
+ while ((opt = getopt(argc, argv, "l:j:b:g:i:I:L:a:S:fwzJsctv")) != -1) {
+ switch (opt) {
+@@ -131,6 +135,7 @@ int main(int argc, char **argv)
+ fprintf(stderr, "Warning: -t (initialize inode tables) is deprecated\n");
+ break;
+ case 'S':
++#if 0
+ #ifndef USE_MINGW
+ seopts[0].value = optarg;
+ sehnd = selabel_open(SELABEL_CTX_FILE, seopts, 1);
+@@ -139,6 +144,7 @@ int main(int argc, char **argv)
+ exit(EXIT_FAILURE);
+ }
+ #endif
++#endif
+ break;
+ case 'v':
+ verbose = 1;
+@@ -149,6 +155,7 @@ int main(int argc, char **argv)
+ }
+ }
+
++#if 0
+ #if !defined(HOST)
+ // Use only if -S option not requested
+ if (!sehnd && mountpoint) {
+@@ -160,6 +167,7 @@ int main(int argc, char **argv)
+ }
+ }
+ #endif
++#endif
+
+ if (wipe && sparse) {
+ fprintf(stderr, "Cannot specifiy both wipe and sparse\n");
diff --git a/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fastboot/reboot-syscall.patch b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fastboot/reboot-syscall.patch
new file mode 100644
index 0000000..0055416
--- /dev/null
+++ b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fastboot/reboot-syscall.patch
@@ -0,0 +1,25 @@
+Subject: port android_reboot() to call the reboot syscall via syscall() (glibc) rather than __reboot (bionic)
+Author: Loïc Minier <loic.minier@ubuntu.com>
+
+--- a/core/libcutils/android_reboot.c
++++ b/core/libcutils/android_reboot.c
+@@ -21,6 +21,8 @@
+ #include <fcntl.h>
+ #include <stdio.h>
+ #include <string.h>
++#include <linux/reboot.h>
++#include <sys/syscall.h>
+
+ #include <cutils/android_reboot.h>
+
+@@ -121,8 +123,8 @@
+ break;
+
+ case ANDROID_RB_RESTART2:
+- ret = __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
+- LINUX_REBOOT_CMD_RESTART2, arg);
++ ret = syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
++ LINUX_REBOOT_CMD_RESTART2, arg);
+ break;
+
+ default:
diff --git a/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fastboot/remove-libselinux.patch b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fastboot/remove-libselinux.patch
new file mode 100644
index 0000000..0544675
--- /dev/null
+++ b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fastboot/remove-libselinux.patch
@@ -0,0 +1,13 @@
+diff --git a/debian/makefiles/fastboot.mk b/debian/makefiles/fastboot.mk
+index 9e8b751..9f047ed 100644
+--- a/debian/makefiles/fastboot.mk
++++ b/debian/makefiles/fastboot.mk
+@@ -37,7 +37,7 @@ CPPFLAGS+= -I../mkbootimg
+ CPPFLAGS+= -I../../extras/ext4_utils/
+ CPPFLAGS+= -I../libsparse/include/
+
+-LIBS+= -lz -lselinux
++LIBS+= -lz
+
+ OBJS= $(SRCS:.c=.o)
+
diff --git a/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fastboot_4.2.2.bb b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fastboot_4.2.2.bb
new file mode 100644
index 0000000..3a429d5
--- /dev/null
+++ b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fastboot_4.2.2.bb
@@ -0,0 +1,60 @@
+DESCRIPTION = "Different utilities from Android - based on the corresponding ubuntu \
+package"
+SECTION = "console/utils"
+LICENSE = "Apache-2.0 & GPL-2.0 & BSD-2-Clause & BSD-3-Clause"
+LIC_FILES_CHKSUM = " \
+ file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10 \
+ file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6 \
+ file://${COMMON_LICENSE_DIR}/BSD-2-Clause;md5=8bef8e6712b1be5aa76af1ebde9d6378 \
+ file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9 \
+ file://${WORKDIR}/debian/copyright;md5=141efd1050596168ca05ced04e4f498b \
+"
+
+DEPENDS = "zlib openssl"
+
+# Use same version than ubuntu does here
+BASE_PV = "4.2.2+git20130218"
+PV = "${BASE_PV}-3ubuntu13"
+
+ALLOW_EMPTY_${PN} = "1"
+
+SRC_URI = " \
+ https://launchpad.net/ubuntu/+archive/primary/+files/android-tools_${BASE_PV}.orig.tar.xz;name=source \
+ https://launchpad.net/ubuntu/+archive/primary/+files/android-tools_${PV}.debian.tar.gz;name=debian \
+ file://reboot-syscall.patch \
+ file://disable-selinux-support.patch \
+ file://remove-libselinux.patch;patchdir=.. \
+"
+S = "${WORKDIR}/android-tools"
+
+SRC_URI[source.md5sum] = "0e653b129ab0c95bdffa91410c8b55be"
+SRC_URI[source.sha256sum] = "9bfba987e1351b12aa983787b9ae4424ab752e9e646d8e93771538dc1e5d932f"
+SRC_URI[debian.md5sum] = "5e409d01caf3c33fc60a2100464754ff"
+SRC_URI[debian.sha256sum] = "320757edc8af015f40335c41dc96bf37e2d50c9f3a40a31e64264ff6e2dba5e3"
+
+do_compile() {
+ # Setting both variables below causing our makefiles to not work with implicit make
+ # rules
+ unset CFLAGS
+ unset CPPFLAGS
+
+ sed -i "s%^CPPFLAGS+= -I/usr/include%# we don't want to include headers from host CPPFLAGS+= -I/usr/include%g" ${WORKDIR}/debian/makefiles/ext4_utils.mk
+
+ oe_runmake -f ${WORKDIR}/debian/makefiles/fastboot.mk -C ${S}/core/fastboot clean
+ oe_runmake -f ${WORKDIR}/debian/makefiles/fastboot.mk -C ${S}/core/fastboot
+}
+
+do_install() {
+ install -d ${D}${bindir}
+ install -m 0755 ${S}/core/fastboot/fastboot ${D}${bindir}
+}
+
+inherit deploy
+
+do_deploy () {
+ install -d ${DEPLOYDIR}
+ install -m 0755 ${S}/core/fastboot/fastboot ${DEPLOYDIR}/fastboot-linux-arm
+}
+
+addtask deploy before do_build after do_compile
+
diff --git a/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fsutils/build.patch b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fsutils/build.patch
new file mode 100644
index 0000000..50c2c7d
--- /dev/null
+++ b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fsutils/build.patch
@@ -0,0 +1,49 @@
+diff --git a/Makefile.am b/Makefile.am
+new file mode 100644
+index 0000000..361667f
+--- /dev/null
++++ b/Makefile.am
+@@ -0,0 +1 @@
++SUBDIRS = libsparse/
+diff --git a/configure.ac b/configure.ac
+new file mode 100644
+index 0000000..cc354e3
+--- /dev/null
++++ b/configure.ac
+@@ -0,0 +1,12 @@
++AC_INIT([img2simg], [1.0])
++AM_INIT_AUTOMAKE([foreign])
++AC_PROG_CC
++AC_PROG_RANLIB
++AC_DISABLE_SHARED
++AC_ENABLE_STATIC
++LT_INIT
++AC_CONFIG_FILES([
++ Makefile
++ libsparse/Makefile
++])
++AC_OUTPUT
+diff --git a/libsparse/Makefile.am b/libsparse/Makefile.am
+new file mode 100644
+index 0000000..02bea1a
+--- /dev/null
++++ b/libsparse/Makefile.am
+@@ -0,0 +1,18 @@
++lib_LIBRARIES = libsparse.a
++libsparse_a_CPPFLAGS = -I$(top_srcdir)/libsparse/include
++libsparse_a_CFLAGS = -Werror
++libsparse_a_SOURCES = \
++ backed_block.c \
++ output_file.c \
++ sparse.c \
++ sparse_crc32.c \
++ sparse_err.c \
++ sparse_read.c
++
++bin_PROGRAMS = img2simg simg2img
++img2simg_SOURCES = img2simg.c
++img2simg_CPPFLAGS = -I$(top_srcdir)/libsparse/include
++img2simg_LDADD = libsparse.a -lz
++simg2img_SOURCES = simg2img.c
++simg2img_CPPFLAGS = -I$(top_srcdir)/libsparse/include
++simg2img_LDADD = libsparse.a -lz
diff --git a/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fsutils_git.bb b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fsutils_git.bb
new file mode 100644
index 0000000..15252bd
--- /dev/null
+++ b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/android-tools-fsutils_git.bb
@@ -0,0 +1,14 @@
+DESCRIPTION = "android-tools-fsutils libraries"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://NOTICE;md5=c1a3ff0b97f199c7ebcfdd4d3fed238e"
+SRC_URI = " \
+ git://android.googlesource.com/platform/system/core;protocol=https \
+ file://build.patch \
+"
+SRCREV = "c6160d2a0ef648ccb3d217c589c60b5c00b80387"
+S = "${WORKDIR}/git"
+FILES_${PN} = "${bindir}/* ${libdir}/*"
+DEPENDS += "zlib"
+BBCLASSEXTEND = "native nativesdk"
+
+inherit autotools
diff --git a/meta/meta-mediatek-gpl/recipes-devtools/android-tools/platform-tools_r26.0.2.bb b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/platform-tools_r26.0.2.bb
new file mode 100644
index 0000000..5753c5f
--- /dev/null
+++ b/meta/meta-mediatek-gpl/recipes-devtools/android-tools/platform-tools_r26.0.2.bb
@@ -0,0 +1,42 @@
+DESCRIPTION = "Android Platform Tools"
+LICENSE = "Apache-2.0 & GPL-2.0 & BSD-2-Clause & BSD-3-Clause"
+
+LIC_FILES_CHKSUM = "file://${S}/platform-tools-linux/platform-tools/NOTICE.txt;md5=d4b39e3d79095f051d1f61901cec410e"
+
+BBCLASSEXTEND = "native"
+
+SRC_URI = " \
+ https://dl.google.com/android/repository/platform-tools_${PV}-windows.zip;name=platform-tools-windows \
+ https://dl.google.com/android/repository/platform-tools_${PV}-darwin.zip;name=platform-tools-darwin \
+ https://dl.google.com/android/repository/platform-tools_${PV}-linux.zip;name=platform-tools-linux \
+"
+
+SRC_URI[platform-tools-windows.md5sum] = "4a2d2e09d3ffdce8252c9136754a1ce9"
+SRC_URI[platform-tools-windows.sha256sum] = "4850c695724ad0328d9100cc3b4475dcd1af1bec904675362259595a3e03ae2e"
+SRC_URI[platform-tools-darwin.md5sum] = "00fa1426da56ed9477f65219213ae1a5"
+SRC_URI[platform-tools-darwin.sha256sum] = "a6d0504e560713af2a3ae71449bcadf011b50ba78f7bf303a9d6d69bf855c73f"
+SRC_URI[platform-tools-linux.md5sum] = "ef952bb31497f7535e061ad0e712bed8"
+SRC_URI[platform-tools-linux.sha256sum] = "63b15a38c2b64e6ec8b54febe9f69fce5fe6c898c554c73b826b49daf7b52519"
+
+SSTATE_DUPWHITELIST += "${DEPLOY_DIR_IMAGE}"
+
+do_unpack () {
+ unzip -q ${DL_DIR}/platform-tools_${PV}-linux.zip -d ${S}/platform-tools-linux
+ unzip -q ${DL_DIR}/platform-tools_${PV}-darwin.zip -d ${S}/platform-tools-darwin
+ unzip -q ${DL_DIR}/platform-tools_${PV}-windows.zip -d ${S}/platform-tools-windows
+}
+
+inherit deploy
+
+do_deploy () {
+ install -d ${DEPLOYDIR}
+ install -m 0755 ${S}/platform-tools-linux/platform-tools/fastboot ${DEPLOYDIR}/fastboot-linux-x86_64
+ install -m 0755 ${S}/platform-tools-darwin/platform-tools/fastboot ${DEPLOYDIR}/fastboot-darwin
+ install -m 0755 ${S}/platform-tools-windows/platform-tools/fastboot.exe ${DEPLOYDIR}/fastboot.exe
+ install -m 0755 ${S}/platform-tools-linux/platform-tools/adb ${DEPLOYDIR}/adb-linux-x86_64
+ install -m 0755 ${S}/platform-tools-darwin/platform-tools/adb ${DEPLOYDIR}/adb-darwin
+ install -m 0755 ${S}/platform-tools-windows/platform-tools/adb.exe ${DEPLOYDIR}/adb.exe
+}
+
+addtask deploy before do_build after do_compile
+