Commits

Doug Freed committed b7da656

sys-block/open-iscsi: Patched for 32/64 systems

Patched version of open-iscsi to fix a bug caused by misalignment in 32
bit userspace / 64 bit kernel environments.

Package-Manager: portage-2.2.8-r1

  • Participants
  • Parent commits 4903c06

Comments (0)

Files changed (9)

File profiles/package.mask

+####################################################################
+# $Header: /var/cvsroot/gentoo-x86/profiles/package.mask,v 1.15383 2014/02/05 07:50:31 pinkbyte Exp $
+#
+# When you add an entry to the top of this file, add your name, the date, and
+# an explanation of why something is getting masked. Please be extremely
+# careful not to commit atoms that are not valid, as it can cause large-scale
+# breakage, especially if it ends up in the daily snapshot.
+#
+## Example:
+##
+## # Dev E. Loper <developer@gentoo.org> (28 Jun 2012)
+## # Masking  these versions until we can get the
+## # v4l stuff to work properly again
+## =media-video/mplayer-0.90_pre5
+## =media-video/mplayer-0.90_pre5-r1
+#
+# - Best last rites (removal) practices -
+# Include the following info:
+# a) reason for masking
+# b) bug # for the removal (and yes you should have one)
+# c) date of removal (either the date or "in x days")
+#
+## Example:
+##
+## # Dev E. Loper <developer@gentoo.org> (25 Jan 2013)
+## # Masked for removal in 30 days.  Doesn't work
+## # with new libfoo. Upstream dead, gtk-1, smells
+## # funny. (bug #987654)
+## app-misc/some-package
+
+#--- END OF EXAMPLES ---
+
+# Douglas Freed <dwfreed@mtu.edu> (6 Feb 2014)
+# Breaks 32 bit ABI.  Unmask only on 32 bit
+# userspace with 64 bit kernel.
+=sys-block/open-iscsi-2.0.873-r1

File sys-block/open-iscsi/Manifest

