[Feature]add MT2731_MP2_MR2_SVN388 baseline version

Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/0001-Use-pkg-config-for-libxml2-detection.patch b/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/0001-Use-pkg-config-for-libxml2-detection.patch
new file mode 100644
index 0000000..f14da06
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/0001-Use-pkg-config-for-libxml2-detection.patch
@@ -0,0 +1,46 @@
+From d3ee8c8df5808b63e86f40831f2ba62cbb33d291 Mon Sep 17 00:00:00 2001
+From: Changqing Li <changqing.li@windriver.com>
+Date: Wed, 8 Aug 2018 09:18:27 +0800
+Subject: [PATCH] postgresql: Use pkg-config for libxml2 detection.
+
+Upstream-Status: Inappropriate [configuration]
+
+xml2-config does not work. Use pkgconfig to set CPPFLAGS and LIBS.
+
+Signed-off-by: Philip Balister <philip@balister.org>
+
+upate to version 10.4
+Signed-off-by: Changqing Li <changqing.li@windriver.com>
+---
+ configure.in | 15 ++-------------
+ 1 file changed, 2 insertions(+), 13 deletions(-)
+
+diff --git a/configure.in b/configure.in
+index d9fe56e..3e2cd3a 100644
+--- a/configure.in
++++ b/configure.in
+@@ -816,19 +816,8 @@ PGAC_ARG_BOOL(with, libxml, no, [build with XML support],
+               [AC_DEFINE([USE_LIBXML], 1, [Define to 1 to build with XML support. (--with-libxml)])])
+ 
+ if test "$with_libxml" = yes ; then
+-  PGAC_PATH_PROGS(XML2_CONFIG, xml2-config)
+-  if test -n "$XML2_CONFIG"; then
+-    for pgac_option in `$XML2_CONFIG --cflags`; do
+-      case $pgac_option in
+-        -I*|-D*) CPPFLAGS="$CPPFLAGS $pgac_option";;
+-      esac
+-    done
+-    for pgac_option in `$XML2_CONFIG --libs`; do
+-      case $pgac_option in
+-        -L*) LDFLAGS="$LDFLAGS $pgac_option";;
+-      esac
+-    done
+-  fi
++    CPPFLAGS="$CPPFLAGS `pkg-config --short-errors --print-errors --cflags "libxml-2.0" 2>&1`"
++    LIBS="`pkg-config --short-errors --print-errors --libs "libxml-2.0" 2>&1` $LIBS"
+ fi
+ 
+ AC_SUBST(with_libxml)
+-- 
+2.7.4
+
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/not-check-libperl.patch b/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/not-check-libperl.patch
new file mode 100644
index 0000000..9715109
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/not-check-libperl.patch
@@ -0,0 +1,28 @@
+[PATCH] not check libperl under cross compiling
+
+Upstream-Status: Inappropriate [configuration]
+
+libperl ldflags returned by PGAC_CHECK_PERL_EMBED_LDFLAGS are native,
+can not be used to check target library.
+
+postpresql has the dependency on perl, so not need to check libperl
+again, like in postgresql-9.2.4 
+
+Signed-off-by: Roy Li <rongqing.li@windriver.com>
+---
+ configure.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+Index: postgresql-9.4.15/configure.in
+===================================================================
+--- postgresql-9.4.15.orig/configure.in
++++ postgresql-9.4.15/configure.in
+@@ -1879,7 +1879,7 @@ if test "$with_tcl" = yes; then
+ fi
+ 
+ # check for <perl.h>
+-if test "$with_perl" = yes; then
++if test "$with_perl" = yes && test "$cross_compiling" = no; then
+   ac_save_CPPFLAGS=$CPPFLAGS
+   CPPFLAGS="$CPPFLAGS -I$perl_archlibexp/CORE"
+   AC_CHECK_HEADER(perl.h, [], [AC_MSG_ERROR([header file <perl.h> is required for Perl])],
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/postgresql-profile b/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/postgresql-profile
new file mode 100644
index 0000000..1c931f3
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/postgresql-profile
@@ -0,0 +1,4 @@
+[ -f /etc/profile ] && source /etc/profile
+
+PGDATA=/var/lib/postgresql/data
+export PGDATA
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/postgresql-setup b/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/postgresql-setup
new file mode 100644
index 0000000..75bb01e
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/postgresql-setup
@@ -0,0 +1,73 @@
+#!/bin/sh
+#
+# postgresql-setup      Initialization operation for PostgreSQL
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+PGENGINE=/usr/bin
+PGDATA=/var/lib/postgresql/data
+PGLOG=/var/lib/postgresql/pgstartup.log
+script_result=0
+
+initdb(){
+    if [ -f "$PGDATA/PG_VERSION" ]
+    then
+	echo -n "Data directory is not empty!"
+	echo -n " [FAILED] "
+	echo
+	script_result=1
+    else
+	echo -n "Initializing database: "
+	if [ ! -e "$PGDATA" -a ! -h "$PGDATA" ]
+	then
+		mkdir -p "$PGDATA" || exit 1
+		chown postgres:postgres "$PGDATA"
+		chmod go-rwx "$PGDATA"
+	fi
+	# Clean up SELinux tagging for PGDATA
+	[ -x /sbin/restorecon ] && /sbin/restorecon "$PGDATA"
+
+	# Make sure the startup-time log file is OK, too
+	if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ]
+	then
+		touch "$PGLOG" || exit 1
+		chown postgres:postgres "$PGLOG"
+		chmod go-rwx "$PGLOG"
+		[ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG"
+	fi
+
+	# Initialize the database
+	$SU -l postgres -c "$PGENGINE/initdb --pgdata='$PGDATA' --auth='ident'" >> "$PGLOG" 2>&1 < /dev/null
+
+	# Create directory for postmaster log
+	mkdir "$PGDATA/pg_log"
+	chown postgres:postgres "$PGDATA/pg_log"
+	chmod go-rwx "$PGDATA/pg_log"
+
+	if [ -f "$PGDATA/PG_VERSION" ]
+	then
+	    echo -n " [ OK ] "
+	else
+	    echo -n " [FAILED] "
+	    script_result=1
+	fi
+	echo
+    fi
+}
+
+case "$1" in
+  initdb)
+	initdb
+	;;
+  *)
+	echo "Usage: $0 initdb"
+	exit 2
+esac
+
+exit $script_result
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/postgresql.init b/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/postgresql.init
new file mode 100644
index 0000000..4a4f0cd
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/postgresql.init
@@ -0,0 +1,193 @@
+#!/bin/sh
+#
+# postgresql	This is the init script for starting up the PostgreSQL
+#		server.
+#
+# chkconfig: - 64 36
+# description: PostgreSQL database server.
+# processname: postmaster
+# pidfile: /var/run/postmaster.PORT.pid
+
+# This script is slightly unusual in that the name of the daemon (postmaster)
+# is not the same as the name of the subsystem (postgresql)
+
+# PGVERSION is the full package version, e.g., 8.4.0
+# Note: the specfile inserts the correct value during package build
+PGVERSION=9.2.4
+# PGMAJORVERSION is major version, e.g., 8.4 (this should match PG_VERSION)
+PGMAJORVERSION=`echo "$PGVERSION" | sed 's/^\([0-9]*\.[0-9]*\).*$/\1/'`
+
+# Source function library.
+. /etc/init.d/functions
+
+# Find the name of the script
+NAME=`basename $0`
+if [ ${NAME:0:1} = "S" -o ${NAME:0:1} = "K" ]
+then
+	NAME=${NAME:3}
+fi
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+
+# Set defaults for configuration variables
+PGENGINE=/usr/bin
+PGPORT=5432
+PGDATA=/var/lib/postgresql/data
+PGLOG=/var/lib/postgresql/pgstartup.log
+# Value to set as postmaster process's oom_adj
+PG_OOM_ADJ=-17
+
+# Override defaults from /etc/sysconfig/postgresql if file is present
+[ -f /etc/default/postgresql/${NAME} ] && . /etc/default/postgresql/${NAME}
+
+export PGDATA
+export PGPORT
+
+lockfile="/var/lock/subsys/${NAME}"
+pidfile="/var/run/postmaster.${PGPORT}.pid"
+
+script_result=0
+
+start(){
+	[ -x "$PGENGINE/postmaster" ] || exit 5
+
+	PSQL_START=$"Starting ${NAME} service: "
+
+	# Make sure startup-time log file is valid
+	if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ]
+	then
+		touch "$PGLOG" || exit 4
+		chown postgres:postgres "$PGLOG"
+		chmod go-rwx "$PGLOG"
+		[ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG"
+	fi
+
+	# Check for the PGDATA structure
+	if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base" ]
+	then
+		# Check version of existing PGDATA
+		if [ x`cat "$PGDATA/PG_VERSION"` != x"$PGMAJORVERSION" ]
+		then
+			SYSDOCDIR="(Your System's documentation directory)"
+			if [ -d "/usr/doc/postgresql-$PGVERSION" ]
+			then
+				SYSDOCDIR=/usr/doc
+			fi
+			if [ -d "/usr/share/doc/postgresql-$PGVERSION" ]
+			then
+				SYSDOCDIR=/usr/share/doc
+			fi
+			if [ -d "/usr/doc/packages/postgresql-$PGVERSION" ]
+			then
+				SYSDOCDIR=/usr/doc/packages
+			fi
+			if [ -d "/usr/share/doc/packages/postgresql-$PGVERSION" ]
+			then
+				SYSDOCDIR=/usr/share/doc/packages
+			fi
+			echo
+			echo $"An old version of the database format was found."
+			echo $"You need to upgrade the data format before using PostgreSQL."
+			echo $"See $SYSDOCDIR/postgresql-$PGVERSION/README.rpm-dist for more information."
+			exit 1
+		fi
+	else
+		# No existing PGDATA! Warn the user to initdb it.
+		echo
+                echo "$PGDATA is missing. Use \"postgresql-setup initdb\" to initialize the cluster first."
+		echo -n " [FAILED] "
+		echo
+		exit 1
+	fi
+
+	echo -n "$PSQL_START"
+	test x"$PG_OOM_ADJ" != x && echo "$PG_OOM_ADJ" > /proc/self/oom_score_adj
+	$SU -l postgres -c "$PGENGINE/postmaster -p '$PGPORT' -D '$PGDATA' ${PGOPTS} &" >> "$PGLOG" 2>&1 < /dev/null
+	sleep 2
+	pid=`head -n 1 "$PGDATA/postmaster.pid" 2>/dev/null`
+	if [ "x$pid" != x ]
+	then
+		echo -n " [ OK ]"
+		touch "$lockfile"
+		echo $pid > "$pidfile"
+		echo
+	else
+		echo -n  " [FAILED]"
+		echo
+		script_result=1
+	fi
+}
+
+stop(){
+	echo -n $"Stopping ${NAME} service: "
+	if [ -e "$lockfile" ]
+	then
+	    $SU -l postgres -c "$PGENGINE/pg_ctl stop -D '$PGDATA' -s -m fast" > /dev/null 2>&1 < /dev/null
+	    ret=$?
+	    if [ $ret -eq 0 ]
+	    then
+		echo -n " [ OK ] "
+		rm -f "$pidfile"
+		rm -f "$lockfile"
+	    else
+		echo -n " [FAILED] "
+		script_result=1
+	    fi
+	else
+	    # not running; per LSB standards this is "ok"
+	    echo -n " [ OK ] "
+	fi
+	echo
+}
+
+restart(){
+    stop
+    start
+}
+
+condrestart(){
+    [ -e "$lockfile" ] && restart || :
+}
+
+reload(){
+    $SU -l postgres -c "$PGENGINE/pg_ctl reload -D '$PGDATA' -s" > /dev/null 2>&1 < /dev/null
+}
+
+
+# See how we were called.
+case "$1" in
+  start)
+	start
+	;;
+  stop)
+	stop
+	;;
+  status)
+	status postmaster
+	script_result=$?
+	;;
+  restart)
+	restart
+	;;
+  condrestart|try-restart)
+	condrestart
+	;;
+  reload)
+	reload
+	;;
+  force-reload)
+	restart
+	;;
+  *)
+	echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+	exit 2
+esac
+
+exit $script_result
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/postgresql.pam b/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/postgresql.pam
new file mode 100644
index 0000000..0b6fdc5
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/postgresql.pam
@@ -0,0 +1,4 @@
+#%PAM-1.0
+auth            include         common-auth
+account         include         common-account
+password        include         common-password
diff --git a/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/postgresql.service b/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/postgresql.service
new file mode 100644
index 0000000..4ec959e
--- /dev/null
+++ b/meta/meta-openembedded/meta-oe/recipes-dbs/postgresql/files/postgresql.service
@@ -0,0 +1,27 @@
+[Unit]
+Description=PostgreSQL database server
+After=network.target
+
+[Service]
+Type=forking
+User=postgres
+Group=postgres
+
+# Port number for server to listen on
+Environment=PGPORT=5432
+
+# Location of database directory
+Environment=PGDATA=/var/lib/postgresql/data
+
+# Disable OOM kill on the postmaster
+OOMScoreAdjust=-17
+
+ExecStart=@BINDIR@/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t 300
+ExecStop=@BINDIR@/pg_ctl stop -D ${PGDATA} -s -m fast
+ExecReload=@BINDIR@/pg_ctl reload -D ${PGDATA} -s
+
+# Give a reasonable amount of time for the server to start up/shut down
+TimeoutSec=300
+
+[Install]
+WantedBy=multi-user.target