summaryrefslogtreecommitdiff
path: root/debian/rules
diff options
context:
space:
mode:
Diffstat (limited to 'debian/rules')
-rwxr-xr-xdebian/rules208
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.
7export DH_OPTIONS
8
9ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
10 RUN_TESTS := yes
11else
12 RUN_TESTS :=
13endif
14
15DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
16DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
17
18ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
19 CC := gcc
20 PKG_CONFIG = pkg-config
21else
22 CC := $(DEB_HOST_GNU_TYPE)-gcc
23 PKG_CONFIG = $(DEB_HOST_GNU_TYPE)-pkg-config
24 RUN_TESTS :=
25endif
26
27DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null)
28
29# Take account of old dpkg-architecture output.
30ifeq ($(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
35endif
36
37# Change the version string to include the Debian version
38SSH_EXTRAVERSION := Debian-$(shell dpkg-parsechangelog | sed -n -e '/^Version:/s/Version: //p' | sed -e 's/[^-]*-//')
39
40DISTRIBUTOR := $(shell dpkg-vendor --derives-from Ubuntu 2>/dev/null && echo Ubuntu)
41ifeq ($(DISTRIBUTOR),Ubuntu)
42DEFAULT_PATH := /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games
43else
44DEFAULT_PATH := /usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
45endif
46SUPERUSER_PATH := /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
47
48ifeq ($(DISTRIBUTOR),Ubuntu)
49server_recommends := ssh-import-id
50else
51server_recommends :=
52endif
53
54# Common path configuration.
55confflags += --sysconfdir=/etc/ssh
56
57# Common build options.
58confflags += --disable-strip
59confflags += --with-mantype=doc
60confflags += --with-4in6
61confflags += --with-privsep-path=/var/run/sshd
62
63# The Hurd needs libcrypt for res_query et al.
64ifeq ($(DEB_HOST_ARCH_OS),hurd)
65confflags += --with-libs=-lcrypt
66endif
67
68# Everything above here is common to the deb and udeb builds.
69confflags_udeb := $(confflags)
70
71# Options specific to the deb build.
72confflags += --with-tcp-wrappers
73confflags += --with-pam
74confflags += --with-libedit
75confflags += --with-kerberos5=/usr
76confflags += --with-ssl-engine
77ifeq ($(DEB_HOST_ARCH_OS),linux)
78confflags += --with-selinux
79endif
80
81# The deb build wants xauth; the udeb build doesn't.
82confflags += --with-xauth=/usr/bin/xauth
83confflags_udeb += --without-xauth
84
85# Default paths. The udeb build has /usr/bin/X11 and /usr/games removed.
86confflags += --with-default-path=$(DEFAULT_PATH) --with-superuser-path=$(SUPERUSER_PATH)
87confflags_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.
90export DEB_BUILD_MAINT_OPTIONS := hardening=+all
91default_cflags := $(shell dpkg-buildflags --get CPPFLAGS) $(shell dpkg-buildflags --get CFLAGS)
92cflags := $(default_cflags)
93cflags += -DLOGIN_PROGRAM=\"/bin/login\" -DLOGIN_NO_ENDOPT
94cflags += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\"
95cflags_udeb := -Os
96cflags_udeb += -DSSH_EXTRAVERSION=\"$(SSH_EXTRAVERSION)\"
97confflags += --with-cflags='$(cflags)'
98confflags_udeb += --with-cflags='$(cflags_udeb)'
99
100# Linker flags.
101default_ldflags := $(shell dpkg-buildflags --get LDFLAGS)
102confflags += --with-ldflags='$(strip -Wl,--as-needed $(default_ldflags))'
103confflags_udeb += --with-ldflags='-Wl,--as-needed'
104
105%:
106 dh $@
107
108override_dh_auto_configure:
109 dh_auto_configure -Bbuild-deb -- $(confflags)
110 dh_auto_configure -Bbuild-udeb -- $(confflags_udeb)
111
112override_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
126override_dh_auto_test:
127ifeq ($(RUN_TESTS),yes)
128 $(MAKE) -C debian/tests
129endif
130
131override_dh_auto_clean:
132 rm -rf build-deb build-udeb
133ifeq ($(RUN_TESTS),yes)
134 $(MAKE) -C debian/tests clean
135endif
136 $(MAKE) -C contrib clean
137 (cat debian/copyright.head; iconv -f ISO-8859-1 -t UTF-8 LICENCE) \
138 > debian/copyright
139
140override_dh_auto_install:
141 $(MAKE) -C build-deb DESTDIR=`pwd`/debian/tmp install-nokeys
142
143override_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
161override_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
167override_dh_installinit:
168 dh_installinit -n --name ssh
169
170override_dh_installpam:
171 dh_installpam --name sshd
172
173override_dh_fixperms:
174 dh_fixperms
175 chmod u+s debian/openssh-client/usr/lib/openssh/ssh-keysign
176
177override_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
191override_dh_gencontrol:
192 dh_gencontrol -- -V'openssh-server:Recommends=$(server_recommends)'
193
194debian/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.
201quilt-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