summaryrefslogtreecommitdiff
path: root/debian/rules
diff options
context:
space:
mode:
Diffstat (limited to 'debian/rules')
-rwxr-xr-xdebian/rules229
1 files changed, 229 insertions, 0 deletions
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 000000000..73a53c309
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,229 @@
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
81confflags += --with-security-key-builtin
82endif
83
84# The deb build wants xauth; the udeb build doesn't.
85confflags += --with-xauth=/usr/bin/xauth
86confflags_udeb += --without-xauth
87
88# Default paths. The udeb build has /usr/games removed.
89confflags += --with-default-path=$(DEFAULT_PATH) --with-superuser-path=$(SUPERUSER_PATH)
90confflags_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
91
92# Compiler flags.
93cflags := $(CPPFLAGS) $(CFLAGS)
94cflags += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\"
95cflags_udeb := -Os
96cflags_udeb += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\"
97confflags += --with-cflags='$(cflags)'
98confflags_udeb += --with-cflags='$(cflags_udeb)'
99
100# Linker flags.
101confflags += --with-ldflags='$(strip -Wl,--as-needed $(LDFLAGS))'
102confflags_udeb += --with-ldflags='-Wl,--as-needed'
103
104ifeq ($(shell dpkg-vendor --is Ubuntu && echo yes) $(DEB_HOST_ARCH), yes i386)
105 BUILD_PACKAGES += -Nopenssh-tests
106endif
107
108%:
109 dh $@ --with=autoreconf,systemd,runit $(BUILD_PACKAGES)
110
111autoreconf:
112 autoreconf -f -i
113 cp -f /usr/share/misc/config.guess /usr/share/misc/config.sub ./
114
115override_dh_autoreconf-arch:
116 dh_autoreconf debian/rules -- autoreconf
117
118override_dh_autoreconf-indep:
119
120override_dh_auto_configure-arch:
121 dh_auto_configure -Bdebian/build-deb -- $(confflags)
122ifeq ($(filter noudeb,$(DEB_BUILD_PROFILES)),)
123 dh_auto_configure -Bdebian/build-udeb -- $(confflags_udeb)
124 # Avoid libnsl linkage. Ugh.
125 perl -pi -e 's/ +-lnsl//' debian/build-udeb/config.status
126 cd debian/build-udeb && ./config.status
127endif
128
129override_dh_auto_configure-indep:
130
131override_dh_auto_build-arch:
132 $(MAKE) -C debian/build-deb $(PARALLEL) ASKPASS_PROGRAM='/usr/bin/ssh-askpass'
133 $(MAKE) -C debian/build-deb regress-prep
134 $(MAKE) -C debian/build-deb $(PARALLEL) regress-binaries
135ifeq ($(filter noudeb,$(DEB_BUILD_PROFILES)),)
136 $(MAKE) -C debian/build-udeb $(PARALLEL) ASKPASS_PROGRAM='/usr/bin/ssh-askpass' ssh scp sftp sshd ssh-keygen
137endif
138
139ifeq ($(filter pkg.openssh.nognome,$(DEB_BUILD_PROFILES)),)
140 $(MAKE) -C contrib gnome-ssh-askpass3 CC='$(CC) $(CPPFLAGS) $(CFLAGS) -Wall -Wl,--as-needed $(LDFLAGS)' PKG_CONFIG=$(PKG_CONFIG)
141endif
142
143override_dh_auto_build-indep:
144
145override_dh_auto_test-arch:
146ifeq ($(RUN_TESTS),yes)
147 $(MAKE) -C debian/build-deb unit compat-tests
148 $(MAKE) -C debian/keygen-test
149endif
150
151override_dh_auto_test-indep:
152
153override_dh_auto_clean:
154 rm -rf debian/build-deb debian/build-udeb
155ifeq ($(RUN_TESTS),yes)
156 $(MAKE) -C debian/keygen-test clean
157endif
158 $(MAKE) -C contrib clean
159
160override_dh_auto_install-arch:
161 $(MAKE) -C debian/build-deb DESTDIR=`pwd`/debian/tmp install-nokeys
162
163override_dh_auto_install-indep:
164
165override_dh_install-arch:
166 rm -f debian/tmp/etc/ssh/sshd_config
167
168 dh_install -Nopenssh-client-udeb -Nopenssh-server-udeb --fail-missing
169ifeq ($(filter noudeb,$(DEB_BUILD_PROFILES)),)
170 dh_install -popenssh-client-udeb -popenssh-server-udeb \
171 --sourcedir=debian/build-udeb
172endif
173
174 # Remove version control tags to avoid unnecessary conffile
175 # resolution steps for administrators.
176 sed -i '/\$$OpenBSD:/d' \
177 debian/openssh-server/etc/ssh/moduli \
178 debian/openssh-client/etc/ssh/ssh_config
179
180# We'd like to use dh_install --fail-missing here, but that doesn't work
181# well in combination with dh-exec: it complains that files generated by
182# dh-exec for architecture-dependent packages aren't installed.
183override_dh_install-indep:
184 rm -f debian/tmp/etc/ssh/sshd_config
185 dh_install
186
187override_dh_installdocs:
188 dh_installdocs -Nopenssh-server -Nopenssh-sftp-server
189 dh_installdocs -popenssh-server -popenssh-sftp-server \
190 --link-doc=openssh-client
191 # Avoid breaking dh_installexamples later.
192 mkdir -p debian/openssh-server/usr/share/doc/openssh-client
193
194override_dh_systemd_enable:
195 dh_systemd_enable -popenssh-server --name ssh ssh.service
196 dh_systemd_enable -popenssh-server --name ssh --no-enable ssh.socket
197
198override_dh_installinit:
199 dh_installinit -R --name ssh
200
201debian/openssh-server.sshd.pam: debian/openssh-server.sshd.pam.in
202ifeq ($(DEB_HOST_ARCH_OS),linux)
203 sed 's/^@IF_KEYINIT@//' $< > $@
204else
205 sed '/^@IF_KEYINIT@/d' $< > $@
206endif
207
208override_dh_installpam: debian/openssh-server.sshd.pam
209 dh_installpam --name sshd
210
211override_dh_runit:
212 dh_runit -popenssh-server
213
214override_dh_fixperms-arch:
215 dh_fixperms
216 chmod u+s debian/openssh-client/usr/lib/openssh/ssh-keysign
217
218# Tighten libssl dependencies to match the check in entropy.c.
219override_dh_shlibdeps:
220 dh_shlibdeps
221 debian/adjust-openssl-dependencies
222
223override_dh_gencontrol:
224 dh_gencontrol -- -V'openssh-server:Recommends=$(server_recommends)'
225
226debian/faq.html:
227 wget -O - http://www.openssh.com/faq.html | \
228 sed 's,\(href="\)\(txt/\|[^":]*\.html\),\1http://www.openssh.com/\2,g' \
229 > debian/faq.html