Fix user/group creation for openssh (#1311)
[openwrt/svn-archive/archive.git] / net / openssh / Makefile
1 #
2 # Copyright (C) 2006 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 # $Id$
8
9 include $(TOPDIR)/rules.mk
10
11 PKG_NAME:=openssh
12 PKG_VERSION:=4.5p1
13 PKG_RELEASE:=1
14
15 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
16 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
17 PKG_SOURCE_URL:=ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/ \
18 ftp://openbsd.wiretapped.net/pub/OpenBSD/OpenSSH/portable/ \
19 ftp://ftp.belnet.be/packages/openbsd/OpenSSH/portable/ \
20 ftp://ftp.de.openbsd.org/pub/unix/OpenBSD/OpenSSH/portable/
21 PKG_MD5SUM:=6468c339886f78e8a149b88f695839dd
22 PKG_CAT:=zcat
23
24 PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
25
26 PKG_BUILD_DEPENDS:=libopenssl
27
28 include $(INCLUDE_DIR)/package.mk
29
30 define Package/openssh-client
31 SECTION:=net
32 CATEGORY:=Network
33 DEPENDS:=+libopenssl +zlib
34 TITLE:=OpenSSH client
35 DESCRIPTION:=OpenSSH client.
36 URL:=http://www.openssh.com/
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 DESCRIPTION:=OpenSSH client utilities.
49 URL:=http://www.openssh.com/
50 endef
51
52 define Package/openssh-server
53 SECTION:=net
54 CATEGORY:=Network
55 DEPENDS:=+libopenssl +zlib
56 TITLE:=OpenSSH server
57 DESCRIPTION:=OpenSSH server.
58 URL:=http://www.openssh.com/
59 endef
60
61 define Package/openssh-server/conffiles
62 /etc/ssh/sshd_config
63 endef
64
65 define Package/openssh-sftp-client
66 SECTION:=net
67 CATEGORY:=Network
68 DEPENDS:=+libopenssl +zlib
69 TITLE:=OpenSSH SFTP client
70 DESCRIPTION:=OpenSSH SFTP client.
71 URL:=http://www.openssh.com/
72 endef
73
74 define Package/openssh-sftp-server
75 SECTION:=net
76 CATEGORY:=Network
77 DEPENDS:=
78 TITLE:=OpenSSH SFTP server
79 DESCRIPTION:=OpenSSH SFTP server.
80 URL:=http://www.openssh.com/
81 endef
82
83 define Build/Configure
84 (cd $(PKG_BUILD_DIR); rm -f config.cache; \
85 $(TARGET_CONFIGURE_OPTS) \
86 CFLAGS="$(TARGET_CFLAGS)" \
87 CPPFLAGS="-I$(STAGING_DIR)/usr/include" \
88 LD="$(TARGET_CC)" \
89 LDFLAGS="-L$(STAGING_DIR)/usr/lib" \
90 ./configure \
91 --target=$(GNU_TARGET_NAME) \
92 --host=$(GNU_TARGET_NAME) \
93 --build=$(GNU_HOST_NAME) \
94 --program-prefix="" \
95 --program-suffix="" \
96 --prefix=/usr \
97 --exec-prefix=/usr \
98 --bindir=/usr/bin \
99 --datadir=/usr/share \
100 --includedir=/usr/include \
101 --infodir=/usr/share/info \
102 --libdir=/usr/lib \
103 --libexecdir=/usr/lib \
104 --localstatedir=/var \
105 --mandir=/usr/share/man \
106 --sbindir=/usr/sbin \
107 --sysconfdir=/etc/ssh \
108 $(DISABLE_LARGEFILE) \
109 $(DISABLE_NLS) \
110 --enable-shared \
111 --disable-static \
112 --disable-debug \
113 --disable-strip \
114 --disable-etc-default-login \
115 --disable-lastlog \
116 --disable-utmp \
117 --disable-utmpx \
118 --disable-wtmp \
119 --disable-wtmpx \
120 --without-bsd-auth \
121 --without-kerberos5 \
122 --without-pam \
123 --without-x \
124 );
125 endef
126
127 define Build/Compile
128 rm -rf $(PKG_INSTALL_DIR)
129 mkdir -p $(PKG_INSTALL_DIR)
130 $(MAKE) -C $(PKG_BUILD_DIR) \
131 DESTDIR="$(PKG_INSTALL_DIR)" \
132 LIBS="" \
133 sftp-server
134 $(MAKE) -C $(PKG_BUILD_DIR) \
135 DESTDIR="$(PKG_INSTALL_DIR)" \
136 all install
137 endef
138
139 define Package/openssh-client/install
140 $(INSTALL_DIR) $(1)/etc/ssh
141 chmod 0700 $(1)/etc/ssh
142 $(CP) $(PKG_INSTALL_DIR)/etc/ssh/ssh_config $(1)/etc/ssh/
143 $(INSTALL_DIR) $(1)/usr/bin
144 $(CP) $(PKG_INSTALL_DIR)/usr/bin/ssh $(1)/usr/bin/
145 $(CP) $(PKG_INSTALL_DIR)/usr/bin/scp $(1)/usr/bin/
146 endef
147
148 define Package/openssh-client-utils/install
149 $(INSTALL_DIR) $(1)/usr/bin
150 $(CP) $(PKG_INSTALL_DIR)/usr/bin/ssh-add $(1)/usr/bin/
151 $(CP) $(PKG_INSTALL_DIR)/usr/bin/ssh-agent $(1)/usr/bin/
152 $(CP) $(PKG_INSTALL_DIR)/usr/bin/ssh-keyscan $(1)/usr/bin/
153 endef
154
155 define Package/openssh-server/install
156 $(INSTALL_DIR) $(1)/etc/ssh
157 chmod 0700 $(1)/etc/ssh
158 $(CP) $(PKG_INSTALL_DIR)/etc/ssh/sshd_config $(1)/etc/ssh/
159 $(INSTALL_DIR) $(1)/etc/init.d
160 $(INSTALL_BIN) ./files/sshd.init $(1)/etc/init.d/sshd
161 $(INSTALL_DIR) $(1)/usr/bin
162 $(CP) $(PKG_INSTALL_DIR)/usr/bin/ssh-keygen $(1)/usr/bin/
163 $(INSTALL_DIR) $(1)/usr/sbin
164 $(CP) $(PKG_INSTALL_DIR)/usr/sbin/sshd $(1)/usr/sbin/
165 endef
166
167 define Package/openssh-server/postinst
168 #!/bin/sh
169
170 name=sshd
171 id=99
172
173 # do not change below
174 # check if we are on real system
175 if [ -z "$${IPKG_INSTROOT}" ]; then
176 # create copies of passwd and group, if we use squashfs
177 rootfs=`mount |awk '/root/ { print $$5 }'`
178 if [ "$$rootfs" = "squashfs" ]; then
179 if [ -h /etc/group ]; then
180 rm /etc/group
181 cp /rom/etc/group /etc/group
182 fi
183 if [ -h /etc/passwd ]; then
184 rm /etc/passwd
185 cp /rom/etc/passwd /etc/passwd
186 fi
187 fi
188 fi
189
190 echo ""
191 if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/group)" ]; then
192 echo "adding group $$name to /etc/group"
193 echo "$${name}:x:$${id}:" >> $${IPKG_INSTROOT}/etc/group
194 fi
195
196 if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/passwd)" ]; then
197 echo "adding user $$name to /etc/passwd"
198 echo "$${name}:x:$${id}:$${id}:$${name}:/var/empty/.$${name}:/bin/false" >> $${IPKG_INSTROOT}/etc/passwd
199 fi
200
201 grep -q '^ssh[[:space:]]*22/tcp' $${IPKG_INSTROOT}/etc/services 2>/dev/null
202 if [ $$? -ne 0 ]; then
203 echo "ssh 22/tcp" >>$${IPKG_INSTROOT}/etc/services
204 fi
205 endef
206
207 define Package/openssh-sftp-client/install
208 $(INSTALL_DIR) $(1)/usr/bin
209 $(CP) $(PKG_INSTALL_DIR)/usr/bin/sftp $(1)/usr/bin/
210 endef
211
212 define Package/openssh-sftp-server/install
213 $(INSTALL_DIR) $(1)/usr/lib
214 $(CP) $(PKG_INSTALL_DIR)/usr/lib/sftp-server $(1)/usr/lib/
215 $(INSTALL_DIR) $(1)/usr/libexec
216 ln -sf ../lib/sftp-server $(1)/usr/libexec/sftp-server
217 endef
218
219 $(eval $(call BuildPackage,openssh-client))
220 $(eval $(call BuildPackage,openssh-client-utils))
221 $(eval $(call BuildPackage,openssh-server))
222 $(eval $(call BuildPackage,openssh-sftp-client))
223 $(eval $(call BuildPackage,openssh-sftp-server))