[Feature]add MT2731_MP2_MR2_SVN388 baseline version

Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/meta/meta-mediatek/recipes-core/coreutils/coreutils/fix-absolute-include.patch b/meta/meta-mediatek/recipes-core/coreutils/coreutils/fix-absolute-include.patch
new file mode 100755
index 0000000..32c130b
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/coreutils/coreutils/fix-absolute-include.patch
@@ -0,0 +1,216 @@
+diff --git a/lib/dirent_.h b/lib/dirent_.h
+index 3fa8480..0bd2fed 100644
+--- a/lib/dirent_.h
++++ b/lib/dirent_.h
+@@ -18,7 +18,7 @@
+ #ifndef _GL_DIRENT_H
+ #define _GL_DIRENT_H
+ 
+-#include @ABSOLUTE_DIRENT_H@
++#include_next <dirent.h>
+ 
+ 
+ /* Declare overridden functions.  */
+diff --git a/lib/fcntl_.h b/lib/fcntl_.h
+index e16ad54..b99d945 100644
+--- a/lib/fcntl_.h
++++ b/lib/fcntl_.h
+@@ -24,7 +24,7 @@
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <unistd.h>
+-#include @ABSOLUTE_FCNTL_H@
++#include_next <fcntl.h>
+ 
+ 
+ /* Declare overridden functions.  */
+diff --git a/lib/inttypes_.h b/lib/inttypes_.h
+index 3d3ead6..ed47fd8 100644
+--- a/lib/inttypes_.h
++++ b/lib/inttypes_.h
+@@ -21,7 +21,7 @@
+    which in turn includes this file.  */
+ #if ! defined INTTYPES_H || defined _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H
+ # if @HAVE_INTTYPES_H@
+-#  include @ABSOLUTE_INTTYPES_H@
++#  include_next <inttypes.h>
+ # endif
+ #endif
+ 
+diff --git a/lib/netinet_in_.h b/lib/netinet_in_.h
+index 4a53605..ce9a979 100644
+--- a/lib/netinet_in_.h
++++ b/lib/netinet_in_.h
+@@ -24,7 +24,7 @@
+    <sys/types.h>.  */
+ 
+ # include <sys/types.h>
+-# include @ABSOLUTE_NETINET_IN_H@
++# include_next <netinet/in.h>
+ 
+ #else
+ 
+diff --git a/lib/socket_.h b/lib/socket_.h
+index 623c98c..a45436d 100644
+--- a/lib/socket_.h
++++ b/lib/socket_.h
+@@ -30,7 +30,7 @@
+    <sys/types.h>.  */
+ 
+ # include <sys/types.h>
+-# include @ABSOLUTE_SYS_SOCKET_H@
++# include_next <sys/socket.h>
+ 
+ #else
+ 
+diff --git a/lib/stat_.h b/lib/stat_.h
+index cbf5ac0..243b4c0 100644
+--- a/lib/stat_.h
++++ b/lib/stat_.h
+@@ -23,7 +23,7 @@
+ /* This file is supposed to be used on platforms where <sys/stat.h> is
+    incomplete.  It is intended to provide definitions and prototypes
+    needed by an application.  Start with what the system provides.  */
+-#include @ABSOLUTE_SYS_STAT_H@
++#include_next <sys/stat.h>
+ 
+ #ifndef S_IFMT
+ # define S_IFMT 0170000
+diff --git a/lib/stdint_.h b/lib/stdint_.h
+index 4fa5251..788a980 100644
+--- a/lib/stdint_.h
++++ b/lib/stdint_.h
+@@ -43,7 +43,7 @@
+      Include it before <inttypes.h>, since any "#include <stdint.h>"
+      in <inttypes.h> would reinclude us, skipping our contents because
+      _GL_STDINT_H is defined.  */
+-# include @ABSOLUTE_STDINT_H@
++# include_next <stdint.h>
+ #endif
+ 
+ /* <sys/types.h> defines some of the stdint.h types as well, on glibc,
+diff --git a/lib/stdio_.h b/lib/stdio_.h
+index 441c0d5..cd1d18c 100644
+--- a/lib/stdio_.h
++++ b/lib/stdio_.h
+@@ -19,14 +19,14 @@
+ #if defined __need_FILE || defined __need___FILE
+ /* Special invocation convention inside glibc header files.  */
+ 
+-#include @ABSOLUTE_STDIO_H@
++#include_next <stdio.h>
+ 
+ #else
+ /* Normal invocation convention.  */
+ #ifndef _GL_STDIO_H
+ #define _GL_STDIO_H
+ 
+-#include @ABSOLUTE_STDIO_H@
++#include_next <stdio.h>
+ 
+ #include <stdarg.h>
+ #include <stddef.h>
+diff --git a/lib/stdlib_.h b/lib/stdlib_.h
+index a920408..dc33b29 100644
+--- a/lib/stdlib_.h
++++ b/lib/stdlib_.h
+@@ -26,7 +26,7 @@
+ # pragma GCC system_header
+ #endif
+ 
+-#include @ABSOLUTE_STDLIB_H@
++#include_next <stdlib.h>
+ 
+ #else
+ /* Normal invocation convention.  */
+@@ -40,7 +40,7 @@
+ # pragma GCC system_header
+ #endif
+ 
+-#include @ABSOLUTE_STDLIB_H@
++#include_next <stdlib.h>
+ 
+ 
+ /* The definition of GL_LINK_WARNING is copied here.  */
+diff --git a/lib/string_.h b/lib/string_.h
+index b50523c..4316660 100644
+--- a/lib/string_.h
++++ b/lib/string_.h
+@@ -25,7 +25,7 @@
+ # pragma GCC system_header
+ #endif
+ 
+-#include @ABSOLUTE_STRING_H@
++#include_next <string.h>
+ 
+ 
+ /* The definition of GL_LINK_WARNING is copied here.  */
+diff --git a/lib/sys_time_.h b/lib/sys_time_.h
+index 46cdb70..f98de57 100644
+--- a/lib/sys_time_.h
++++ b/lib/sys_time_.h
+@@ -22,7 +22,7 @@
+ #define _gl_SYS_TIME_H
+ 
+ #if @HAVE_SYS_TIME_H@
+-# include @ABSOLUTE_SYS_TIME_H@
++# include_next <sys/time.h>
+ #else
+ # include <time.h>
+ #endif
+diff --git a/lib/time_.h b/lib/time_.h
+index 5467d3d..fe97130 100644
+--- a/lib/time_.h
++++ b/lib/time_.h
+@@ -20,11 +20,11 @@
+    declare a few standard symbols, rather than to declare all the
+    symbols.  */
+ #if defined __need_time_t || defined __need_clock_t || defined __need_timespec
+-# include @ABSOLUTE_TIME_H@
++# include_next <time.h>
+ 
+ #elif ! defined _GL_TIME_H
+ # define _GL_TIME_H
+-# include @ABSOLUTE_TIME_H@
++# include_next <time.h>
+ 
+ # ifdef __cplusplus
+ extern "C" {
+diff --git a/lib/unistd_.h b/lib/unistd_.h
+index 77df861..9241475 100644
+--- a/lib/unistd_.h
++++ b/lib/unistd_.h
+@@ -19,7 +19,7 @@
+ #define _GL_UNISTD_H
+ 
+ #if @HAVE_UNISTD_H@
+-# include @ABSOLUTE_UNISTD_H@
++# include_next <unistd.h>
+ #endif
+ 
+ 
+diff --git a/lib/wchar_.h b/lib/wchar_.h
+index 6813a21..bd86ce4 100644
+--- a/lib/wchar_.h
++++ b/lib/wchar_.h
+@@ -37,6 +37,6 @@
+ #include <time.h>
+ 
+ /* Include the original <wchar.h>.  */
+-#include @ABSOLUTE_WCHAR_H@
++#include_next <wchar.h>
+ 
+ #endif /* _GL_WCHAR_H */
+diff --git a/lib/wctype_.h b/lib/wctype_.h
+index 1297c61..fca78cd 100644
+--- a/lib/wctype_.h
++++ b/lib/wctype_.h
+@@ -47,7 +47,7 @@ typedef int __wctype_wint_t;
+ /* Include the original <wctype.h> if it exists.
+    BeOS 5 has the functions but no <wctype.h>.  */
+ #if @HAVE_WCTYPE_H@
+-# include @ABSOLUTE_WCTYPE_H@
++# include_next <wctype.h>
+ #endif
+ 
+ /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
diff --git a/meta/meta-mediatek/recipes-core/coreutils/coreutils_6.9.bbappend b/meta/meta-mediatek/recipes-core/coreutils/coreutils_6.9.bbappend
new file mode 100644
index 0000000..302450f
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/coreutils/coreutils_6.9.bbappend
@@ -0,0 +1,3 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI_append_toolchain-clang = " file://fix-absolute-include.patch"
diff --git a/meta/meta-mediatek/recipes-core/images/mtk-core-image-initubifs.bb b/meta/meta-mediatek/recipes-core/images/mtk-core-image-initubifs.bb
new file mode 100644
index 0000000..110d626
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/images/mtk-core-image-initubifs.bb
@@ -0,0 +1,22 @@
+# Simple ubifs image. Only add bootimage in the rootfs

+DESCRIPTION = "Small image capable of booting a device. The kernel includes \

+the Minimal RAM-based Initial Root Filesystem (initramfs), which finds the \

+first 'init' program more efficiently."

+

+PACKAGE_INSTALL = ""

+

+# Do not pollute the initrd image with rootfs features

+IMAGE_FEATURES = ""

+

+IMAGE_LINGUAS = ""

+

+LICENSE = "MIT"

+

+IMAGE_FSTYPES = "ubi"

+inherit core-image

+

+inherit boot-ubifs

+do_rootfs[depends] += "virtual/kernel:do_deploy"

+do_rootfs[postfuncs] += "add_boot_image"

+

+IMAGE_ROOTFS_SIZE = "8192"

diff --git a/meta/meta-mediatek/recipes-core/images/mtk-core-image-minimal-initramfs.bb b/meta/meta-mediatek/recipes-core/images/mtk-core-image-minimal-initramfs.bb
new file mode 100644
index 0000000..439fdd8
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/images/mtk-core-image-minimal-initramfs.bb
@@ -0,0 +1,31 @@
+# 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 finds the \
+first 'init' program more efficiently."
+
+PACKAGE_INSTALL = " \
+                   ${@bb.utils.contains('MTK_LDVT_SUPPORT','yes','uvvf','',d)} \
+                   ${@bb.utils.contains('MTK_LDVT_SUPPORT','yes','ldvt-scripts','',d)} \
+                   initramfs-live-boot \
+                   busybox \
+                   udev \
+                   base-passwd \
+                   ${@bb.utils.contains('MTK_UBIFS_SUPPORT','yes','mtd-utils-ubifs','',d)} \
+                   ${ROOTFS_BOOTSTRAP_INSTALL} \
+"
+
+
+# Do not pollute the initrd image with rootfs features
+IMAGE_FEATURES = ""
+
+export IMAGE_BASENAME = "mtk-core-image-minimal-initramfs"
+IMAGE_LINGUAS = ""
+
+LICENSE = "MIT"
+
+IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}"
+inherit core-image
+
+IMAGE_ROOTFS_SIZE = "8192"
+
+BAD_RECOMMENDATIONS += "busybox-syslog"
diff --git a/meta/meta-mediatek/recipes-core/images/mtk-core-image-minimal.bb b/meta/meta-mediatek/recipes-core/images/mtk-core-image-minimal.bb
new file mode 100644
index 0000000..2f6c970
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/images/mtk-core-image-minimal.bb
@@ -0,0 +1,19 @@
+SUMMARY = "A small image just capable of allowing a device to boot."
+
+IMAGE_INSTALL = "packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL}"
+
+IMAGE_LINGUAS = " "
+
+LICENSE = "MIT"
+
+inherit core-image
+inherit create-link
+inherit create-nfsb
+
+
+IMAGE_FEATURES_append = " \
+    ssh-server-openssh    \
+"
+
+IMAGE_ROOTFS_SIZE ?= "8192"
+IMAGE_ROOTFS_EXTRA_SPACE_append = "${@bb.utils.contains("DISTRO_FEATURES", "systemd", " + 4096", "" ,d)}"
diff --git a/meta/meta-mediatek/recipes-core/images/mtk-core-image-recovery-initramfs.bb b/meta/meta-mediatek/recipes-core/images/mtk-core-image-recovery-initramfs.bb
new file mode 100644
index 0000000..1af6db5
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/images/mtk-core-image-recovery-initramfs.bb
@@ -0,0 +1,32 @@
+# 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 finds the \
+first 'init' program more efficiently."
+
+PACKAGE_INSTALL = " \
+                   initramfs-live-boot \
+                   busybox \
+                   udev \
+                   base-passwd \
+                   recovery-scripts \
+                   ${ROOTFS_BOOTSTRAP_INSTALL} \
+"
+
+
+# Do not pollute the initrd image with rootfs features
+IMAGE_FEATURES = ""
+
+export IMAGE_BASENAME = "mtk-core-image-recovery-initramfs"
+IMAGE_LINGUAS = ""
+
+LICENSE = "MIT"
+
+IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}"
+inherit core-image
+
+IMAGE_ROOTFS_SIZE = "8192"
+
+
+do_rootfs[depends] += "virtual/kernel:do_deploy"
+
+inherit recovery-ramdisk-kernel-fitimage
diff --git a/meta/meta-mediatek/recipes-core/images/mtk-core-image-recovery.bb b/meta/meta-mediatek/recipes-core/images/mtk-core-image-recovery.bb
new file mode 100644
index 0000000..ea95703
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/images/mtk-core-image-recovery.bb
@@ -0,0 +1,40 @@
+SUMMARY = "A small image just capable of allowing a device to boot."
+
+IMAGE_INSTALL = "packagegroup-core-boot ${ROOTFS_PKGMANAGE_BOOTSTRAP} ${CORE_IMAGE_EXTRA_INSTALL}"
+
+IMAGE_LINGUAS = " "
+
+LICENSE = "MIT"
+
+inherit core-image
+
+DEPENDS += "virtual/kernel"
+
+IMAGE_ROOTFS_SIZE ?= "8192"
+
+IMAGE_INSTALL_append = " \
+              util-linux \
+              udev-extraconf \
+              recovery-scripts \
+"
+BAD_RECOMMENDATIONS += "busybox-syslog"
+
+install_recovery_fstab() {
+    cat > ${IMAGE_ROOTFS}${sysconfdir}/fstab <<EOF
+/dev/root            /                    auto       ro                    0  0
+proc                 /proc                proc       defaults              0  0
+devpts               /dev/pts             devpts     mode=0620,gid=5       0  0
+tmpfs                /run                 tmpfs      mode=0755,nodev,nosuid,strictatime 0  0
+tmpfs                /var/volatile        tmpfs      defaults              0  0
+EOF
+}
+
+soft_link_to_recovery_image() {
+        ln -nfs ${IMAGE_NAME}.rootfs.${IMAGE_FSTYPES} ${DEPLOY_DIR_IMAGE}/recovery.${IMAGE_FSTYPES}
+}
+
+ROOTFS_POSTPROCESS_COMMAND += " install_recovery_fstab; soft_link_to_recovery_image;"
+
+do_rootfs[depends] += "virtual/kernel:do_deploy"
+
+inherit recovery-kernel-fitimage
diff --git a/meta/meta-mediatek/recipes-core/initscripts/initscripts/init-functions b/meta/meta-mediatek/recipes-core/initscripts/initscripts/init-functions
new file mode 100644
index 0000000..a798c82
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/initscripts/initscripts/init-functions
@@ -0,0 +1,406 @@
+# /lib/lsb/init-functions for Debian -*- shell-script -*-
+#
+#Copyright (c) 2002-08 Chris Lawrence
+#All rights reserved.
+#
+#Redistribution and use in source and binary forms, with or without
+#modification, are permitted provided that the following conditions
+#are met:
+#1. Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+#3. Neither the name of the author nor the names of other contributors
+#   may be used to endorse or promote products derived from this software
+#   without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+#IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+#ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+#LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+#CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+#SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+#BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+#WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+#OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+#EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+start_daemon_background () {
+    local force nice pidfile exec i args
+    force=0
+    nice=0
+    pidfile=/dev/null
+
+    OPTIND=1
+    while getopts fn:p: opt ; do
+        case "$opt" in
+            f)  force=1;;
+            n)  nice="$OPTARG";;
+            p)  pidfile="$OPTARG";;
+        esac
+    done
+    
+    shift $(($OPTIND - 1))
+    if [ "$1" = '--' ]; then
+        shift
+    fi
+
+    exec="$1"; shift
+
+    args="--start --nicelevel $nice --quiet --oknodo --background"
+    if [ $force = 1 ]; then
+        /sbin/start-stop-daemon $args --chdir "$PWD" --startas $exec --pidfile /dev/null -- "$@"
+    elif [ $pidfile ]; then
+        /sbin/start-stop-daemon $args --chdir "$PWD" --exec $exec --oknodo --pidfile "$pidfile" -- "$@"
+    else
+        /sbin/start-stop-daemon $args --chdir "$PWD" --exec $exec -- "$@"
+    fi
+}
+
+
+start_daemon () {
+    local force nice pidfile exec i args
+    force=0
+    nice=0
+    pidfile=/dev/null
+
+    OPTIND=1
+    while getopts fn:p: opt ; do
+        case "$opt" in
+            f)  force=1;;
+            n)  nice="$OPTARG";;
+            p)  pidfile="$OPTARG";;
+        esac
+    done
+    
+    shift $(($OPTIND - 1))
+    if [ "$1" = '--' ]; then
+        shift
+    fi
+
+    exec="$1"; shift
+
+    args="--start --nicelevel $nice --quiet --oknodo"
+    if [ $force = 1 ]; then
+        /sbin/start-stop-daemon $args --chdir "$PWD" --startas $exec --pidfile /dev/null -- "$@"
+    elif [ $pidfile ]; then
+        /sbin/start-stop-daemon $args --chdir "$PWD" --exec $exec --oknodo --pidfile "$pidfile" -- "$@"
+    else
+        /sbin/start-stop-daemon $args --chdir "$PWD" --exec $exec -- "$@"
+    fi
+}
+
+pidofproc () {
+    local pidfile line i pids= status specified pid
+    pidfile=
+    specified=
+    
+    OPTIND=1
+    while getopts p: opt ; do
+        case "$opt" in
+            p)  pidfile="$OPTARG"; specified=1;;
+        esac
+    done
+    shift $(($OPTIND - 1))
+
+    base=${1##*/}
+    if [ ! "$specified" ]; then
+        pidfile="/var/run/$base.pid"
+    fi
+
+    if [ -n "${pidfile:-}" -a -r "$pidfile" ]; then
+        read pid < "$pidfile"
+        if [ -n "${pid:-}" ]; then
+            if $(kill -0 "${pid:-}" 2> /dev/null); then
+                echo "$pid"
+                return 0
+            elif ps "${pid:-}" >/dev/null 2>&1; then
+                echo "$pid"
+                return 0 # program is running, but not owned by this user
+            else
+                return 1 # program is dead and /var/run pid file exists
+            fi
+        fi
+    fi
+    if [ -x /bin/pidof -a ! "$specified" ]; then
+        status="0"
+        /bin/pidof -o %PPID -x $1 || status="$?"
+        if [ "$status" = 1 ]; then
+            return 3 # program is not running
+        fi
+        return 0
+    fi
+    return 4 # Unable to determine status
+}
+
+# start-stop-daemon uses the same algorithm as "pidofproc" above.
+killproc () {
+    local pidfile sig status base i name_param is_term_sig
+    pidfile=
+    name_param=
+    is_term_sig=no
+
+    OPTIND=1
+    while getopts p: opt ; do
+        case "$opt" in
+            p)  pidfile="$OPTARG";;
+        esac
+    done
+    shift $(($OPTIND - 1))
+
+    base=${1##*/}
+    if [ ! $pidfile ]; then
+        name_param="--name $base --pidfile /var/run/$base.pid"
+    else
+        name_param="--pidfile $pidfile"
+    fi
+
+    sig=$(echo ${2:-} | sed -e 's/^-\(.*\)/\1/')
+    sig=$(echo $sig | sed -e 's/^SIG\(.*\)/\1/')
+    if [ -z "$sig" -o "$sig" = 15 -o "$sig" = TERM ]; then
+        is_term_sig=yes
+    fi
+    status=0
+    if [ ! "$is_term_sig" = yes ]; then
+        if [ -n "$sig" ]; then
+            /sbin/start-stop-daemon --stop --signal "$sig" --quiet $name_param || status="$?"
+        else
+            /sbin/start-stop-daemon --stop --quiet $name_param || status="$?"
+        fi
+    else
+        /sbin/start-stop-daemon --stop --quiet --oknodo $name_param || status="$?"
+    fi
+    if [ "$status" = 1 ]; then
+        if [ -n "$sig" ]; then
+            return 0
+        fi
+        return 3 # program is not running
+    fi
+
+    if [ "$status" = 0 -a "$is_term_sig" = yes -a "$pidfile" ]; then
+        pidofproc -p "$pidfile" "$1" >/dev/null || rm -f "$pidfile"
+    fi
+    return 0
+}
+
+# Return LSB status
+status_of_proc () {
+    local pidfile daemon name status
+
+    pidfile=
+    OPTIND=1
+    while getopts p: opt ; do
+        case "$opt" in
+            p)  pidfile="$OPTARG";;
+        esac
+    done
+    shift $(($OPTIND - 1))
+
+    if [ -n "$pidfile" ]; then
+        pidfile="-p $pidfile"
+    fi
+    daemon="$1"
+    name="$2"
+
+    status="0"
+    pidofproc $pidfile $daemon >/dev/null || status="$?"
+    if [ "$status" = 0 ]; then
+        log_success_msg "$name is running"
+        return 0
+    elif [ "$status" = 4 ]; then
+        log_failure_msg "could not access PID file for $name"
+        return $status
+    else
+        log_failure_msg "$name is not running"
+        return $status
+    fi
+}
+
+log_use_fancy_output () {
+    TPUT=/usr/bin/tput
+    EXPR=/usr/bin/expr
+    if [ -t 1 ] && [ "x${TERM:-}" != "x" ] && [ "x${TERM:-}" != "xdumb" ] && [ -x $TPUT ] && [ -x $EXPR ] && $TPUT hpa 60 >/dev/null 2>&1 && $TPUT setaf 1 >/dev/null 2>&1; then
+        [ -z $FANCYTTY ] && FANCYTTY=1 || true
+    else
+        FANCYTTY=0
+    fi
+    case "$FANCYTTY" in
+        1|Y|yes|true)   true;;
+        *)              false;;
+    esac
+}
+
+log_success_msg () {
+    if [ -n "${1:-}" ]; then
+        log_begin_msg $@
+    fi
+    log_end_msg 0
+}
+
+log_failure_msg () {
+    if [ -n "${1:-}" ]; then
+        log_begin_msg $@ "..."
+    fi
+    log_end_msg 1 || true
+}
+
+log_warning_msg () {
+    if [ -n "${1:-}" ]; then
+        log_begin_msg $@ "..."
+    fi
+    log_end_msg 255 || true
+}
+
+#
+# NON-LSB HELPER FUNCTIONS
+#
+# int get_lsb_header_val (char *scriptpathname, char *key)
+get_lsb_header_val () {
+        if [ ! -f "$1" ] || [ -z "${2:-}" ]; then
+                return 1
+        fi
+        LSB_S="### BEGIN INIT INFO"
+        LSB_E="### END INIT INFO"
+        sed -n "/$LSB_S/,/$LSB_E/ s/# $2: \(.*\)/\1/p" $1
+}
+
+# int log_begin_message (char *message)
+log_begin_msg () {
+    if [ -z "${1:-}" ]; then
+        return 1
+    fi
+    echo -n "$@"
+}
+
+# Sample usage:
+# log_daemon_msg "Starting GNOME Login Manager" "gdm"
+#
+# On Debian, would output "Starting GNOME Login Manager: gdm"
+# On Ubuntu, would output " * Starting GNOME Login Manager..."
+#
+# If the second argument is omitted, logging suitable for use with
+# log_progress_msg() is used:
+#
+# log_daemon_msg "Starting remote filesystem services"
+#
+# On Debian, would output "Starting remote filesystem services:"
+# On Ubuntu, would output " * Starting remote filesystem services..."
+
+log_daemon_msg () {
+    if [ -z "${1:-}" ]; then
+        return 1
+    fi
+    log_daemon_msg_pre "$@"
+
+    if [ -z "${2:-}" ]; then
+        echo -n "$1:"
+        return
+    fi
+    
+    echo -n "$1: $2"
+    log_daemon_msg_post "$@"
+}
+
+# #319739
+#
+# Per policy docs:
+#
+#     log_daemon_msg "Starting remote file system services"
+#     log_progress_msg "nfsd"; start-stop-daemon --start --quiet nfsd
+#     log_progress_msg "mountd"; start-stop-daemon --start --quiet mountd
+#     log_progress_msg "ugidd"; start-stop-daemon --start --quiet ugidd
+#     log_end_msg 0
+#
+# You could also do something fancy with log_end_msg here based on the
+# return values of start-stop-daemon; this is left as an exercise for
+# the reader...
+#
+# On Ubuntu, one would expect log_progress_msg to be a no-op.
+log_progress_msg () {
+    if [ -z "${1:-}" ]; then
+        return 1
+    fi
+    echo -n " $@"
+}
+
+
+# int log_end_message (int exitstatus)
+log_end_msg () {
+    # If no arguments were passed, return
+    if [ -z "${1:-}" ]; then
+        return 1
+    fi
+
+    retval=$1
+
+    log_end_msg_pre "$@"
+
+    # Only do the fancy stuff if we have an appropriate terminal
+    # and if /usr is already mounted
+    if log_use_fancy_output; then
+        RED=`$TPUT setaf 1`
+        YELLOW=`$TPUT setaf 3`
+        NORMAL=`$TPUT op`
+    else
+        RED=''
+        YELLOW=''
+        NORMAL=''
+    fi
+
+    if [ $1 -eq 0 ]; then
+        echo "."
+    elif [ $1 -eq 255 ]; then
+        /bin/echo -e " ${YELLOW}(warning).${NORMAL}"
+    else
+        /bin/echo -e " ${RED}failed!${NORMAL}"
+    fi
+    log_end_msg_post "$@"
+    return $retval
+}
+
+log_action_msg () {
+    echo "$@."
+}
+
+log_action_begin_msg () {
+    echo -n "$@..."
+}
+
+log_action_cont_msg () {
+    echo -n "$@..."
+}
+
+log_action_end_msg () {
+    log_action_end_msg_pre "$@"
+    if [ -z "${2:-}" ]; then
+        end="."
+    else
+        end=" ($2)."
+    fi
+
+    if [ $1 -eq 0 ]; then
+        echo "done${end}"
+    else
+        if log_use_fancy_output; then
+            RED=`$TPUT setaf 1`
+            NORMAL=`$TPUT op`
+            /bin/echo -e "${RED}failed${end}${NORMAL}"
+        else
+            echo "failed${end}"
+        fi
+    fi
+    log_action_end_msg_post "$@"
+}
+
+# Hooks for /etc/lsb-base-logging.sh
+log_daemon_msg_pre () { :; }
+log_daemon_msg_post () { :; }
+log_end_msg_pre () { :; }
+log_end_msg_post () { :; }
+log_action_end_msg_pre () { :; }
+log_action_end_msg_post () { :; }
+
+FANCYTTY=
+[ -e /etc/lsb-base-logging.sh ] && . /etc/lsb-base-logging.sh || true
\ No newline at end of file
diff --git a/meta/meta-mediatek/recipes-core/initscripts/initscripts_1.0.bbappend b/meta/meta-mediatek/recipes-core/initscripts/initscripts_1.0.bbappend
new file mode 100644
index 0000000..9b81261
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/initscripts/initscripts_1.0.bbappend
@@ -0,0 +1,11 @@
+FILESEXTRAPATHS_append := ":${THISDIR}/${PN}"
+
+SRC_URI_append = " file://init-functions "
+
+DEPENDS += " start-stop-daemon "
+
+do_install_append() {
+        install -d ${D}${sysconfdir}/init.d
+        install -m 0755 ${WORKDIR}/init-functions ${D}${sysconfdir}/init.d
+}
+
diff --git a/meta/meta-mediatek/recipes-core/ldvt-scripts/files/init-ldvt.sh b/meta/meta-mediatek/recipes-core/ldvt-scripts/files/init-ldvt.sh
new file mode 100644
index 0000000..cb41ef7
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/ldvt-scripts/files/init-ldvt.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+
+ROOT_MOUNT="/rootfs/"
+ROOT_IMAGE="rootfs.img"
+MOUNT="/bin/mount"
+UMOUNT="/bin/umount"
+ISOLINUX=""
+
+ROOT_DISK=""
+
+# Copied from initramfs-framework. The core of this script probably should be
+# turned into initramfs-framework modules to reduce duplication.
+udev_daemon() {
+	OPTIONS="/sbin/udev/udevd /sbin/udevd /lib/udev/udevd /lib/systemd/systemd-udevd"
+
+	for o in $OPTIONS; do
+		if [ -x "$o" ]; then
+			echo $o
+			return 0
+		fi
+	done
+
+	return 1
+}
+
+_UDEV_DAEMON=`udev_daemon`
+
+early_setup() {
+    mkdir -p /proc
+    mkdir -p /sys
+    mount -t proc proc /proc
+    mount -t sysfs sysfs /sys
+    mount -t devtmpfs none /dev
+
+    # support modular kernel
+    # modprobe isofs 2> /dev/null
+
+    mkdir -p /run
+    mkdir -p /var/run
+
+    $_UDEV_DAEMON --daemon
+    udevadm trigger --action=add
+}
+
+
+boot_live_root() {
+    # Watches the udev event queue, and exits if all current events are handled
+    udevadm settle --timeout=3 --quiet
+    killall "${_UDEV_DAEMON##*/}" 2>/dev/null
+}
+
+fatal() {
+    echo $1 >$CONSOLE
+    echo >$CONSOLE
+    exec sh
+}
+
+early_setup
+
+sleep 5
+
+boot_live_root
+
diff --git a/meta/meta-mediatek/recipes-core/ldvt-scripts/ldvt-scripts.bb b/meta/meta-mediatek/recipes-core/ldvt-scripts/ldvt-scripts.bb
new file mode 100644
index 0000000..d03a8b3
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/ldvt-scripts/ldvt-scripts.bb
@@ -0,0 +1,17 @@
+SUMMARY = "Ldvt init script"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+DEPENDS = "virtual/kernel"
+RDEPENDS_${PN} = "udev udev-extraconf"
+SRC_URI = "file://init-ldvt.sh"
+
+S = "${WORKDIR}"
+
+do_install() {
+        install -m 0755 ${WORKDIR}/init-ldvt.sh ${D}/ldvt_init
+}
+
+FILES_${PN} += " /ldvt_init "
+
+# Due to kernel dependency
+PACKAGE_ARCH = "${MACHINE_ARCH}"
diff --git a/meta/meta-mediatek/recipes-core/packagegroups/packagegroup-mtk-upgrade-kit-native.bb b/meta/meta-mediatek/recipes-core/packagegroups/packagegroup-mtk-upgrade-kit-native.bb
new file mode 100644
index 0000000..3c7bdf1
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/packagegroups/packagegroup-mtk-upgrade-kit-native.bb
@@ -0,0 +1,10 @@
+SUMMARY = "Mediatek Upgrade Kit"
+LICENSE = "MediaTekProprietary"
+
+inherit packagegroup
+
+DEPENDS += "\
+           platform-tools-native \
+           fbtool-native \
+           flashtool-native \
+           "
diff --git a/meta/meta-mediatek/recipes-core/packagegroups/packagegroup-mtk-upgrade-kit.bb b/meta/meta-mediatek/recipes-core/packagegroups/packagegroup-mtk-upgrade-kit.bb
new file mode 100644
index 0000000..c703c4c
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/packagegroups/packagegroup-mtk-upgrade-kit.bb
@@ -0,0 +1,9 @@
+SUMMARY = "Mediatek Upgrade Kit"
+LICENSE = "MediaTekProprietary"
+
+inherit packagegroup
+
+DEPENDS += "\
+           platform-tools \
+           fbtool \
+           "
diff --git a/meta/meta-mediatek/recipes-core/packagegroups/packagegroup-self-hosted-without-x11.bb b/meta/meta-mediatek/recipes-core/packagegroups/packagegroup-self-hosted-without-x11.bb
new file mode 100644
index 0000000..79e56bd
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/packagegroups/packagegroup-self-hosted-without-x11.bb
@@ -0,0 +1,155 @@
+#
+# Copyright (C) 2010 Intel Corporation
+#
+
+SUMMARY = "Essential build dependencies"
+LICENSE = "MIT"
+
+inherit packagegroup
+
+
+RDEPENDS_packagegroup-self-hosted-without-x11 = "\
+    autoconf \
+    automake \
+    binutils \
+    binutils-symlinks \
+    cpp \
+    cpp-symlinks \
+    gcc \
+    gcc-symlinks \
+    g++ \
+    g++-symlinks \
+    gettext \
+    make \
+    libstdc++ \
+    libstdc++-dev \
+    libtool \
+    pkgconfig \
+    connman \
+    connman-plugin-ethernet \
+    dhcp-client \
+    e2fsprogs \
+    e2fsprogs-e2fsck \
+    e2fsprogs-mke2fs \
+    e2fsprogs-tune2fs \
+    hdparm \
+    iptables \
+    lsb \
+    mc \
+    mc-fish \
+    mc-helpers \
+    mc-helpers-perl \
+    mc-helpers-python \
+    parted \
+    pseudo \
+    screen \
+    autoconf \
+    automake \
+    binutils \
+    binutils-symlinks \
+    ccache \
+    coreutils \
+    cpp \
+    cpp-symlinks \
+    glibc-utils \
+    glibc-gconv-ibm850 \
+    file \
+    findutils \
+    g++ \
+    g++-symlinks \
+    gcc \
+    gcc-symlinks \
+    intltool \
+    ldd \
+    less \
+    libssp \
+    libssp-dev \
+    libssp-staticdev \
+    libstdc++ \
+    libstdc++-dev \
+    libtool \
+    make \
+    mktemp \
+    perl-module-re \
+    perl-module-text-wrap \
+    pkgconfig \
+    quilt \
+    sed \
+    gdb \
+    gdbserver \
+    rsync \
+    strace \
+    tcf-agent \
+    bzip2 \
+    chkconfig \
+    chrpath \
+    cpio \
+    curl \
+    diffstat \
+    diffutils \
+    elfutils \
+    expat \
+    gamin \
+    gawk \
+    gdbm \
+    gettext \
+    gettext-runtime \
+    git \
+    git-perltools \
+    grep \
+    groff \
+    gzip \
+    hicolor-icon-theme \
+    sato-icon-theme \
+    libaio \
+    libusb1 \
+    libxml2 \
+    lrzsz \
+    lsof \
+    lzo \
+    man \
+    man-pages \
+    mdadm \
+    minicom \
+    mtools \
+    ncurses \
+    ncurses-terminfo-base \
+    neon \
+    nfs-utils \
+    nfs-utils-client \
+    openssl \
+    openssh-sftp-server \
+    opkg \
+    opkg-utils \
+    patch \
+    perl \
+    perl-dev \
+    perl-modules \
+    perl-pod \
+    python \
+    python-compiler \
+    python-git \
+    python-misc \
+    python-modules \
+    python-rpm \
+    quota \
+    readline \
+    rpm \
+    setserial \
+    socat \
+    subversion \
+    sudo \
+    sysstat \
+    tar \
+    tcl \
+    texi2html \
+    texinfo \
+    unzip \
+    usbutils \
+    wget \
+    which \
+    xinetd \
+    zip \
+    zlib \
+    xz \
+    "
diff --git a/meta/meta-mediatek/recipes-core/recovery-scripts/recovery-scripts.bb b/meta/meta-mediatek/recipes-core/recovery-scripts/recovery-scripts.bb
new file mode 100644
index 0000000..0618106
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/recovery-scripts/recovery-scripts.bb
@@ -0,0 +1,14 @@
+DESCRIPTION = "An Example for Recovery Mode"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://README;md5=6b2da25093d94b7c2bd0b5ce697f27b9"
+SRC_URI = "file://README \
+           file://recovery.sh \
+"
+S = "${WORKDIR}"
+FILES_${PN} = "${bindir}/recovery.sh"
+
+do_install () {
+        install -d ${D}${bindir}
+        install -m 755 ${S}/recovery.sh ${D}${bindir}/recovery.sh
+}
+
diff --git a/meta/meta-mediatek/recipes-core/recovery-scripts/recovery-scripts/README b/meta/meta-mediatek/recipes-core/recovery-scripts/recovery-scripts/README
new file mode 100644
index 0000000..70ec215
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/recovery-scripts/recovery-scripts/README
@@ -0,0 +1 @@
+An example for recovery mode
diff --git a/meta/meta-mediatek/recipes-core/recovery-scripts/recovery-scripts/recovery.sh b/meta/meta-mediatek/recipes-core/recovery-scripts/recovery-scripts/recovery.sh
new file mode 100644
index 0000000..6af4a51
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/recovery-scripts/recovery-scripts/recovery.sh
@@ -0,0 +1,35 @@
+MOUNTFOLDER="/run/media/sda1"
+MOUNTDEV="/dev/sda1"
+BOOTIMAGE="${MOUNTFOLDER}/boot.img"
+BOOT_PARTITION="/dev/mmcblk0p2"
+ROOTFS="${MOUNTFOLDER}/system.ext4"
+ROOTFS_PARTITION="/dev/mmcblk0p3"
+
+# mount USB device
+if ! test -d ${MOUNTFOLDER} ; then
+  mkdir -p ${MOUNTFOLDER}
+  /bin/mount ${MOUNTDEV} ${MOUNTFOLDER}
+fi
+
+#Flashing boot.img (kernel image)
+while ! test -f ${BOOTIMAGE} ; do
+  echo "Please insert usb disk and place boot.img in usb disk"
+  echo "Press ENTER key to Continue"
+  read
+done
+echo "Flashing boot.img ..."
+/bin/dd if=${BOOTIMAGE} of=${BOOT_PARTITION} bs=1048576
+
+#Flashing rootfs.ext4
+while ! test -f ${ROOTFS} ; do
+  echo "Please insert usb disk and place rootfs.ext4 in usb disk"
+  echo "Press ENTER key to Continue"
+  read
+done
+echo "Flashing rootfs.ext4 ..."
+/bin/dd if=${ROOTFS} of=${ROOTFS_PARTITION} bs=1048576
+
+echo "Finish ... Press ENTER key to Reboot"
+read
+echo "Rebooting ..."
+/sbin/reboot -f
diff --git a/meta/meta-mediatek/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bbappend b/meta/meta-mediatek/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bbappend
new file mode 100644
index 0000000..5fced55
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bbappend
@@ -0,0 +1,7 @@
+USE_VT := "0"

