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