meta-mellanox/meta-msn add ipmi daemon recipe

Add ipmi daemon recipe, including the systemd service file.

Change-Id: Ice5c373603b482835beb9cec59e9a5b2346f21aa
Signed-off-by: Mykola Kostenok <c_mykolak@mellanox.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
diff --git a/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid.bb b/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid.bb
new file mode 100644
index 0000000..0236c24
--- /dev/null
+++ b/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid.bb
@@ -0,0 +1,13 @@
+PV = "git${SRCPV}"
+
+MLX_IPMID_BRANCH = "openbmc"
+
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI = "git://github.com/mellanoxbmc/ipmi.git;protocol=git;branch=${MLX_IPMID_BRANCH};"
+SRC_URI += "file://mlx_ipmid.service"
+SRC_URI += "file://remove_libdir.patch"
+
+SRCREV = "${AUTOREV}"
+
+require mlx-ipmid.inc
diff --git a/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid.inc b/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid.inc
new file mode 100644
index 0000000..73e7614
--- /dev/null
+++ b/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid.inc
@@ -0,0 +1,60 @@
+DESCRIPTION = "This is the OpenIPMI library, a library that makes simplifies building complex IPMI management software."
+SECTION = "console/network"
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f"
+DEPENDS = " \
+    openssl \
+    popt \
+    zlib \
+    ncurses \
+    glib-2.0 \
+    gdbm \
+    dbus \
+    dbus-glib \
+"
+RDEPENDS_${PN} += " bash dbus"
+
+INC_PR = "r2"
+
+inherit autotools gettext update-alternatives systemd pkgconfig
+
+PACKAGECONFIG ??= "net-snmp"
+
+PACKAGECONFIG[net-snmp] = ",--with-ucdsnmp=no,net-snmp"
+PACKAGECONFIG[python] = "--with-python,--without-python,python,"
+PACKAGECONFIG[perl] = "--with-perl=${STAGING_BINDIR_NATIVE},--with-perl=no,perl,"
+PACKAGECONFIG[tcl] = "--with-tcl,--without-tcl,tcl,"
+
+EXTRA_OECONF = "\
+    --prefix=${prefix} \
+    --with-mellanox \
+    --with-dbus \
+    "
+
+S = "${WORKDIR}/git"
+
+PARALLEL_MAKEINST = ""
+
+SYSTEMD_PACKAGES = "${PN}"
+
+SYSTEMD_SERVICE_${PN} = " mlx_ipmid.service"
+
+
+do_install_append() {
+    install -d ${D}/etc/init.d
+    install -d ${D}/${systemd_unitdir}/system
+    install -m 644 ${WORKDIR}/mlx_ipmid.service ${D}/${systemd_unitdir}/system/mlx_ipmid.service
+    install -d ${D}${libdir}/mlx_ipmid
+    install -m 0644 ${B}/lanserv/mellanox/.libs/mellanox.so ${D}${libdir}/mlx_ipmid/
+    install -Dpm 644 ${D}/var/mlx_ipmid/mellanox/50-mlx-events-4.10.rules ${D}/lib/udev/rules.d/50-mlx-events.rules
+    install -Dpm 644 ${D}/var/mlx_ipmid/mellanox/50-mlx-hwmon-4-10-events.rules ${D}/lib/udev/rules.d/50-mlx-hwmon-events.rules
+}
+
+FILES_${PN} += "/usr/lib/perl5 \
+		/usr/lib/mlx_ipmid \
+                ${systemd_unitdir} \
+                "
+
+FILES_${PN}-dev += "/usr/lib/OpenIPMI"
+
+FILES_${PN}-dbg += "/usr/lib/perl5/auto/OpenIPMI/.debug"
diff --git a/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid/mlx_ipmid.service b/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid/mlx_ipmid.service
new file mode 100644
index 0000000..09abe1e
--- /dev/null
+++ b/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid/mlx_ipmid.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=mlx_ipmid
+
+[Service]
+Restart=always
+OOMScoreAdjust=-1000
+
+ExecStart=/usr/bin/mlx_ipmid -n
+TimeoutSec=120
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid/remove_libdir.patch b/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid/remove_libdir.patch
new file mode 100644
index 0000000..e74e06f
--- /dev/null
+++ b/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid/remove_libdir.patch
@@ -0,0 +1,67 @@
+diff --git a/cmdlang/Makefile.am b/cmdlang/Makefile.am
+index e80090d..b59ff24 100644
+--- a/cmdlang/Makefile.am
++++ b/cmdlang/Makefile.am
+@@ -16,7 +16,7 @@ libOpenIPMIcmdlang_la_LIBADD = -lm \
+ 	$(top_builddir)/utils/libOpenIPMIutils.la \
+ 	$(top_builddir)/lib/libOpenIPMI.la
+ libOpenIPMIcmdlang_la_LDFLAGS = -rdynamic -version-info $(LD_VERSION) \
+-	-Wl,-Map -Wl,libOpenIPMIcmdlang.map -L$(libdir)
++	-Wl,-Map -Wl,libOpenIPMIcmdlang.map
+ 
+ bin_PROGRAMS = openipmish
+ 
+diff --git a/glib/Makefile.am b/glib/Makefile.am
+index 671cae2..eff55f3 100644
+--- a/glib/Makefile.am
++++ b/glib/Makefile.am
+@@ -11,14 +11,14 @@ libOpenIPMIglib_la_SOURCES = glib_os_hnd.c
+ libOpenIPMIglib_la_CFLAGS = $(GLIB_CFLAGS) $(AM_CFLAGS)
+ libOpenIPMIglib_la_LIBADD = $(GDBM_LIB)
+ libOpenIPMIglib_la_LDFLAGS = -rdynamic -version-info $(LD_VERSION) \
+-	-Wl,-Map -Wl,libOpenIPMIglib.map $(GLIB_LIBS) -L$(libdir) \
++	-Wl,-Map -Wl,libOpenIPMIglib.map $(GLIB_LIBS) \
+ 	-rpath $(libdir)
+ 
+ libOpenIPMIglib12_la_SOURCES = glib_os_hnd.c
+ libOpenIPMIglib12_la_CFLAGS = $(GLIB12_CFLAGS) $(AM_CFLAGS)
+ libOpenIPMIglib12_la_LIBADD = $(GDBM_LIB)
+ libOpenIPMIglib12_la_LDFLAGS = -rdynamic -version-info $(LD_VERSION) \
+-	-Wl,-Map -Wl,libOpenIPMIglib12.map $(GLIB12_LIBS) -L$(libdir) \
++	-Wl,-Map -Wl,libOpenIPMIglib12.map $(GLIB12_LIBS) \
+ 	-rpath $(libdir)
+ 
+ CLEANFILES = libOpenIPMIglib.map libOpenIPMIglib12.map
+diff --git a/tcl/Makefile.am b/tcl/Makefile.am
+index e2a98dc..256af0c 100644
+--- a/tcl/Makefile.am
++++ b/tcl/Makefile.am
+@@ -11,7 +11,7 @@ libOpenIPMItcl_la_SOURCES = tcl_os_hnd.c
+ libOpenIPMItcl_la_CFLAGS = $(TCL_CFLAGS) $(AM_CFLAGS)
+ libOpenIPMItcl_la_LIBADD = $(GDBM_LIB)
+ libOpenIPMItcl_la_LDFLAGS = -rdynamic -version-info $(LD_VERSION) \
+-	-Wl,-Map -Wl,libOpenIPMItcl.map $(TCL_LIBS) -L$(libdir) \
++	-Wl,-Map -Wl,libOpenIPMItcl.map $(TCL_LIBS) \
+ 	-rpath $(libdir)
+ 
+ noinst_PROGRAMS = test_handlers
+diff --git a/unix/Makefile.am b/unix/Makefile.am
+index ac5b9f4..d5d4b82 100644
+--- a/unix/Makefile.am
++++ b/unix/Makefile.am
+@@ -11,13 +11,13 @@ libOpenIPMIpthread_la_SOURCES = posix_thread_os_hnd.c selector.c
+ libOpenIPMIpthread_la_LIBADD = -lpthread $(GDBM_LIB) \
+ 	$(top_builddir)/utils/libOpenIPMIutils.la
+ libOpenIPMIpthread_la_LDFLAGS = -rdynamic -version-info $(LD_VERSION) \
+-	-Wl,-Map -Wl,libOpenIPMIpthread.map -L$(libdir)
++	-Wl,-Map -Wl,libOpenIPMIpthread.map
+ 
+ libOpenIPMIposix_la_SOURCES = posix_os_hnd.c selector.c
+ libOpenIPMIposix_la_LIBADD = $(top_builddir)/utils/libOpenIPMIutils.la \
+ 	$(GDBM_LIB)
+ libOpenIPMIposix_la_LDFLAGS = -rdynamic -version-info $(LD_VERSION) \
+-	-Wl,-Map -Wl,libOpenIPMIposix.map -L$(libdir)
++	-Wl,-Map -Wl,libOpenIPMIposix.map
+ 
+ noinst_HEADERS = heap.h
+ 
diff --git a/meta-mellanox/meta-msn/recipes-phosphor/images/obmc-phosphor-image.bbappend b/meta-mellanox/meta-msn/recipes-phosphor/images/obmc-phosphor-image.bbappend
new file mode 100644
index 0000000..fb6a244
--- /dev/null
+++ b/meta-mellanox/meta-msn/recipes-phosphor/images/obmc-phosphor-image.bbappend
@@ -0,0 +1 @@
+OBMC_IMAGE_EXTRA_INSTALL_append = " mlx-ipmid"