+

+DEFAULT_RUNLEVEL ?= "3"

+

+do_install_append() {

+	sed -i -e 's/id:5:initdefault/id:${DEFAULT_RUNLEVEL}:initdefault/' ${D}${sysconfdir}/inittab

+}

diff --git a/meta/meta-mediatek/recipes-core/udev/udev-only-hdmi/hdmi_hotplug.rules b/meta/meta-mediatek/recipes-core/udev/udev-only-hdmi/hdmi_hotplug.rules
new file mode 100644
index 0000000..db05df8
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/udev/udev-only-hdmi/hdmi_hotplug.rules
@@ -0,0 +1 @@
+ACTION=="change", KERNEL=="card0", SUBSYSTEM=="drm", RUN+="/etc/udev/scripts/hdmi_hotplug.sh"
diff --git a/meta/meta-mediatek/recipes-core/udev/udev-only-hdmi/hdmi_hotplug.sh b/meta/meta-mediatek/recipes-core/udev/udev-only-hdmi/hdmi_hotplug.sh
new file mode 100644
index 0000000..37afef7
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/udev/udev-only-hdmi/hdmi_hotplug.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+HDMIStatus=$(cat /sys/class/drm/card0-HDMI-A-1/status)
+
+if [ $HDMIStatus = 'connected' ]; then
+        systemctl restart weston
+else
+        systemctl stop weston
+fi
diff --git a/meta/meta-mediatek/recipes-core/udev/udev-only-hdmi_1.0.bb b/meta/meta-mediatek/recipes-core/udev/udev-only-hdmi_1.0.bb
new file mode 100644
index 0000000..52978df
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/udev/udev-only-hdmi_1.0.bb
@@ -0,0 +1,20 @@
+SUMMARY = "Extra machine specific configuration files"
+DESCRIPTION = "Extra machine specific configuration files for udev, specifically blacklist information."
+LICENSE = "MediaTekProprietary"
+
+SRC_URI = " \
+       file://hdmi_hotplug.rules \
+       file://hdmi_hotplug.sh \
+"
+
+S = "${WORKDIR}"
+
+do_install() {
+    install -d ${D}${sysconfdir}/udev/rules.d
+    install -m 0644 ${WORKDIR}/hdmi_hotplug.rules ${D}${sysconfdir}/udev/rules.d/hdmi_hotplug.rules
+    install -d ${D}${sysconfdir}/udev/scripts/
+    install -m 0755 ${WORKDIR}/hdmi_hotplug.sh ${D}${sysconfdir}/udev/scripts/hdmi_hotplug.sh
+}
+
+FILES_${PN} = "${sysconfdir}/udev"
+RDEPENDS_${PN} = "udev"
diff --git a/meta/meta-mediatek/recipes-core/uvvf/uvvf.bb b/meta/meta-mediatek/recipes-core/uvvf/uvvf.bb
new file mode 100644
index 0000000..835f2a7
--- /dev/null
+++ b/meta/meta-mediatek/recipes-core/uvvf/uvvf.bb
@@ -0,0 +1,24 @@
+inherit package
+
+INHIBIT_PACKAGE_STRIP = "1"
+
+DESCRIPTION = "Mediatek ldvt uvvf library"
+LICENSE = "MediaTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=cfae02679eba352c5d667a0cda7ef56e"
+
+TESTCASE_SRC = "${TOPDIR}/../src/ldvt/ldvt_tc/"
+TESTCASE_BIN_DIR = "${D}/usr/local/ldvt/bin"
+TESTCASE_BIN_INSTALL = "/usr/local/ldvt/bin"
+SRC_URI = "file://${TESTCASE_SRC}"
+S = "${TESTCASE_SRC}"
+
+do_compile () {
+	oe_runmake
+}
+
+do_install () {
+	oe_runmake \
+		DESTDIR="${D}" install
+}
+
+FILES_${PN} += "${TESTCASE_BIN_INSTALL}"