+AUX fix-alignment.patch 953 SHA256 5010765904e77724c99ecc33912ebd9e67affc4d0b3070bf5c53b6d7e1407aca SHA512 a873679adb7c89156e28d5a5408bc875132a9a23e9261b093de2b656c2befe87ae8feb4b13efdb9ec0751fe17eae20e3261f86eb153907af99e51bf086d59768 WHIRLPOOL 095fe9f524387e6ec8b021918e4e23f8b9d2e67bc6c869fa0c62f7035b100d88cebabd451741a92da85e6122ddf187e9e8b308a0c1e5aa9bda7f6764deb28b78
+AUX initiatorname.iscsi 1282 SHA256 4ae558522881796f67ad5915ecf38d01e64c9d9768469847adb17405404485f3 SHA512 c37990050123c6f805016f009a3d09452db2a3cfbb359efa50350c7ff4b6adc75bc1f8aba26190829729b75639b8e52c77f31bd719c5f945869941f651121743 WHIRLPOOL 7ff4ef48a7d3decc96160681a8ed82b6848b238ac38f8973d3e5da12e346a0c26f7bee67d7ba81197b9fecb679e9046e6fec85f90d97068aa622aceca875bda0
+AUX iscsid-conf.d 422 SHA256 3e2a63143e3167f20844ef94f1383180b69c245092583856fd26316674cf4114 SHA512 d197bbe2ce610cc2d4a1269c8d7a067ca5e3b0f3d8bb0804c2c39e0cf512bcbf7b5de45b7d6ffd5cf918dc395c7cf32c40e64b4348d00a4d0223ee44c463709a WHIRLPOOL 19e7dc2d647a271dd67bf2f92e3c866719b1a7c978ecc86395d3586ab0c897e93ab4dce740497a6139f4fae1c5a34c455b806c627c9a9f876133d808890a85bf
+AUX iscsid-init.d 2206 SHA256 9462e7018527f6ec26db623694070a6d2e834af8e174439ecb3ee5b5cab6da5d SHA512 bbd3e120a08cbc506ceec9bf2cec0b1ef9a379b9e39339cfedf68bd0f1bff4185877c305a9276eb7a6da3c33e866439c0bc781f1c92411c4173b15704a1fbab6 WHIRLPOOL 8a7e38f380e9b1c3d9993ed6ed06fb1efe1ff740fad264747f8f433842acb318ad63125dd37865018c8d220cc45d76dad51e3fa258fc0c2fd036e4a07fe50f51
+AUX open-iscsi-2.0.873-Makefiles.patch 5441 SHA256 8b12789550bef694d49a4bf89752c5bd3e60ca9c7ce63d6268f49bf672af317f SHA512 8dd3433db748f2fd0da0ab6a1059d7058eb09c527e9d039e768bc359a6b665da3e5c13463c32f35d7c630a3b901a689315ece3adb88cccabe452352658705f33 WHIRLPOOL 2115505cc80080454f810f973dd2b80ee6dd6567e2e3a9e2d1d3b4457e2bd3254958d6cdeae7bbce3e3f38c86a577d2900f11e5321b21b264658f38b171ebb8e
+DIST open-iscsi-2.0-873.tar.gz 667069 SHA256 7dd9f2f97da417560349a8da44ea4fcfe98bfd5ef284240a2cc4ff8e88ac7cd9 SHA512 4e67116cb7dd49381c9279645e5a661f05596ae6be3b832772089828b3764ca2d04b5dea1bcc337071efb52c3c75a6fb943136c659ee59500f3a198ed0dcea6b WHIRLPOOL 05af106f11da9f9f02c10edd5412d0f99816349e06e192059700eb1ae24a36027c3f0d7ed423aa7bb1c0b9d8b3aa1b6aa72a2aadb00f27762edf16b7f7d08c09
+EBUILD open-iscsi-2.0.873-r1.ebuild 2211 SHA256 498a5260c247b9a45ccb40bf93e88ca129e27c188500a1c6653868d9f85888fd SHA512 fa3ebdde8bca6b4291b6fa68f333456b2577090ce5a7f8c29df49fc71d9c0e4aac288dc3629ae50e41aef92e04b139ad3265388566e5848a8a70420ca1ea0e3a WHIRLPOOL 4ea18ccc5d8530bc8fcccea57b27234c6084d059d8d8dc2ecd0d9609c0dfc1e09b6eb71298a6d0f4841ac31e2eb4d9f165bcc186c12e3f8f8be3f68683b09f28
+MISC metadata.xml 166 SHA256 a33d3505ea834e19cd196ef8af9d438f1e476abb2aca27b0ea9f1219e93b8b26 SHA512 9a924987983984221311fc13539b270e032c8a18bfb2e863480dd4be10d36f3ec22d6824cc443c4dcbd34a6a0abce33ba70eeb90766122e072d442216af4f8dc WHIRLPOOL c28ad7db1ab0447a86899c0b1e504795754cc1ac75250e1b81ddb3ea1ea318abdeca1712695d18f8a12ff8b72e73b4cefef35adc05eb15a448aff88e7bd4b330

File sys-block/open-iscsi/files/fix-alignment.patch

