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