File: rules

package info (click to toggle)
ganeti 2.16.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 16,660 kB
  • sloc: python: 105,115; haskell: 43,768; sh: 3,896; makefile: 2,763
file content (197 lines) | stat: -rwxr-xr-x 7,230 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# Debian package major.minor version
VER = $(shell dpkg-parsechangelog -Sversion | sed -r 's/([0-9]+\.[0-9]+)(\..*)/\1/')

# Closest upstream VCS tag, used to generate debian/control and DH files
VCS_VER = $(shell git describe --abbrev=0 --match="v*" 2>/dev/null | sed -r 's/v([0-9]+\.[0-9]+)(\..*)/\1/')

GNT_USERGROUP_PREFIX="gnt-"

GHC_FLAGS = -optl -Wl,-z,relro -optl -Wl,--as-needed

# Architectures with GHC DWARF support (as of GHC 8.2)
# Temporarily disabled for GHC 8.2
#GHC_SUPPORTED_DWARF_ARCHS = amd64 i386

ifneq (,$(filter $(DEB_HOST_ARCH), $(GHC_SUPPORTED_DWARF_ARCHS)))
	GHC_FLAGS += -g
endif

# Set the Python interpreter path, as ganeti will use /usr/bin/python2
# otherwise.

PYTHON := /usr/bin/python
export PYTHON

%:
	dh $@ --with python2,python3,sphinxdoc,bash_completion

ifeq ($(VCS_VER),)
debian/control:
	$(error Empty VCS version, the target must be run within the packaging git repository)
else
debian/control: debian/control.in
	for file in debian/templates/*-VER*; do \
		fname="$$(echo $$file | sed -e 's#VER#$(VCS_VER)#' -e 's#templates/##')"; \
		sed -e 's/@version@/$(VCS_VER)/g' $$file >"$$fname"; \
	done
	
	for package in ganeti-haskell-$(VCS_VER) ganeti-htools-$(VCS_VER) ganeti-$(VCS_VER); do \
		for file in debian/templates/versioned.*; do \
			kind="$$(echo $$file | sed -r 's#.*\.(.*)#\1#')"; \
			sed -e "s/@package@/$$package/g" \
			    -e 's/@version@/$(VCS_VER)/g' \
			    "$$file" > "debian/$${package}.$${kind}"; \
		done; \
	done
	
	sed -s 's/#VER#/$(VCS_VER)/g' debian/control.in > debian/control
endif

clean: debian/control
	dh clean --with python2,python3,sphinxdoc,bash_completion,autoreconf

override_dh_autoreconf:
	dh_autoreconf $(CURDIR)/autogen.sh

override_dh_auto_configure:
	dpkg-parsechangelog -Sversion > vcs-version
	./configure \
	  IP_PATH=/bin/ip \
	  --prefix=/usr \
	  --localstatedir=/var \
	  --sysconfdir=/etc \
	  --with-export-dir=/var/lib/ganeti/export \
	  --with-iallocator-search-path=/usr/local/lib/ganeti/iallocators,/usr/lib/ganeti/iallocators \
	  --with-os-search-path=/srv/ganeti/os,/usr/local/lib/ganeti/os,/usr/lib/ganeti/os,/usr/share/ganeti/os \
	  --with-extstorage-search-path=/srv/ganeti/extstorage,/usr/local/lib/ganeti/extstorage,/usr/lib/ganeti/extstorage,/usr/share/ganeti/extstorage \
	  --docdir=/usr/share/doc/ganeti \
	  --enable-restricted-commands \
	  --disable-symlinks \
	  --with-haskell-flags="$(GHC_FLAGS)" \
	  --with-user-prefix=$(GNT_USERGROUP_PREFIX) \
	  --with-group-prefix=$(GNT_USERGROUP_PREFIX) \
	  --with-ssh-initscript="/usr/sbin/invoke-rc.d ssh" \
	  --with-backup-dir="/var/backups"

override_dh_auto_clean:
	[ ! -f Makefile ] || $(MAKE) distclean
	# this is not removed by make distclean :(
	rm -f ganeti

	rm -f debian/ganeti.init
	rm -f debian/ganeti.cron.d
	rm -f debian/ganeti.default
	rm -f debian/ganeti.postinst
	rm -f debian/ganeti.postrm
	rm -f vcs-version
	dh_auto_clean

override_dh_auto_build:
	dh_auto_build

	# Generate postinst and postrm scripts
	$(CURDIR)/debian/genscript.py postinst "$(CURDIR)" | \
		sed -f "$(CURDIR)/autotools/replace_vars.sed" \
		    -e "s#@VER@#$(VER)#g" >"$(CURDIR)/debian/ganeti.postinst"
	$(CURDIR)/debian/genscript.py postrm "$(CURDIR)" >"$(CURDIR)/debian/ganeti.postrm"
	make -f $(CURDIR)/debian/helper.make install-tests

override_dh_install-indep:
	dh_install -pganeti-$(VER) -Xsbin/ganeti-confd -Xganeti/mon-collector \
		-Xganeti/default -Xbin/h -Xman1/h -Xsbin/ganeti-mond -Xsbin/ganeti-luxid -Xhail
	dh_install -i -Nganeti-$(VER) -Xganeti/$(VER)

	cp $(CURDIR)/doc/examples/ganeti.initd $(CURDIR)/debian/ganeti.init
	cp $(CURDIR)/doc/examples/ganeti.cron $(CURDIR)/debian/ganeti.cron.d
	sed -e 's/^RAPI_ARGS=.*/RAPI_ARGS="-b 127.0.0.1 --require-authentication"/' \
		$(CURDIR)/doc/examples/ganeti.default > $(CURDIR)/debian/ganeti.default

	# Dummy Python module for the RAPI client
	# Add missing bits to ganeti and python-ganeti-rapi.
	# Python 2
	cp $(CURDIR)/debian/tmp/usr/share/ganeti/$(VER)/ganeti/rapi/client.py \
	   $(CURDIR)/debian/python-ganeti-rapi/usr/share/pyshared/ganeti/rapi/
	touch $(CURDIR)/debian/python-ganeti-rapi/usr/share/pyshared/ganeti/__init__.py
	touch $(CURDIR)/debian/python-ganeti-rapi/usr/share/pyshared/ganeti/rapi/__init__.py
	# Python 3
	cp $(CURDIR)/debian/tmp/usr/share/ganeti/$(VER)/ganeti/rapi/client.py \
	   $(CURDIR)/debian/python3-ganeti-rapi/usr/lib/python3/dist-packages/ganeti/rapi/
	touch $(CURDIR)/debian/python3-ganeti-rapi/usr/lib/python3/dist-packages/ganeti/__init__.py
	touch $(CURDIR)/debian/python3-ganeti-rapi/usr/lib/python3/dist-packages/ganeti/rapi/__init__.py
	
