~mathiaz/mysql-server/pkg-ubuntu

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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
#!/usr/bin/make -f

export DH_VERBOSE=1

PACKAGE=mysql-dfsg-5.0

include /usr/share/dpatch/dpatch.make

TMP=$(CURDIR)/debian/tmp/

ARCH = $(shell dpkg-architecture -qDEB_BUILD_ARCH)
ARCH_OS = $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEBVERSION = $(shell dpkg-parsechangelog | awk '/^Version: / { print $$2 }' | sed 's/^.*-//' )

DEB_SOURCE_PACKAGE ?= $(strip $(shell egrep '^Source: ' debian/control | cut -f 2 -d ':'))
DEB_VERSION ?= $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
DEB_NOEPOCH_VERSION ?= $(shell echo $(DEB_VERSION) | cut -d: -f2-)
DEB_UPSTREAM_VERSION ?= $(shell echo $(DEB_NOEPOCH_VERSION) | sed 's/-[^-]*$$//')
DEB_UPSTREAM_VERSION_MAJOR_MINOR := $(shell echo $(DEB_UPSTREAM_VERSION) | sed -r -n 's/^([0-9]+\.[0-9]+).*/\1/p')

MAKE_J = -j$(shell grep -c processor.* /proc/cpuinfo)
ifeq (${MAKE_J}, -j0)
  MAKE_J = -j1
endif

ifeq ($(findstring $(ARCH),i386 sparc),$(ARCH))
    USE_ASSEMBLER=--enable-assembler 
endif

# This causes seg11 crashes if LDAP is used for groups in /etc/nsswitch.conf
# so it is disabled by default although, according to MySQL, it brings >10%
# performance gain if enabled. See #299382.
ifeq ($(STATIC_MYSQLD), 1)
    USE_STATIC_MYSQLD=--with-mysqld-ldflags=-all-static
endif
		
configure: patch configure-stamp
configure-stamp:
	@echo "RULES.configure-stamp"
	dh_testdir

ifneq ($(ARCH_OS),hurd)
	if [ ! -d /proc/self ]; then echo "/proc IS NEEDED" 1>&2; exit 1; fi 
endif

	sh -c  'PATH=$${MYSQL_BUILD_PATH:-"/bin:/usr/bin"} \
		CC=$${MYSQL_BUILD_CC:-gcc} \
	    	CFLAGS=$${MYSQL_BUILD_CFLAGS:-"-DBIG_JOINS=1 -O2 -fPIC"} \
		CXX=$${MYSQL_BUILD_CXX:-g++} \
	    	CXXFLAGS=$${MYSQL_BUILD_CXXFLAGS:-"-DBIG_JOINS=1 -felide-constructors -fno-rtti -O2"} \
	    ./configure \
		--build=${DEB_BUILD_GNU_TYPE} \
		--host=${DEB_HOST_GNU_TYPE} \
		\
		--prefix=/usr \
	        --exec-prefix=/usr \
	        --libexecdir=/usr/sbin \
	        --datadir=/usr/share \
	        --localstatedir=/var/lib/mysql \
	        --includedir=/usr/include \
	        --infodir=/usr/share/info \
	        --mandir=/usr/share/man \
		\
		--with-server-suffix="-$(DEBVERSION)" \
		--with-comment="(Debian)" \
                --with-system-type="debian-linux-gnu" \
		\
		--enable-shared \
		--enable-static \
		--enable-thread-safe-client \
	        $(USE_ASSEMBLER) \
		--enable-local-infile \
		\
                --with-big-tables \
		--with-raid \
		--with-unix-socket-path=/var/run/mysqld/mysqld.sock \
	       	--with-mysqld-user=mysql \
		--with-libwrap \
		$(USE_STATIC_MYSQLD) \
		--with-vio \
		--without-openssl \
		--with-yassl \
	    	--without-docs \
		--with-bench \
		--without-readline \
		--with-extra-charsets=all \
		--with-innodb \
		\
		--with-isam \
		--with-archive-storage-engine \
		--with-csv-storage-engine \
		--with-federated-storage-engine \
		--with-blackhole-storage-engine \
		--with-sphinx-storage-engine \
		--without-embedded-server \
		--with-ndbcluster \
		--with-ndb-ccflags="-fPIC" \
		--with-ndb-shm \
		--without-ndb-sci \
		--without-ndb-test \
		--with-embedded-server \
		--with-embedded-privilege-control \
		--with-ndb-docs'
		
	#       --sysconfdir=/etc/mysql 	-- Appends /etc/mysql after ~/ in the my.cnf search patch!
	#	--with-embedded-server \
	#	--with-embedded-privilege-control \
	#	--with-debug \
	#	--with-mysqlfs 	 # does not build, no toplevel fs/ directory! Needs CORBA.
	
	touch configure-stamp


build: build-stamp
build-stamp: configure
	dh_testdir

	$(MAKE) $(MAKE_J)

	if [ ! -f testsuite-stamp ] ; then \
	  cd mysql-test ; \
	  /usr/bin/perl ./mysql-test-run.pl --mysqld=--user=root --force ; \
	  /usr/bin/perl ./mysql-test-run.pl --mysqld=--user=root --force --ps-protocol ; \
	fi

	touch testsuite-stamp

	touch build-stamp
	

