project-lakitu : Modify open-isns and open-iscsi packages.

Generate patch to compile open-isns and open-iscsi packages.

BUG=b/179425963
TEST=presubmit
RELEASE_NOTE=Install open-iscsi package.

Change-Id: I00730645447d7762bd89be76c1336f89dbb0e775
Reviewed-on: https://cos-review.googlesource.com/c/cos/overlays/board-overlays/+/20491
Reviewed-by: Roy Yang <royyang@google.com>
Tested-by: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com>
diff --git a/project-lakitu/sys-block/open-iscsi/files/open-iscsi-2.1.1-Makefiles.patch b/project-lakitu/sys-block/open-iscsi/files/open-iscsi-2.1.1-Makefiles.patch
index 02e651e..daefcf2 100644
--- a/project-lakitu/sys-block/open-iscsi/files/open-iscsi-2.1.1-Makefiles.patch
+++ b/project-lakitu/sys-block/open-iscsi/files/open-iscsi-2.1.1-Makefiles.patch
@@ -1,3 +1,8 @@
+From: Meena Shanmugam
+Date: Wed, 04 Aug 2021
+Subject: With crbug/985180 all unprefixed compilers have been blocked.
+So pkg-config, gcc, rm commnads cannot be directly used. So modify the Makefiles to
+use -lsystemd, $GCC, $RM.
 --- a/libopeniscsiusr/Makefile
 +++ b/libopeniscsiusr/Makefile
 @@ -44,7 +44,7 @@ EXTRA_MAN_FILES = libopeniscsiusr.h.3
@@ -76,3 +81,50 @@
 +	$(CC) $(CFLAGS) -M `ls *.c` > .depend
  
  -include .depend
