blob: 6e6c42604149ae87881353be6d46c6211f03ab22 [file] [log] [blame]
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00001SUMMARY = "The Suricata Engine is an Open Source Next Generation Intrusion Detection and Prevention Engine"
2
3require suricata.inc
4
5LIC_FILES_CHKSUM = "file://LICENSE;beginline=1;endline=2;md5=c70d8d3310941dcdfcd1e02800a1f548"
6
7SRC_URI = "http://www.openinfosecfoundation.org/download/suricata-${PV}.tar.gz"
Andrew Geissler220dafd2023-10-04 10:18:08 -05008SRC_URI[sha256sum] = "7bcd1313118366451465dc3f8385a3f6aadd084ffe44dd257dda8105863bb769"
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00009
10DEPENDS = "lz4 libhtp"
11
12SRC_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 \
Patrick Williams84603582024-12-14 08:00:57 -050019 file://CVE-2024-37151.patch \
20 file://CVE-2024-38534.patch \
21 file://CVE-2024-38535_pre.patch \
22 file://CVE-2024-38535.patch \
23 file://CVE-2024-38536.patch \
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000024 "
25
Patrick Williams8e7b46e2023-05-01 14:19:06 -050026inherit autotools pkgconfig python3native systemd ptest cargo cargo-update-recipe-crates
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000027
Patrick Williams8e7b46e2023-05-01 14:19:06 -050028require ${BPN}-crates.inc
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000029
30EXTRA_OECONF += " --disable-debug \
31 --disable-gccmarch-native \
32 --enable-non-bundled-htp \
33 --disable-suricata-update \
34 --with-libhtp-includes=${STAGING_INCDIR} --with-libhtp-libraries=${STAGING_LIBDIR} \
35 "
36
37CARGO_SRC_DIR = "rust"
Andrew Geissler220dafd2023-10-04 10:18:08 -050038
39CARGO_BUILD_FLAGS:remove = "--frozen"
40CARGO_BUILD_FLAGS:append = " --offline"
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000041
42B = "${S}"
43
Andrew Geisslerd5838332022-05-27 11:33:10 -050044# nfnetlink has a dependancy to meta-networking
Andrew Geissler220dafd2023-10-04 10:18:08 -050045PACKAGECONFIG ??= "jansson file pcre2 yaml python pcap cap-ng net nss nspr "
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000046PACKAGECONFIG:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'ptest', 'unittests', '', d)}"
47
Andrew Geissler220dafd2023-10-04 10:18:08 -050048PACKAGECONFIG[pcre2] = "--with-libpcre2-includes=${STAGING_INCDIR} --with-libpcre2-libraries=${STAGING_LIBDIR}, ,libpcre2 ,"
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000049PACKAGECONFIG[yaml] = "--with-libyaml-includes=${STAGING_INCDIR} --with-libyaml-libraries=${STAGING_LIBDIR}, ,libyaml ,"
50PACKAGECONFIG[pcap] = "--with-libpcap-includes=${STAGING_INCDIR} --with-libpcap-libraries=${STAGING_LIBDIR}, ,libpcap"
51PACKAGECONFIG[cap-ng] = "--with-libcap_ng-includes=${STAGING_INCDIR} --with-libcap_ng-libraries=${STAGING_LIBDIR}, ,libcap-ng , "
52PACKAGECONFIG[net] = "--with-libnet-includes=${STAGING_INCDIR} --with-libnet-libraries=${STAGING_LIBDIR}, , libnet,"
53PACKAGECONFIG[nfnetlink] = "--with-libnfnetlink-includes=${STAGING_INCDIR} --with-libnfnetlink-libraries=${STAGING_LIBDIR}, ,libnfnetlink ,"
54PACKAGECONFIG[nfq] = "--enable-nfqueue, --disable-nfqueue,libnetfilter-queue,"
55
56PACKAGECONFIG[jansson] = "--with-libjansson-includes=${STAGING_INCDIR} --with-libjansson-libraries=${STAGING_LIBDIR},,jansson, jansson"
57PACKAGECONFIG[file] = ",,file, file"
58PACKAGECONFIG[nss] = "--with-libnss-includes=${STAGING_INCDIR} --with-libnss-libraries=${STAGING_LIBDIR}, nss, nss,"
59PACKAGECONFIG[nspr] = "--with-libnspr-includes=${STAGING_INCDIR} --with-libnspr-libraries=${STAGING_LIBDIR}, nspr, nspr,"
60PACKAGECONFIG[python] = "--enable-python, --disable-python, python3, python3-core"
61PACKAGECONFIG[unittests] = "--enable-unittests, --disable-unittests,"
62
63export logdir = "${localstatedir}/log"
64
65CACHED_CONFIGUREVARS = "ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes"
66
67do_configure:prepend () {
Andrew Geissler87f5cff2022-09-30 13:13:31 -050068 # use host for RUST_SURICATA_LIB_XC_DIR
69 sed -i -e 's,\${host_alias},${RUST_HOST_SYS},' ${S}/configure.ac
Andrew Geissler220dafd2023-10-04 10:18:08 -050070 sed -i -e 's,libsuricata_rust.a,libsuricata.a,' ${S}/configure.ac
Patrick Williams84603582024-12-14 08:00:57 -050071 autotools_do_configure
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000072}
73
Patrick Williams84603582024-12-14 08:00:57 -050074CFLAGS += "-Wno-error=incompatible-pointer-types"
75
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000076do_compile () {
77 # we do this to bypass the make provided by this pkg
78 # patches Makefile to skip the subdir
79 cargo_do_compile
80
81 # Finish building
82 cd ${S}
83 make
84}
85
86do_install () {
87 install -d ${D}${sysconfdir}/suricata
88
89 oe_runmake install DESTDIR=${D}
90
91 install -d ${D}${sysconfdir}/suricata ${D}${sysconfdir}/default/volatiles
Patrick Williams84603582024-12-14 08:00:57 -050092 install -m 0644 ${UNPACKDIR}/volatiles.03_suricata ${D}${sysconfdir}/default/volatiles/03_suricata
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000093
94 install -m 0644 ${S}/threshold.config ${D}${sysconfdir}/suricata
95 install -m 0644 ${S}/suricata.yaml ${D}${sysconfdir}/suricata
96
97 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
98 install -d ${D}${sysconfdir}/tmpfiles.d
Patrick Williams84603582024-12-14 08:00:57 -050099 install -m 0644 ${UNPACKDIR}/tmpfiles.suricata ${D}${sysconfdir}/tmpfiles.d/suricata.conf
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000100
101 install -d ${D}${systemd_unitdir}/system
102 sed -e s:/etc:${sysconfdir}:g \
103 -e s:/var/run:/run:g \
104 -e s:/var:${localstatedir}:g \
105 -e s:/usr/bin:${bindir}:g \
106 -e s:/bin/kill:${base_bindir}/kill:g \
107 -e s:/usr/lib:${libdir}:g \
Patrick Williams84603582024-12-14 08:00:57 -0500108 ${UNPACKDIR}/suricata.service > ${D}${systemd_unitdir}/system/suricata.service
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000109 fi
110
111 # Remove /var/run as it is created on startup
112 rm -rf ${D}${localstatedir}/run
113
Patrick Williams03514f12024-04-05 07:04:11 -0500114 sed -i -e "s:#!.*$:#!${USRBINPATH}/env python3:g" ${D}${bindir}/suricatasc
115 sed -i -e "s:#!.*$:#!${USRBINPATH}/env python3:g" ${D}${bindir}/suricatactl
116 sed -i -e "s:#!.*$:#!${USRBINPATH}/env python3:g" ${D}${libdir}/suricata/python/suricata/sc/suricatasc.py
Patrick Williams84603582024-12-14 08:00:57 -0500117 # The build process dumps config logs into the binary, remove them.
118 sed -i -e 's#${RECIPE_SYSROOT}##g' ${D}${bindir}/suricata
119 sed -i -e 's#${RECIPE_SYSROOT_NATIVE}##g' ${D}${bindir}/suricata
120 sed -i -e 's#CFLAGS.*##g' ${D}${bindir}/suricata
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000121}
122
123pkg_postinst_ontarget:${PN} () {
124if command -v systemd-tmpfiles >/dev/null; then
125 systemd-tmpfiles --create ${sysconfdir}/tmpfiles.d/suricata.conf
126elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
127 ${sysconfdir}/init.d/populate-volatile.sh update
128fi
129}
130
131SYSTEMD_PACKAGES = "${PN}"
132
133PACKAGES =+ "${PN}-python"
134FILES:${PN} += "${systemd_unitdir} ${sysconfdir}/tmpfiles.d"
135FILES:${PN}-python = "${bindir}/suricatasc ${PYTHON_SITEPACKAGES_DIR}"
136
137CONFFILES:${PN} = "${sysconfdir}/suricata/suricata.yaml"
Patrick Williams84603582024-12-14 08:00:57 -0500138INSANE_SKIP:${PN} = "already-stripped"