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