dropbear: bump to 2022.83
[openwrt/openwrt.git] / package / network / services / dropbear / Makefile
1 #
2 # Copyright (C) 2006-2020 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=dropbear
11 PKG_VERSION:=2022.83
12 PKG_RELEASE:=1
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
15 PKG_SOURCE_URL:= \
16 https://matt.ucc.asn.au/dropbear/releases/ \
17 https://dropbear.nl/mirror/releases/
18 PKG_HASH:=bc5a121ffbc94b5171ad5ebe01be42746d50aa797c9549a4639894a16749443b
19
20 PKG_LICENSE:=MIT
21 PKG_LICENSE_FILES:=LICENSE libtomcrypt/LICENSE libtommath/LICENSE
22 PKG_CPE_ID:=cpe:/a:matt_johnston:dropbear_ssh_server
23
24 PKG_BUILD_PARALLEL:=1
25 PKG_ASLR_PIE_REGULAR:=1
26 PKG_BUILD_FLAGS:=no-mips16 gc-sections lto
27 PKG_FIXUP:=autoreconf
28 PKG_FLAGS:=nonshared
29
30 PKG_CONFIG_DEPENDS:= \
31 CONFIG_TARGET_INIT_PATH CONFIG_DROPBEAR_ECC CONFIG_DROPBEAR_ECC_FULL \
32 CONFIG_DROPBEAR_CURVE25519 CONFIG_DROPBEAR_ZLIB \
33 CONFIG_DROPBEAR_ED25519 CONFIG_DROPBEAR_CHACHA20POLY1305 \
34 CONFIG_DROPBEAR_UTMP CONFIG_DROPBEAR_PUTUTLINE \
35 CONFIG_DROPBEAR_DBCLIENT CONFIG_DROPBEAR_SCP CONFIG_DROPBEAR_ASKPASS \
36 CONFIG_DROPBEAR_DBCLIENT_AGENTFORWARD CONFIG_DROPBEAR_AGENTFORWARD
37
38 include $(INCLUDE_DIR)/package.mk
39
40 ifneq ($(DUMP),1)
41 STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell echo $(CONFIG_TARGET_INIT_PATH) | $(MKHASH) md5)
42 endif
43
44 define Package/dropbear/Default
45 URL:=https://matt.ucc.asn.au/dropbear/
46 endef
47
48 define Package/dropbear/config
49 source "$(SOURCE)/Config.in"
50 endef
51
52 define Package/dropbear
53 $(call Package/dropbear/Default)
54 SECTION:=net
55 CATEGORY:=Base system
56 TITLE:=Small SSH2 client/server
57 DEPENDS:= +DROPBEAR_ZLIB:zlib
58 ALTERNATIVES:=
59 $(if $(CONFIG_DROPBEAR_SCP),ALTERNATIVES+= \
60 100:/usr/bin/scp:/usr/sbin/dropbear,)
61 $(if $(CONFIG_DROPBEAR_DBCLIENT),ALTERNATIVES+= \
62 100:/usr/bin/ssh:/usr/sbin/dropbear,)
63
64 endef
65
66 define Package/dropbear/description
67 A small SSH2 server/client designed for small memory environments.
68 endef
69
70 define Package/dropbear/conffiles
71 $(if $(CONFIG_DROPBEAR_ED25519),/etc/dropbear/dropbear_ed25519_host_key)
72 $(if $(CONFIG_DROPBEAR_ECC),/etc/dropbear/dropbear_ecdsa_host_key)
73 /etc/dropbear/dropbear_rsa_host_key
74 /etc/config/dropbear
75 endef
76
77 define Package/dropbearconvert
78 $(call Package/dropbear/Default)
79 SECTION:=utils
80 CATEGORY:=Utilities
81 TITLE:=Utility for converting SSH keys
82 DEPENDS:= +DROPBEAR_ZLIB:zlib
83 endef
84
85 CONFIGURE_ARGS += \
86 --disable-pam \
87 --enable-openpty \
88 --enable-syslog \
89 --disable-lastlog \
90 --disable-utmpx \
91 $(if $(CONFIG_DROPBEAR_UTMP),,--disable-utmp) \
92 --disable-wtmp \
93 --disable-wtmpx \
94 --disable-loginfunc \
95 $(if $(CONFIG_DROPBEAR_PUTUTLINE),,--disable-pututline) \
96 --disable-pututxline \
97 $(if $(CONFIG_DROPBEAR_ZLIB),,--disable-zlib) \
98 --enable-bundled-libtom
99
100 ##############################################################################
101 #
102 # option|value - add option to localoptions.h
103 # !!option|value - replace option in sysoptions.h
104 #
105 ##############################################################################
106
107 # remove protocol idented software version number:
108 # - LOCAL_IDENT
109 # disable legacy/unsafe methods and unused functionality:
110 # - DROPBEAR_CLI_NETCAT
111 # - DROPBEAR_DSS
112 # - DO_MOTD
113 DB_OPT_COMMON = \
114 DEFAULT_PATH|"$(TARGET_INIT_PATH)" \
115 !!LOCAL_IDENT|"SSH-2.0-dropbear" \
116 DROPBEAR_CLI_NETCAT|0 \
117 !!DROPBEAR_DSS|0 \
118 DROPBEAR_DSS|0 \
119 DO_MOTD|0 \
120
121
122 ##############################################################################
123 #
124 # option|config|enabled|disabled = add option to localoptions.h
125 # !!option|config|enabled|disabled = replace option in sysoptions.h
126 #
127 # option := (config) ? enabled : disabled
128 #
129 ##############################################################################
130
131 DB_OPT_CONFIG = \
132 DROPBEAR_CURVE25519|CONFIG_DROPBEAR_CURVE25519|1|0 \
133 DROPBEAR_ED25519|CONFIG_DROPBEAR_ED25519|1|0 \
134 DROPBEAR_SK_ED25519|CONFIG_DROPBEAR_ED25519|1|0 \
135 DROPBEAR_CHACHA20POLY1305|CONFIG_DROPBEAR_CHACHA20POLY1305|1|0 \
136 DROPBEAR_ECDSA|CONFIG_DROPBEAR_ECC|1|0 \
137 DROPBEAR_SK_ECDSA|CONFIG_DROPBEAR_ECC|1|0 \
138 DROPBEAR_ECDH|CONFIG_DROPBEAR_ECC|1|0 \
139 !!DROPBEAR_ECC_384|CONFIG_DROPBEAR_ECC_FULL|1|0 \
140 !!DROPBEAR_ECC_521|CONFIG_DROPBEAR_ECC_FULL|1|0 \
141 DROPBEAR_CLI_ASKPASS_HELPER|CONFIG_DROPBEAR_ASKPASS|1|0 \
142 DROPBEAR_CLI_AGENTFWD|CONFIG_DROPBEAR_DBCLIENT_AGENTFORWARD|1|0 \
143 DROPBEAR_SVR_AGENTFWD|CONFIG_DROPBEAR_AGENTFORWARD|1|0 \
144
145
146 TARGET_CFLAGS += -DARGTYPE=3
147
148 db_opt_add =echo '\#define $(1) $(2)' >> $(PKG_BUILD_DIR)/localoptions.h
149 db_opt_replace =$(ESED) 's,^(\#define $(1)) .*$$$$,\1 $(2),g' $(PKG_BUILD_DIR)/sysoptions.h
150
151 define Build/Configure/dropbear_headers
152 $(strip $(foreach s,$(DB_OPT_COMMON), \
153 $(if $(filter !!%,$(word 1,$(subst |, ,$(s)))), \
154 $(call db_opt_replace,$(patsubst !!%,%,$(word 1,$(subst |, ,$(s)))),$(word 2,$(subst |, ,$(s)))), \
155 $(call db_opt_add,$(word 1,$(subst |, ,$(s))),$(word 2,$(subst |, ,$(s)))) \
156 ) ; \
157 ))
158
159 $(strip $(foreach s,$(DB_OPT_CONFIG), \
160 $(if $(filter !!%,$(word 1,$(subst |, ,$(s)))), \
161 $(call db_opt_replace,$(patsubst !!%,%,$(word 1,$(subst |, ,$(s)))),$(if $($(word 2,$(subst |, ,$(s)))),$(word 3,$(subst |, ,$(s))),$(word 4,$(subst |, ,$(s))))), \
162 $(call db_opt_add,$(word 1,$(subst |, ,$(s))),$(if $($(word 2,$(subst |, ,$(s)))),$(word 3,$(subst |, ,$(s))),$(word 4,$(subst |, ,$(s))))) \
163 ) ; \
164 ))
165 endef
166
167 define Build/Configure
168 : > $(PKG_BUILD_DIR)/localoptions.h
169
170 $(Build/Configure/Default)
171
172 $(Build/Configure/dropbear_headers)
173
174 # Enforce rebuild of svr-chansession.c
175 rm -f $(PKG_BUILD_DIR)/svr-chansession.o
176
177 # Rebuild them on config change
178 +$(MAKE) -C $(PKG_BUILD_DIR)/libtomcrypt clean
179 +$(MAKE) -C $(PKG_BUILD_DIR)/libtommath clean
180 endef
181
182 define Build/Compile
183 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
184 $(TARGET_CONFIGURE_OPTS) \
185 IGNORE_SPEED=1 \
186 PROGRAMS="dropbear $(if $(CONFIG_DROPBEAR_DBCLIENT),dbclient,) dropbearkey $(if $(CONFIG_DROPBEAR_SCP),scp,)" \
187 MULTI=1 SCPPROGRESS=1
188 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
189 $(TARGET_CONFIGURE_OPTS) \
190 IGNORE_SPEED=1 \
191 PROGRAMS="dropbearconvert"
192 endef
193
194 define Package/dropbear/install
195 $(INSTALL_DIR) $(1)/usr/sbin
196 $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearmulti $(1)/usr/sbin/dropbear
197 $(INSTALL_DIR) $(1)/usr/bin
198 $(if $(CONFIG_DROPBEAR_DBCLIENT),$(LN) ../sbin/dropbear $(1)/usr/bin/dbclient,)
199 $(LN) ../sbin/dropbear $(1)/usr/bin/dropbearkey
200 $(INSTALL_DIR) $(1)/etc/config
201 $(INSTALL_CONF) ./files/dropbear.config $(1)/etc/config/dropbear
202 $(INSTALL_DIR) $(1)/etc/init.d
203 $(INSTALL_BIN) ./files/dropbear.init $(1)/etc/init.d/dropbear
204 $(INSTALL_DIR) $(1)/usr/lib/opkg/info
205 $(INSTALL_DIR) $(1)/etc/dropbear
206 $(INSTALL_DIR) $(1)/lib/preinit
207 $(INSTALL_DATA) ./files/dropbear.failsafe $(1)/lib/preinit/99_10_failsafe_dropbear
208 $(if $(CONFIG_DROPBEAR_ED25519),touch $(1)/etc/dropbear/dropbear_ed25519_host_key)
209 $(if $(CONFIG_DROPBEAR_ECC),touch $(1)/etc/dropbear/dropbear_ecdsa_host_key)
210 touch $(1)/etc/dropbear/dropbear_rsa_host_key
211 endef
212
213 define Package/dropbearconvert/install
214 $(INSTALL_DIR) $(1)/usr/bin
215 $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearconvert $(1)/usr/bin/dropbearconvert
216 endef
217
218 $(eval $(call BuildPackage,dropbear))
219 $(eval $(call BuildPackage,dropbearconvert))