1
0

Makefile 6.9 KB

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