Merge pull request #17303 from CarlosDerSeher/feature_bt_agent
[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.3.0
10 PKG_RELEASE:=$(AUTORELEASE)
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:=b81419d9a1af500c16a02f052ac6af54253a621ee1575131dfae0f578426d816
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_USE_MIPS16:=0
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/crowdsec/pkg/cwversion
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 define Package/crowdsec/install
86 $(call GoPackage/Package/Install/Bin,$(1))
87
88 $(INSTALL_DIR) $(1)/etc/crowdsec
89 $(INSTALL_DIR) $(1)/etc/crowdsec/scenarios
90 $(INSTALL_DIR) $(1)/etc/crowdsec/postoverflows
91 $(INSTALL_DIR) $(1)/etc/crowdsec/collections
92 $(INSTALL_DIR) $(1)/etc/crowdsec/patterns
93 $(INSTALL_DIR) $(1)/etc/crowdsec/hub
94
95 $(INSTALL_DATA) \
96 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/config.yaml \
97 $(1)/etc/crowdsec
98 $(INSTALL_DATA) \
99 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/dev.yaml \
100 $(1)/etc/crowdsec
101 $(INSTALL_DATA) \
102 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/user.yaml \
103 $(1)/etc/crowdsec
104 $(INSTALL_DATA) \
105 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/acquis.yaml \
106 $(1)/etc/crowdsec
107 $(INSTALL_DATA) \
108 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/profiles.yaml \
109 $(1)/etc/crowdsec
110 $(INSTALL_DATA) \
111 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/simulation.yaml \
112 $(1)/etc/crowdsec
113 $(INSTALL_DATA) \
114 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/local_api_credentials.yaml \
115 $(1)/etc/crowdsec
116 $(INSTALL_DATA) \
117 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/online_api_credentials.yaml \
118 $(1)/etc/crowdsec
119
120 $(CP) \
121 $(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/patterns/* \
122 $(1)/etc/crowdsec/patterns
123
124 $(INSTALL_DIR) $(1)/srv/crowdsec/data/
125
126 $(INSTALL_DIR) $(1)/etc/init.d
127 $(INSTALL_BIN) \
128 ./files/crowdsec.initd \
129 $(1)/etc/init.d/crowdsec
130
131 $(INSTALL_DIR) $(1)/etc/config
132 $(INSTALL_CONF) \
133 ./files/crowdsec.config \
134 $(1)/etc/config/crowdsec
135
136 $(LN) /usr/bin/crowdsec-cli $(1)/usr/bin/cscli
137
138 $(INSTALL_DIR) $(1)/etc/uci-defaults
139 $(INSTALL_BIN) \
140 ./files/crowdsec.defaults \
141 $(1)/etc/uci-defaults/99_crowdsec
142 endef
143
144 define Package/crowdsec/conffiles
145 /etc/crowdsec/
146 /etc/config/crowdsec
147 endef
148
149 $(eval $(call GoBinPackage,crowdsec))
150 $(eval $(call BuildPackage,crowdsec))