Hi!

I'm trying to integrate the Icinga (https://github.com/Icinga/icinga2) in our Yocto project. As there are no ready recipes for it, I'm trying to write my own, starting from the one used for Nagios which is the original project Icinga forked from.
Icinga uses CMake for the compile process. Problem is that the compilation relies on two binaries, mkclass and mkunity, that get built by the process itself and obviously the compilation stops because those commands cannot be found.

Searching the web I found only this hint in the Technical FAQ https://wiki.yoctoproject.org/wiki/Technical_FAQ#I_have_some_software_which_needs_to_build_a_binary_that_it_then_runs_as_part_of_its_own_build_process.2C_how_do_I_make_this_work.3F, but the problem is still there.

How can I get around this?


Best regards
Matteo Iervasi

require icinga-common.inc

DESCRIPTION = "A host/service/network monitoring and management system core 
files"
HOMEPAGE = "https://icinga.com";
SECTION = "console/network"
PRIORITY = "optional"
LICENSE = "CLOSED"

LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"

SRCNAME = "icinga2"

SRC_URI = "https://github.com/Icinga/icinga2/archive/v${PV}.tar.gz \
           file://volatiles \
           file://icinga-core.service \
           file://icinga-core-systemd-volatile.conf \
           "

SRC_URI[md5sum] = "9b5db45aebcdb6f5a5cc3b0faa7a8b05"
SRC_URI[sha256sum] = 
"47b409755ded2752a13c3f5fd62dab0411c3e1069653b3c099e8276528d96f7c"

S = "${WORKDIR}/${SRCNAME}-${PV}"

BBCLASSEXTEND += "native"

inherit pkgconfig cmake update-rc.d systemd update-alternatives

#DEPENDS = "bison flex gd unzip-native boost libconfig openssl systemd"

DEPENDS = "icinga-core-native"
DEPENDS_class-target = "bison flex boost"

RDEPENDS_${PN} += "\
    bison \
    flex \
    gd \
    libpng \
    fontconfig \
    apache2 \
    php \
    openssl \
    boost \
    systemd \
"

acpaths = "-I ${S}/autoconf-macros"

# Set default password for the hardcoded Icinga admin user "icingaadmin".
# If this variable is empty then will prompt user for password.
ICINGA_DEFAULT_ADMINUSER_PASSWORD ??= "password"
ICINGA_CGIBIN_DIR = "${libdir}/icinga/cgi-bin"

EXTRA_OECONF += "--sbindir=${ICINGA_CGIBIN_DIR} \
                 --datadir=${datadir}/icinga/htdocs \
                 --with-command-group=nagcmd \
                 --with-httpd-conf=${sysconfdir}/apache2/conf.d \
                 --with-lockfile=${localstatedir}/run/icinga/icinga.pid \
                 --with-init-dir=${sysconfdir}/init.d \
"

# Prevent icinga from stripping binaries, bitbake will take care of that
EXTRA_OECONF += "ac_cv_path_STRIP=true"

# Prevent icinga from using dynamic libtool library
EXTRA_OECONF += "ac_cv_header_ltdl_h=no"

# Prevent icinga from suffering host contamination if host has /bin/perl
EXTRA_OECONF += "ac_cv_path_PERL=${bindir}/perl"

# Fix build failure for gcc-10
CFLAGS_append = " -fcommon"

# Set to "1" to allow icinga-core post-init to modify Apache configuration
ICINGA_MODIFY_APACHE ??= "1"

# do_configure_prepend() {
# rename these macros to have .m4 suffix so that autoreconf could recognize them
# for macro in `ls ${S}/autoconf-macros/ax_icinga_get_*`; do
#       mv $macro $macro.m4
# done
# }


do_compile() {
        oe_runmake mkclass

    oe_runmake all
}


