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