diff options
Diffstat (limited to 'debian/rules')
-rwxr-xr-x | debian/rules | 230 |
1 files changed, 230 insertions, 0 deletions
diff --git a/debian/rules b/debian/rules new file mode 100755 index 000000000..d377ed2b0 --- /dev/null +++ b/debian/rules | |||
@@ -0,0 +1,230 @@ | |||
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 | endif | ||
95 | ifeq ($(DISTRIBUTOR),Ubuntu) | ||
96 | confflags += --with-consolekit | ||
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 += -DLOGIN_PROGRAM=\"/bin/login\" -DLOGIN_NO_ENDOPT | ||
112 | cflags += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\" | ||
113 | cflags_udeb := -Os | ||
114 | cflags_udeb += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\" | ||
115 | confflags += --with-cflags='$(cflags)' | ||
116 | confflags_udeb += --with-cflags='$(cflags_udeb)' | ||
117 | |||
118 | # Linker flags. | ||
119 | confflags += --with-ldflags='$(strip -Wl,--as-needed $(LDFLAGS))' | ||
120 | confflags_udeb += --with-ldflags='-Wl,--as-needed' | ||
121 | |||
122 | %: | ||
123 | dh $@ --with=autoreconf,systemd | ||
124 | |||
125 | autoreconf: | ||
126 | autoreconf -f -i | ||
127 | cp -f /usr/share/misc/config.guess /usr/share/misc/config.sub ./ | ||
128 | |||
129 | override_dh_autoreconf: | ||
130 | dh_autoreconf debian/rules -- autoreconf | ||
131 | |||
132 | override_dh_auto_configure: | ||
133 | dh_auto_configure -Bbuild-deb -- $(confflags) | ||
134 | dh_auto_configure -Bbuild-udeb -- $(confflags_udeb) | ||
135 | |||
136 | override_dh_auto_build: | ||
137 | # Avoid libnsl linkage. Ugh. | ||
138 | perl -pi -e 's/ +-lnsl//' build-udeb/config.status | ||
139 | cd build-udeb && ./config.status | ||
140 | |||
141 | $(MAKE) -C build-deb $(PARALLEL) ASKPASS_PROGRAM='/usr/bin/ssh-askpass' | ||
142 | $(MAKE) -C build-udeb $(PARALLEL) ASKPASS_PROGRAM='/usr/bin/ssh-askpass' ssh scp sftp sshd ssh-keygen | ||
143 | |||
144 | $(MAKE) -C contrib gnome-ssh-askpass2 CC='$(CC) $(CPPFLAGS) $(CFLAGS) -Wall -Wl,--as-needed $(LDFLAGS)' PKG_CONFIG=$(PKG_CONFIG) | ||
145 | |||
146 | override_dh_auto_test: | ||
147 | ifeq ($(RUN_TESTS),yes) | ||
148 | $(MAKE) -C build-deb regress-prep | ||
149 | $(MAKE) -C build-deb $(PARALLEL) \ | ||
150 | regress/unittests/sshbuf/test_sshbuf \ | ||
151 | regress/unittests/sshkey/test_sshkey \ | ||
152 | regress/unittests/bitmap/test_bitmap \ | ||
153 | regress/unittests/hostkeys/test_hostkeys \ | ||
154 | regress/unittests/kex/test_kex | ||
155 | $(MAKE) -C build-deb/regress \ | ||
156 | .OBJDIR="$(CURDIR)/build-deb/regress" \ | ||
157 | .CURDIR="$(CURDIR)/regress" \ | ||
158 | unit | ||
159 | $(MAKE) -C build-deb compat-tests | ||
160 | $(MAKE) -C debian/keygen-test | ||
161 | endif | ||
162 | |||
163 | override_dh_auto_clean: | ||
164 | rm -rf build-deb build-udeb | ||
165 | ifeq ($(RUN_TESTS),yes) | ||
166 | $(MAKE) -C debian/keygen-test clean | ||
167 | endif | ||
168 | $(MAKE) -C contrib clean | ||
169 | (cat debian/copyright.head; iconv -f ISO-8859-1 -t UTF-8 LICENCE) \ | ||
170 | > debian/copyright | ||
171 | |||
172 | override_dh_auto_install: | ||
173 | $(MAKE) -C build-deb DESTDIR=`pwd`/debian/tmp install-nokeys | ||
174 | |||
175 | override_dh_install: | ||
176 | rm -f debian/tmp/etc/ssh/sshd_config | ||
177 | |||
178 | dh_install -Nopenssh-client-udeb -Nopenssh-server-udeb --fail-missing | ||
179 | dh_install -popenssh-client-udeb -popenssh-server-udeb \ | ||
180 | --sourcedir=build-udeb | ||
181 | |||
182 | # Remove version control tags to avoid unnecessary conffile | ||
183 | # resolution steps for administrators. | ||
184 | sed -i '/\$$OpenBSD:/d' \ | ||
185 | debian/openssh-client/etc/ssh/moduli \ | ||
186 | debian/openssh-client/etc/ssh/ssh_config | ||
187 | |||
188 | override_dh_installdocs: | ||
189 | dh_installdocs -Nopenssh-server -Nopenssh-sftp-server | ||
190 | dh_installdocs -popenssh-server -popenssh-sftp-server \ | ||
191 | --link-doc=openssh-client | ||
192 | # Avoid breaking dh_installexamples later. | ||
193 | mkdir -p debian/openssh-server/usr/share/doc/openssh-client | ||
194 | |||
195 | override_dh_systemd_enable: | ||
196 | dh_systemd_enable -popenssh-server --name ssh ssh.service | ||
197 | dh_systemd_enable -popenssh-server --name ssh --no-enable ssh.socket | ||
198 | |||
199 | override_dh_installinit: | ||
200 | dh_installinit -R --name ssh | ||
201 | |||
202 | debian/openssh-server.sshd.pam: debian/openssh-server.sshd.pam.in | ||
203 | ifeq ($(DEB_HOST_ARCH_OS),linux) | ||
204 | sed 's/^@IF_KEYINIT@//' $< > $@ | ||
205 | else | ||
206 | sed '/^@IF_KEYINIT@/d' $< > $@ | ||
207 | endif | ||
208 | |||
209 | override_dh_installpam: debian/openssh-server.sshd.pam | ||
210 | dh_installpam --name sshd | ||
211 | |||
212 | override_dh_fixperms: | ||
213 | dh_fixperms | ||
214 | chmod u+s debian/openssh-client/usr/lib/openssh/ssh-keysign | ||
215 | |||
216 | # Tighten libssl dependencies to match the check in entropy.c. | ||
217 | override_dh_shlibdeps: | ||
218 | dh_shlibdeps | ||
219 | debian/adjust-openssl-dependencies | ||
220 | |||
221 | override_dh_gencontrol: | ||
222 | dh_gencontrol -- -V'openssh-server:Recommends=$(server_recommends)' | ||
223 | |||
224 | override_dh_builddeb: | ||
225 | dh_builddeb -- -Zxz | ||
226 | |||
227 | debian/faq.html: | ||
228 | wget -O - http://www.openssh.org/faq.html | \ | ||
229 | sed 's,\(href="\)\(txt/\|[^":]*\.html\),\1http://www.openssh.org/\2,g' \ | ||
230 | > debian/faq.html | ||