blob: a01b3d937e2fb2a47f0994ee07e376ab8daeaf84 [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 \
19 "
20
Patrick Williams8e7b46e2023-05-01 14:19:06 -050021inherit autotools pkgconfig python3native systemd ptest cargo cargo-update-recipe-crates
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000022
Patrick Williams8e7b46e2023-05-01 14:19:06 -050023require ${BPN}-crates.inc
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000024
25EXTRA_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
32CARGO_SRC_DIR = "rust"
Andrew Geissler220dafd2023-10-04 10:18:08 -050033
34CARGO_BUILD_FLAGS:remove = "--frozen"
35CARGO_BUILD_FLAGS:append = " --offline"
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000036
37B = "${S}"
38
Andrew Geisslerd5838332022-05-27 11:33:10 -050039# nfnetlink has a dependancy to meta-networking
Andrew Geissler220dafd2023-10-04 10:18:08 -050040PACKAGECONFIG ??= "jansson file pcre2 yaml python pcap cap-ng net nss nspr "
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000041PACKAGECONFIG:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'ptest', 'unittests', '', d)}"
42
Andrew Geissler220dafd2023-10-04 10:18:08 -050043PACKAGECONFIG[pcre2] = "--with-libpcre2-includes=${STAGING_INCDIR} --with-libpcre2-libraries=${STAGING_LIBDIR}, ,libpcre2 ,"
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000044PACKAGECONFIG[yaml] = "--with-libyaml-includes=${STAGING_INCDIR} --with-libyaml-libraries=${STAGING_LIBDIR}, ,libyaml ,"
45PACKAGECONFIG[pcap] = "--with-libpcap-includes=${STAGING_INCDIR} --with-libpcap-libraries=${STAGING_LIBDIR}, ,libpcap"
46PACKAGECONFIG[cap-ng] = "--with-libcap_ng-includes=${STAGING_INCDIR} --with-libcap_ng-libraries=${STAGING_LIBDIR}, ,libcap-ng , "
47PACKAGECONFIG[net] = "--with-libnet-includes=${STAGING_INCDIR} --with-libnet-libraries=${STAGING_LIBDIR}, , libnet,"
48PACKAGECONFIG[nfnetlink] = "--with-libnfnetlink-includes=${STAGING_INCDIR} --with-libnfnetlink-libraries=${STAGING_LIBDIR}, ,libnfnetlink ,"
49PACKAGECONFIG[nfq] = "--enable-nfqueue, --disable-nfqueue,libnetfilter-queue,"
50
51PACKAGECONFIG[jansson] = "--with-libjansson-includes=${STAGING_INCDIR} --with-libjansson-libraries=${STAGING_LIBDIR},,jansson, jansson"
52PACKAGECONFIG[file] = ",,file, file"
53PACKAGECONFIG[nss] = "--with-libnss-includes=${STAGING_INCDIR} --with-libnss-libraries=${STAGING_LIBDIR}, nss, nss,"
54PACKAGECONFIG[nspr] = "--with-libnspr-includes=${STAGING_INCDIR} --with-libnspr-libraries=${STAGING_LIBDIR}, nspr, nspr,"
55PACKAGECONFIG[python] = "--enable-python, --disable-python, python3, python3-core"
56PACKAGECONFIG[unittests] = "--enable-unittests, --disable-unittests,"
57
58export logdir = "${localstatedir}/log"
59
60CACHED_CONFIGUREVARS = "ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes"
61
62do_configure:prepend () {
Andrew Geissler87f5cff2022-09-30 13:13:31 -050063 # use host for RUST_SURICATA_LIB_XC_DIR
64 sed -i -e 's,\${host_alias},${RUST_HOST_SYS},' ${S}/configure.ac
Andrew Geissler220dafd2023-10-04 10:18:08 -050065 sed -i -e 's,libsuricata_rust.a,libsuricata.a,' ${S}/configure.ac
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000066 oe_runconf
67}
68
69do_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
79do_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
Patrick Williams03514f12024-04-05 07:04:11 -0500107 sed -i -e "s:#!.*$:#!${USRBINPATH}/env python3:g" ${D}${bindir}/suricatasc
108 sed -i -e "s:#!.*$:#!${USRBINPATH}/env python3:g" ${D}${bindir}/suricatactl
109 sed -i -e "s:#!.*$:#!${USRBINPATH}/env python3:g" ${D}${libdir}/suricata/python/suricata/sc/suricatasc.py
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000110}
111
112pkg_postinst_ontarget:${PN} () {
113if command -v systemd-tmpfiles >/dev/null; then
114 systemd-tmpfiles --create ${sysconfdir}/tmpfiles.d/suricata.conf
115elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
116 ${sysconfdir}/init.d/populate-volatile.sh update
117fi
118}
119
120SYSTEMD_PACKAGES = "${PN}"
121
122PACKAGES =+ "${PN}-python"
123FILES:${PN} += "${systemd_unitdir} ${sysconfdir}/tmpfiles.d"
124FILES:${PN}-python = "${bindir}/suricatasc ${PYTHON_SITEPACKAGES_DIR}"
125
126CONFFILES:${PN} = "${sysconfdir}/suricata/suricata.yaml"