+diff --git a/include/iscsi_if.h b/include/iscsi_if.h
+index dad9fd8..71171ab 100644
+--- a/include/iscsi_if.h
++++ b/include/iscsi_if.h
+@@ -131,7 +131,7 @@ struct iscsi_uevent {
+ 			uint32_t	cid;
+ 			uint64_t	transport_eph;
+ 			uint32_t	is_leading;
+-		} b_conn;
++		} b_conn __attribute__((aligned (sizeof(uint64_t))));
+ 		struct msg_destroy_conn {
+ 			uint32_t	sid;
+ 			uint32_t	cid;
+@@ -157,7 +157,7 @@ struct iscsi_uevent {
+ 			uint32_t	cid;
+ 			uint64_t	conn_handle;
+ 			uint32_t	flag;
+-		} stop_conn;
++		} stop_conn __attribute__((aligned (sizeof(uint64_t))));
+ 		struct msg_get_stats {
+ 			uint32_t	sid;
+ 			uint32_t	cid;
+@@ -206,7 +206,7 @@ struct iscsi_uevent {
+ 			uint32_t	payload_size;
+ 			uint32_t	pid;	/* unique ping id associated
+ 						   with each ping request */
+-		} iscsi_ping;
++		} iscsi_ping __attribute__((aligned (sizeof(uint64_t))));
+ 		struct msg_get_chap {
+ 			uint32_t	host_no;
+ 			uint32_t	num_entries; /* number of CHAP entries

File sys-block/open-iscsi/files/initiatorname.iscsi

+# Copyright 1999-2005 Gentoo Technologies, Inc.
+# Distributed under the terms of the GNU General Public License, v2 or later
+# $Header: /var/cvsroot/gentoo-x86/sys-block/open-iscsi/files/initiatorname.iscsi,v 1.2 2006/03/08 09:19:25 robbat2 Exp $
+#
+# This file must contain a InitiatorName entry!
+# white space is significent here!
+#InitiatorName=iqn.2005-09.tld.domain.hostname:openiscsi-initiator
+#InitiatorAlias=foobar
+
+# Sample documentation follows:
+
+# The InitiatorName should take the following format
+# iqn.${YEAR}-${MONTH}-${DOMAIN_REVERSED}.${HOSTNAME}:${UNIQUE_STRING}
+# Where YEAR and MONTH are the dates that your domain was registered.
+# You can use WHOIS to find when your domain was registered.
+# If you don't have a real domain in the outside world, invent one, but use
+# .local for your top-level.
+
+# Example case #1:
+# This assumes you own foobar.co.uk.
+# Domain name: foobar.co.uk.
+# Registration date: March 2001
+# Hostname: linux
+# InitiatorName=iqn.2001-03.uk.co.foobar.linux:openiscsi-29b48ad602d5f83dd9cd9aa3ef741216
+
+# Example case #2:
+# This assumes you don't have a domain of your own.
+# Domain name: foobar.local
+# Registration date: March 2001
+# Hostname: linux
+# InitiatorName=iqn.2001-03.local.foobar.linux:openiscsi-29b48ad602d5f83dd9cd9aa3ef741216

File sys-block/open-iscsi/files/iscsid-conf.d

+# /etc/conf.d/iscsid
+
+# config file to use
+CONFIG_FILE=/etc/iscsi/iscsid.conf
+
+# you need to specify an initiatorname in the file
+INITIATORNAME_FILE=/etc/iscsi/initiatorname.iscsi
+
+# options to pass to iscsid
+OPTS="-i ${INITIATORNAME_FILE}"
+
+# Start automatic targets when iscsid is started
+AUTOSTARTTARGETS="yes"
+
+# if set to "strict", iscsid will stop, if connecting the
+# autostart targets failed
+# AUTOSTART="strict"
+

File sys-block/open-iscsi/files/iscsid-init.d

+#!/sbin/runscript
+# Copyright 1999-2013 Gentoo Foundation, Inc.
+# Distributed under the terms of the GNU General Public License, v2 or later
+# $Header: /var/cvsroot/gentoo-x86/sys-block/open-iscsi/files/iscsid-init.d,v 1.8 2013/10/20 20:19:52 idl0r Exp $
+
+command="/usr/sbin/iscsid"
+command_args="${OPTS}"
+start_stop_daemon_args="-w 10" # iscsid might fail e.g. when the iSCSI kernel modules aren't available
+pidfile=${PIDFILE:-/var/run/${SVCNAME}.pid}
+
+extra_started_commands="starttargets stoptargets"
+extra_commands="restarttargets"
+
+ISCSIADM=/usr/sbin/iscsiadm
+
+depend() {
+	after modules multipath
+	use net
+}
+
+checkconfig() {
+	if [ ! -e /etc/conf.d/${SVCNAME} ]; then
+		eerror "Config file /etc/conf.d/${SVCNAME} does not exist!"
+		return 1
+	fi
+	if [ ! -e "${CONFIG_FILE}" ]; then
+		eerror "Config file ${CONFIG_FILE} does not exist!"
+		return 1
+	fi
+
+	if [ -e ${INITIATORNAME_FILE} ]; then
+		. ${INITIATORNAME_FILE}
+	fi
+	if [ ! -e ${INITIATORNAME_FILE} -o -z "${InitiatorName}" ]; then
+		ewarn "${INITIATORNAME_FILE} should contain a string with your initiatior name."
+		local IQN=$(/usr/sbin/iscsi-iname)
+		ebegin "Creating InitiatorName ${IQN} in ${INITIATORNAME_FILE}"
+		echo "InitiatorName=${IQN}" >> "${INITIATORNAME_FILE}"
+		eend $?
+	fi
+}
+
+starttargets() {
+	ebegin "Setting up iSCSI targets"
+	$ISCSIADM -m node --loginall=automatic
+	local ret=$?
+	eend $ret
+	return $ret
+}
+
+stoptargets() {
+	ebegin "Disconnecting iSCSI targets"
+	sync
+	$ISCSIADM -m node --logoutall=all
+	local ret=$?
+
+	if [ $ret -eq 21 ]; then
+		# See man iscsiadm(8)
+		einfo "No active sessions to disconnect"
+		eend 0
+		return 0
+	fi
+
+	eend $ret
+	return $ret
+}
+
+restarttargets() {
+        stoptargets
+        starttargets
+}
+
+status() {
+	ebegin "Showing current active iSCSI sessions"
+	$ISCSIADM -m session
+}
+
+
+start_pre() {
+	local ret=1
+
+	ebegin "Checking Open-iSCSI configuration"
+	checkconfig
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		eend 1
+		return 1
+	fi
+	eend 0
+}
+
+start_post() {
+	# Start automatic targets when iscsid is started
+	if [ "${AUTOSTARTTARGETS}" = "yes" ]; then
+		starttargets
+		local ret=$?
+		if [ "${AUTOSTART}" = "strict" -a $ret -ne 0 ]; then
+			stop
+			return $ret
+		fi
+	fi
+	return 0
+}
+
+stop_pre() {
+	stoptargets
+}

File sys-block/open-iscsi/files/open-iscsi-2.0.873-Makefiles.patch

+diff --git a/Makefile b/Makefile
+index c5d9700..4dbff18 100644
+--- a/Makefile
++++ b/Makefile
+@@ -14,8 +14,8 @@ mandir = $(prefix)/share/man
+ etcdir = /etc
+ initddir = $(etcdir)/init.d
+ 
+-MANPAGES = doc/iscsid.8 doc/iscsiadm.8 doc/iscsi_discovery.8
+-PROGRAMS = usr/iscsid usr/iscsiadm utils/iscsi_discovery utils/iscsi-iname
++MANPAGES = doc/iscsid.8 doc/iscsiadm.8 doc/iscsi_discovery.8 doc/iscsistart.8 doc/iscsi-iname.8
++PROGRAMS = usr/iscsid usr/iscsiadm utils/iscsi_discovery utils/iscsi-iname usr/iscsistart
+ INSTALL = install
+ ETCFILES = etc/iscsid.conf
+ IFACEFILES = etc/iface.example
+@@ -84,11 +84,11 @@ install_programs:  $(PROGRAMS)
+ # ugh, auto-detection is evil
+ # Gentoo maintains their own init.d stuff
+ install_initd:
+-	if [ -f /etc/debian_version ]; then \
++	if [ -f $(DESTDIR)$(etcdir)/debian_version ]; then \
+ 		$(MAKE) install_initd_debian ; \
+-	elif [ -f /etc/redhat-release ]; then \
++	elif [ -f $(DESTDIR)$(etcdir)/redhat-release ]; then \
+ 		$(MAKE) install_initd_redhat ; \
+-	elif [ -f /etc/SuSE-release ]; then \
++	elif [ -f $(DESTDIR)$(etcdir)/SuSE-release ]; then \
+ 		$(MAKE) install_initd_suse ; \
+ 	fi
+ 
+@@ -115,7 +115,7 @@ install_iface: $(IFACEFILES)
+ 	$(INSTALL) -m 644 $^ $(DESTDIR)$(etcdir)/iscsi/ifaces
+ 
+ install_etc: $(ETCFILES)
+-	if [ ! -f /etc/iscsi/iscsid.conf ]; then \
++	if [ ! -f $(DESTDIR)$(etcdir)/iscsi/iscsid.conf ]; then \
+ 		$(INSTALL) -d $(DESTDIR)$(etcdir)/iscsi ; \
+ 		$(INSTALL) -m 644 $^ $(DESTDIR)$(etcdir)/iscsi ; \
+ 	fi
+@@ -128,11 +128,11 @@ install_kernel:
+ 	$(MAKE) -C kernel install_kernel
+ 
+ install_iname:
+-	if [ ! -f /etc/iscsi/initiatorname.iscsi ]; then \
+-		echo "InitiatorName=`$(DESTDIR)/sbin/iscsi-iname`" > $(DESTDIR)/etc/iscsi/initiatorname.iscsi ; \
++	if [ ! -f $(DESTDIR)$(etcdir)/iscsi/initiatorname.iscsi ]; then \
++		echo "InitiatorName=`$(DESTDIR)$(sbindir)/iscsi-iname`" > $(DESTDIR)$(etcdir)/iscsi/initiatorname.iscsi ; \
+ 		echo "***************************************************" ; \
+-		echo "Setting InitiatorName to `cat $(DESTDIR)/etc/iscsi/initiatorname.iscsi`" ; \
+-		echo "To override edit /etc/iscsi/initiatorname.iscsi" ; \
++		echo "Setting InitiatorName to `cat $(DESTDIR)$(etcdir)/iscsi/initiatorname.iscsi`" ; \
++		echo "To override edit $(etcdir)/iscsi/initiatorname.iscsi" ; \
+ 		echo "***************************************************" ; \
+ 	fi
+ 
+diff --git a/usr/Makefile b/usr/Makefile
+index 673b7f1..83507f3 100644
+--- a/usr/Makefile
++++ b/usr/Makefile
+@@ -54,18 +54,18 @@ all: $(PROGRAMS)
+ 
+ iscsid: $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(DISCOVERY_SRCS) \
+ 	iscsid.o session_mgmt.o discoveryd.o
+-	$(CC) $(CFLAGS) $^ -o $@  -L../utils/open-isns -lisns
++	$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@  -L../utils/open-isns -lisns
+ 
+ iscsiadm: $(ISCSI_LIB_SRCS) $(DISCOVERY_SRCS) iscsiadm.o session_mgmt.o
+-	$(CC) $(CFLAGS) $^ -o $@ -L../utils/open-isns -lisns
++	$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ -L../utils/open-isns -lisns
+ 
+ iscsistart: $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(FW_BOOT_SRCS) \
+ 		iscsistart.o statics.o
+-	$(CC) $(CFLAGS) -static $^ -o $@
++	$(CC) $(CFLAGS) -static $(LDFLAGS) $^ -o $@
+ clean:
+-	rm -f *.o $(PROGRAMS) .depend $(LIBSYS)
++	$(RM) *.o $(PROGRAMS) .depend $(LIBSYS)
+ 
+ depend:
+-	gcc $(CFLAGS) -M `ls *.c` > .depend
++	$(CC) $(CFLAGS) -M `ls *.c` > .depend
+ 
+ -include .depend
+diff --git a/utils/Makefile b/utils/Makefile
+index 2c7e891..62c49fa 100644
+--- a/utils/Makefile
++++ b/utils/Makefile
+@@ -1,17 +1,18 @@
+ # This Makefile will work only with GNU make.
+ 
+-CFLAGS += $(OPTFLAGS) -O2 -fno-inline -Wall -Wstrict-prototypes -g
++OPTFLAGS ?= -O2 -g
++CFLAGS += $(OPTFLAGS) -fno-inline -Wall -Wstrict-prototypes
+ PROGRAMS = iscsi-iname
+ 
+ all: $(PROGRAMS)
+ 
+ iscsi-iname: md5.o iscsi-iname.o
+-	$(CC) $(CFLAGS) $^ $(DBM_LIB) -o $@
++	$(CC) $(CFLAGS) $(LDFLAGS) $^ $(DBM_LIB) -o $@
+ 
+ clean:
+-	rm -f *.o $(PROGRAMS) .depend
++	$(RM) *.o $(PROGRAMS) .depend
+ 
+ depend:
+-	gcc $(CFLAGS) -M `ls *.c` > .depend
++	$(GCC) $(CFLAGS) -M `ls *.c` > .depend
+ 
+ -include .depend
+diff --git a/utils/fwparam_ibft/Makefile b/utils/fwparam_ibft/Makefile
+index c72bb7f..a36c2d2 100644
+--- a/utils/fwparam_ibft/Makefile
++++ b/utils/fwparam_ibft/Makefile
+@@ -26,18 +26,18 @@ OBJS := fw_entry.o fwparam_sysfs.o $(SYSDEPS_OBJS) ../../usr/iscsi_net_util.o
+ OBJS += prom_lex.o prom_parse.tab.o fwparam_ppc.o
+ CLEANFILES = $(OBJS) *.output *~
+ 
+-OPTFLAGS ?= -O2 -g -fPIC
++OPTFLAGS ?= -O2 -g
+ WARNFLAGS ?= -Wall -Wstrict-prototypes
+-CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -I../../include -I../../usr -D_GNU_SOURCE
++CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -fPIC -I../../include -I../../usr -D_GNU_SOURCE
+ 
+ all: $(OBJS)
+ 
+ clean:
+-	rm -f *.o $(CLEANFILES) .depend
++	$(RM) *.o $(CLEANFILES) .depend
+ 
+ $(OBJS): prom_parse.tab.h prom_parse.h fwparam_ibft.h
+ 
+ depend:
+-	gcc $(CFLAGS) -M `ls *.c` > .depend
++	$(CC) $(CFLAGS) -M `ls *.c` > .depend
+ 
+ -include .depend
+diff --git a/utils/sysdeps/Makefile b/utils/sysdeps/Makefile
+index 53c10e5..19cfe19 100644
+--- a/utils/sysdeps/Makefile
++++ b/utils/sysdeps/Makefile
+@@ -1,15 +1,16 @@
+ # This Makefile will work only with GNU make.
+ 
+-CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -O2 -fno-inline -Wall -Wstrict-prototypes -g
++OPTFLAGS ?= -O2 -g
++CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -fno-inline -Wall -Wstrict-prototypes
+ 
+ SYSDEPS_OBJS=sysdeps.o
+ 
+ all: $(SYSDEPS_OBJS)
+ 
+ clean:
+-	rm -f *.o .depend
++	$(RM) *.o .depend
+ 
+ depend:
+-	gcc $(CFLAGS) -M `ls *.c` > .depend
++	$(CC) $(CFLAGS) -M `ls *.c` > .depend
+ 
+ -include .depend

File sys-block/open-iscsi/metadata.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+  <herd>base-system</herd>
+</pkgmetadata>

File sys-block/open-iscsi/open-iscsi-2.0.873-r1.ebuild

+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+EAPI=5
+
+inherit versionator linux-info eutils flag-o-matic toolchain-funcs
+
+MY_PV="${PN}-$(replace_version_separator 2 "-" $MY_PV)"
+
+DESCRIPTION="Open-iSCSI is a high performance, transport independent, multi-platform implementation of RFC3720"
+HOMEPAGE="http://www.open-iscsi.org/"
+SRC_URI="http://www.open-iscsi.org/bits/${MY_PV}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS=""
+IUSE="debug slp"
+
+DEPEND="slp? ( net-libs/openslp )"
+RDEPEND="${DEPEND}
+	sys-apps/util-linux"
+
+S="${WORKDIR}/${MY_PV}"
+
+pkg_setup() {
+	linux-info_pkg_setup
+
+	if kernel_is -lt 2 6 16; then
+		die "Sorry, your kernel must be 2.6.16-rc5 or newer!"
+	fi
+
+	# Needs to be done, as iscsid currently only starts, when having the iSCSI
+	# support loaded as module. Kernel builtion options don't work. See this for
+	# more information:
+	# http://groups.google.com/group/open-iscsi/browse_thread/thread/cc10498655b40507/fd6a4ba0c8e91966
+	# If there's a new release, check whether this is still valid!
+	CONFIG_CHECK_MODULES="SCSI_ISCSI_ATTRS ISCSI_TCP"
+	if linux_config_exists; then
+		for module in ${CONFIG_CHECK_MODULES}; do
+			linux_chkconfig_module ${module} || ewarn "${module} needs to be built as module (builtin doesn't work)"
+		done
+	fi
+}
+
+src_prepare() {
+	epatch "${FILESDIR}"/${P}-Makefiles.patch
+	epatch "${FILESDIR}"/fix-alignment.patch
+
+	sed -i -e 's:^\(iscsid.startup\)\s*=.*:\1 = /usr/sbin/iscsid:' etc/iscsid.conf || die
+}
+
+src_configure() {
+	cd utils/open-isns || die
+
+	# SSL (--with-security) is broken
+	econf $(use_with slp) \
+		--without-security
+}
+
+src_compile() {
+	use debug && append-flags -DDEBUG_TCP -DDEBUG_SCSI
+
+	KSRC="${KV_DIR}" CFLAGS="" \
+	emake \
+		OPTFLAGS="${CFLAGS}" \
+		AR="$(tc-getAR)" CC="$(tc-getCC)" \
+		user
+}
+
+src_install() {
+	emake DESTDIR="${D}" sbindir="${ROOT}usr/sbin/" install
+
+	dodoc README THANKS
+
+	docinto test/
+	dodoc test/*
+
+	newins "${FILESDIR}"/initiatorname.iscsi initiatorname.iscsi.example
+
+	newconfd "${FILESDIR}"/iscsid-conf.d iscsid
+	newinitd "${FILESDIR}"/iscsid-init.d iscsid
+
+	keepdir /var/db/iscsi
+	fperms 700 /var/db/iscsi
+	fperms 600 /etc/iscsi/iscsid.conf
+}