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" |
Patrick Williams | db4c27e | 2022-08-05 08:10:29 -0500 | [diff] [blame] | 8 | SRC_URI[sha256sum] = "00173634fa76aee636e38a90b1c02616c903e42173107d47b4114960b5fbe839" |
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 | |
| 21 | SRC_URI += " \ |
| 22 | crate://crates.io/autocfg/1.0.1 \ |
| 23 | crate://crates.io/semver-parser/0.7.0 \ |
| 24 | crate://crates.io/arrayvec/0.4.12 \ |
| 25 | crate://crates.io/ryu/1.0.5 \ |
| 26 | crate://crates.io/libc/0.2.86 \ |
| 27 | crate://crates.io/bitflags/1.2.1 \ |
| 28 | crate://crates.io/version_check/0.9.2 \ |
| 29 | crate://crates.io/memchr/2.3.4 \ |
| 30 | crate://crates.io/nodrop/0.1.14 \ |
| 31 | crate://crates.io/cfg-if/0.1.9 \ |
| 32 | crate://crates.io/static_assertions/0.3.4 \ |
| 33 | crate://crates.io/getrandom/0.1.16 \ |
| 34 | crate://crates.io/cfg-if/1.0.0 \ |
| 35 | crate://crates.io/siphasher/0.3.3 \ |
| 36 | crate://crates.io/ppv-lite86/0.2.10 \ |
| 37 | crate://crates.io/proc-macro-hack/0.5.19 \ |
| 38 | crate://crates.io/proc-macro2/0.4.30 \ |
| 39 | crate://crates.io/unicode-xid/0.1.0 \ |
| 40 | crate://crates.io/syn/0.15.44 \ |
| 41 | crate://crates.io/build_const/0.2.1 \ |
| 42 | crate://crates.io/num-derive/0.2.5 \ |
| 43 | crate://crates.io/base64/0.11.0 \ |
| 44 | crate://crates.io/widestring/0.4.3 \ |
| 45 | crate://crates.io/md5/0.7.0 \ |
| 46 | crate://crates.io/uuid/0.8.2 \ |
| 47 | crate://crates.io/byteorder/1.4.2 \ |
| 48 | crate://crates.io/semver/0.9.0 \ |
| 49 | crate://crates.io/nom/5.1.1 \ |
| 50 | crate://crates.io/num-traits/0.2.14 \ |
| 51 | crate://crates.io/num-integer/0.1.44 \ |
| 52 | crate://crates.io/num-bigint/0.2.6 \ |
| 53 | crate://crates.io/num-bigint/0.3.1 \ |
| 54 | crate://crates.io/num-rational/0.2.4 \ |
| 55 | crate://crates.io/num-complex/0.2.4 \ |
| 56 | crate://crates.io/num-iter/0.1.42 \ |
| 57 | crate://crates.io/phf_shared/0.8.0 \ |
| 58 | crate://crates.io/crc/1.8.1 \ |
| 59 | crate://crates.io/rustc_version/0.2.3 \ |
| 60 | crate://crates.io/phf/0.8.0 \ |
| 61 | crate://crates.io/lexical-core/0.6.8 \ |
| 62 | crate://crates.io/time/0.1.44 \ |
| 63 | crate://crates.io/quote/0.6.13 \ |
| 64 | crate://crates.io/rand_core/0.5.1 \ |
| 65 | crate://crates.io/rand_chacha/0.2.2 \ |
| 66 | crate://crates.io/rand_pcg/0.2.1 \ |
| 67 | crate://crates.io/num-traits/0.1.43 \ |
| 68 | crate://crates.io/rand/0.7.3 \ |
| 69 | crate://crates.io/enum_primitive/0.1.1 \ |
| 70 | crate://crates.io/phf_generator/0.8.0 \ |
| 71 | crate://crates.io/phf_codegen/0.8.0 \ |
| 72 | crate://crates.io/tls-parser/0.9.4 \ |
| 73 | crate://crates.io/num/0.2.1 \ |
| 74 | crate://crates.io/rusticata-macros/2.1.0 \ |
| 75 | crate://crates.io/ntp-parser/0.4.0 \ |
| 76 | crate://crates.io/der-oid-macro/0.2.0 \ |
| 77 | crate://crates.io/der-parser/3.0.4 \ |
| 78 | crate://crates.io/ipsec-parser/0.5.0 \ |
| 79 | crate://crates.io/x509-parser/0.6.5 \ |
| 80 | crate://crates.io/der-parser/4.1.0 \ |
| 81 | crate://crates.io/snmp-parser/0.6.0 \ |
| 82 | crate://crates.io/kerberos-parser/0.5.0 \ |
| 83 | crate://crates.io/wasi/0.10.0+wasi-snapshot-preview1 \ |
| 84 | crate://crates.io/winapi/0.3.9 \ |
| 85 | crate://crates.io/winapi-i686-pc-windows-gnu/0.4.0 \ |
| 86 | crate://crates.io/winapi-x86_64-pc-windows-gnu/0.4.0 \ |
| 87 | crate://crates.io/log/0.4.0 \ |
| 88 | crate://crates.io/rand_hc/0.2.0 \ |
| 89 | crate://crates.io/wasi/0.9.0+wasi-snapshot-preview1 \ |
| 90 | crate://crates.io/sawp/0.5.0 \ |
| 91 | crate://crates.io/sawp-modbus/0.5.0 \ |
| 92 | crate://crates.io/brotli/3.3.0 \ |
| 93 | crate://crates.io/flate2/1.0.20 \ |
| 94 | crate://crates.io/alloc-no-stdlib/2.0.1 \ |
| 95 | crate://crates.io/alloc-stdlib/0.2.1 \ |
| 96 | crate://crates.io/brotli-decompressor/2.3.1 \ |
| 97 | crate://crates.io/crc32fast/1.2.1 \ |
| 98 | crate://crates.io/miniz_oxide/0.4.4 \ |
| 99 | crate://crates.io/adler/1.0.2 \ |
| 100 | " |
| 101 | |
| 102 | # test case support |
| 103 | SRC_URI += " \ |
| 104 | crate://crates.io/test-case/1.0.1 \ |
| 105 | crate://crates.io/proc-macro2/1.0.1 \ |
| 106 | crate://crates.io/quote/1.0.1 \ |
| 107 | crate://crates.io/syn/1.0.1 \ |
| 108 | crate://crates.io/unicode-xid/0.2.0 \ |
| 109 | " |
| 110 | |
| 111 | inherit autotools pkgconfig python3native systemd ptest cargo |
| 112 | |
| 113 | EXTRA_OECONF += " --disable-debug \ |
| 114 | --disable-gccmarch-native \ |
| 115 | --enable-non-bundled-htp \ |
| 116 | --disable-suricata-update \ |
| 117 | --with-libhtp-includes=${STAGING_INCDIR} --with-libhtp-libraries=${STAGING_LIBDIR} \ |
| 118 | " |
| 119 | |
| 120 | CARGO_SRC_DIR = "rust" |
| 121 | |
| 122 | B = "${S}" |
| 123 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 124 | # nfnetlink has a dependancy to meta-networking |
| 125 | PACKAGECONFIG ??= "jansson file pcre yaml python pcap cap-ng net nss nspr " |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 126 | PACKAGECONFIG:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'ptest', 'unittests', '', d)}" |
| 127 | |
| 128 | PACKAGECONFIG[pcre] = "--with-libpcre-includes=${STAGING_INCDIR} --with-libpcre-libraries=${STAGING_LIBDIR}, ,libpcre ," |
| 129 | PACKAGECONFIG[yaml] = "--with-libyaml-includes=${STAGING_INCDIR} --with-libyaml-libraries=${STAGING_LIBDIR}, ,libyaml ," |
| 130 | PACKAGECONFIG[pcap] = "--with-libpcap-includes=${STAGING_INCDIR} --with-libpcap-libraries=${STAGING_LIBDIR}, ,libpcap" |
| 131 | PACKAGECONFIG[cap-ng] = "--with-libcap_ng-includes=${STAGING_INCDIR} --with-libcap_ng-libraries=${STAGING_LIBDIR}, ,libcap-ng , " |
| 132 | PACKAGECONFIG[net] = "--with-libnet-includes=${STAGING_INCDIR} --with-libnet-libraries=${STAGING_LIBDIR}, , libnet," |
| 133 | PACKAGECONFIG[nfnetlink] = "--with-libnfnetlink-includes=${STAGING_INCDIR} --with-libnfnetlink-libraries=${STAGING_LIBDIR}, ,libnfnetlink ," |
| 134 | PACKAGECONFIG[nfq] = "--enable-nfqueue, --disable-nfqueue,libnetfilter-queue," |
| 135 | |
| 136 | PACKAGECONFIG[jansson] = "--with-libjansson-includes=${STAGING_INCDIR} --with-libjansson-libraries=${STAGING_LIBDIR},,jansson, jansson" |
| 137 | PACKAGECONFIG[file] = ",,file, file" |
| 138 | PACKAGECONFIG[nss] = "--with-libnss-includes=${STAGING_INCDIR} --with-libnss-libraries=${STAGING_LIBDIR}, nss, nss," |
| 139 | PACKAGECONFIG[nspr] = "--with-libnspr-includes=${STAGING_INCDIR} --with-libnspr-libraries=${STAGING_LIBDIR}, nspr, nspr," |
| 140 | PACKAGECONFIG[python] = "--enable-python, --disable-python, python3, python3-core" |
| 141 | PACKAGECONFIG[unittests] = "--enable-unittests, --disable-unittests," |
| 142 | |
| 143 | export logdir = "${localstatedir}/log" |
| 144 | |
| 145 | CACHED_CONFIGUREVARS = "ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes" |
| 146 | |
| 147 | do_configure:prepend () { |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 148 | # use host for RUST_SURICATA_LIB_XC_DIR |
| 149 | sed -i -e 's,\${host_alias},${RUST_HOST_SYS},' ${S}/configure.ac |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 150 | oe_runconf |
| 151 | } |
| 152 | |
| 153 | do_compile () { |
| 154 | # we do this to bypass the make provided by this pkg |
| 155 | # patches Makefile to skip the subdir |
| 156 | cargo_do_compile |
| 157 | |
| 158 | # Finish building |
| 159 | cd ${S} |
| 160 | make |
| 161 | } |
| 162 | |
| 163 | do_install () { |
| 164 | install -d ${D}${sysconfdir}/suricata |
| 165 | |
| 166 | oe_runmake install DESTDIR=${D} |
| 167 | |
| 168 | install -d ${D}${sysconfdir}/suricata ${D}${sysconfdir}/default/volatiles |
| 169 | install -m 0644 ${WORKDIR}/volatiles.03_suricata ${D}${sysconfdir}/default/volatiles/03_suricata |
| 170 | |
| 171 | install -m 0644 ${S}/threshold.config ${D}${sysconfdir}/suricata |
| 172 | install -m 0644 ${S}/suricata.yaml ${D}${sysconfdir}/suricata |
| 173 | |
| 174 | if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then |
| 175 | install -d ${D}${sysconfdir}/tmpfiles.d |
| 176 | install -m 0644 ${WORKDIR}/tmpfiles.suricata ${D}${sysconfdir}/tmpfiles.d/suricata.conf |
| 177 | |
| 178 | install -d ${D}${systemd_unitdir}/system |
| 179 | sed -e s:/etc:${sysconfdir}:g \ |
| 180 | -e s:/var/run:/run:g \ |
| 181 | -e s:/var:${localstatedir}:g \ |
| 182 | -e s:/usr/bin:${bindir}:g \ |
| 183 | -e s:/bin/kill:${base_bindir}/kill:g \ |
| 184 | -e s:/usr/lib:${libdir}:g \ |
| 185 | ${WORKDIR}/suricata.service > ${D}${systemd_unitdir}/system/suricata.service |
| 186 | fi |
| 187 | |
| 188 | # Remove /var/run as it is created on startup |
| 189 | rm -rf ${D}${localstatedir}/run |
| 190 | |
| 191 | sed -i -e "s:#!.*$:#!${USRBINPATH}/env ${PYTHON_PN}:g" ${D}${bindir}/suricatasc |
| 192 | sed -i -e "s:#!.*$:#!${USRBINPATH}/env ${PYTHON_PN}:g" ${D}${bindir}/suricatactl |
| 193 | } |
| 194 | |
| 195 | pkg_postinst_ontarget:${PN} () { |
| 196 | if command -v systemd-tmpfiles >/dev/null; then |
| 197 | systemd-tmpfiles --create ${sysconfdir}/tmpfiles.d/suricata.conf |
| 198 | elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then |
| 199 | ${sysconfdir}/init.d/populate-volatile.sh update |
| 200 | fi |
| 201 | } |
| 202 | |
| 203 | SYSTEMD_PACKAGES = "${PN}" |
| 204 | |
| 205 | PACKAGES =+ "${PN}-python" |
| 206 | FILES:${PN} += "${systemd_unitdir} ${sysconfdir}/tmpfiles.d" |
| 207 | FILES:${PN}-python = "${bindir}/suricatasc ${PYTHON_SITEPACKAGES_DIR}" |
| 208 | |
| 209 | CONFFILES:${PN} = "${sysconfdir}/suricata/suricata.yaml" |