override_dh_python2:
	dh_python2

	# /usr/share/ganeti/<VER> is not in the default search path of dh_python2
	dh_python2 -pganeti-$(VER) usr/share/ganeti/$(VER)

override_dh_missing:
	dh_missing --fail-missing

override_dh_installinit:
	dh_installinit --error-handler=true --no-restart-on-upgrade -i -- defaults 20 80

override_dh_compress:
	dh_compress

	# Compress version-specific manpages, not automatically detected by dh_compress
	for package in ganeti-$(VER) ganeti-htools-$(VER); do \
		(cd $(CURDIR)/debian/$$package && \
			find usr/share/ganeti/$(VER)/root/usr/share/man -type f) | \
			xargs dh_compress -p$$package; \
	done

	# Fix the symlinks under /usr/share/man to point to the compressed
	# files. The symlinks are shipped in the ganeti package, and because
	# they are indirect links through /etc, they would not be detected by
	# dh_compress anyway.
	for file in $$(find $(CURDIR)/debian/ganeti/usr/share/man \
			    $(CURDIR)/debian/ganeti-htools/usr/share/man \
			    -type l); do \
		target=$$(readlink "$$file"); \
		rm "$$file"; \
		ln -sf "$${target}.gz" "$${file}.gz"; \
	done

override_dh_link:
	# Fix the links in ganeti-htools to refer directly to the version at hand
	for file in $$(find $(CURDIR)/debian/ganeti-htools/usr -type l); do \
		target="$$(readlink "$$file" | sed -r -e 's#/usr/(lib|share)/ganeti/default/#/usr/\1/ganeti/$(VER)/#')"; \
		ln -sf "$$target" "$$file"; \
	done

	# Now let dh_link fix all symlinks
	dh_link
	
	# Make bash completion autoloadable
	for script in $$(grep ^complete $(CURDIR)/debian/ganeti/usr/share/bash-completion/completions/ganeti \
		| awk '/ +[a-z_-]+$$/ { print $$NF }') ; do \
		dh_link -pganeti "usr/share/bash-completion/completions/ganeti" \
			         "usr/share/bash-completion/completions/$$script" ; \
	done

# Disable dh_sphinxdoc for binary-arch, as it will raise an error
override_dh_sphinxdoc-arch:

# Disable the test suite, as it requires the daemon users to be present
# at build time.
override_dh_auto_test:

ifeq (,$(filter $(DEB_HOST_ARCH), $(GHC_SUPPORTED_DWARF_ARCHS)))
# Skip creating dbgsym packages, as they contain no useful information
override_dh_strip:
	dh_strip --no-automatic-dbgsym

.PHONY: override_dh_strip
endif

.PHONY: override_dh_auto_configure override_dh_auto_clean override_dh_auto_build \
	override_dh_installinit override_dh_install-indep override_dh_sphinxdoc-arch \
	override_dh_auto_test override_dh_compress override_dh_python2 \
	override_dh_link genfiles override_dh_autoreconf check-vcs-version \
	override_dh_missing