1SUMMARY = "iSCSI daemon and utility programs"
2DESCRIPTION = "Open-iSCSI project is a high performance, transport \
3independent, multi-platform implementation of RFC3720. The iscsi package \
4provides the server daemon for the iSCSI protocol, as well as the utility \
5programs used to manage it. iSCSI is a protocol for distributed \
6disk access using SCSI commands sent over Internet Protocol networks."
7HOMEPAGE = "http://www.open-iscsi.com/"
8LICENSE = "GPL-2.0-only & LGPL-2.1-only"
9SECTION = "net"
10DEPENDS = "openssl flex-native bison-native open-isns util-linux kmod"
11DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}"
12
13LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
14
15SRCREV = "d0f04ae4b9bf0bc0be55fbda5f235afdfbf5dd19"
16
17SRC_URI = "git://github.com/open-iscsi/open-iscsi;branch=master;protocol=https \
18           file://0001-Makefile-Do-not-set-Werror.patch \
19           file://initd.debian \
20           file://99_iscsi-initiator-utils \
21           file://iscsi-initiator \
22           file://iscsi-initiator.service \
23           file://iscsi-initiator-targets.service \
24           file://set_initiatorname \
25           "
26S = "${WORKDIR}/git"
27
28inherit update-rc.d systemd autotools pkgconfig
29
30EXTRA_OECONF = " \
31    --target=${TARGET_SYS} \
32    --host=${BUILD_SYS} \
33"
34
35EXTRA_OECONF += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '', '--without-systemd NO_SYSTEMD=1',     d)}"
36
37EXTRA_OEMAKE = ' \
38    OS="${TARGET_SYS}" \
39    TARGET="${TARGET_OS}" \
40    BASE="${prefix}" \
41    MANDIR="${mandir}" \
42    OPTFLAGS="-DNO_SYSTEMD ${CFLAGS}" \
43    PKG_CONFIG="${STAGING_BINDIR_NATIVE}/pkg-config" \
44    SED=sed \
45'
46
47
48do_configure () {
49    cd ${S}/iscsiuio ; autoreconf --install; ./configure ${EXTRA_OECONF}
50}
51
52do_compile () {
53    # Make sure we DO NOT regenerate prom_lex.c.
54    if [ -f ${S}/utils/fwparam_ibft/prom_lex.l ]; then
55        mv ${S}/utils/fwparam_ibft/prom_lex.l ${S}/utils/fwparam_ibft/prom_lex.l.unused
56    fi
57    oe_runmake -C ${S} ${EXTRA_OEMAKE} user
58}
59
60do_install () {
61    #install necessary directories
62    install -d ${D}${sbindir} \
63        ${D}${sysconfdir}/init.d \
64        ${D}${sysconfdir}/iscsi \
65        ${D}${localstatedir}/lib/iscsi/nodes \
66        ${D}${localstatedir}/lib/iscsi/send_targets \
67        ${D}${localstatedir}/lib/iscsi/static \
68        ${D}${localstatedir}/lib/iscsi/isns \
69        ${D}${localstatedir}/lib/iscsi/slp \
70        ${D}${localstatedir}/lib/iscsi/ifaces \
71        ${D}${libdir} \
72        ${D}${mandir}/man8
73
74    install -p -m 755 ${S}/usr/iscsid ${S}/usr/iscsiadm \
75        ${S}/utils/iscsi-iname \
76        ${S}/usr/iscsistart ${D}/${sbindir}
77
78    cp -dR ${S}/libopeniscsiusr/libopeniscsiusr.so* ${D}${libdir}
79    install -p -m 644 ${S}/doc/iscsiadm.8 ${S}/doc/iscsid.8 ${D}/${mandir}/man8
80    install -p -m 644 ${S}/etc/iscsid.conf ${D}${sysconfdir}/iscsi
81    install -p -m 755 ${UNPACKDIR}/initd.debian ${D}${sysconfdir}/init.d/iscsid
82
83    sed -i -e "s:= /sbin/iscsid:= ${sbindir}/iscsid:" ${D}${sysconfdir}/iscsi/iscsid.conf
84
85    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
86        install -d ${D}${sysconfdir}/tmpfiles.d
87        echo "d /run/${BPN}/lock - - - -" \
88                     > ${D}${sysconfdir}/tmpfiles.d/iscsi.conf
89        install -d ${D}/etc/default/
90        install -p -m 755 ${UNPACKDIR}/iscsi-initiator ${D}${sysconfdir}/default/
91
92        install -d ${D}${systemd_unitdir}/system/
93        install -m 0644 ${UNPACKDIR}/iscsi-initiator.service \
94                        ${UNPACKDIR}/iscsi-initiator-targets.service \
95                        ${D}${systemd_unitdir}/system/
96        install -d ${D}${nonarch_libdir}/iscsi
97        install -m 0755 ${UNPACKDIR}/set_initiatorname ${D}${nonarch_libdir}/iscsi
98    else
99        install -d ${D}/etc/default/volatiles
100        install -m 0644 ${UNPACKDIR}/99_iscsi-initiator-utils ${D}/etc/default/volatiles
101    fi
102}
103
104pkg_postinst:${PN}() {
105    if [ "x$D" = "x" ]; then
106        if [ -e /etc/init.d/populate-volatile.sh ]; then
107            /etc/init.d/populate-volatile.sh update
108        elif command -v systemd-tmpfiles >/dev/null; then
109            systemd-tmpfiles --create ${sysconfdir}/tmpfiles.d/iscsi.conf
110        fi
111    fi
112}
113
114SYSTEMD_SERVICE = " iscsi-initiator.service iscsi-initiator-targets.service "
115INITSCRIPT_NAME = "iscsid"
116INITSCRIPT_PARAMS = "start 30 1 2 3 4 5 . stop 70 0 1 2 3 4 5 6 ."
117
118FILES:${PN} += "${nonarch_libdir}/iscsi"
119