blob: 9d533568c7246e7ced572f6ff0fb5c6d8d4d3242 [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 Geissler2daf84b2023-03-31 09:57:23 -05008SRC_URI[sha256sum] = "59bfd1bf5d9c1596226fa4815bf76643ce59698866c107a26269c481f125c4d7"
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"
Patrick Williams8e7b46e2023-05-01 14:19:06 -050033#CARGO_LOCK_SRC_DIR = "${S}/rust"
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000034
35B = "${S}"
36
Andrew Geisslerd5838332022-05-27 11:33:10 -050037# nfnetlink has a dependancy to meta-networking
38PACKAGECONFIG ??= "jansson file pcre yaml python pcap cap-ng net nss nspr "
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000039PACKAGECONFIG:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'ptest', 'unittests', '', d)}"
40
41PACKAGECONFIG[pcre] = "--with-libpcre-includes=${STAGING_INCDIR} --with-libpcre-libraries=${STAGING_LIBDIR}, ,libpcre ,"
42PACKAGECONFIG[yaml] = "--with-libyaml-includes=${STAGING_INCDIR} --with-libyaml-libraries=${STAGING_LIBDIR}, ,libyaml ,"
43PACKAGECONFIG[pcap] = "--with-libpcap-includes=${STAGING_INCDIR} --with-libpcap-libraries=${STAGING_LIBDIR}, ,libpcap"
44PACKAGECONFIG[cap-ng] = "--with-libcap_ng-includes=${STAGING_INCDIR} --with-libcap_ng-libraries=${STAGING_LIBDIR}, ,libcap-ng , "
45PACKAGECONFIG[net] = "--with-libnet-includes=${STAGING_INCDIR} --with-libnet-libraries=${STAGING_LIBDIR}, , libnet,"
46PACKAGECONFIG[nfnetlink] = "--with-libnfnetlink-includes=${STAGING_INCDIR} --with-libnfnetlink-libraries=${STAGING_LIBDIR}, ,libnfnetlink ,"
47PACKAGECONFIG[nfq] = "--enable-nfqueue, --disable-nfqueue,libnetfilter-queue,"
48
49PACKAGECONFIG[jansson] = "--with-libjansson-includes=${STAGING_INCDIR} --with-libjansson-libraries=${STAGING_LIBDIR},,jansson, jansson"
50PACKAGECONFIG[file] = ",,file, file"
51PACKAGECONFIG[nss] = "--with-libnss-includes=${STAGING_INCDIR} --with-libnss-libraries=${STAGING_LIBDIR}, nss, nss,"
52PACKAGECONFIG[nspr] = "--with-libnspr-includes=${STAGING_INCDIR} --with-libnspr-libraries=${STAGING_LIBDIR}, nspr, nspr,"
53PACKAGECONFIG[python] = "--enable-python, --disable-python, python3, python3-core"
54PACKAGECONFIG[unittests] = "--enable-unittests, --disable-unittests,"
55
56export logdir = "${localstatedir}/log"
57
58CACHED_CONFIGUREVARS = "ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes"
59
60do_configure:prepend () {
Andrew Geissler87f5cff2022-09-30 13:13:31 -050061 # use host for RUST_SURICATA_LIB_XC_DIR
62 sed -i -e 's,\${host_alias},${RUST_HOST_SYS},' ${S}/configure.ac
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000063 oe_runconf
64}
65
66do_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
76do_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 Geissler2daf84b2023-03-31 09:57:23 -0500106 sed -i -e "s:#!.*$:#!${USRBINPATH}/env ${PYTHON_PN}:g" ${D}${libdir}/suricata/python/suricata/sc/suricatasc.py
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000107}
108
109pkg_postinst_ontarget:${PN} () {
110if command -v systemd-tmpfiles >/dev/null; then
111 systemd-tmpfiles --create ${sysconfdir}/tmpfiles.d/suricata.conf
112elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
113 ${sysconfdir}/init.d/populate-volatile.sh update
114fi
115}
116
117SYSTEMD_PACKAGES = "${PN}"
118
119PACKAGES =+ "${PN}-python"
120FILES:${PN} += "${systemd_unitdir} ${sysconfdir}/tmpfiles.d"
121FILES:${PN}-python = "${bindir}/suricatasc ${PYTHON_SITEPACKAGES_DIR}"
122
123CONFFILES:${PN} = "${sysconfdir}/suricata/suricata.yaml"