Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 1 | SUMMARY = "The Suricata Engine is an Open Source Next Generation Intrusion Detection and Prevention Engine" |
| 2 | |
| 3 | require suricata.inc |
| 4 | |
| 5 | LIC_FILES_CHKSUM = "file://LICENSE;beginline=1;endline=2;md5=c70d8d3310941dcdfcd1e02800a1f548" |
| 6 | |
| 7 | SRC_URI = "http://www.openinfosecfoundation.org/download/suricata-${PV}.tar.gz" |
Andrew Geissler | 2daf84b | 2023-03-31 09:57:23 -0500 | [diff] [blame] | 8 | SRC_URI[sha256sum] = "59bfd1bf5d9c1596226fa4815bf76643ce59698866c107a26269c481f125c4d7" |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 9 | |
| 10 | DEPENDS = "lz4 libhtp" |
| 11 | |
| 12 | SRC_URI += " \ |
| 13 | file://volatiles.03_suricata \ |
| 14 | file://tmpfiles.suricata \ |
| 15 | file://suricata.yaml \ |
| 16 | file://suricata.service \ |
| 17 | file://run-ptest \ |
| 18 | file://fixup.patch \ |
| 19 | " |
| 20 | |
Patrick Williams | 8e7b46e | 2023-05-01 14:19:06 -0500 | [diff] [blame^] | 21 | inherit autotools pkgconfig python3native systemd ptest cargo cargo-update-recipe-crates |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 22 | |
Patrick Williams | 8e7b46e | 2023-05-01 14:19:06 -0500 | [diff] [blame^] | 23 | require ${BPN}-crates.inc |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 24 | |
| 25 | EXTRA_OECONF += " --disable-debug \ |
| 26 | --disable-gccmarch-native \ |
| 27 | --enable-non-bundled-htp \ |
| 28 | --disable-suricata-update \ |
| 29 | --with-libhtp-includes=${STAGING_INCDIR} --with-libhtp-libraries=${STAGING_LIBDIR} \ |
| 30 | " |
| 31 | |
| 32 | CARGO_SRC_DIR = "rust" |
Patrick Williams | 8e7b46e | 2023-05-01 14:19:06 -0500 | [diff] [blame^] | 33 | #CARGO_LOCK_SRC_DIR = "${S}/rust" |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 34 | |
| 35 | B = "${S}" |
| 36 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 37 | # nfnetlink has a dependancy to meta-networking |
| 38 | PACKAGECONFIG ??= "jansson file pcre yaml python pcap cap-ng net nss nspr " |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 39 | PACKAGECONFIG:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'ptest', 'unittests', '', d)}" |
| 40 | |
| 41 | PACKAGECONFIG[pcre] = "--with-libpcre-includes=${STAGING_INCDIR} --with-libpcre-libraries=${STAGING_LIBDIR}, ,libpcre ," |
| 42 | PACKAGECONFIG[yaml] = "--with-libyaml-includes=${STAGING_INCDIR} --with-libyaml-libraries=${STAGING_LIBDIR}, ,libyaml ," |
| 43 | PACKAGECONFIG[pcap] = "--with-libpcap-includes=${STAGING_INCDIR} --with-libpcap-libraries=${STAGING_LIBDIR}, ,libpcap" |
| 44 | PACKAGECONFIG[cap-ng] = "--with-libcap_ng-includes=${STAGING_INCDIR} --with-libcap_ng-libraries=${STAGING_LIBDIR}, ,libcap-ng , " |
| 45 | PACKAGECONFIG[net] = "--with-libnet-includes=${STAGING_INCDIR} --with-libnet-libraries=${STAGING_LIBDIR}, , libnet," |
| 46 | PACKAGECONFIG[nfnetlink] = "--with-libnfnetlink-includes=${STAGING_INCDIR} --with-libnfnetlink-libraries=${STAGING_LIBDIR}, ,libnfnetlink ," |
| 47 | PACKAGECONFIG[nfq] = "--enable-nfqueue, --disable-nfqueue,libnetfilter-queue," |
| 48 | |
| 49 | PACKAGECONFIG[jansson] = "--with-libjansson-includes=${STAGING_INCDIR} --with-libjansson-libraries=${STAGING_LIBDIR},,jansson, jansson" |
| 50 | PACKAGECONFIG[file] = ",,file, file" |
| 51 | PACKAGECONFIG[nss] = "--with-libnss-includes=${STAGING_INCDIR} --with-libnss-libraries=${STAGING_LIBDIR}, nss, nss," |
| 52 | PACKAGECONFIG[nspr] = "--with-libnspr-includes=${STAGING_INCDIR} --with-libnspr-libraries=${STAGING_LIBDIR}, nspr, nspr," |
| 53 | PACKAGECONFIG[python] = "--enable-python, --disable-python, python3, python3-core" |
| 54 | PACKAGECONFIG[unittests] = "--enable-unittests, --disable-unittests," |
| 55 | |
| 56 | export logdir = "${localstatedir}/log" |
| 57 | |
| 58 | CACHED_CONFIGUREVARS = "ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes" |
| 59 | |
| 60 | do_configure:prepend () { |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 61 | # use host for RUST_SURICATA_LIB_XC_DIR |
| 62 | sed -i -e 's,\${host_alias},${RUST_HOST_SYS},' ${S}/configure.ac |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 63 | oe_runconf |
| 64 | } |
| 65 | |
| 66 | do_compile () { |
| 67 | # we do this to bypass the make provided by this pkg |
| 68 | # patches Makefile to skip the subdir |
| 69 | cargo_do_compile |
| 70 | |
| 71 | # Finish building |
| 72 | cd ${S} |
| 73 | make |
| 74 | } |
| 75 | |
| 76 | do_install () { |
| 77 | install -d ${D}${sysconfdir}/suricata |
| 78 | |
| 79 | oe_runmake install DESTDIR=${D} |
| 80 | |
| 81 | install -d ${D}${sysconfdir}/suricata ${D}${sysconfdir}/default/volatiles |
| 82 | install -m 0644 ${WORKDIR}/volatiles.03_suricata ${D}${sysconfdir}/default/volatiles/03_suricata |
| 83 | |
| 84 | install -m 0644 ${S}/threshold.config ${D}${sysconfdir}/suricata |
| 85 | install -m 0644 ${S}/suricata.yaml ${D}${sysconfdir}/suricata |
| 86 | |
| 87 | if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then |
| 88 | install -d ${D}${sysconfdir}/tmpfiles.d |
| 89 | install -m 0644 ${WORKDIR}/tmpfiles.suricata ${D}${sysconfdir}/tmpfiles.d/suricata.conf |
| 90 | |
| 91 | install -d ${D}${systemd_unitdir}/system |
| 92 | sed -e s:/etc:${sysconfdir}:g \ |
| 93 | -e s:/var/run:/run:g \ |
| 94 | -e s:/var:${localstatedir}:g \ |
| 95 | -e s:/usr/bin:${bindir}:g \ |
| 96 | -e s:/bin/kill:${base_bindir}/kill:g \ |
| 97 | -e s:/usr/lib:${libdir}:g \ |
| 98 | ${WORKDIR}/suricata.service > ${D}${systemd_unitdir}/system/suricata.service |
| 99 | fi |
| 100 | |
| 101 | # Remove /var/run as it is created on startup |
| 102 | rm -rf ${D}${localstatedir}/run |
| 103 | |
| 104 | sed -i -e "s:#!.*$:#!${USRBINPATH}/env ${PYTHON_PN}:g" ${D}${bindir}/suricatasc |
| 105 | sed -i -e "s:#!.*$:#!${USRBINPATH}/env ${PYTHON_PN}:g" ${D}${bindir}/suricatactl |
Andrew Geissler | 2daf84b | 2023-03-31 09:57:23 -0500 | [diff] [blame] | 106 | sed -i -e "s:#!.*$:#!${USRBINPATH}/env ${PYTHON_PN}:g" ${D}${libdir}/suricata/python/suricata/sc/suricatasc.py |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | pkg_postinst_ontarget:${PN} () { |
| 110 | if command -v systemd-tmpfiles >/dev/null; then |
| 111 | systemd-tmpfiles --create ${sysconfdir}/tmpfiles.d/suricata.conf |
| 112 | elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then |
| 113 | ${sysconfdir}/init.d/populate-volatile.sh update |
| 114 | fi |
| 115 | } |
| 116 | |
| 117 | SYSTEMD_PACKAGES = "${PN}" |
| 118 | |
| 119 | PACKAGES =+ "${PN}-python" |
| 120 | FILES:${PN} += "${systemd_unitdir} ${sysconfdir}/tmpfiles.d" |
| 121 | FILES:${PN}-python = "${bindir}/suricatasc ${PYTHON_SITEPACKAGES_DIR}" |
| 122 | |
| 123 | CONFFILES:${PN} = "${sysconfdir}/suricata/suricata.yaml" |