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