+diff --git a/usr/Makefile b/usr/Makefile
+index 21bb154..e5fcf14 100644
+--- a/usr/Makefile
++++ b/usr/Makefile
+@@ -42,7 +42,8 @@ CFLAGS += $(shell $(PKG_CONFIG) --cflags libkmod)
+ ISCSI_LIB = -L$(TOPDIR)/libopeniscsiusr -lopeniscsiusr
+ LDFLAGS += $(shell $(PKG_CONFIG) --libs libkmod)
+ ifeq ($(NO_SYSTEMD),)
+-LDFLAGS += $(shell $(PKG_CONFIG) --libs libsystemd)
++#LDFLAGS += $(shell $(PKG_CONFIG) --libs libsystemd)
++LDFLAGS += -lsystemd
+ endif
+ PROGRAMS = iscsid iscsiadm iscsistart
+
+diff --git a/iscsiuio/src/unix/Makefile.am b/iscsiuio/src/unix/Makefile.am
+index a989ef0..6ffc607 100644
+--- a/iscsiuio/src/unix/Makefile.am
++++ b/iscsiuio/src/unix/Makefile.am
+@@ -31,7 +31,8 @@ iscsiuio_LDFLAGS= 	$(AM_LDADD)		\
+ 			-ldl			\
+ 			-rdynamic		\
+ 			$(LIBNL_LIBS)		\
+-			-lpthread
++			-lpthread               \
++			-lsystemd
+ 
+ iscsiuio_LDADD  = 	${top_srcdir}/src/uip/lib_iscsi_uip.a	\
+ 			${top_srcdir}/src/apps/dhcpc/lib_apps_dhcpc.a\
+
+diff --git a/iscsiuio/configure.ac b/iscsiuio/configure.ac
+index 8099f09..e1e7947 100644
+--- a/iscsiuio/configure.ac
++++ b/iscsiuio/configure.ac
+@@ -67,10 +67,10 @@ AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])
+ AC_ARG_WITH([systemd],
+ 	    AS_HELP_STRING([--without-systemd], [Build without systemd]),
+     [case "${withval}" in
+-     yes) LDFLAGS="`pkg-config --libs libsystemd`" ;;
++     yes) LDFLAGS="-lsystemd" ;;
+      no)  CFLAGS="${CFLAGS} -DNO_SYSTEMD" ;;
+      *)   AC_MSG_ERROR([bad value $withval for --with-systemd]) ;;
+-     esac],[LDFLAGS="`pkg-config --libs libsystemd`"])
++     esac],[LDFLAGS="-lsystemd"])
+ 
+ AC_CONFIG_COMMANDS([default],[[
+     if [ -n "$SOURCE_DATE_EPOCH" ] ; then
+
diff --git a/project-lakitu/sys-block/open-iscsi/open-iscsi-2.1.3-r1.ebuild b/project-lakitu/sys-block/open-iscsi/open-iscsi-2.1.3-r1.ebuild
new file mode 120000
index 0000000..39a19b0
--- /dev/null
+++ b/project-lakitu/sys-block/open-iscsi/open-iscsi-2.1.3-r1.ebuild
@@ -0,0 +1 @@
+open-iscsi-2.1.3.ebuild
\ No newline at end of file
diff --git a/project-lakitu/sys-block/open-iscsi/open-iscsi-2.1.3.ebuild b/project-lakitu/sys-block/open-iscsi/open-iscsi-2.1.3.ebuild
index 0dea508..07b62ce 100644
--- a/project-lakitu/sys-block/open-iscsi/open-iscsi-2.1.3.ebuild
+++ b/project-lakitu/sys-block/open-iscsi/open-iscsi-2.1.3.ebuild
@@ -11,7 +11,7 @@
 
 LICENSE="GPL-2"
 SLOT="0/0.2"
-KEYWORDS="~alpha amd64 arm arm64 ~ia64 ~mips ppc ppc64 sparc x86"
+KEYWORDS="*"
 IUSE="debug infiniband +tcp rdma systemd"
 
 DEPEND="
@@ -22,8 +22,9 @@
 	dev-libs/openssl:0=
 	sys-apps/systemd
 "
+# lakitu: remove lsscsi utility as it is not used.
+#	sys-fs/lsscsi
 RDEPEND="${DEPEND}
-	sys-fs/lsscsi
 	sys-apps/util-linux"
 BDEPEND="virtual/pkgconfig"
 
@@ -121,10 +122,12 @@
 	for unit in ${units[@]} ; do
 		systemd_dounit etc/systemd/${unit}
 	done
-
-	keepdir /var/db/iscsi
-	fperms 700 /var/db/iscsi
+	# lakitu: don't keep any directories/files in var as emerge expects it
+	# to be empty.
+	# keepdir /var/db/iscsi
+	# fperms 700 /var/db/iscsi
 	fperms 600 /etc/iscsi/iscsid.conf
+	systemd_enable_service multi-user.target iscsid.service
 }
 
 pkg_postinst() {
diff --git a/project-lakitu/sys-block/open-isns/files/open-isns-0.100-Makefile.patch b/project-lakitu/sys-block/open-isns/files/open-isns-0.100-Makefile.patch
new file mode 100644
index 0000000..ec64478
--- /dev/null
+++ b/project-lakitu/sys-block/open-isns/files/open-isns-0.100-Makefile.patch
@@ -0,0 +1,15 @@
+diff --git a/Makefile.in b/Makefile.in
+index f001a87..68a206f 100644
+From: Meena Shanmugam
+Date: Wed, 04 Aug 2021
+Subject: Do not install /var directory as it is not used.
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -110,7 +110,6 @@ all: $(LIB) $(SOLIB) isnsd isnsadm isnsdd $(TESTS)
+ install:
+ 	@echo "*** Installing Open-iSNS ***"
+ 	$(INSTALL) -m 755 -d $(CFGDIR) $(MANDIR)/man8 $(MANDIR)/man5 $(SBINDIR) $(SYSTEMDDIR)
+-	$(INSTALL) -m 700 -d $(VARDIR)
+ 	$(INSTALL) -m 555 isnsd isnsadm isnsdd $(SBINDIR)
+ 	$(INSTALL) -m 644 $(srcdir)/etc/isnsd.conf $(CFGDIR)
+ 	$(INSTALL) -m 644 $(srcdir)/etc/isnsdd.conf $(CFGDIR)
diff --git a/project-lakitu/sys-block/open-isns/open-isns-0.101-r1.ebuild b/project-lakitu/sys-block/open-isns/open-isns-0.101-r1.ebuild
new file mode 120000
index 0000000..d039be7
--- /dev/null
+++ b/project-lakitu/sys-block/open-isns/open-isns-0.101-r1.ebuild
@@ -0,0 +1 @@
+open-isns-0.101.ebuild
\ No newline at end of file
diff --git a/project-lakitu/sys-block/open-isns/open-isns-0.101.ebuild b/project-lakitu/sys-block/open-isns/open-isns-0.101.ebuild
index 3959779..732e000 100644
--- a/project-lakitu/sys-block/open-isns/open-isns-0.101.ebuild
+++ b/project-lakitu/sys-block/open-isns/open-isns-0.101.ebuild
@@ -11,7 +11,7 @@
 
 LICENSE="LGPL-2.1"
 SLOT="0"
-KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86"
+KEYWORDS="*"
 IUSE="debug ssl static"
 
 DEPEND="
@@ -23,6 +23,7 @@
 
 PATCHES=(
 	"${FILESDIR}/${PN}-0.100-respect-AR.patch"
+	"${FILESDIR}/${PN}-0.100-Makefile.patch"
 )
 
 src_prepare() {
@@ -46,7 +47,9 @@
 	default
 	emake DESTDIR="${D}" install_hdrs
 	emake DESTDIR="${D}" install_lib
-	keepdir /var/lib/${PN/open-}
+	# lakitu: don't keep any directories/files in var as emerge expects it
+	# to be empty.
+	# keepdir /var/lib/${PN/open-}
 	if ! use static ; then
 		find "${ED}" -type f -name "*.a" -delete || die
 	fi