summaryrefslogtreecommitdiff
path: root/debian/rules
diff options
context:
space:
mode:
Diffstat (limited to 'debian/rules')
-rwxr-xr-xdebian/rules304
1 files changed, 304 insertions, 0 deletions
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 000000000..80c1ea45e
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,304 @@
1#!/usr/bin/make -f
2
3# Uncomment this to turn on verbose mode.
4# export DH_VERBOSE=1
5
6# This is the debhelper compatibility version to use.
7export DH_COMPAT=3
8
9# This has to be exported to make some magic below work.
10export DH_OPTIONS
11
12ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
13OPTFLAGS := -O2
14else
15OPTFLAGS := -O0
16endif
17
18VERSION := $(shell dpkg-parsechangelog | grep ^Version: | cut -d' ' -f2 | sed 's/.*://')
19DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
20DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null)
21
22# Take account of old dpkg-architecture output.
23ifeq ($(DEB_HOST_ARCH_OS),)
24 DEB_HOST_ARCH_OS := $(subst -gnu,,$(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM))
25 ifeq ($(DEB_HOST_ARCH_OS),gnu)
26 DEB_HOST_ARCH_OS := hurd
27 endif
28endif
29
30CLIENT_UDEB := openssh-client-udeb_$(VERSION)_$(DEB_HOST_ARCH).udeb
31SERVER_UDEB := openssh-server-udeb_$(VERSION)_$(DEB_HOST_ARCH).udeb
32
33ifeq (,$(wildcard /usr/bin/po2debconf))
34PO2DEBCONF := no
35MINDEBCONFVER := 0.5
36else
37PO2DEBCONF := yes
38MINDEBCONFVER := 1.2.0
39endif
40
41# We need a new libpam-runtime for sane PAM handling
42# (http://lists.debian.org/debian-devel-announce-0308/msg00012.html).
43# Unfortunately it's hard to detect during the build whether this is
44# appropriate, so woody-compatibility is a pain. I've had to punt and go for
45# a DEB_BUILD_SSH_WOODY environment variable. We can remove this hack once
46# we no longer care about woody.
47ifeq ($(DEB_BUILD_SSH_WOODY),)
48PAMSUBST := no
49PAMDEP := libpam-runtime (>= 0.76-14)
50else
51PAMSUBST := yes
52PAMDEP := libpam-runtime
53endif
54
55# The Hurd needs libcrypt for res_query et al.
56ifeq ($(DEB_HOST_ARCH_OS),hurd)
57FORCE_LIBS := LIBS=-lcrypt
58endif
59
60# SELinux support?
61ifeq ($(DEB_HOST_ARCH_OS),linux)
62SELINUX := --with-selinux
63endif
64
65# Change the version string to include the Debian version
66SSH_EXTRAVERSION := Debian-$(shell dpkg-parsechangelog | sed -n -e '/^Version:/s/Version: //p' | sed -e 's/[^-]*-//')
67
68build: build-deb build-udeb
69
70build-deb: build-deb-stamp
71build-deb-stamp:
72 dh_testdir
73 mkdir -p build-deb
74 cd build-deb && $(FORCE_LIBS) ../configure --prefix=/usr --sysconfdir=/etc/ssh --libexecdir=/usr/lib/openssh --mandir=/usr/share/man --with-tcp-wrappers --with-xauth=/usr/bin/X11/xauth --with-default-path=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin --with-superuser-path=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin --with-pam --with-4in6 --with-privsep-path=/var/run/sshd --without-rand-helper --with-libedit $(SELINUX)
75
76ifeq ($(DEB_HOST_ARCH_OS),linux)
77 # Some 2.2 kernels have trouble with setres[ug]id() (bug #239999).
78 perl -pi -e 's/.*#undef (BROKEN_SETRES[UG]ID).*/#define $$1 1/' build-deb/config.h
79endif
80 # Debian's /var/log/btmp has inappropriate permissions.
81 perl -pi -e 's,.*#define USE_BTMP .*,/* #undef USE_BTMP */,' build-deb/config.h
82
83 $(MAKE) -C build-deb -j 2 ASKPASS_PROGRAM='/usr/bin/ssh-askpass' CFLAGS='$(OPTFLAGS) -g -Wall -DLOGIN_PROGRAM=\"/bin/login\" -DLOGIN_NO_ENDOPT -DSSHD_PAM_SERVICE=\"ssh\" -DSSH_EXTRAVERSION="\" $(SSH_EXTRAVERSION)\""'
84 # Support building on Debian 3.0 (with GNOME 1.4) and later.
85 if [ -f /usr/include/libgnomeui-2.0/gnome.h ]; then \
86 $(MAKE) -C contrib gnome-ssh-askpass2 CC='gcc $(OPTFLAGS) -g -Wall'; \
87 elif [ -f /usr/include/gnome-1.0/gnome.h ]; then \
88 $(MAKE) -C contrib gnome-ssh-askpass1 CC='gcc $(OPTFLAGS) -g -Wall'; \
89 fi
90
91 touch build-deb-stamp
92
93build-udeb: build-udeb-stamp
94build-udeb-stamp:
95 dh_testdir
96 mkdir -p build-udeb
97 cd build-udeb && $(FORCE_LIBS) ../configure --prefix=/usr --sysconfdir=/etc/ssh --libexecdir=/usr/lib/openssh --without-xauth --with-default-path=/usr/local/bin:/bin:/usr/bin --with-superuser-path=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin --with-4in6 --with-privsep-path=/var/run/sshd --without-rand-helper
98 # Debian's /var/log/btmp has inappropriate permissions.
99 perl -pi -e 's,.*#define USE_BTMP .*,/* #undef USE_BTMP */,' build-udeb/config.h
100 # Avoid libnsl linkage. Ugh.
101 perl -pi -e 's/ +-lnsl//' build-udeb/config.status
102 cd build-udeb && ./config.status
103 $(MAKE) -C build-udeb -j 2 ASKPASS_PROGRAM='/usr/bin/ssh-askpass' CFLAGS='-Os -g -Wall -DSSH_EXTRAVERSION="\" $(SSH_EXTRAVERSION)\""' ssh scp sftp sshd ssh-keygen
104 touch build-udeb-stamp
105
106clean:
107 dh_testdir
108 rm -f build-deb-stamp build-udeb-stamp
109 rm -rf build-deb build-udeb
110 -$(MAKE) -C contrib clean
111 rm -f config.log
112ifeq ($(PO2DEBCONF),yes)
113 # Hack for woody compatibility. This makes sure that the
114 # debian/templates file shipped in the source package doesn't
115 # specify encodings, which woody's debconf can't handle. If building
116 # on a system with po-debconf installed (conveniently debhelper (>=
117 # 4.1.16) depends on it), the binary-arch target will generate a
118 # better version for sarge.
119 echo 1 > debian/po/output
120 po2debconf debian/openssh-server.templates.master > debian/openssh-server.templates
121 rm -f debian/po/output
122endif
123ifeq ($(PAMSUBST),yes)
124 if [ -f debian/ssh.pam.new-style ]; then \
125 mv debian/ssh.pam.new-style debian/ssh.pam; \
126 fi
127endif
128 rm -f debian/ssh-askpass-gnome.png
129 dh_clean
130
131install: DH_OPTIONS=-a
132install: build
133 dh_testdir
134 dh_testroot
135 dh_clean -k
136 dh_installdirs
137
138 $(MAKE) -C build-deb DESTDIR=`pwd`/debian/openssh-client install-nokeys
139
140 rm -f debian/openssh-client/etc/ssh/sshd_config
141 #Temporary hack: remove /usr/share/Ssh.bin, since we have no smartcard support anyway.
142 rm -f debian/openssh-client/usr/share/Ssh.bin
143
144 # Split off the server.
145 mv debian/openssh-client/usr/sbin/sshd debian/openssh-server/usr/sbin/
146 mv debian/openssh-client/usr/lib/openssh/sftp-server debian/openssh-server/usr/lib/openssh/
147 mv debian/openssh-client/usr/share/man/man5/sshd_config.5 debian/openssh-server/usr/share/man/man5/
148 mv debian/openssh-client/usr/share/man/man8/sshd.8 debian/openssh-server/usr/share/man/man8/
149 mv debian/openssh-client/usr/share/man/man8/sftp-server.8 debian/openssh-server/usr/share/man/man8/
150 rmdir debian/openssh-client/usr/sbin debian/openssh-client/var/run/sshd
151
152 install -m 755 contrib/ssh-copy-id debian/openssh-client/usr/bin/ssh-copy-id
153 install -m 644 -c contrib/ssh-copy-id.1 debian/openssh-client/usr/share/man/man1/ssh-copy-id.1
154 install -m 644 debian/moduli.5 debian/openssh-client/usr/share/man/man5/moduli.5
155
156 if [ -f contrib/gnome-ssh-askpass2 ]; then \
157 install -s -o root -g root -m 755 contrib/gnome-ssh-askpass2 debian/ssh-askpass-gnome/usr/lib/openssh/gnome-ssh-askpass; \
158 elif [ -f contrib/gnome-ssh-askpass1 ]; then \
159 install -s -o root -g root -m 755 contrib/gnome-ssh-askpass1 debian/ssh-askpass-gnome/usr/lib/openssh/gnome-ssh-askpass; \
160 fi
161 install -m 644 debian/gnome-ssh-askpass.1 debian/ssh-askpass-gnome/usr/share/man/man1/gnome-ssh-askpass.1
162 uudecode -o debian/ssh-askpass-gnome/usr/share/pixmaps/ssh-askpass-gnome.png debian/ssh-askpass-gnome.png.uue
163
164 install -m 755 debian/ssh-argv0 debian/openssh-client/usr/bin/ssh-argv0
165 install -m 644 debian/ssh-argv0.1 debian/openssh-client/usr/share/man/man1/ssh-argv0.1
166
167 install -o root -g root debian/openssh-server.init debian/openssh-server/etc/init.d/ssh
168 install -o root -g root -m 644 debian/openssh-server.default debian/openssh-server/etc/default/ssh
169
170 install -m 755 build-udeb/ssh debian/openssh-client-udeb/usr/bin/ssh
171 install -m 755 build-udeb/scp debian/openssh-client-udeb/usr/bin/scp
172 install -m 755 build-udeb/sftp debian/openssh-client-udeb/usr/bin/sftp
173 install -m 755 build-udeb/sshd debian/openssh-server-udeb/usr/sbin/sshd
174 install -m 755 build-udeb/ssh-keygen debian/openssh-server-udeb/usr/bin/ssh-keygen
175
176# Build architecture-independent files here.
177binary-indep: binary-ssh
178
179# Build architecture-dependent files here.
180binary-arch: binary-openssh-client binary-openssh-server
181binary-arch: binary-ssh-askpass-gnome
182binary-arch: binary-openssh-client-udeb binary-openssh-server-udeb
183
184binary-openssh-client: DH_OPTIONS=-popenssh-client
185binary-openssh-client: build install
186 dh_testdir
187 dh_testroot
188 dh_installdebconf
189 dh_installdocs OVERVIEW README README.dns
190 cat debian/copyright.head LICENCE > debian/openssh-client/usr/share/doc/openssh-client/copyright
191 dh_installchangelogs ChangeLog
192 install -m644 debian/openssh-client.lintian debian/openssh-client/usr/share/lintian/overrides/openssh-client
193 dh_strip
194 dh_compress
195 dh_fixperms
196 chmod u+s debian/openssh-client/usr/lib/openssh/ssh-keysign
197 dh_installdeb
198 test ! -e debian/ssh/etc/ssh/ssh_prng_cmds \
199 || echo "/etc/ssh/ssh_prng_cmds" >> debian/openssh-client/DEBIAN/conffiles
200 dh_shlibdeps
201 dh_gencontrol -- -V'debconf-depends=debconf (>= $(MINDEBCONFVER)) | debconf-2.0'
202 dh_md5sums
203 dh_builddeb
204
205binary-openssh-server: DH_OPTIONS=-popenssh-server
206binary-openssh-server: build install
207 dh_testdir
208 dh_testroot
209ifeq ($(PO2DEBCONF),yes)
210 po2debconf -e utf8 debian/openssh-server.templates.master > debian/openssh-server.templates
211endif
212 dh_installdebconf
213 dh_installdocs
214 mv debian/openssh-server/usr/share/doc/openssh-server debian/openssh-server/usr/share/doc/openssh-client
215 rm -f debian/openssh-server/usr/share/doc/openssh-client/copyright
216ifeq ($(PAMSUBST),yes)
217 # Clean up if we've done this already, to ensure idempotency.
218 if [ -f debian/openssh-server.ssh.pam.new-style ]; then \
219 mv debian/openssh-server.ssh.pam.new-style debian/openssh-server.ssh.pam; \
220 fi
221 cp -a debian/openssh-server.ssh.pam debian/openssh-server.ssh.pam.new-style
222 sed -e "s/@include common-auth/auth required pam_unix.so/" \
223 -e "s/@include common-account/account required pam_unix.so/" \
224 -e "s/@include common-session/session required pam_unix.so/" \
225 -e "s/@include common-password/password required pam_unix.so/" \
226 debian/openssh-server.ssh.pam.new-style > debian/openssh-server.ssh.pam
227endif
228 dh_installpam --name ssh # TODO: breaks woody backports
229 dh_link
230 dh_strip
231 dh_compress
232 dh_fixperms
233 dh_installdeb
234 dh_shlibdeps
235 dh_gencontrol -- -V'debconf-depends=debconf (>= $(MINDEBCONFVER)) | debconf-2.0' \
236 -V'pam-depends=$(PAMDEP)'
237 dh_md5sums
238 dh_builddeb
239
240binary-ssh: DH_OPTIONS=-pssh
241binary-ssh: build install
242 dh_testdir
243 dh_testroot
244 dh_installdocs
245 mv debian/ssh/usr/share/doc/ssh debian/ssh/usr/share/doc/openssh-client
246 rm -f debian/ssh/usr/share/doc/openssh-client/copyright
247 dh_link
248 dh_compress
249 dh_fixperms
250 dh_installdeb
251 dh_gencontrol
252 dh_md5sums
253 dh_builddeb
254
255binary-ssh-askpass-gnome: DH_OPTIONS=-pssh-askpass-gnome
256binary-ssh-askpass-gnome: build install
257 dh_testdir
258 dh_testroot
259 dh_installdocs
260 dh_installexamples debian/ssh-askpass-gnome.desktop
261 dh_installchangelogs ChangeLog
262 dh_strip
263 dh_compress
264 dh_fixperms
265 dh_installdeb
266 dh_shlibdeps
267 dh_gencontrol
268 dh_md5sums
269 dh_builddeb
270
271binary-openssh-client-udeb: DH_OPTIONS=-popenssh-client-udeb
272binary-openssh-client-udeb: build install
273 dh_testdir
274 dh_testroot
275 dh_strip
276 dh_compress
277 dh_fixperms
278 dh_installdeb
279 install -p -o root -g root -m 755 debian/openssh-client-udeb.isinstallable debian/openssh-client-udeb/DEBIAN/isinstallable
280 dh_shlibdeps
281 dh_gencontrol -- -fdebian/files~
282 dpkg-distaddfile $(CLIENT_UDEB) debian-installer optional
283 dh_builddeb --filename=$(CLIENT_UDEB)
284
285binary-openssh-server-udeb: DH_OPTIONS=-popenssh-server-udeb
286binary-openssh-server-udeb: build install
287 dh_testdir
288 dh_testroot
289 dh_strip
290 dh_compress
291 dh_fixperms
292 dh_installdeb
293 dh_shlibdeps
294 dh_gencontrol -- -fdebian/files~
295 dpkg-distaddfile $(SERVER_UDEB) debian-installer optional
296 dh_builddeb --filename=$(SERVER_UDEB)
297
298binary: binary-indep binary-arch
299
300.PHONY: build clean binary-indep binary-arch binary install
301.PHONY: build-deb build-udeb
302.PHONY: binary-openssh-client binary-openssh-server binary-ssh
303.PHONY: binary-ssh-askpass-gnome
304.PHONY: binary-openssh-client-udeb binary-openssh-server-udeb