1#!/bin/bash 2# 3# Build MariaDB .deb packages for test and release at mariadb.org 4# 5 6# Exit immediately on any error 7set -e 8 9# This file is invocated from Buildbot and Travis-CI to build deb packages. 10# As both of those CI systems have many parallel jobs that include different 11# parts of the test suite, we don't need to run the mysql-test-run at all when 12# building the deb packages here. 13export DEB_BUILD_OPTIONS="nocheck $DEB_BUILD_OPTIONS" 14 15# Travis-CI optimizations 16if [[ $TRAVIS ]] 17then 18 # On Travis-CI, the log must stay under 4MB so make the build less verbose 19 sed -i -e '/Add support for verbose builds/,/^$/d' debian/rules 20 21 # Don't include test suite package on Travis-CI to make the build time shorter 22 sed '/Package: mariadb-test-data/,/^$/d' -i debian/control 23 sed '/Package: mariadb-test$/,/^$/d' -i debian/control 24 25 # Don't build the test package at all to save time and disk space 26 sed 's|DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test|DINSTALL_MYSQLTESTDIR=false|' -i debian/rules 27 28 # Also skip building RocksDB and TokuDB to save even more time and disk space 29 sed 's|-DDEB|-DPLUGIN_TOKUDB=NO -DPLUGIN_MROONGA=NO -DPLUGIN_ROCKSDB=NO -DPLUGIN_SPIDER=NO -DPLUGIN_OQGRAPH=NO -DPLUGIN_PERFSCHEMA=NO -DPLUGIN_SPHINX=NO -WITH_EMBEDDED_SERVER=OFF -DDEB|' -i debian/rules 30fi 31 32# Convert gcc version to numberical value. Format is Mmmpp where M is Major 33# version, mm is minor version and p is patch. 34# -dumpfullversion & -dumpversion to make it uniform across old and new (>=7) 35GCCVERSION=$(gcc -dumpfullversion -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' \ 36 -e 's/\.\([0-9]\)/0\1/g' \ 37 -e 's/^[0-9]\{3,4\}$/&00/') 38 39# Look up distro-version specific stuff 40# 41# Always keep the actual packaging as up-to-date as possible following the latest 42# Debian policy and targeting Debian Sid. Then case-by-case run in autobake-deb.sh 43# tests for backwards compatibility and strip away parts on older builders. 44 45# If libcrack2 (>= 2.9.0) is not available (before Debian Jessie and Ubuntu Trusty) 46# clean away the cracklib stanzas so the package can build without them. 47if ! apt-cache madison libcrack2-dev | grep 'libcrack2-dev *| *2\.9' >/dev/null 2>&1 48then 49 sed '/libcrack2-dev/d' -i debian/control 50 sed '/Package: mariadb-plugin-cracklib/,/^$/d' -i debian/control 51fi 52 53# If libpcre3-dev (>= 2:8.35-3.2~) is not available (before Debian Jessie or Ubuntu Wily) 54# clean away the PCRE3 stanzas so the package can build without them. 55# Update check when version 2:8.40 or newer is available. 56if ! apt-cache madison libpcre3-dev | grep 'libpcre3-dev *| *2:8\.3[2-9]' >/dev/null 2>&1 57then 58 sed '/libpcre3-dev/d' -i debian/control 59fi 60 61# If libsystemd-dev is not available (before Debian Jessie or Ubuntu Wily) 62# clean away the systemd stanzas so the package can build without them. 63if ! apt-cache madison libsystemd-dev | grep 'libsystemd-dev' >/dev/null 2>&1 64then 65 sed '/dh-systemd/d' -i debian/control 66 sed '/libsystemd-dev/d' -i debian/control 67 sed 's/ --with systemd//' -i debian/rules 68 sed '/systemd/d' -i debian/rules 69 sed '/\.service/d' -i debian/rules 70 sed '/galera_new_cluster/d' -i debian/mariadb-server-10.4.install 71 sed '/galera_recovery/d' -i debian/mariadb-server-10.4.install 72 sed '/mariadb-service-convert/d' -i debian/mariadb-server-10.4.install 73fi 74 75# If libzstd-dev is not available (before Debian Stretch and Ubuntu Xenial) 76# remove the dependency from server and rocksdb so it can build properly 77if ! apt-cache madison libzstd-dev | grep 'libzstd-dev' >/dev/null 2>&1 78then 79 sed '/libzstd-dev/d' -i debian/control 80fi 81 82# The binaries should be fully hardened by default. However TokuDB compilation seems to fail on 83# Debian Jessie and older and on Ubuntu Xenial and older with the following error message: 84# /usr/bin/ld.bfd.real: /tmp/ccOIwjFo.ltrans0.ltrans.o: relocation R_X86_64_PC32 against symbol 85# `toku_product_name_strings' can not be used when making a shared object; recompile with -fPIC 86# Therefore we need to disable PIE on those releases using gcc as proxy for detection. 87if [[ $GCCVERSION -lt 60000 ]] 88then 89 sed 's/hardening=+all$/hardening=+all,-pie/' -i debian/rules 90fi 91 92# Don't build rocksdb package if gcc version is less than 4.8 or we are running on 93# x86 32 bit. 94if [[ $GCCVERSION -lt 40800 ]] || [[ $(arch) =~ i[346]86 ]] || [[ $TRAVIS ]] 95then 96 sed '/Package: mariadb-plugin-rocksdb/,/^$/d' -i debian/control 97fi 98 99## Skip TokuDB if arch is not amd64 100if [[ ! $(dpkg-architecture -q DEB_BUILD_ARCH) =~ amd64 ]] 101then 102 sed '/Package: mariadb-plugin-tokudb/,/^$/d' -i debian/control 103fi 104 105# Always remove aws plugin, see -DNOT_FOR_DISTRIBUTION in CMakeLists.txt 106sed '/Package: mariadb-plugin-aws-key-management-10.2/,/^$/d' -i debian/control 107 108# Don't build cassandra package if thrift is not installed 109if [[ ! -f /usr/local/include/thrift/Thrift.h && ! -f /usr/include/thrift/Thrift.h ]] 110then 111 sed '/Package: mariadb-plugin-cassandra/,/^$/d' -i debian/control 112fi 113 114# From Debian Stretch/Ubuntu Bionic onwards dh-systemd is just an empty 115# transitional metapackage and the functionality was merged into debhelper. 116# In Ubuntu Hirsute is was completely removed, so it can't be referenced anymore. 117# Keep using it only on Debian Jessie and Ubuntu Xenial. 118if apt-cache madison dh-systemd | grep 'dh-systemd' >/dev/null 2>&1 119then 120 sed 's/debhelper (>= 9.20160709~),/debhelper (>= 9), dh-systemd,/' -i debian/control 121fi 122 123# Mroonga, TokuDB never built on Travis CI anyway, see build flags above 124if [[ $TRAVIS ]] 125then 126 sed -i -e "/Package: mariadb-plugin-tokudb/,/^$/d" debian/control 127 sed -i -e "/Package: mariadb-plugin-mroonga/,/^$/d" debian/control 128 sed -i -e "/Package: mariadb-plugin-spider/,/^$/d" debian/control 129 sed -i -e "/Package: mariadb-plugin-oqgraph/,/^$/d" debian/control 130 sed -i -e "/usr\/lib\/mysql\/plugin\/ha_sphinx.so/d" debian/mariadb-server-10.4.install 131 sed -i -e "/Package: libmariadbd-dev/,/^$/d" debian/control 132fi 133 134# Adjust changelog, add new version 135echo "Incrementing changelog and starting build scripts" 136 137# Find major.minor version 138source ./VERSION 139UPSTREAM="${MYSQL_VERSION_MAJOR}.${MYSQL_VERSION_MINOR}.${MYSQL_VERSION_PATCH}${MYSQL_VERSION_EXTRA}" 140PATCHLEVEL="+maria" 141LOGSTRING="MariaDB build" 142CODENAME="$(lsb_release -sc)" 143EPOCH="1:" 144 145dch -b -D ${CODENAME} -v "${EPOCH}${UPSTREAM}${PATCHLEVEL}~${CODENAME}" "Automatic build with ${LOGSTRING}." 146 147echo "Creating package version ${EPOCH}${UPSTREAM}${PATCHLEVEL}~${CODENAME} ... " 148 149# On Travis CI, use -b to build binary only packages as there is no need to 150# waste time on generating the source package. 151if [[ $TRAVIS ]] 152then 153 BUILDPACKAGE_FLAGS="-b" 154fi 155 156# Build the package 157# Pass -I so that .git and other unnecessary temporary and source control files 158# will be ignored by dpkg-source when creating the tar.gz source package. 159fakeroot dpkg-buildpackage -us -uc -I $BUILDPACKAGE_FLAGS -j$(nproc) 160 161# If the step above fails due to missing dependencies, you can manually run 162# sudo mk-build-deps debian/control -r -i 163 164# Don't log package contents on Travis-CI to save time and log size 165if [[ ! $TRAVIS ]] 166then 167 echo "List package contents ..." 168 cd .. 169 for package in `ls *.deb` 170 do 171 echo $package | cut -d '_' -f 1 172 dpkg-deb -c $package | awk '{print $1 " " $2 " " $6}' | sort -k 3 173 echo "------------------------------------------------" 174 done 175fi 176 177echo "Build complete" 178