summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKacper Kowalik <xarthisius@gentoo.org>2012-03-14 10:07:11 +0000
committerKacper Kowalik <xarthisius@gentoo.org>2012-03-14 10:07:11 +0000
commit6fc727891ce8d1f7af50852947fde4d86d0b1690 (patch)
tree6b4f62b82563cd2bcfa3e1851b55419a9b75b33c /sys-block
parentBlock old version of app-emulation/emul-linux-x86-soundlibs for file collisio... (diff)
downloadgentoo-2-6fc727891ce8d1f7af50852947fde4d86d0b1690.tar.gz
gentoo-2-6fc727891ce8d1f7af50852947fde4d86d0b1690.tar.bz2
gentoo-2-6fc727891ce8d1f7af50852947fde4d86d0b1690.zip
Allow to pass options to daemon via confd file. Fixes 408107 bug by Christian Bricart <christian@bricart.de> Improve sed to add LDFLAGS only where they're needed, respect CC properly
(Portage version: 2.2.0_alpha90/cvs/Linux x86_64)
Diffstat (limited to 'sys-block')
-rw-r--r--sys-block/tgt/ChangeLog10
-rw-r--r--sys-block/tgt/files/tgtd-1.0.24.confd4
-rw-r--r--sys-block/tgt/files/tgtd-1.0.24.initd126
-rw-r--r--sys-block/tgt/tgt-1.0.24-r1.ebuild (renamed from sys-block/tgt/tgt-1.0.24.ebuild)14
4 files changed, 147 insertions, 7 deletions
diff --git a/sys-block/tgt/ChangeLog b/sys-block/tgt/ChangeLog
index a60ebf7e2576..f7f21c92124a 100644
--- a/sys-block/tgt/ChangeLog
+++ b/sys-block/tgt/ChangeLog
@@ -1,6 +1,14 @@
# ChangeLog for sys-block/tgt
# Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-block/tgt/ChangeLog,v 1.18 2012/02/04 16:54:30 alexxy Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-block/tgt/ChangeLog,v 1.19 2012/03/14 10:07:11 xarthisius Exp $
+
+*tgt-1.0.24-r1 (14 Mar 2012)
+
+ 14 Mar 2012; Kacper Kowalik <xarthisius@gentoo.org> +files/tgtd-1.0.24.confd,
+ +files/tgtd-1.0.24.initd, +tgt-1.0.24-r1.ebuild, -tgt-1.0.24.ebuild:
+ Allow to pass options to daemon via confd file. Fixes 408107 bug by Christian
+ Bricart <christian@bricart.de> Improve sed to add LDFLAGS only where they're
+ needed, respect CC properly
*tgt-1.0.24 (04 Feb 2012)
diff --git a/sys-block/tgt/files/tgtd-1.0.24.confd b/sys-block/tgt/files/tgtd-1.0.24.confd
new file mode 100644
index 000000000000..c58e9cb2a705
--- /dev/null
+++ b/sys-block/tgt/files/tgtd-1.0.24.confd
@@ -0,0 +1,4 @@
+# Here you can specify options that are passed directyl to tgt daemon
+TGTD_OPTS=""
+
+# vim: ft=gentoo-conf-d
diff --git a/sys-block/tgt/files/tgtd-1.0.24.initd b/sys-block/tgt/files/tgtd-1.0.24.initd
new file mode 100644
index 000000000000..523775eb57f6
--- /dev/null
+++ b/sys-block/tgt/files/tgtd-1.0.24.initd
@@ -0,0 +1,126 @@
+#!/sbin/runscript
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-block/tgt/files/tgtd-1.0.24.initd,v 1.1 2012/03/14 10:07:11 xarthisius Exp $
+
+TGTD_CONFIG=/etc/tgt/targets.conf
+
+TASK=$1
+
+depend() {
+ need net
+}
+
+start() {
+ ebegin "Starting target framework daemon"
+ ebegin "Starting ${SVCNAME}"
+ # Start tgtd first.
+ start-stop-daemon --start --quiet \
+ --name tgtd \
+ --exec /usr/sbin/tgtd -- \
+ ${TGTD_OPTS}
+ RETVAL=$?
+ if [ "$RETVAL" -ne 0 ] ; then
+ echo "Could not start tgtd (is tgtd already running?)"
+ exit 1
+ fi
+ # We need to wait for 1 second before do anything with tgtd
+ sleep 1
+ # Put tgtd into "offline" state until all the targets are configured.
+ # We don't want initiators to (re)connect and fail the connection
+ # if it's not ready
+ tgtadm --op update --mode sys --name State -v offline
+ # Configure the targets.
+ tgt-admin --update ALL -c $TGTD_CONFIG
+ # Put tgtd into "ready" state.
+ tgtadm --op update --mode sys --name State -v ready
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ${SVCNAME}"
+ ebegin "Stopping target framework daemon"
+ # start-stop-daemon --stop --exec /usr/sbin/tgtd --quiet
+ if [ "$RUNLEVEL" == 0 -o "$RUNLEVEL" == 6 ] ; then
+ forcedstop
+ fi
+ # Remove all targets. It only removes targets which are not in use.
+ tgt-admin --update ALL -c /dev/null &>/dev/null
+ # tgtd will exit if all targets were removed
+ tgtadm --op delete --mode system &>/dev/null
+ RETVAL=$?
+ if [ "$RETVAL" -eq 107 ] ; then
+ echo "tgtd is not running"
+ if [ "$TASK" != "restart" ] ; then
+ exit 1
+ fi
+ elif [ "$RETVAL" -ne 0 ] ; then
+ echo "Some initiators are still connected - could not stop tgtd"
+ exit 2
+ fi
+ # echo -n
+ eend $?
+}
+
+forcedstop() {
+ # NOTE: Forced shutdown of the iscsi target may cause data corruption
+ # for initiators that are connected.
+ echo "Force-stopping target framework daemon"
+ # Offline everything first. May be needed if we're rebooting, but
+ # expect the initiators to reconnect cleanly when we boot again
+ # (i.e. we don't want them to reconnect to a tgtd which is still
+ # working, but the target is gone).
+ tgtadm --op update --mode sys --name State -v offline &>/dev/null
+ RETVAL=$?
+ if [ "$RETVAL" -eq 107 ] ; then
+ echo "tgtd is not running"
+ if [ "$TASK" != "restart" ] ; then
+ exit 1
+ fi
+ else
+ tgt-admin --offline ALL
+ # Remove all targets, even if they are still in use.
+ tgt-admin --update ALL -c /dev/null -f
+ # It will shut down tgtd only after all targets were removed.
+ tgtadm --op delete --mode system
+ RETVAL=$?
+ if [ "$RETVAL" -ne 0 ] ; then
+ echo "Failed to shutdown tgtd"
+ exit 1
+ fi
+ fi
+ echo -n
+}
+
+reload() {
+ echo "Updating target framework daemon configuration"
+ # Update configuration for targets. Only targets which
+ # are not in use will be updated.
+ tgt-admin --update ALL -c $TGTD_CONFIG &>/dev/null
+ RETVAL=$?
+ if [ "$RETVAL" -eq 107 ] ; then
+ echo "tgtd is not running"
+ exit 1
+ fi
+}
+
+forcedreload() {
+ echo "Force-updating target framework daemon configuration"
+ # Update configuration for targets, even those in use.
+ tgt-admin --update ALL -f -c $TGTD_CONFIG &>/dev/null
+ RETVAL=$?
+ if [ "$RETVAL" -eq 107 ] ; then
+ echo "tgtd is not running"
+ exit 1
+ fi
+}
+
+status() {
+ # Don't name this script "tgtd"...
+ TGTD_PROC=$(ps -C tgtd | grep -c tgtd)
+ if [ "$TGTD_PROC" -eq 2 ] ; then
+ echo "tgtd is running. Run 'tgt-admin -s' to see detailed target info."
+ else
+ echo "tgtd is NOT running."
+ fi
+}
diff --git a/sys-block/tgt/tgt-1.0.24.ebuild b/sys-block/tgt/tgt-1.0.24-r1.ebuild
index 7ea934a217bc..6ed63c07c14f 100644
--- a/sys-block/tgt/tgt-1.0.24.ebuild
+++ b/sys-block/tgt/tgt-1.0.24-r1.ebuild
@@ -1,10 +1,10 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-block/tgt/tgt-1.0.24.ebuild,v 1.1 2012/02/04 16:54:30 alexxy Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-block/tgt/tgt-1.0.24-r1.ebuild,v 1.1 2012/03/14 10:07:11 xarthisius Exp $
EAPI=4
-inherit flag-o-matic linux-info
+inherit flag-o-matic linux-info toolchain-funcs
MY_TREE="e039354"
@@ -26,19 +26,20 @@ DEPEND="dev-perl/config-general
RDEPEND="${DEPEND}
sys-apps/sg3_utils"
-S="${WORKDIR}"/fujita-tgt-"${MY_TREE}"
+S=${WORKDIR}/fujita-tgt-${MY_TREE}
pkg_setup() {
CONFIG_CHECK="~SCSI_TGT"
WARNING_SCSI_TGT="Your kernel needs CONFIG_SCSI_TGT"
linux-info_pkg_setup
+ tc-export CC
}
src_prepare() {
- sed -i -e 's:\($(CC)\):\1 $(LDFLAGS):' usr/Makefile || die "sed failed"
+ sed -i -e 's:\($(CC)\) $^:\1 $(LDFLAGS) $^:' usr/Makefile || die
# make sure xml docs are generated before trying to install them
- sed -i -e "s@install: @install: all @g" doc/Makefile || die
+ sed -i -e "s@install: @& all @g" doc/Makefile || die
}
src_compile() {
@@ -54,7 +55,8 @@ src_compile() {
src_install() {
emake install-programs install-scripts install-doc DESTDIR="${D}" \
docdir=/usr/share/doc/${PF}
- doinitd "${FILESDIR}/tgtd"
+ newinitd "${FILESDIR}"/tgtd-${PV}.initd tgtd
+ newconfd "${FILESDIR}"/tgtd-${PV}.confd tgtd
dodir /etc/tgt
keepdir /etc/tgt
}