summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Thode <prometheanfire@gentoo.org>2015-08-05 02:14:33 +0000
committerMatthew Thode <prometheanfire@gentoo.org>2015-08-05 02:14:33 +0000
commit21e5fb92bba9f1ba381d32f70fd570a3eb12a283 (patch)
treece110466facc27ee0fd7e2e3e077aad50a022be5 /sys-block
parentBump (diff)
downloadgentoo-2-21e5fb92bba9f1ba381d32f70fd570a3eb12a283.tar.gz
gentoo-2-21e5fb92bba9f1ba381d32f70fd570a3eb12a283.tar.bz2
gentoo-2-21e5fb92bba9f1ba381d32f70fd570a3eb12a283.zip
adding udev scripts to generate symlinks for bug 556632
(Portage version: 2.2.20/cvs/Linux x86_64, signed Manifest commit with key 0x33ED3FD25AFC78BA)
Diffstat (limited to 'sys-block')
-rw-r--r--sys-block/open-iscsi/ChangeLog10
-rw-r--r--sys-block/open-iscsi/files/99-iscsi.rules1
-rw-r--r--sys-block/open-iscsi/files/iscsidev.sh77
-rw-r--r--sys-block/open-iscsi/open-iscsi-2.0.872-r3.ebuild112
4 files changed, 198 insertions, 2 deletions
diff --git a/sys-block/open-iscsi/ChangeLog b/sys-block/open-iscsi/ChangeLog
index 7a26aea0c980..d22dfae878fd 100644
--- a/sys-block/open-iscsi/ChangeLog
+++ b/sys-block/open-iscsi/ChangeLog
@@ -1,6 +1,12 @@
# ChangeLog for sys-block/open-iscsi
-# Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-block/open-iscsi/ChangeLog,v 1.61 2014/02/02 15:24:49 ago Exp $
+# Copyright 1999-2015 Gentoo Foundation; Distributed under the GPL v2
+# $Header: /var/cvsroot/gentoo-x86/sys-block/open-iscsi/ChangeLog,v 1.62 2015/08/05 02:14:33 prometheanfire Exp $
+
+*open-iscsi-2.0.872-r3 (05 Aug 2015)
+
+ 05 Aug 2015; Matthew Thode <prometheanfire@gentoo.org> +files/99-iscsi.rules,
+ +files/iscsidev.sh, +open-iscsi-2.0.872-r3.ebuild:
+ adding udev scripts to generate symlinks for bug 556632
02 Feb 2014; Agostino Sarubbo <ago@gentoo.org> open-iscsi-2.0.872-r2.ebuild:
Stable for alpha, wrt bug #498446
diff --git a/sys-block/open-iscsi/files/99-iscsi.rules b/sys-block/open-iscsi/files/99-iscsi.rules
new file mode 100644
index 000000000000..74c8e14bc540
--- /dev/null
+++ b/sys-block/open-iscsi/files/99-iscsi.rules
@@ -0,0 +1 @@
+KERNEL=="sd*", SUBSYSTEMS=="block", RUN{program}="/etc/udev/scripts/iscsidev.sh"
diff --git a/sys-block/open-iscsi/files/iscsidev.sh b/sys-block/open-iscsi/files/iscsidev.sh
new file mode 100644
index 000000000000..bcceb115ba69
--- /dev/null
+++ b/sys-block/open-iscsi/files/iscsidev.sh
@@ -0,0 +1,77 @@
+#!/usr/bin/env bash
+
+# KERNEL=="sd*", SUBSYSTEMS=="block", RUN{program}="/etc/udev/scripts/iscsidev.sh"
+
+# we only care about iscsi devices
+[[ $ID_VENDOR = "IET" ]] || exit 1
+
+# don't care about partitions either
+echo $DEVNAME | egrep -q "[0-9]$"
+status=$?
+[[ $status != 0 ]] || exit 1
+
+#ID_MODEL=VIRTUAL-DISK
+#ID_MODEL_ENC=VIRTUAL-DISK
+#ID_REVISION=0001
+#DEVTYPE=disk
+#ID_BUS=scsi
+#SUBSYSTEM=block
+#ID_SERIAL=1IET_00010001
+#DEVPATH=/devices/platform/host74/session68/target74:0:0/74:0:0:1/block/sde
+#ID_VENDOR_ENC=IET\x20\x20\x20\x20\x20
+#MINOR=64
+#ID_SCSI=1
+#ACTION=add
+#PWD=/
+#ID_PART_TABLE_UUID=54f71c65-a5d5-45cd-8915-5ffd5ff4fea6
+#ID_FS_TYPE=
+#USEC_INITIALIZED=999037905
+#MAJOR=8
+#ID_SCSI_SERIAL=beaf11
+#DEVLINKS=/dev/disk/by-id/scsi-1IET_00010001
+#DEVNAME=/dev/sde
+#SHLVL=1
+#ID_TYPE=disk
+#ID_PART_TABLE_TYPE=gpt
+#ID_VENDOR=IET
+#ID_SERIAL_SHORT=IET_00010001
+#SEQNUM=25775
+
+# do the removal
+if [[ $ACTION = 'remove' ]]; then
+ find -L /dev/disk/by-path/ -type l -lname ${DEVNAME} -exec rm "{}" + 2>/dev/null
+ exit 0
+fi
+
+TARGET_NAME=$(lsscsi -t | grep "${DEVNAME}" | awk '{print $3}' | awk -F, '{print $1}')
+[[ $TARGET_NAME = '' ]] && exit 1
+
+# we don't know which host is correct
+declare -a POSSIBLE_HOSTS
+declare -a POSSIBLE_PORTS
+for item in $(cat /sys/class/iscsi_connection/connection*/address); do
+ POSSIBLE_HOSTS+=("${item}")
+done
+for item in $(cat /sys/class/iscsi_connection/connection*/port); do
+ POSSIBLE_PORTS+=("${item}")
+done
+
+#get correct ip and port
+for ((i=0;i<${#POSSIBLE_HOSTS[@]};++i)); do
+ printf "%s is in %s\n" "$POSSIBLE_HOSTS[i]}" "${POSSIBLE_PORTS[i]}"
+ iscsiadm --mode node --targetname "${TARGET_NAME}" -p "${POSSIBLE_HOSTS[i]}":"${POSSIBLE_PORTS[i]}"
+ status=$?
+ if [[ $status = 0 ]]; then
+ TARGET_IP="${POSSIBLE_HOSTS[i]}"
+ TARGET_PORT="${POSSIBLE_PORTS[i]}"
+ break
+ fi
+done
+
+# exit if not found
+[[ -z $TARGET_IP ]] && exit 1
+[[ -z $TARGET_PORT ]] && exit 1
+
+# actually create the link
+mkdir -p /dev/disk/by-path/
+ln -s "${DEVNAME}" "/dev/disk/by-path/ip-${TARGET_IP}:${TARGET_PORT}-iscsi-${TARGET_NAME}-lun-1" \ No newline at end of file
diff --git a/sys-block/open-iscsi/open-iscsi-2.0.872-r3.ebuild b/sys-block/open-iscsi/open-iscsi-2.0.872-r3.ebuild
new file mode 100644
index 000000000000..c3464881c290
--- /dev/null
+++ b/sys-block/open-iscsi/open-iscsi-2.0.872-r3.ebuild
@@ -0,0 +1,112 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-block/open-iscsi/open-iscsi-2.0.872-r3.ebuild,v 1.1 2015/08/05 02:14:33 prometheanfire Exp $
+
+EAPI=2
+inherit versionator linux-info eutils flag-o-matic toolchain-funcs
+
+DESCRIPTION="Open-iSCSI is a high performance, transport independent, multi-platform implementation of RFC3720"
+HOMEPAGE="http://www.open-iscsi.org/"
+MY_PV="${PN}-$(replace_version_separator 2 "-" $MY_PV)"
+SRC_URI="http://www.open-iscsi.org/bits/${MY_PV}.tar.gz"
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86"
+IUSE="debug slp"
+DEPEND="slp? ( net-libs/openslp )"
+RDEPEND="${DEPEND}
+ virtual/udev
+ 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() {
+ export EPATCH_OPTS="-d${S}"
+ epatch "${FILESDIR}"/${PN}-2.0.872-makefile-cleanup.patch
+ epatch "${FILESDIR}"/${P}-glibc212.patch
+ epatch "${FILESDIR}"/${P}-dont-call-configure.patch
+ epatch "${FILESDIR}"/${P}-ldflags.patch
+ epatch "${FILESDIR}"/${P}-isns-slp.patch
+ epatch "${FILESDIR}"/${PN}-2.0.872-makefile-cleanup-pass2.patch
+}
+
+src_configure() {
+ cd utils/open-isns || die
+ econf $(use_with slp)
+}
+
+src_compile() {
+ use debug && append-flags -DDEBUG_TCP -DDEBUG_SCSI
+
+ einfo "Building userspace"
+ local SLP_LIBS
+ use slp && SLP_LIBS="-lslp"
+ cd "${S}" && \
+ KSRC="${KV_DIR}" CFLAGS="" \
+ emake \
+ OPTFLAGS="${CFLAGS}" SLP_LIBS="${SLP_LIBS}" \
+ AR="$(tc-getAR)" CC="$(tc-getCC)" \
+ user \
+ || die "emake failed"
+}
+
+src_install() {
+ einfo "Installing userspace"
+ dosbin usr/iscsid usr/iscsiadm usr/iscsistart || die
+
+ einfo "Installing utilities"
+ dosbin utils/iscsi-iname utils/iscsi_discovery || die
+
+ einfo "Installing docs"
+ doman doc/*[1-8] || die
+ dodoc README THANKS || die
+ docinto test || die
+ dodoc test/* || die
+
+ einfo "Installing configuration"
+ insinto /etc/iscsi
+ doins etc/iscsid.conf || die
+ newins "${FILESDIR}"/initiatorname.iscsi initiatorname.iscsi.example || die
+ insinto /etc/iscsi/ifaces
+ doins etc/iface.example || die
+
+ newconfd "${FILESDIR}"/${P}-conf.d iscsid || die
+ newinitd "${FILESDIR}"/${P}-init.d-r1 iscsid || die
+
+ # udev pieces
+ insinto /etc/udev/scripts
+ doins "${FILESDIR}"/iscsidev.sh
+ insinto /lib/udev/rules.d
+ doins "${FILESDIR}"/99-iscsi.rules
+
+ keepdir /var/db/iscsi
+ fperms 700 /var/db/iscsi || die
+ fperms 600 /etc/iscsi/iscsid.conf || die
+}
+
+pkg_postinst() {
+ in='/etc/iscsi/initiatorname.iscsi'
+ if [ ! -f "${ROOT}${in}" -a -f "${ROOT}${in}.example" ]; then
+ cp -f "${ROOT}${in}.example" "${ROOT}${in}"
+ fi
+}