25ff989d66fccfcf78d6f02587b0808b2dec36e3
[packages.git] / net / openssh / Makefile
1 #
2 # Copyright (C) 2006,2008 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:=openssh
11 PKG_VERSION:=5.3p1
12 PKG_RELEASE:=1
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15 PKG_SOURCE_URL:=ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/ \
16                 ftp://openbsd.wiretapped.net/pub/OpenBSD/OpenSSH/portable/ \
17                 ftp://ftp.belnet.be/packages/openbsd/OpenSSH/portable/ \
18                 ftp://ftp.de.openbsd.org/pub/unix/OpenBSD/OpenSSH/portable/
19 PKG_MD5SUM:=13563dbf61f36ca9a1e4254260131041
20
21 PKG_BUILD_DEPENDS:=libopenssl
22
23 include $(INCLUDE_DIR)/package.mk
24
25 define Package/openssh-client
26   SECTION:=net
27   CATEGORY:=Network
28   DEPENDS:=+libopenssl +zlib
29   TITLE:=OpenSSH client
30   URL:=http://www.openssh.com/
31   SUBMENU:=SSH
32 endef
33
34 define Package/openssh-client/description
35 OpenSSH client.
36 endef
37
38 define Package/openssh-client/conffiles
39 /etc/ssh/ssh_config
40 endef
41
42 define Package/openssh-client-utils
43   SECTION:=net
44   CATEGORY:=Network
45   DEPENDS:=openssh-client
46   TITLE:=OpenSSH client utilities
47   URL:=http://www.openssh.com/
48   SUBMENU:=SSH
49 endef
50
51 define Package/openssh-client-utils/description
52 OpenSSH client utilities.
53 endef
54
55 define Package/openssh-server
56   SECTION:=net
57   CATEGORY:=Network
58   DEPENDS:=+libopenssl +zlib
59   TITLE:=OpenSSH server
60   URL:=http://www.openssh.com/
61   SUBMENU:=SSH
62 endef
63
64 define Package/openssh-server/description
65 OpenSSH server.
66 endef
67
68 define Package/openssh-server/conffiles
69 /etc/ssh/sshd_config
70 endef
71
72 define Package/openssh-sftp-client
73   SECTION:=net
74   CATEGORY:=Network
75   DEPENDS:=+libopenssl +zlib
76   TITLE:=OpenSSH SFTP client
77   URL:=http://www.openssh.com/
78   SUBMENU:=SSH
79 endef
80
81 define Package/openssh-sftp-client/description
82 OpenSSH SFTP client.
83 endef
84
85 define Package/openssh-sftp-server
86   SECTION:=net
87   CATEGORY:=Network
88   DEPENDS:=
89   TITLE:=OpenSSH SFTP server
90   URL:=http://www.openssh.com/
91   SUBMENU:=SSH
92 endef
93
94 define Package/openssh-sftp-server/description
95 OpenSSH SFTP server.
96 endef
97
98 CONFIGURE_ARGS+= \
99         $(DISABLE_LARGEFILE) \
100         $(DISABLE_NLS) \
101         --sysconfdir=/etc/ssh \
102         --enable-shared \
103         --disable-static \
104         --disable-debug \
105         --disable-strip \
106         --disable-etc-default-login \
107         --disable-lastlog \
108         --disable-utmp \
109         --disable-utmpx \
110         --disable-wtmp \
111         --disable-wtmpx \
112         --without-bsd-auth \
113         --without-kerberos5 \
114         --without-pam \
115         --without-x
116
117 ifneq ($(CONFIG_SSP_SUPPORT),y)
118 CONFIGURE_ARGS += \
119         --without-stackprotect
120 endif
121
122 CONFIGURE_VARS += LD="$(TARGET_CC)"
123
124 define Build/Compile
125         rm -rf $(PKG_INSTALL_DIR)
126         mkdir -p $(PKG_INSTALL_DIR)
127         $(MAKE) -C $(PKG_BUILD_DIR) \
128                 DESTDIR="$(PKG_INSTALL_DIR)" \
129                 LIBS="" \
130                 sftp-server
131         $(MAKE) -C $(PKG_BUILD_DIR) \
132                 DESTDIR="$(PKG_INSTALL_DIR)" \
133                 STRIP_OPT="" \
134                 all install
135 endef
136
137 define Package/openssh-client/install
138         $(INSTALL_DIR) $(1)/etc/ssh
139         chmod 0700 $(1)/etc/ssh
140         $(CP) $(PKG_INSTALL_DIR)/etc/ssh/ssh_config $(1)/etc/ssh/
141         $(INSTALL_DIR) $(1)/usr/bin
142         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ssh $(1)/usr/bin/
143         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/scp $(1)/usr/bin/
144 endef
145
146 define Package/openssh-client-utils/install
147         $(INSTALL_DIR) $(1)/usr/bin
148         $(INSTALL_BIN) $(foreach bin,add agent keyscan keysign,$(PKG_BUILD_DIR)/ssh-$(bin)) $(1)/usr/bin/
149 endef
150
151 define Package/openssh-server/install
152         $(INSTALL_DIR) $(1)/etc/ssh
153         chmod 0700 $(1)/etc/ssh
154         $(CP) $(PKG_INSTALL_DIR)/etc/ssh/sshd_config $(1)/etc/ssh/
155         $(INSTALL_DIR) $(1)/etc/init.d
156         $(INSTALL_BIN) ./files/sshd.init $(1)/etc/init.d/sshd
157         $(INSTALL_DIR) $(1)/usr/bin
158         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ssh-keygen $(1)/usr/bin/
159         $(INSTALL_DIR) $(1)/usr/sbin
160         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/sshd $(1)/usr/sbin/
161 endef
162
163 define Package/openssh-server/postinst
164 #!/bin/sh
165
166 name=sshd
167 id=99
168
169 # do not change below
170 # check if we are on real system
171 if [ -z "$${IPKG_INSTROOT}" ]; then
172         # create copies of passwd and group, if we use squashfs
173         rootfs=`mount |awk '/root/ { print $$5 }'`
174         if [ "$$rootfs" = "squashfs" ]; then
175                 if [ -h /etc/group ]; then
176                         rm /etc/group
177                         cp /rom/etc/group /etc/group
178                 fi
179                 if [ -h /etc/passwd ]; then
180                         rm /etc/passwd
181                         cp /rom/etc/passwd /etc/passwd
182                 fi
183         fi
184 fi
185
186 echo ""
187 if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/group)" ]; then
188         echo "adding group $$name to /etc/group"
189         echo "$${name}:x:$${id}:" >> $${IPKG_INSTROOT}/etc/group
190 fi
191
192 if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/passwd)" ]; then
193         echo "adding user $$name to /etc/passwd"
194         echo "$${name}:x:$${id}:$${id}:$${name}:/var/empty/.$${name}:/bin/false" >> $${IPKG_INSTROOT}/etc/passwd
195 fi
196
197 grep -q '^ssh[[:space:]]*22/tcp' $${IPKG_INSTROOT}/etc/services 2>/dev/null
198 if [ $$? -ne 0 ]; then
199 echo "ssh           22/tcp" >>$${IPKG_INSTROOT}/etc/services
200 fi
201 endef
202
203 define Package/openssh-sftp-client/install
204         $(INSTALL_DIR) $(1)/usr/bin
205         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/sftp $(1)/usr/bin/
206 endef
207
208 define Package/openssh-sftp-server/install
209         $(INSTALL_DIR) $(1)/usr/lib
210         $(CP) $(PKG_INSTALL_DIR)/usr/lib/sftp-server $(1)/usr/lib/
211         $(INSTALL_DIR) $(1)/usr/libexec
212         ln -sf ../lib/sftp-server $(1)/usr/libexec/sftp-server
213 endef
214
215 $(eval $(call BuildPackage,openssh-client))
216 $(eval $(call BuildPackage,openssh-client-utils))
217 $(eval $(call BuildPackage,openssh-server))
218 $(eval $(call BuildPackage,openssh-sftp-client))
219 $(eval $(call BuildPackage,openssh-sftp-server))