summaryrefslogtreecommitdiff
path: root/sys-block/tgt
diff options
context:
space:
mode:
Diffstat (limited to 'sys-block/tgt')
-rw-r--r--sys-block/tgt/Manifest3
-rw-r--r--sys-block/tgt/files/tgtd.confd-new7
-rw-r--r--sys-block/tgt/files/tgtd.initd-new136
-rw-r--r--sys-block/tgt/tgt-1.0.87-r1.ebuild61
4 files changed, 207 insertions, 0 deletions
diff --git a/sys-block/tgt/Manifest b/sys-block/tgt/Manifest
index 1b7d626d97c3..d871cebc4322 100644
--- a/sys-block/tgt/Manifest
+++ b/sys-block/tgt/Manifest
@@ -1,7 +1,10 @@
AUX tgtd.confd 108 BLAKE2B 74e5f66f6fb193541853e562cd1de5e99806f1f324db6efb5f9a5217935044dd61237171b368dc1747017fbd9094d8c3acae4dfde0d5dfff69957c3f8800d63c SHA512 2153e99e3f6a2178bbbb2bda1d6af9a67d6080b36e7c5cbb4f951b10324c80a24fa224a7003c26b3b51d40a77bba97856bc009bbb0e664e93625face723edc91
+AUX tgtd.confd-new 202 BLAKE2B 3cba1a90194f893933339fb816bcad1a15f3e7c5e5c1bf9a76e4a725ec4d3ce94ba7a898ee247ae3008db125d3d6dba95894ecedf1fa0c4171a07655fc6701c7 SHA512 c137b224726ff9a502abbd642fc8ce07f4cdc40db32d0478f300108be3328521926fe4084629889fdcc6c842356318966f5fab84c07f5506f9bbaacc4476d6ac
AUX tgtd.initd 3435 BLAKE2B d2441a515c7a270472efd0c4ef5e928827bde54b248d09bb47f4fcc53c46e4678acf049c16ee761f29eb8e928f0713f38a9f73bd13db1e0408da56f42f64b337 SHA512 1e6d114dbb89c7a26e65546b6c775bcabc3c9508e0757e118a4272fbf4299a185b4679bc510d9cc3da7db25b96343ddc8e45de044543ebe26d952132eba4de30
+AUX tgtd.initd-new 3922 BLAKE2B 02e91c2c2f1d04af2ca9ae00143420aeb8c56e37842be1362364f4581f185a2cacad636e4a97508e6208fa8e1480f0335cf5c5d60eac3f5f60700647fe3e07ad SHA512 2bd2e3fdc263bb631035dfbf370cc2dabd4d35e25b0d3172926cef10eab0d85c81d6a103ee0b0018db8f1681a5b8768574f3627cbfafc8de2a2e40f9f8274427
DIST tgt-1.0.86.tar.gz 304697 BLAKE2B 60233019e9f09dd4288ca70f398992452dc00f7a2f46d82e333a9e1bfa4fe5dcc8583da3d4ce4382b32c60b1b009dd03d36faa9770faa11222b9ec4592bd6d96 SHA512 f4e8e87691be2793c5eee9d7dc744ae3a7b47f710f559141f0533de345f727fb68223a3090282f5c51f70ea55fbf5936d81e3b08ce953b7ac48013295c32bef7
DIST tgt-1.0.87.tar.gz 304798 BLAKE2B e8772a02078204373dd43276cc5534dd9e8996841bdfef613f34a9c59ef2886f866ff6fb56e6bdaea653b4081b477e1ab15cb3ed3d125b7c08b45ab11a63a7cb SHA512 362adfc92f9fc6528b3de0aa9f202e39f6035b92fe3078236a3f75c0aef540a82cb4594077fdc7de2e524acc75601f5696111cc9aebc6de6265c53cd1d073db2
EBUILD tgt-1.0.86.ebuild 1597 BLAKE2B 01ae3a331c0468acdb90a8b9ff0bbaf9ce1293cf188c6e8f27a34df9320baa8d28a9adebac263b4dba547d90b5299c2bdb309eb0701b4ac5ce80b57db0da1ca1 SHA512 f267a845ad8ed28fcccb4c8a461e3ef233b387a244fb13cb42106ec52401f89d7f53a1ba9129e93abf3cbefe0c852c110b1efeb322647115b68fcf65d2781734
+EBUILD tgt-1.0.87-r1.ebuild 1609 BLAKE2B 41f0e3db37f6bffdfe7c01a67e2c078d2b165d96371c12b9132cca1f80d91bb83e5953cc0d49f5869d0d45e22e2b79628bc51b23dd9956db50dbe5b77fcadfc9 SHA512 9276b84e2b8bdc18548b088b2f5de55e02d45cee8d36ae151eb812513c28448885ebbab20dfc14fcc6d7f5ef4b266bc5cf90cd8cb6786a897cc9bc7e363114f9
EBUILD tgt-1.0.87.ebuild 1601 BLAKE2B b6ab887208587e59ff96a19eaa1c4f10c07f17123b5d8db11d4a233f70fe1a467e40d1f9493835c642c36678e6b2afd025fb3b43d35da300883195843aba0d34 SHA512 36b3c08630558984409aca543374603567df016ca1d7a97deb4bf5958063c386ccd46a52c6d7b7df65bfc04fab97539d0bc5a9c89cd5eaf0ddae14ceb5243848
MISC metadata.xml 749 BLAKE2B 0bc71ded3e2d650bd34edcb3e5515926248ff71354db504d94c548ec951ded4f71e5af1d5127d8fa3a0a3b398204436743d016fbd1cc1e765b6303a8bd734fd8 SHA512 94f7b923adade87a471854f469731094b00872727c7a668ea7e34e558eb87e661ab01c42fbe920a885f28c394f2bc9bf0fba0e48b84893ecade9c3d967e4c2ea
diff --git a/sys-block/tgt/files/tgtd.confd-new b/sys-block/tgt/files/tgtd.confd-new
new file mode 100644
index 000000000000..99a8f8db02fd
--- /dev/null
+++ b/sys-block/tgt/files/tgtd.confd-new
@@ -0,0 +1,7 @@
+# Here you can specify options that are passed directly to tgt daemon
+#tgtd_opts=""
+
+# Config file for automatic configuration with tgt-admin
+#tgtd_conf="/etc/tgt/targets.conf"
+
+# vim: ft=gentoo-conf-d
diff --git a/sys-block/tgt/files/tgtd.initd-new b/sys-block/tgt/files/tgtd.initd-new
new file mode 100644
index 000000000000..7941f1a7e974
--- /dev/null
+++ b/sys-block/tgt/files/tgtd.initd-new
@@ -0,0 +1,136 @@
+#!/sbin/openrc-run
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# shellcheck shell=sh
+
+# Default configuration fike
+: "${tgtd_conf:=/etc/tgt/targets.conf}"
+
+pidfile="/var/run/${RC_SVCNAME}.pid"
+command="/usr/sbin/tgtd"
+command_args_background="--pid-file ${pidfile}"
+extra_commands="forcedstop"
+extra_started_commands="forcedreload reload"
+
+depend() {
+ use net
+}
+
+start_post() {
+ # 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 configuration is not ready.
+ tgtadm --op update --mode sys --name State -v offline
+
+ # Configure the targets.
+ if [ ! -r "${tgtd_conf}" ]; then
+ ewarn "Configuration file '${tgtd_conf}' not found!"
+ ewarn "Leaving ${SVCNAME} running in 'offline' state."
+ eend 0
+ else
+ ebegin "Loading target configuration"
+ tgt-admin --update ALL -c "${tgtd_conf}"
+ retval=$?
+ if [ $retval -ne 0 ]; then
+ eerror "Could not load configuration!"
+ stop
+ exit $?
+ fi
+ eend $retval
+
+ # Put tgtd into "ready" state.
+ ebegin "Onlining targets. Accepting connections"
+ tgtadm --op update --mode sys --name State -v ready
+ eend $?
+ fi
+}
+
+stop() {
+ ebegin "Stopping ${SVCNAME}"
+ # We need to force shutdown if system is restarting
+ # or shutting down.
+ if [ "$RC_RUNLEVEL" = "shutdown" ] ; then
+ forcedstop
+ else
+ # Remove all targets. Only remove targets which are not in use.
+ tgt-admin --update ALL -c /dev/null >/dev/null 2>&1
+ retval=$?
+ if [ $retval -eq 107 ] ; then
+ einfo "tgtd is not running"
+ else
+ # tgtd will exit if all targets were removed.
+ tgtadm --op delete --mode system >/dev/null 2>&1
+ retval=$?
+ if [ $retval -ne 0 ] ; then
+ eerror "WARNING: Some initiators are still connected - could not stop tgtd"
+ fi
+ fi
+ fi
+ eend $retval
+}
+
+forcedstop() {
+ # NOTE: Forced shutdown of the iscsi target may cause data corruption
+ # for initiators that are connected.
+ ewarn "WARNING: Force-stopping target framework daemon"
+ for i in 5 4 3 2 1; do
+ einfo "Continuing in $i seconds..."
+ sleep 1
+ done
+
+ # 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
+ # onlineg, but the target is gone).
+ tgtadm --op update --mode sys --name State -v offline >/dev/null 2>&1
+ retval=$?
+ if [ $retval -eq 107 ] ; then
+ einfo "tgtd is not running"
+ else
+ # Offline all targets
+ tgt-admin --offline ALL
+
+ # Remove all targets, even if they are still in use.
+ tgt-admin --update ALL -c /dev/null -f
+
+ # tgtd shuts down after all targets are removed.
+ tgtadm --op delete --mode system
+ retval=$?
+ if [ $retval -ne 0 ] ; then
+ eerror "Failed to shutdown tgtd"
+ eend 1
+ fi
+ fi
+ eend $retval
+}
+
+reload() {
+ ebegin "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_conf}" >/dev/null 2>&1
+ retval=$?
+ if [ $retval -eq 107 ]; then
+ ewarn "WARNING: tgtd is not running"
+ fi
+ eend $retval
+}
+
+forcedreload() {
+ ebegin "Updating target framework daemon configuration"
+ ewarn "WARNING: Force-updating running configuration!"
+ # Update configuration for targets, even those in use.
+ tgt-admin --update ALL -f -c "${tgtd_conf}" >/dev/null 2>&1
+ retval=$?
+ if [ $retval -eq 107 ]; then
+ ewarn "WARNING: tgtd is not running"
+ fi
+ eend $retval
+}
+
+status_post() {
+ einfo "Run 'tgt-admin -s' to see detailed target info."
+}
diff --git a/sys-block/tgt/tgt-1.0.87-r1.ebuild b/sys-block/tgt/tgt-1.0.87-r1.ebuild
new file mode 100644
index 000000000000..559e0ae2c41b
--- /dev/null
+++ b/sys-block/tgt/tgt-1.0.87-r1.ebuild
@@ -0,0 +1,61 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+inherit toolchain-funcs systemd
+
+DESCRIPTION="Linux SCSI target framework (tgt)"
+HOMEPAGE="https://github.com/fujita/tgt"
+SRC_URI="https://github.com/fujita/tgt/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm64 ~hppa ~ia64 ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86"
+IUSE="fcoe fcp ibmvio infiniband rbd selinux"
+
+DEPEND="
+ app-text/docbook-xsl-stylesheets
+ dev-libs/libxslt
+ dev-perl/Config-General
+ rbd? ( sys-cluster/ceph )
+ infiniband? ( sys-cluster/rdma-core )
+"
+RDEPEND="
+ ${DEPEND}
+ dev-libs/libaio
+ sys-apps/sg3_utils
+ selinux? ( sec-policy/selinux-tgtd )
+"
+
+pkg_setup() {
+ tc-export CC
+}
+
+src_prepare() {
+ default
+ 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: @& all @g" doc/Makefile || die
+ sed -i -e 's|-Werror||g' usr/Makefile || die
+}
+
+src_compile() {
+ local myconf
+ use ibmvio && myconf="${myconf} IBMVIO=1"
+ use infiniband && myconf="${myconf} ISCSI_RDMA=1"
+ use fcp && myconf="${myconf} FCP=1"
+ use fcoe && myconf="${myconf} FCOE=1"
+ use rbd && myconf="${myconf} CEPH_RBD=1"
+
+ emake -C usr/ KERNELSRC="${KERNEL_DIR}" ISCSI=1 ${myconf}
+ emake -C doc
+}
+
+src_install() {
+ emake install-programs install-scripts install-doc DESTDIR="${D}" docdir=/usr/share/doc/${PF}
+ newinitd "${FILESDIR}"/tgtd.initd-new tgtd
+ newconfd "${FILESDIR}"/tgtd.confd-new tgtd
+ systemd_dounit "${S}"/scripts/tgtd.service
+ dodir /etc/tgt
+ keepdir /etc/tgt
+}