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