add CPE ids to package and tools
[openwrt/staging/lynxis.git] / package / network / services / dropbear / Makefile
1 #
2 # Copyright (C) 2006-2016 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:=2017.75
12 PKG_RELEASE:=4
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
15 PKG_SOURCE_URL:= \
16 http://matt.ucc.asn.au/dropbear/releases/ \
17 https://dropbear.nl/mirror/releases/
18 PKG_HASH:=6cbc1dcb1c9709d226dff669e5604172a18cf5dbf9a201474d5618ae4465098c
19
20 PKG_LICENSE:=MIT
21 PKG_LICENSE_FILES:=LICENSE libtomcrypt/LICENSE libtommath/LICENSE
22 PKG_CPE=cpe:/a:matt_johnston:dropbear_ssh_server
23
24 PKG_BUILD_PARALLEL:=1
25 PKG_USE_MIPS16:=0
26
27 PKG_CONFIG_DEPENDS:=CONFIG_TARGET_INIT_PATH CONFIG_DROPBEAR_ECC CONFIG_DROPBEAR_CURVE25519 CONFIG_DROPBEAR_ZLIB
28
29 include $(INCLUDE_DIR)/package.mk
30
31 ifneq ($(DUMP),1)
32 STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell echo $(CONFIG_TARGET_INIT_PATH) | mkhash md5)
33 endif
34
35 define Package/dropbear/Default
36 URL:=http://matt.ucc.asn.au/dropbear/
37 endef
38
39 define Package/dropbear/config
40 source "$(SOURCE)/Config.in"
41 endef
42
43 define Package/dropbear
44 $(call Package/dropbear/Default)
45 SECTION:=net
46 CATEGORY:=Base system
47 TITLE:=Small SSH2 client/server
48 DEPENDS:= +DROPBEAR_ZLIB:zlib
49 endef
50
51 define Package/dropbear/description
52 A small SSH2 server/client designed for small memory environments.
53 endef
54
55 define Package/dropbear/conffiles
56 /etc/dropbear/dropbear_rsa_host_key
57 /etc/config/dropbear
58 endef
59
60 define Package/dropbearconvert
61 $(call Package/dropbear/Default)
62 SECTION:=utils
63 CATEGORY:=Utilities
64 TITLE:=Utility for converting SSH keys
65 endef
66
67 CONFIGURE_ARGS += \
68 --disable-pam \
69 --enable-openpty \
70 --enable-syslog \
71 --disable-lastlog \
72 --disable-utmpx \
73 $(if $(CONFIG_DROPBEAR_UTMP),,--disable-utmp) \
74 --disable-wtmp \
75 --disable-wtmpx \
76 --disable-loginfunc \
77 $(if $(CONFIG_DROPBEAR_PUTUTLINE),,--disable-pututline) \
78 --disable-pututxline \
79 $(if $(CONFIG_DROPBEAR_ZLIB),,--disable-zlib) \
80 --enable-bundled-libtom
81
82 TARGET_CFLAGS += -DARGTYPE=3 -ffunction-sections -fdata-sections
83 TARGET_LDFLAGS += -Wl,--gc-sections
84
85 define Build/Configure
86 $(Build/Configure/Default)
87
88 $(SED) 's,^#define DEFAULT_PATH .*$$$$,#define DEFAULT_PATH "$(TARGET_INIT_PATH)",g' \
89 $(PKG_BUILD_DIR)/options.h
90
91 awk 'BEGIN { rc = 1 } \
92 /'DROPBEAR_CURVE25519'/ { $$$$0 = "$(if $(CONFIG_DROPBEAR_CURVE25519),,// )#define 'DROPBEAR_CURVE25519'"; rc = 0 } \
93 { print } \
94 END { exit(rc) }' $(PKG_BUILD_DIR)/options.h \
95 >$(PKG_BUILD_DIR)/options.h.new && \
96 mv $(PKG_BUILD_DIR)/options.h.new $(PKG_BUILD_DIR)/options.h
97
98 # Enforce that all replacements are made, otherwise options.h has changed
99 # format and this logic is broken.
100 for OPTION in DROPBEAR_ECDSA DROPBEAR_ECDH; do \
101 awk 'BEGIN { rc = 1 } \
102 /'$$$$OPTION'/ { $$$$0 = "$(if $(CONFIG_DROPBEAR_ECC),,// )#define '$$$$OPTION'"; rc = 0 } \
103 { print } \
104 END { exit(rc) }' $(PKG_BUILD_DIR)/options.h \
105 >$(PKG_BUILD_DIR)/options.h.new && \
106 mv $(PKG_BUILD_DIR)/options.h.new $(PKG_BUILD_DIR)/options.h || exit 1; \
107 done
108
109 # remove protocol idented software version number
110 $(SED) 's,^#define LOCAL_IDENT .*$$$$,#define LOCAL_IDENT "SSH-2.0-dropbear",g' \
111 $(PKG_BUILD_DIR)/sysoptions.h
112
113 # Enforce rebuild of svr-chansession.c
114 rm -f $(PKG_BUILD_DIR)/svr-chansession.o
115 endef
116
117 define Build/Compile
118 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
119 $(TARGET_CONFIGURE_OPTS) \
120 PROGRAMS="dropbear dbclient dropbearkey scp" \
121 MULTI=1 SCPPROGRESS=1
122 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
123 $(TARGET_CONFIGURE_OPTS) \
124 PROGRAMS="dropbearconvert"
125 endef
126
127 define Package/dropbear/install
128 $(INSTALL_DIR) $(1)/usr/sbin
129 $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearmulti $(1)/usr/sbin/dropbear
130 $(INSTALL_DIR) $(1)/usr/bin
131 $(LN) ../sbin/dropbear $(1)/usr/bin/scp
132 $(LN) ../sbin/dropbear $(1)/usr/bin/ssh
133 $(LN) ../sbin/dropbear $(1)/usr/bin/dbclient
134 $(LN) ../sbin/dropbear $(1)/usr/bin/dropbearkey
135 $(INSTALL_DIR) $(1)/etc/config
136 $(INSTALL_DATA) ./files/dropbear.config $(1)/etc/config/dropbear
137 $(INSTALL_DIR) $(1)/etc/init.d
138 $(INSTALL_BIN) ./files/dropbear.init $(1)/etc/init.d/dropbear
139 $(INSTALL_DIR) $(1)/usr/lib/opkg/info
140 $(INSTALL_DIR) $(1)/etc/dropbear
141 touch $(1)/etc/dropbear/dropbear_rsa_host_key
142 endef
143
144 define Package/dropbearconvert/install
145 $(INSTALL_DIR) $(1)/usr/bin
146 $(INSTALL_BIN) $(PKG_BUILD_DIR)/dropbearconvert $(1)/usr/bin/dropbearconvert
147 endef
148
149 $(eval $(call BuildPackage,dropbear))
150 $(eval $(call BuildPackage,dropbearconvert))