summaryrefslogtreecommitdiff
path: root/debian/rules
diff options
context:
space:
mode:
Diffstat (limited to 'debian/rules')
-rwxr-xr-xdebian/rules221
1 files changed, 221 insertions, 0 deletions
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 000000000..0b63cbd48
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,221 @@
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)
24
25ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
26 CC := gcc
27 PKG_CONFIG = pkg-config
28else
29 CC := $(DEB_HOST_GNU_TYPE)-gcc
30 PKG_CONFIG = $(DEB_HOST_GNU_TYPE)-pkg-config
31 RUN_TESTS :=
32endif
33
34DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null)
35
36# Take account of old dpkg-architecture output.
37ifeq ($(DEB_HOST_ARCH_OS),)
38 DEB_HOST_ARCH_OS := $(subst -gnu,,$(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM))
39 ifeq ($(DEB_HOST_ARCH_OS),gnu)
40 DEB_HOST_ARCH_OS := hurd
41 endif
42endif
43
44# Change the version string to reflect distribution
45DISTRIBUTION := $(shell dpkg-vendor --query vendor)
46SSH_EXTRAVERSION := $(DISTRIBUTION)-$(shell dpkg-parsechangelog | sed -n -e '/^Version:/s/Version: //p' | sed -e 's/[^-]*-//')
47
48DISTRIBUTOR := $(shell if dpkg-vendor --derives-from Ubuntu 2>/dev/null; then echo Ubuntu; else echo Debian; fi)
49ifeq ($(DISTRIBUTOR),Ubuntu)
50DEFAULT_PATH := /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
51else
52DEFAULT_PATH := /usr/local/bin:/usr/bin:/bin:/usr/games
53endif
54SUPERUSER_PATH := /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
55
56ifeq ($(DISTRIBUTOR),Ubuntu)
57server_recommends := ssh-import-id
58else
59server_recommends :=
60endif
61
62# Common path configuration.
63confflags += --sysconfdir=/etc/ssh
64
65# Common build options.
66confflags += --disable-strip
67confflags += --with-mantype=doc
68confflags += --with-4in6
69confflags += --with-privsep-path=/var/run/sshd
70
71# The Hurd needs libcrypt for res_query et al.
72ifeq ($(DEB_HOST_ARCH_OS),hurd)
73confflags += --with-libs=-lcrypt
74endif
75
76# Everything above here is common to the deb and udeb builds.
77confflags_udeb := $(confflags)
78
79# Options specific to the deb build.
80confflags += --with-tcp-wrappers
81confflags += --with-pam
82confflags += --with-libedit
83confflags += --with-kerberos5=/usr
84confflags += --with-ssl-engine
85ifeq ($(DEB_HOST_ARCH_OS),linux)
86confflags += --with-selinux
87endif
88ifeq ($(DISTRIBUTOR),Ubuntu)
89confflags += --with-consolekit
90endif
91
92# The deb build wants xauth; the udeb build doesn't.
93confflags += --with-xauth=/usr/bin/xauth
94confflags_udeb += --without-xauth
95
96# Default paths. The udeb build has /usr/games removed.
97confflags += --with-default-path=$(DEFAULT_PATH) --with-superuser-path=$(SUPERUSER_PATH)
98confflags_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
99
100# Compiler flags.
101export DEB_BUILD_MAINT_OPTIONS := hardening=+all
102default_cflags := $(shell dpkg-buildflags --get CPPFLAGS) $(shell dpkg-buildflags --get CFLAGS)
103cflags := $(default_cflags)
104cflags += -DLOGIN_PROGRAM=\"/bin/login\" -DLOGIN_NO_ENDOPT
105cflags += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\"
106cflags_udeb := -Os
107cflags_udeb += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\"
108confflags += --with-cflags='$(cflags)'
109confflags_udeb += --with-cflags='$(cflags_udeb)'
110
111# Linker flags.
112default_ldflags := $(shell dpkg-buildflags --get LDFLAGS)
113confflags += --with-ldflags='$(strip -Wl,--as-needed $(default_ldflags))'
114confflags_udeb += --with-ldflags='-Wl,--as-needed'
115
116%:
117 dh $@ --with=autoreconf,systemd
118
119autoreconf:
120 autoreconf -f -i
121 cp -f /usr/share/misc/config.guess /usr/share/misc/config.sub ./
122
123override_dh_autoreconf:
124 dh_autoreconf debian/rules -- autoreconf
125
126override_dh_auto_configure:
127 dh_auto_configure -Bbuild-deb -- $(confflags)
128 dh_auto_configure -Bbuild-udeb -- $(confflags_udeb)
129
130override_dh_auto_build:
131 # Debian's /var/log/btmp has inappropriate permissions.
132 perl -pi -e 's,.*#define USE_BTMP .*,/* #undef USE_BTMP */,' build-deb/config.h
133 perl -pi -e 's,.*#define USE_BTMP .*,/* #undef USE_BTMP */,' build-udeb/config.h
134
135 # Avoid libnsl linkage. Ugh.
136 perl -pi -e 's/ +-lnsl//' build-udeb/config.status
137 cd build-udeb && ./config.status
138
139 $(MAKE) -C build-deb $(PARALLEL) ASKPASS_PROGRAM='/usr/bin/ssh-askpass'
140 $(MAKE) -C build-udeb $(PARALLEL) ASKPASS_PROGRAM='/usr/bin/ssh-askpass' ssh scp sftp sshd ssh-keygen
141
142 $(MAKE) -C contrib gnome-ssh-askpass2 CC='$(CC) $(default_cflags) -Wall -Wl,--as-needed $(default_ldflags)' PKG_CONFIG=$(PKG_CONFIG)
143
144override_dh_auto_test:
145ifeq ($(RUN_TESTS),yes)
146 $(MAKE) -C debian/tests
147endif
148
149override_dh_auto_clean:
150 rm -rf build-deb build-udeb
151ifeq ($(RUN_TESTS),yes)
152 $(MAKE) -C debian/tests clean
153endif
154 $(MAKE) -C contrib clean
155 (cat debian/copyright.head; iconv -f ISO-8859-1 -t UTF-8 LICENCE) \
156 > debian/copyright
157
158override_dh_auto_install:
159 $(MAKE) -C build-deb DESTDIR=`pwd`/debian/tmp install-nokeys
160
161override_dh_install:
162 rm -f debian/tmp/etc/ssh/sshd_config
163
164 dh_install -Nopenssh-client-udeb -Nopenssh-server-udeb --fail-missing
165 dh_install -popenssh-client-udeb -popenssh-server-udeb \
166 --sourcedir=build-udeb
167
168 install -o root -g root -m 755 contrib/gnome-ssh-askpass2 debian/ssh-askpass-gnome/usr/lib/openssh/gnome-ssh-askpass
169
170 install -o root -g root debian/openssh-server.if-up debian/openssh-server/etc/network/if-up.d/openssh-server
171 install -o root -g root -m 644 debian/openssh-server.ufw.profile debian/openssh-server/etc/ufw/applications.d/openssh-server
172
173 # Remove version control tags to avoid unnecessary conffile
174 # resolution steps for administrators.
175 sed -i '/\$$OpenBSD:/d' \
176 debian/openssh-client/etc/ssh/moduli \
177 debian/openssh-client/etc/ssh/ssh_config
178
179 # dh_apport would be neater, but at the time of writing it isn't in
180 # unstable yet.
181 install -p -m 644 debian/openssh-client.apport debian/openssh-client/usr/share/apport/package-hooks/openssh-client.py
182 install -p -m 644 debian/openssh-server.apport debian/openssh-server/usr/share/apport/package-hooks/openssh-server.py
183
184 # Upstart user job (only used under user sessions)
185 install -p -m 644 -D debian/ssh-agent.user-session.upstart debian/openssh-client/usr/share/upstart/sessions/ssh-agent.conf
186
187override_dh_installdocs:
188 dh_installdocs -Nopenssh-server -Nssh
189 dh_installdocs -popenssh-server -pssh --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 --name ssh ssh.service
195 dh_systemd_enable --name ssh --no-enable ssh.socket
196
197override_dh_installinit:
198 dh_installinit -R --name ssh -- start 16 2 3 4 5 .
199
200override_dh_installpam:
201 dh_installpam --name sshd
202
203override_dh_fixperms:
204 dh_fixperms
205 chmod u+s debian/openssh-client/usr/lib/openssh/ssh-keysign
206
207# Tighten libssl dependencies to match the check in entropy.c.
208override_dh_shlibdeps:
209 dh_shlibdeps
210 debian/adjust-openssl-dependencies
211
212override_dh_gencontrol:
213 dh_gencontrol -- -V'openssh-server:Recommends=$(server_recommends)'
214
215override_dh_builddeb:
216 dh_builddeb -- -Zxz
217
218debian/faq.html:
219 wget -O - http://www.openssh.org/faq.html | \
220 sed 's,\(href="\)\(txt/\|[^":]*\.html\),\1http://www.openssh.org/\2,g' \
221 > debian/faq.html