summaryrefslogtreecommitdiff
path: root/debian/rules
diff options
context:
space:
mode:
Diffstat (limited to 'debian/rules')
-rwxr-xr-xdebian/rules245
1 files changed, 245 insertions, 0 deletions
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 000000000..993a70539
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,245 @@
1#!/usr/bin/make -f
2
3# Uncomment this to turn on verbose mode.
4# export DH_VERBOSE=1
5
6# This has to be exported to make some magic below work.
7export DH_OPTIONS
8
9ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
10 RUN_TESTS := yes
11else
12 RUN_TESTS :=
13endif
14
15ifeq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
16 PARALLEL :=
17else
18 PARALLEL := \
19 -j$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
20endif
21
22DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
23DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
24DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
25
26ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
27 CC := gcc
28 PKG_CONFIG = pkg-config
29else
30 CC := $(DEB_HOST_GNU_TYPE)-gcc
31 PKG_CONFIG = $(DEB_HOST_GNU_TYPE)-pkg-config
32 RUN_TESTS :=
33endif
34
35DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null)
36
37# Take account of old dpkg-architecture output.
38ifeq ($(DEB_HOST_ARCH_OS),)
39 DEB_HOST_ARCH_OS := $(subst -gnu,,$(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM))
40 ifeq ($(DEB_HOST_ARCH_OS),gnu)
41 DEB_HOST_ARCH_OS := hurd
42 endif
43endif
44
45# Change the version string to reflect distribution
46DISTRIBUTION := $(shell dpkg-vendor --query vendor)
47SSH_EXTRAVERSION := $(DISTRIBUTION)-$(shell dpkg-parsechangelog | sed -n -e '/^Version:/s/Version: //p' | sed -e 's/[^-]*-//')
48
49DISTRIBUTOR := $(shell if dpkg-vendor --derives-from Ubuntu 2>/dev/null; then echo Ubuntu; else echo Debian; fi)
50ifeq ($(DISTRIBUTOR),Ubuntu)
51DEFAULT_PATH := /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
52else
53DEFAULT_PATH := /usr/local/bin:/usr/bin:/bin:/usr/games
54endif
55SUPERUSER_PATH := /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
56
57ifeq ($(DISTRIBUTOR),Ubuntu)
58server_recommends := ssh-import-id
59else
60server_recommends :=
61endif
62
63# Common path configuration.
64confflags += --sysconfdir=/etc/ssh
65confflags += --libexecdir=\$${prefix}/lib/openssh
66
67# Common build options.
68confflags += --disable-strip
69confflags += --with-mantype=doc
70confflags += --with-4in6
71confflags += --with-privsep-path=/var/run/sshd
72
73# The Hurd needs libcrypt for res_query et al.
74ifeq ($(DEB_HOST_ARCH_OS),hurd)
75confflags += --with-libs=-lcrypt
76endif
77
78# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60155
79ifeq ($(DEB_HOST_ARCH),hppa)
80confflags += --without-hardening
81endif
82
83# Everything above here is common to the deb and udeb builds.
84confflags_udeb := $(confflags)
85
86# Options specific to the deb build.
87confflags += --with-tcp-wrappers
88confflags += --with-pam
89confflags += --with-libedit
90confflags += --with-kerberos5=/usr
91confflags += --with-ssl-engine
92ifeq ($(DEB_HOST_ARCH_OS),linux)
93confflags += --with-selinux
94confflags += --with-audit=linux
95endif
96
97# The deb build wants xauth; the udeb build doesn't.
98confflags += --with-xauth=/usr/bin/xauth
99confflags_udeb += --without-xauth
100
101# Default paths. The udeb build has /usr/games removed.
102confflags += --with-default-path=$(DEFAULT_PATH) --with-superuser-path=$(SUPERUSER_PATH)
103confflags_udeb += --with-default-path=/usr/local/bin:/usr/bin:/bin --with-superuser-path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
104
105# Compiler flags.
106export DEB_BUILD_MAINT_OPTIONS := hardening=+all
107include /usr/share/dpkg/buildflags.mk
108cflags := $(CPPFLAGS) $(CFLAGS)
109cflags += -DLOGIN_PROGRAM=\"/bin/login\" -DLOGIN_NO_ENDOPT
110cflags += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\"
111cflags_udeb := -Os
112cflags_udeb += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\"
113confflags += --with-cflags='$(cflags)'
114confflags_udeb += --with-cflags='$(cflags_udeb)'
115
116# Linker flags.
117confflags += --with-ldflags='$(strip -Wl,--as-needed $(LDFLAGS))'
118confflags_udeb += --with-ldflags='-Wl,--as-needed'
119
120%:
121 dh $@ --with=autoreconf,systemd
122
123autoreconf:
124 autoreconf -f -i
125 cp -f /usr/share/misc/config.guess /usr/share/misc/config.sub ./
126
127override_dh_autoreconf-arch:
128 dh_autoreconf debian/rules -- autoreconf
129
130override_dh_autoreconf-indep:
131
132override_dh_auto_configure-arch:
133 dh_auto_configure -Bbuild-deb -- $(confflags)
134 dh_auto_configure -Bbuild-udeb -- $(confflags_udeb)
135
136override_dh_auto_configure-indep:
137
138override_dh_auto_build-arch:
139 # Avoid libnsl linkage. Ugh.
140 perl -pi -e 's/ +-lnsl//' build-udeb/config.status
141 cd build-udeb && ./config.status
142
143 $(MAKE) -C build-deb $(PARALLEL) ASKPASS_PROGRAM='/usr/bin/ssh-askpass'
144 $(MAKE) -C build-udeb $(PARALLEL) ASKPASS_PROGRAM='/usr/bin/ssh-askpass' ssh scp sftp sshd ssh-keygen
145
146 $(MAKE) -C contrib gnome-ssh-askpass2 CC='$(CC) $(CPPFLAGS) $(CFLAGS) -Wall -Wl,--as-needed $(LDFLAGS)' PKG_CONFIG=$(PKG_CONFIG)
147
148override_dh_auto_build-indep:
149
150override_dh_auto_test-arch:
151ifeq ($(RUN_TESTS),yes)
152 $(MAKE) -C build-deb regress-prep
153 $(MAKE) -C build-deb $(PARALLEL) \
154 regress/unittests/sshbuf/test_sshbuf \
155 regress/unittests/sshkey/test_sshkey \
156 regress/unittests/bitmap/test_bitmap \
157 regress/unittests/hostkeys/test_hostkeys \
158 regress/unittests/kex/test_kex
159 $(MAKE) -C build-deb/regress \
160 .OBJDIR="$(CURDIR)/build-deb/regress" \
161 .CURDIR="$(CURDIR)/regress" \
162 unit
163 $(MAKE) -C build-deb compat-tests
164 $(MAKE) -C debian/keygen-test
165endif
166
167override_dh_auto_test-indep:
168
169override_dh_auto_clean:
170 rm -rf build-deb build-udeb
171ifeq ($(RUN_TESTS),yes)
172 $(MAKE) -C debian/keygen-test clean
173endif
174 $(MAKE) -C contrib clean
175 (cat debian/copyright.head; iconv -f ISO-8859-1 -t UTF-8 LICENCE) \
176 > debian/copyright
177
178override_dh_auto_install-arch:
179 $(MAKE) -C build-deb DESTDIR=`pwd`/debian/tmp install-nokeys
180
181override_dh_auto_install-indep:
182
183override_dh_install-arch:
184 rm -f debian/tmp/etc/ssh/sshd_config
185
186 dh_install -Nopenssh-client-udeb -Nopenssh-server-udeb --fail-missing
187 dh_install -popenssh-client-udeb -popenssh-server-udeb \
188 --sourcedir=build-udeb
189
190 # Remove version control tags to avoid unnecessary conffile
191 # resolution steps for administrators.
192 sed -i '/\$$OpenBSD:/d' \
193 debian/openssh-client/etc/ssh/moduli \
194 debian/openssh-client/etc/ssh/ssh_config
195
196# We'd like to use dh_install --fail-missing here, but that doesn't work
197# well in combination with dh-exec: it complains that files generated by
198# dh-exec for architecture-dependent packages aren't installed.
199override_dh_install-indep:
200 rm -f debian/tmp/etc/ssh/sshd_config
201 dh_install
202
203override_dh_installdocs:
204 dh_installdocs -Nopenssh-server -Nopenssh-sftp-server
205 dh_installdocs -popenssh-server -popenssh-sftp-server \
206 --link-doc=openssh-client
207 # Avoid breaking dh_installexamples later.
208 mkdir -p debian/openssh-server/usr/share/doc/openssh-client
209
210override_dh_systemd_enable:
211 dh_systemd_enable -popenssh-server --name ssh ssh.service
212 dh_systemd_enable -popenssh-server --name ssh --no-enable ssh.socket
213
214override_dh_installinit:
215 dh_installinit -R --name ssh
216
217debian/openssh-server.sshd.pam: debian/openssh-server.sshd.pam.in
218ifeq ($(DEB_HOST_ARCH_OS),linux)
219 sed 's/^@IF_KEYINIT@//' $< > $@
220else
221 sed '/^@IF_KEYINIT@/d' $< > $@
222endif
223
224override_dh_installpam: debian/openssh-server.sshd.pam
225 dh_installpam --name sshd
226
227override_dh_fixperms-arch:
228 dh_fixperms
229 chmod u+s debian/openssh-client/usr/lib/openssh/ssh-keysign
230
231# Tighten libssl dependencies to match the check in entropy.c.
232override_dh_shlibdeps:
233 dh_shlibdeps
234 debian/adjust-openssl-dependencies
235
236override_dh_gencontrol:
237 dh_gencontrol -- -V'openssh-server:Recommends=$(server_recommends)'
238
239override_dh_builddeb:
240 dh_builddeb -- -Zxz
241
242debian/faq.html:
243 wget -O - http://www.openssh.org/faq.html | \
244 sed 's,\(href="\)\(txt/\|[^":]*\.html\),\1http://www.openssh.org/\2,g' \
245 > debian/faq.html