clean: clean-patched unpatch
	rm -rf debian/patched
clean-patched:
	@echo "RULES.clean-patched"
	dh_testdir 
	dh_testroot
	rm -f configure-stamp
	rm -f build-stamp
	rm -f testsuite-stamp
	
	[ ! -f Makefile ] || $(MAKE) clean

	# We like to see how long this is neccessary
	@echo "CRUFT BEGIN" 
	@find -type l -print0 | xargs --no-run-if-empty -0 rm -v
	@find -name .deps -type d -print0 | xargs --no-run-if-empty -0 rm -rfv
	@rm -vrf ndb/docs/.doxy* ndb/docs/*html ndb/docs/*pdf innobase/autom4te.cache
	@for i in \
	  readline/Makefile \
	  sql-bench/Makefile \
	  scripts/make_win_binary_distribution \
	  scripts/mysql_explain_log \
	  scripts/mysql_tableinfo \
	  scripts/mysqlbug \
	  sql/gen_lex_hash \
	  sql/lex_hash.h \
	  strings/ctype_autoconf.c \
	  config.log \
	  config.cache \
	  ; \
	do \
	  rm -vf $$i; \
	done
	@echo "CRUFT END"

	debconf-updatepo
	dh_clean -v

	
install:
install: build
	@echo "RULES.install"
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# this is stupid, if mysql-server symlinks point to something in the
	# mysql-client package they get not compressed and end up stale
	mkdir -p $(TMP)/usr/share/man/man1/
	mkdir -p $(TMP)/usr/share/man/man8/
	cp debian/additions/manpages/*.1 $(TMP)/usr/share/man/man1/

	# make install (trailing slash needed for innobase)
	$(MAKE) install DESTDIR=$(TMP)/
		
	# After installing, remove rpath to make lintian happy.
	set +e; \
	find ./debian/tmp/ -type f -print0 \
		| xargs -0 --no-run-if-empty chrpath -k 2>/dev/null \
		| fgrep RPATH= \
		| cut -d: -f 1 \
		| xargs --no-run-if-empty chrpath -d; \
	set -e

	# libmysqlclient: move shared libraries (but not the rest like libheap.a & co)
	mv $(TMP)/usr/lib/mysql/libmysqlclient* $(TMP)/usr/lib
	perl -pi -e 's#/usr/lib/mysql#/usr/lib#' $(TMP)/usr/lib/libmysqlclient.la
	perl -pi -e 's#/usr/lib/mysql#/usr/lib#' $(TMP)/usr/lib/libmysqlclient_r.la
	# Check if our beloved versioned symbols are really there
	if [ "`objdump -T $(TMP)/usr/lib/libmysqlclient.so.15.0.0 | grep -c libmysqlclient_15`" -lt 500 ]; then \
	  echo "ERROR: versioned symbols are absent"; \
	  exit 1; \
	fi     

	# libmysqlclient-dev: forgotten header file since 3.23.25?
	cp include/my_config.h $(TMP)/usr/include/mysql/
	cp include/my_dir.h $(TMP)/usr/include/mysql/

	# mysql-common: We now provide our own config file.
	install -d $(TMP)/etc/mysql
	install -m 0644 debian/additions/my.cnf $(TMP)/etc/mysql/my.cnf

	# mysql-client
	install -m 0755 debian/additions/mysqlreport/mysqlreport $(TMP)/usr/bin/
	install -m 0644 debian/additions/mysqlreport/mysqlreport.1 $(TMP)/usr/share/man/man1/
	install -m 0755 debian/additions/innotop/innotop $(TMP)/usr/bin/
	install -m 0644 debian/additions/innotop/innotop.1 $(TMP)/usr/share/man/man1/
	install -m 0644 -D debian/additions/innotop/InnoDBParser.pm $(TMP)/usr/share/perl5/InnoDBParser.pm

	# mysql-server
	install -m 0755 scripts/mysqld_safe $(TMP)/usr/bin/mysqld_safe
	mkdir -p $(TMP)/usr/share/doc/mysql-server-5.0/examples
	mv $(TMP)/usr/share/mysql/*cnf 	    $(TMP)/usr/share/doc/mysql-server-5.0/examples/
	rm -vf $(TMP)/usr/share/mysql/mi_test_all* \
	       $(TMP)/usr/share/mysql/mysql-log-rotate \
	       $(TMP)/usr/share/mysql/mysql.server \
	       $(TMP)/usr/share/mysql/binary-configure
	nm -n sql/mysqld |gzip -9 > $(TMP)/usr/share/doc/mysql-server-5.0/mysqld.sym.gz
	install -m 0644 debian/additions/ndb_mgmd.cnf $(TMP)/usr/share/doc/mysql-server-5.0/examples/
	install -m 0755 debian/additions/echo_stderr $(TMP)/usr/share/mysql/
	install -m 0755 debian/additions/debian-start $(TMP)/etc/mysql/
	install -m 0755 debian/additions/debian-start.inc.sh $(TMP)/usr/share/mysql/
	sed "s#filename => 'ndb_size.tmpl#filename => '/usr/share/mysql/ndb_size.tmpl#" < $(TMP)/usr/bin/ndb_size.pl > $(TMP)/usr/bin/ndb_size
	mv $(TMP)/usr/mysql-test $(TMP)/usr/share/mysql/
	mv $(TMP)/usr/sql-bench $(TMP)/usr/share/mysql/
	# lintian overrides
	mkdir -p $(TMP)/usr/share/lintian/overrides/
	cp debian/mysql-server-5.0.lintian-overrides $(TMP)/usr/share/lintian/overrides/mysql-server-5.0
	cp debian/mysql-client-5.0.lintian-overrides $(TMP)/usr/share/lintian/overrides/mysql-client-5.0
	cp debian/libmysqlclient15-dev.lintian-overrides $(TMP)/usr/share/lintian/overrides/libmysqlclient15-dev

	# For 4.1 -> 5.0 transition
	d=$(TMP)/usr/share/mysql-common/internal-use-only/; \
	mkdir -p $$d; \
	cp debian/mysql-server-5.0.mysql.init $$d/_etc_init.d_mysql; \
	cp debian/mysql-server-5.0.mysql-server.logrotate $$d/_etc_logrotate.d_mysql-server; \
	cp debian/additions/debian-start $$d/_etc_mysql_debian-start

	dh_movefiles
	
# Build architecture-independent files here.
binary-indep: build install
	@echo "RULES.binary-indep"
	dh_testdir -i
	dh_testroot -i
	dh_installdebconf -i
	dh_installdocs -i
	dh_installexamples -i
	dh_installmenu -i
	dh_installlogrotate -i
	dh_installinit -i
	dh_installcron -i 
	dh_installman -i
	dh_installinfo -i
	dh_installlogcheck -i
	dh_installchangelogs -i
	dh_link -i
	dh_compress -i
	dh_fixperms -i
	dh_installdeb -i
	dh_perl -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i
	
# Build architecture-dependent files here.
binary-arch: build install
	@echo "RULES.binary-arch"
	dh_testdir 
	dh_testroot

	dh_installdebconf -a
	dh_installdocs -a
	dh_installexamples -a
	dh_installmenu -a
	dh_installlogrotate -a --name mysql-server
	# NDB needs to start before MySQL if they share a machine
	# Neither should automatically restart on package install. There
	# is a rolling order in which nodes in a cluster should be 
	# restarted that is not possible to manage here.
	dh_installinit -a -r --no-start --name=mysql-ndb-mgm -- defaults 17 23
	dh_installinit -a -r --no-start --name=mysql-ndb -- defaults 18 22
	# Start mysql in runlevel 19 before 20 where apache, proftpd etc gets
	# started which might depend on a running database server.
	dh_installinit -a --name=mysql -- defaults 19 21
	dh_installcron -a --name mysql-server
	dh_installman -a
	dh_installinfo -a
	dh_installlogcheck -a
	dh_installchangelogs -a
	dh_strip -a
	dh_link -a	# .so muss nach .so.1.2.3 installier werden!
	dh_compress -a
	dh_fixperms -a
	dh_makeshlibs -a
	dh_makeshlibs -plibmysqlclient15off -V'libmysqlclient15off (>= 5.0.27-1)'
	dh_installdeb -a
	dh_perl -a
	dh_shlibdeps -a -l debian/libmysqlclient15off/usr/lib -L libmysqlclient15off
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

source diff:
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

binary:	binary-indep binary-arch

get-orig-source:
	@wget -nv -T10 -t3 \
	  -O /tmp/mysql-$(DEB_UPSTREAM_VERSION).tar.gz \
	  http://ftp.gwdg.de/pub/misc/mysql/Downloads/MySQL-$(DEB_UPSTREAM_VERSION_MAJOR_MINOR)/mysql-$(DEB_UPSTREAM_VERSION).tar.gz
	@tar xfz /tmp/mysql-$(DEB_UPSTREAM_VERSION).tar.gz -C /tmp
	@rm -rf /tmp/mysql-$(DEB_UPSTREAM_VERSION)/Docs
	@rm -rf /tmp/mysql-$(DEB_UPSTREAM_VERSION)/debian
	@mv /tmp/mysql-$(DEB_UPSTREAM_VERSION) /tmp/$(DEB_SOURCE_PACKAGE)-$(DEB_UPSTREAM_VERSION).orig
	@cd /tmp ; tar czf $(DEB_SOURCE_PACKAGE)_$(DEB_UPSTREAM_VERSION).orig.tar.gz $(DEB_SOURCE_PACKAGE)-$(DEB_UPSTREAM_VERSION).orig
	@rm -f /tmp/mysql-$(DEB_UPSTREAM_VERSION).tar.gz
	@rm -rf /tmp/$(DEB_SOURCE_PACKAGE)-$(DEB_UPSTREAM_VERSION).orig
	
.PHONY: clean clean-patched configure build binary binary-indep binary-arch install patch unpatch

# vim: ts=8