do_install() {
    oe_runmake 'DESTDIR=${D}' install
    oe_runmake 'DESTDIR=${D}' install-init
    oe_runmake 'DESTDIR=${D}' install-config
    oe_runmake 'DESTDIR=${D}' install-commandmode

    install -d ${D}${sysconfdir}/apache2/conf.d
    oe_runmake 'DESTDIR=${D}' install-webconf

    install -d ${D}${ICINGA_PLUGIN_CONF_DIR}

    # There is no install target for the contributed eventhandlers so we
    # just do it.
    install -d ${D}${ICINGA_PLUGIN_DIR}/eventhandlers
    for f in ${S}/contrib/eventhandlers/* ; do
        if ! [ -f $f ] ; then
            continue;
        fi
        install $f ${D}${ICINGA_PLUGIN_DIR}/eventhandlers/
    done

    echo "cfg_dir=${ICINGA_PLUGIN_CONF_DIR}" >> 
${D}${ICINGA_CONF_DIR}/icinga.cfg

    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; 
then
        install -d ${D}${systemd_unitdir}/system
        install -m 644 ${WORKDIR}/icinga-core.service 
${D}${systemd_unitdir}/system/
        # use our own service file
        rm -f ${D}${systemd_unitdir}/system/icinga.service
        install -d ${D}${sysconfdir}/tmpfiles.d
        install -m 755 ${WORKDIR}/icinga-core-systemd-volatile.conf 
${D}${sysconfdir}/tmpfiles.d/icinga-core-volatile.conf
    else
        install -d ${D}${sysconfdir}/default/volatiles
        install -m 0644 ${WORKDIR}/volatiles 
${D}${sysconfdir}/default/volatiles/99_icinga
    fi
}

pkg_postinst_ontarget_${PN}-setup () {
    # Set password for icingaadmin user
    if [ -z "${ICINGA_DEFAULT_ADMINUSER_PASSWORD}" ]; then
        htpasswd -c ${ICINGA_CONF_DIR}/htpasswd.users icingaadmin
    else
        htpasswd -b -c ${ICINGA_CONF_DIR}/htpasswd.users icingaadmin \
           "${ICINGA_DEFAULT_ADMINUSER_PASSWORD}"
    fi

    # Apache2 might by default turn off CGI
    if [ "${ICINGA_MODIFY_APACHE}" == "1" ] && [ -f 
"${sysconfdir}/apache2/httpd.conf" ]; then
        sed -e 's/^#LoadModule cgid_module/LoadModule cgid_module/g' -i 
${sysconfdir}/apache2/httpd.conf
    fi
}

PACKAGES += "${SRCNAME}-base ${PN}-setup"

FILES_${PN} += "${datadir} \
                ${ICINGA_PLUGIN_DIR} \
                ${ICINGA_CGIBIN_DIR} \
"

FILES_${PN}-dbg += "${ICINGA_CGIBIN_DIR}/.debug"

ALLOW_EMPTY_${SRCNAME}-base = "1"
ALLOW_EMPTY_${PN}-setup = "1"

SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE_${PN} = "icinga-core.service"
SYSTEMD_AUTO_ENABLE_${PN} = "enable"

USERADD_PACKAGES += "${SRCNAME}-base"
GROUPADD_PARAM_${SRCNAME}-base = "-r ${ICINGA_GROUP}"
USERADD_PARAM_${SRCNAME}-base = "-r -M -g ${ICINGA_GROUP} ${ICINGA_USER}"

INITSCRIPT_NAME = "icinga"
INITSCRIPT_PARAMS = "defaults"

CVE_PRODUCT = "icinga_core"

ALTERNATIVE_PRIORITY_${PN} = '20'
ALTERNATIVE_${PN} = "icinga"
ALTERNATIVE_LINK_NAME[icinga] = "${localstatedir}/icinga"
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#51525): https://lists.yoctoproject.org/g/yocto/message/51525
Mute This Topic: https://lists.yoctoproject.org/mt/78448727/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to