yggdrasil: bump to 0.5.4
[feed/packages.git] / net / crowdsec / Makefile
1 # SPDX-License-Identifier: MIT
2 #
3 # Copyright (C) 2021-2022 Gerald Kerma <gandalf@gk2.net>
4 #
5
6 include $(TOPDIR)/rules.mk
7
8 PKG_NAME:=crowdsec
9 PKG_VERSION:=1.5.4
10 PKG_RELEASE:=1
11
12 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
13 PKG_SOURCE_URL:=https://codeload.github.com/crowdsecurity/crowdsec/tar.gz/v$(PKG_VERSION)?
14 PKG_HASH:=afa4021f77e9cb87d7fd11cd86146770836dc15cad1ae8a4edce1314b14be98a
15
16 PKG_LICENSE:=MIT
17 PKG_LICENSE_FILES:=LICENSE
18 PKG_MAINTAINER:=Gerald Kerma <gandalf@gk2.net>
19
20 PKG_BUILD_DEPENDS:=golang/host
21 PKG_BUILD_PARALLEL:=1
22 PKG_BUILD_FLAGS:=no-mips16
23
24 CWD_SYSTEM:=openwrt
25
26 CWD_BUILD_VERSION?=v$(PKG_VERSION)
27 CWD_BUILD_GOVERSION:=$(shell go version | cut -d " " -f3 | sed -E 's/[go]+//g')
28 CWD_BUILD_CODENAME:=alphaga
29 CWD_BUILD_TIMESTAMP:=$(shell date +%F"_"%T)
30 CWD_BUILD_TAG:=openwrt-$(PKG_VERSION)-$(PKG_RELEASE)
31
32 CWD_VERSION_PKG:=github.com/crowdsecurity/go-cs-lib/version
33
34 GO_PKG:=github.com/crowdsecurity/crowdsec
35 GO_PKG_INSTALL_ALL:=1
36 GO_PKG_LDFLAGS_X:=$(CWD_VERSION_PKG).Version=$(CWD_BUILD_VERSION) \
37 $(CWD_VERSION_PKG).System=$(CWD_SYSTEM) \
38 $(CWD_VERSION_PKG).BuildDate=$(CWD_BUILD_TIMESTAMP) \
39 $(CWD_VERSION_PKG).Codename=$(CWD_BUILD_CODENAME) \
40 $(CWD_VERSION_PKG).Tag=$(CWD_BUILD_TAG) \
41 $(CWD_VERSION_PKG).GoVersion=$(CWD_BUILD_GOVERSION)
42
43 include $(INCLUDE_DIR)/package.mk
44 include ../../lang/golang/golang-package.mk
45
46 define Package/crowdsec/Default
47 SECTION:=net
48 CATEGORY:=Network
49 TITLE:=Crowdsec detection engine
50 URL:=https://crowdsec.net/
51 endef
52
53 define Package/crowdsec
54 $(call Package/crowdsec/Default)
55 DEPENDS:=$(GO_ARCH_DEPENDS)
56 endef
57
58 define Package/golang-crowdsec-dev
59 $(call Package/crowdsec/Default)
60 $(call GoPackage/GoSubMenu)
61 TITLE+= (source files)
62 DEPENDS:=$(GO_ARCH_DEPENDS)
63 PKGARCH:=all
64 endef
65
66 define Package/crowdsec/Default/description
67 Crowdsec - An open-source, lightweight agent to detect
68 and respond to bad behaviours.
69 It also automatically benefits from a global
70 community-wide IP reputation database.
71 endef
72
73 define Package/crowdsec/description
74 $(call Package/crowdsec/Default/description)
75
76 This package contains the main program.
77 endef
78
79 define Package/golang-crowdsec-dev/description
80 $(call Package/crowdsec/Default/description)
81
82 This package provides the source files for the program.
83 endef
84
85 ifneq ($(CONFIG_USE_MUSL),)
86 TARGET_CFLAGS += -D_LARGEFILE64_SOURCE
87 endif
88
89 define Package/crowdsec/install
90 $(call GoPackage/Package/Install/Bin,$(1))
91
92 $(INSTALL_DIR) $(1)/etc/crowdsec
93 $(INSTALL_DIR) $(1)/etc/crowdsec/scenarios
94 $(INSTALL_DIR) $(1)/etc/crowdsec/postoverflows
95 $(INSTALL_DIR) $(1)/etc/crowdsec/collections
96 $(INSTALL_DIR) $(1)/etc/crowdsec/patterns
97 $(INSTALL_DIR) $(1)/etc/crowdsec/hub
98
99 $(INSTALL_DATA) \
100 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/config.yaml \
101 $(1)/etc/crowdsec
102 $(INSTALL_DATA) \
103 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/dev.yaml \
104 $(1)/etc/crowdsec
105 $(INSTALL_DATA) \
106 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/user.yaml \
107 $(1)/etc/crowdsec
108 $(INSTALL_DATA) \
109 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/acquis.yaml \
110 $(1)/etc/crowdsec
111 $(INSTALL_DATA) \
112 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/profiles.yaml \
113 $(1)/etc/crowdsec
114 $(INSTALL_DATA) \
115 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/simulation.yaml \
116 $(1)/etc/crowdsec
117 $(INSTALL_DATA) \
118 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/local_api_credentials.yaml \
119 $(1)/etc/crowdsec
120 $(INSTALL_DATA) \
121 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/online_api_credentials.yaml \
122 $(1)/etc/crowdsec
123
124 $(CP) \
125 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/patterns/* \
126 $(1)/etc/crowdsec/patterns
127
128 $(INSTALL_DIR) $(1)/srv/crowdsec/data/
129
130 $(INSTALL_DIR) $(1)/etc/init.d
131 $(INSTALL_BIN) \
132 ./files/crowdsec.initd \
133 $(1)/etc/init.d/crowdsec
134
135 $(INSTALL_DIR) $(1)/etc/config
136 $(INSTALL_CONF) \
137 ./files/crowdsec.config \
138 $(1)/etc/config/crowdsec
139
140 $(LN) /usr/bin/crowdsec-cli $(1)/usr/bin/cscli
141
142 $(INSTALL_DIR) $(1)/etc/uci-defaults
143 $(INSTALL_BIN) \
144 ./files/crowdsec.defaults \
145 $(1)/etc/uci-defaults/99_crowdsec
146 endef
147
148 define Package/crowdsec/conffiles
149 /etc/crowdsec/
150 /etc/config/crowdsec
151 endef
152
153 $(eval $(call GoBinPackage,crowdsec))
154 $(eval $(call BuildPackage,crowdsec))