summaryrefslogtreecommitdiff
path: root/debian/rules
diff options
context:
space:
mode:
Diffstat (limited to 'debian/rules')
-rwxr-xr-xdebian/rules230
1 files changed, 230 insertions, 0 deletions
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 000000000..550306d4f
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,230 @@
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# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60155
69ifeq ($(DEB_HOST_ARCH),hppa)
70confflags += --without-hardening
71endif
72
73# Everything above here is common to the deb and udeb builds.
74confflags_udeb := $(confflags)
75
76# Options specific to the deb build.
77confflags += --with-tcp-wrappers
78confflags += --with-pam
79confflags += --with-libedit
80confflags += --with-kerberos5=/usr
81confflags += --with-ssl-engine
82ifeq ($(DEB_HOST_ARCH_OS),linux)
83confflags += --with-selinux
84confflags += --with-audit=linux
85confflags += --with-systemd
86endif
87
88# The deb build wants xauth; the udeb build doesn't.
89confflags += --with-xauth=/usr/bin/xauth
90confflags_udeb += --without-xauth
91
92# Default paths. The udeb build has /usr/games removed.
93confflags += --with-default-path=$(DEFAULT_PATH) --with-superuser-path=$(SUPERUSER_PATH)
94confflags_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
95
96# Compiler flags.
97cflags := $(CPPFLAGS) $(CFLAGS)
98cflags += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\"
99cflags_udeb := -Os
100cflags_udeb += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\"
101confflags += --with-cflags='$(cflags)'
102confflags_udeb += --with-cflags='$(cflags_udeb)'
103
104# Linker flags.
105confflags += --with-ldflags='$(strip -Wl,--as-needed $(LDFLAGS))'
106confflags_udeb += --with-ldflags='-Wl,--as-needed'
107
108%:
109 dh $@ --with=autoreconf,systemd
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/regress \
148 .OBJDIR="$(CURDIR)/debian/build-deb/regress" \
149 .CURDIR="$(CURDIR)/regress" \
150 unit
151 $(MAKE) -C debian/build-deb compat-tests
152 $(MAKE) -C debian/keygen-test
153endif
154
155override_dh_auto_test-indep:
156
157override_dh_auto_clean:
158 rm -rf debian/build-deb debian/build-udeb
159ifeq ($(RUN_TESTS),yes)
160 $(MAKE) -C debian/keygen-test clean
161endif
162 $(MAKE) -C contrib clean
163
164override_dh_auto_install-arch:
165 $(MAKE) -C debian/build-deb DESTDIR=`pwd`/debian/tmp install-nokeys
166
167override_dh_auto_install-indep:
168
169override_dh_install-arch:
170 rm -f debian/tmp/etc/ssh/sshd_config
171
172 dh_install -Nopenssh-client-udeb -Nopenssh-server-udeb --fail-missing
173ifeq ($(filter noudeb,$(DEB_BUILD_PROFILES)),)
174 dh_install -popenssh-client-udeb -popenssh-server-udeb \
175 --sourcedir=debian/build-udeb
176endif
177
178 # Remove version control tags to avoid unnecessary conffile
179 # resolution steps for administrators.
180 sed -i '/\$$OpenBSD:/d' \
181 debian/openssh-server/etc/ssh/moduli \
182 debian/openssh-client/etc/ssh/ssh_config
183
184# We'd like to use dh_install --fail-missing here, but that doesn't work
185# well in combination with dh-exec: it complains that files generated by
186# dh-exec for architecture-dependent packages aren't installed.
187override_dh_install-indep:
188 rm -f debian/tmp/etc/ssh/sshd_config
189 dh_install
190
191override_dh_installdocs:
192 dh_installdocs -Nopenssh-server -Nopenssh-sftp-server
193 dh_installdocs -popenssh-server -popenssh-sftp-server \
194 --link-doc=openssh-client
195 # Avoid breaking dh_installexamples later.
196 mkdir -p debian/openssh-server/usr/share/doc/openssh-client
197
198override_dh_systemd_enable:
199 dh_systemd_enable -popenssh-server --name ssh ssh.service
200 dh_systemd_enable -popenssh-server --name ssh --no-enable ssh.socket
201
202override_dh_installinit:
203 dh_installinit -R --name ssh
204
205debian/openssh-server.sshd.pam: debian/openssh-server.sshd.pam.in
206ifeq ($(DEB_HOST_ARCH_OS),linux)
207 sed 's/^@IF_KEYINIT@//' $< > $@
208else
209 sed '/^@IF_KEYINIT@/d' $< > $@
210endif
211
212override_dh_installpam: debian/openssh-server.sshd.pam
213 dh_installpam --name sshd
214
215override_dh_fixperms-arch:
216 dh_fixperms
217 chmod u+s debian/openssh-client/usr/lib/openssh/ssh-keysign
218
219# Tighten libssl dependencies to match the check in entropy.c.
220override_dh_shlibdeps:
221 dh_shlibdeps
222 debian/adjust-openssl-dependencies
223
224override_dh_gencontrol:
225 dh_gencontrol -- -V'openssh-server:Recommends=$(server_recommends)'
226
227debian/faq.html:
228 wget -O - http://www.openssh.com/faq.html | \
229 sed 's,\(href="\)\(txt/\|[^":]*\.html\),\1http://www.openssh.com/\2,g' \
230 > debian/faq.html