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 | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame^] | 8 | SRC_URI[sha256sum] = "7bcd1313118366451465dc3f8385a3f6aadd084ffe44dd257dda8105863bb769" |
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" |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame^] | 33 | |
| 34 | CARGO_BUILD_FLAGS:remove = "--frozen" |
| 35 | CARGO_BUILD_FLAGS:append = " --offline" |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 36 | |
| 37 | B = "${S}" |
| 38 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 39 | # nfnetlink has a dependancy to meta-networking |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame^] | 40 | PACKAGECONFIG ??= "jansson file pcre2 yaml python pcap cap-ng net nss nspr " |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 41 | PACKAGECONFIG:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'ptest', 'unittests', '', d)}" |
| 42 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame^] | 43 | PACKAGECONFIG[pcre2] = "--with-libpcre2-includes=${STAGING_INCDIR} --with-libpcre2-libraries=${STAGING_LIBDIR}, ,libpcre2 ," |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 44 | PACKAGECONFIG[yaml] = "--with-libyaml-includes=${STAGING_INCDIR} --with-libyaml-libraries=${STAGING_LIBDIR}, ,libyaml ," |
| 45 | PACKAGECONFIG[pcap] = "--with-libpcap-includes=${STAGING_INCDIR} --with-libpcap-libraries=${STAGING_LIBDIR}, ,libpcap" |
| 46 | PACKAGECONFIG[cap-ng] = "--with-libcap_ng-includes=${STAGING_INCDIR} --with-libcap_ng-libraries=${STAGING_LIBDIR}, ,libcap-ng , " |
| 47 | PACKAGECONFIG[net] = "--with-libnet-includes=${STAGING_INCDIR} --with-libnet-libraries=${STAGING_LIBDIR}, , libnet," |
| 48 | PACKAGECONFIG[nfnetlink] = "--with-libnfnetlink-includes=${STAGING_INCDIR} --with-libnfnetlink-libraries=${STAGING_LIBDIR}, ,libnfnetlink ," |
| 49 | PACKAGECONFIG[nfq] = "--enable-nfqueue, --disable-nfqueue,libnetfilter-queue," |
| 50 | |
| 51 | PACKAGECONFIG[jansson] = "--with-libjansson-includes=${STAGING_INCDIR} --with-libjansson-libraries=${STAGING_LIBDIR},,jansson, jansson" |
| 52 | PACKAGECONFIG[file] = ",,file, file" |
| 53 | PACKAGECONFIG[nss] = "--with-libnss-includes=${STAGING_INCDIR} --with-libnss-libraries=${STAGING_LIBDIR}, nss, nss," |
| 54 | PACKAGECONFIG[nspr] = "--with-libnspr-includes=${STAGING_INCDIR} --with-libnspr-libraries=${STAGING_LIBDIR}, nspr, nspr," |
| 55 | PACKAGECONFIG[python] = "--enable-python, --disable-python, python3, python3-core" |
| 56 | PACKAGECONFIG[unittests] = "--enable-unittests, --disable-unittests," |
| 57 | |
| 58 | export logdir = "${localstatedir}/log" |
| 59 | |
| 60 | CACHED_CONFIGUREVARS = "ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes" |
| 61 | |
| 62 | do_configure:prepend () { |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 63 | # use host for RUST_SURICATA_LIB_XC_DIR |
| 64 | sed -i -e 's,\${host_alias},${RUST_HOST_SYS},' ${S}/configure.ac |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame^] | 65 | sed -i -e 's,libsuricata_rust.a,libsuricata.a,' ${S}/configure.ac |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 66 | oe_runconf |
| 67 | } |
| 68 | |
| 69 | do_compile () { |
| 70 | # we do this to bypass the make provided by this pkg |
| 71 | # patches Makefile to skip the subdir |
| 72 | cargo_do_compile |
| 73 | |
| 74 | # Finish building |
| 75 | cd ${S} |
| 76 | make |
| 77 | } |
| 78 | |
| 79 | do_install () { |
| 80 | install -d ${D}${sysconfdir}/suricata |
| 81 | |
| 82 | oe_runmake install DESTDIR=${D} |
| 83 | |
| 84 | install -d ${D}${sysconfdir}/suricata ${D}${sysconfdir}/default/volatiles |
| 85 | install -m 0644 ${WORKDIR}/volatiles.03_suricata ${D}${sysconfdir}/default/volatiles/03_suricata |
| 86 | |
| 87 | install -m 0644 ${S}/threshold.config ${D}${sysconfdir}/suricata |
| 88 | install -m 0644 ${S}/suricata.yaml ${D}${sysconfdir}/suricata |
| 89 | |
| 90 | if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then |
| 91 | install -d ${D}${sysconfdir}/tmpfiles.d |
| 92 | install -m 0644 ${WORKDIR}/tmpfiles.suricata ${D}${sysconfdir}/tmpfiles.d/suricata.conf |
| 93 | |
| 94 | install -d ${D}${systemd_unitdir}/system |
| 95 | sed -e s:/etc:${sysconfdir}:g \ |
| 96 | -e s:/var/run:/run:g \ |
| 97 | -e s:/var:${localstatedir}:g \ |
| 98 | -e s:/usr/bin:${bindir}:g \ |
| 99 | -e s:/bin/kill:${base_bindir}/kill:g \ |
| 100 | -e s:/usr/lib:${libdir}:g \ |
| 101 | ${WORKDIR}/suricata.service > ${D}${systemd_unitdir}/system/suricata.service |
| 102 | fi |
| 103 | |
| 104 | # Remove /var/run as it is created on startup |
| 105 | rm -rf ${D}${localstatedir}/run |
| 106 | |
| 107 | sed -i -e "s:#!.*$:#!${USRBINPATH}/env ${PYTHON_PN}:g" ${D}${bindir}/suricatasc |
| 108 | sed -i -e "s:#!.*$:#!${USRBINPATH}/env ${PYTHON_PN}:g" ${D}${bindir}/suricatactl |
Andrew Geissler | 2daf84b | 2023-03-31 09:57:23 -0500 | [diff] [blame] | 109 | 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] | 110 | } |
| 111 | |
| 112 | pkg_postinst_ontarget:${PN} () { |
| 113 | if command -v systemd-tmpfiles >/dev/null; then |
| 114 | systemd-tmpfiles --create ${sysconfdir}/tmpfiles.d/suricata.conf |
| 115 | elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then |
| 116 | ${sysconfdir}/init.d/populate-volatile.sh update |
| 117 | fi |
| 118 | } |
| 119 | |
| 120 | SYSTEMD_PACKAGES = "${PN}" |
| 121 | |
| 122 | PACKAGES =+ "${PN}-python" |
| 123 | FILES:${PN} += "${systemd_unitdir} ${sysconfdir}/tmpfiles.d" |
| 124 | FILES:${PN}-python = "${bindir}/suricatasc ${PYTHON_SITEPACKAGES_DIR}" |
| 125 | |
| 126 | CONFFILES:${PN} = "${sysconfdir}/suricata/suricata.yaml" |