diff options
Diffstat (limited to 'debian/rules')
-rwxr-xr-x | debian/rules | 208 |
1 files changed, 208 insertions, 0 deletions
diff --git a/debian/rules b/debian/rules new file mode 100755 index 000000000..889b5a079 --- /dev/null +++ b/debian/rules | |||
@@ -0,0 +1,208 @@ | |||
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 | DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) | ||
16 | DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) | ||
17 | |||
18 | ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) | ||
19 | CC := gcc | ||
20 | PKG_CONFIG = pkg-config | ||
21 | else | ||
22 | CC := $(DEB_HOST_GNU_TYPE)-gcc | ||
23 | PKG_CONFIG = $(DEB_HOST_GNU_TYPE)-pkg-config | ||
24 | RUN_TESTS := | ||
25 | endif | ||
26 | |||
27 | DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null) | ||
28 | |||
29 | # Take account of old dpkg-architecture output. | ||
30 | ifeq ($(DEB_HOST_ARCH_OS),) | ||
31 | DEB_HOST_ARCH_OS := $(subst -gnu,,$(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)) | ||
32 | ifeq ($(DEB_HOST_ARCH_OS),gnu) | ||
33 | DEB_HOST_ARCH_OS := hurd | ||
34 | endif | ||
35 | endif | ||
36 | |||
37 | # Change the version string to include the Debian version | ||
38 | SSH_EXTRAVERSION := Debian-$(shell dpkg-parsechangelog | sed -n -e '/^Version:/s/Version: //p' | sed -e 's/[^-]*-//') | ||
39 | |||
40 | DISTRIBUTOR := $(shell dpkg-vendor --derives-from Ubuntu 2>/dev/null && echo Ubuntu) | ||
41 | ifeq ($(DISTRIBUTOR),Ubuntu) | ||
42 | DEFAULT_PATH := /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games | ||
43 | else | ||
44 | DEFAULT_PATH := /usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games | ||
45 | endif | ||
46 | SUPERUSER_PATH := /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11 | ||
47 | |||
48 | ifeq ($(DISTRIBUTOR),Ubuntu) | ||
49 | server_recommends := ssh-import-id | ||
50 | else | ||
51 | server_recommends := | ||
52 | endif | ||
53 | |||
54 | # Common path configuration. | ||
55 | confflags += --sysconfdir=/etc/ssh | ||
56 | |||
57 | # Common build options. | ||
58 | confflags += --disable-strip | ||
59 | confflags += --with-mantype=doc | ||
60 | confflags += --with-4in6 | ||
61 | confflags += --with-privsep-path=/var/run/sshd | ||
62 | |||
63 | # The Hurd needs libcrypt for res_query et al. | ||
64 | ifeq ($(DEB_HOST_ARCH_OS),hurd) | ||
65 | confflags += --with-libs=-lcrypt | ||
66 | endif | ||
67 | |||
68 | # Everything above here is common to the deb and udeb builds. | ||
69 | confflags_udeb := $(confflags) | ||
70 | |||
71 | # Options specific to the deb build. | ||
72 | confflags += --with-tcp-wrappers | ||
73 | confflags += --with-pam | ||
74 | confflags += --with-libedit | ||
75 | confflags += --with-kerberos5=/usr | ||
76 | confflags += --with-ssl-engine | ||
77 | ifeq ($(DEB_HOST_ARCH_OS),linux) | ||
78 | confflags += --with-selinux | ||
79 | endif | ||
80 | |||
81 | # The deb build wants xauth; the udeb build doesn't. | ||
82 | confflags += --with-xauth=/usr/bin/xauth | ||
83 | confflags_udeb += --without-xauth | ||
84 | |||
85 | # Default paths. The udeb build has /usr/bin/X11 and /usr/games removed. | ||
86 | confflags += --with-default-path=$(DEFAULT_PATH) --with-superuser-path=$(SUPERUSER_PATH) | ||
87 | 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 | ||
88 | |||
89 | # Compiler flags. | ||
90 | export DEB_BUILD_MAINT_OPTIONS := hardening=+all | ||
91 | default_cflags := $(shell dpkg-buildflags --get CPPFLAGS) $(shell dpkg-buildflags --get CFLAGS) | ||
92 | cflags := $(default_cflags) | ||
93 | cflags += -DLOGIN_PROGRAM=\"/bin/login\" -DLOGIN_NO_ENDOPT | ||
94 | cflags += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\" | ||
95 | cflags_udeb := -Os | ||
96 | cflags_udeb += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\" | ||
97 | confflags += --with-cflags='$(cflags)' | ||
98 | confflags_udeb += --with-cflags='$(cflags_udeb)' | ||
99 | |||
100 | # Linker flags. | ||
101 | default_ldflags := $(shell dpkg-buildflags --get LDFLAGS) | ||
102 | confflags += --with-ldflags='$(strip -Wl,--as-needed $(default_ldflags))' | ||
103 | confflags_udeb += --with-ldflags='-Wl,--as-needed' | ||
104 | |||
105 | %: | ||
106 | dh $@ | ||
107 | |||
108 | override_dh_auto_configure: | ||
109 | dh_auto_configure -Bbuild-deb -- $(confflags) | ||
110 | dh_auto_configure -Bbuild-udeb -- $(confflags_udeb) | ||
111 | |||
112 | override_dh_auto_build: | ||
113 | # Debian's /var/log/btmp has inappropriate permissions. | ||
114 | perl -pi -e 's,.*#define USE_BTMP .*,/* #undef USE_BTMP */,' build-deb/config.h | ||
115 | perl -pi -e 's,.*#define USE_BTMP .*,/* #undef USE_BTMP */,' build-udeb/config.h | ||
116 | |||
117 | # Avoid libnsl linkage. Ugh. | ||
118 | perl -pi -e 's/ +-lnsl//' build-udeb/config.status | ||
119 | cd build-udeb && ./config.status | ||
120 | |||
121 | $(MAKE) -C build-deb -j 2 ASKPASS_PROGRAM='/usr/bin/ssh-askpass' | ||
122 | $(MAKE) -C build-udeb -j 2 ASKPASS_PROGRAM='/usr/bin/ssh-askpass' ssh scp sftp sshd ssh-keygen | ||
123 | |||
124 | $(MAKE) -C contrib gnome-ssh-askpass2 CC='$(CC) $(default_cflags) -Wall -Wl,--as-needed $(default_ldflags)' PKG_CONFIG=$(PKG_CONFIG) | ||
125 | |||
126 | override_dh_auto_test: | ||
127 | ifeq ($(RUN_TESTS),yes) | ||
128 | $(MAKE) -C debian/tests | ||
129 | endif | ||
130 | |||
131 | override_dh_auto_clean: | ||
132 | rm -rf build-deb build-udeb | ||
133 | ifeq ($(RUN_TESTS),yes) | ||
134 | $(MAKE) -C debian/tests clean | ||
135 | endif | ||
136 | $(MAKE) -C contrib clean | ||
137 | (cat debian/copyright.head; iconv -f ISO-8859-1 -t UTF-8 LICENCE) \ | ||
138 | > debian/copyright | ||
139 | |||
140 | override_dh_auto_install: | ||
141 | $(MAKE) -C build-deb DESTDIR=`pwd`/debian/tmp install-nokeys | ||
142 | |||
143 | override_dh_install: | ||
144 | rm -f debian/tmp/etc/ssh/sshd_config | ||
145 | |||
146 | dh_install -Nopenssh-client-udeb -Nopenssh-server-udeb --fail-missing | ||
147 | dh_install -popenssh-client-udeb -popenssh-server-udeb \ | ||
148 | --sourcedir=build-udeb | ||
149 | |||
150 | install -o root -g root -m 755 contrib/gnome-ssh-askpass2 debian/ssh-askpass-gnome/usr/lib/openssh/gnome-ssh-askpass | ||
151 | |||
152 | install -o root -g root debian/openssh-server.if-up debian/openssh-server/etc/network/if-up.d/openssh-server | ||
153 | install -o root -g root -m 644 debian/openssh-server.ufw.profile debian/openssh-server/etc/ufw/applications.d/openssh-server | ||
154 | |||
155 | # Remove version control tags to avoid unnecessary conffile | ||
156 | # resolution steps for administrators. | ||
157 | sed -i '/\$$OpenBSD:/d' \ | ||
158 | debian/openssh-client/etc/ssh/moduli \ | ||
159 | debian/openssh-client/etc/ssh/ssh_config | ||
160 | |||
161 | override_dh_installdocs: | ||
162 | dh_installdocs -Nopenssh-server -Nssh | ||
163 | dh_installdocs -popenssh-server -pssh --link-doc=openssh-client | ||
164 | # Avoid breaking dh_installexamples later. | ||
165 | mkdir -p debian/openssh-server/usr/share/doc/openssh-client | ||
166 | |||
167 | override_dh_installinit: | ||
168 | dh_installinit -n --name ssh | ||
169 | |||
170 | override_dh_installpam: | ||
171 | dh_installpam --name sshd | ||
172 | |||
173 | override_dh_fixperms: | ||
174 | dh_fixperms | ||
175 | chmod u+s debian/openssh-client/usr/lib/openssh/ssh-keysign | ||
176 | |||
177 | override_dh_installdeb: | ||
178 | dh_installdeb | ||
179 | perl -i debian/substitute-conffile.pl \ | ||
180 | ETC_SSH_MODULI debian/openssh-client/etc/ssh/moduli \ | ||
181 | ETC_SSH_SSH_CONFIG debian/openssh-client/etc/ssh/ssh_config \ | ||
182 | debian/openssh-client/DEBIAN/preinst | ||
183 | # Yes, ETC_PAM_D_SSH is meant to be spelled that way, to match the | ||
184 | # old configuration file name we need to transfer. | ||
185 | perl -i debian/substitute-conffile.pl \ | ||
186 | ETC_DEFAULT_SSH debian/openssh-server/etc/default/ssh \ | ||
187 | ETC_INIT_D_SSH debian/openssh-server/etc/init.d/ssh \ | ||
188 | ETC_PAM_D_SSH debian/openssh-server/etc/pam.d/sshd \ | ||
189 | debian/openssh-server/DEBIAN/preinst | ||
190 | |||
191 | override_dh_gencontrol: | ||
192 | dh_gencontrol -- -V'openssh-server:Recommends=$(server_recommends)' | ||
193 | |||
194 | debian/faq.html: | ||
195 | wget -O - http://www.openssh.org/faq.html | \ | ||
196 | sed 's,\(href="\)\(txt/\|[^":]*\.html\),\1http://www.openssh.org/\2,g' \ | ||
197 | > debian/faq.html | ||
198 | |||
199 | # You only need to run this immediately after checking out the package from | ||
200 | # revision control. | ||
201 | quilt-setup: | ||
202 | [ ! -d .pc ] | ||
203 | set -e; for patch in $$(quilt series | tac); do \ | ||
204 | patch -p1 -R --no-backup-if-mismatch <"debian/patches/$$patch"; \ | ||
205 | done | ||
206 | quilt push -a | ||
207 | |||
208 | .PHONY: quilt-setup | ||