[MDEV-20339] FreeBSD VM builder Created: 2013-06-14  Updated: 2022-09-21

Status: Open
Project: MariaDB Server
Component/s: None
Fix Version/s: None

Type: Task Priority: Critical
Reporter: Sergei Golubchik Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 2
Labels: None

Issue Links:
Blocks
PartOf
includes MDEV-4282 Build on FreeBSD from ports Open
Relates
relates to MDEV-3833 FreeBSD pkgNG porting Repo add Open
relates to MDEV-4174 MariaDB 5.5 thread pool code fails to... Closed
relates to MDEV-4553 NetBSD patches for MariaDB 5.5.30 Closed
relates to MDEV-4658 connect storage engine fails to build... Closed
relates to MDBF-51 Add FreeBSD buildbot In Progress

 Description   

We need a FreeBSD VM in the buildbot.
To make any sense it should build from the port collection, not just cmake .



 Comments   
Comment by Sergei Golubchik [ 2013-09-29 ]

Daniel, any news on that?
To have any success in FreeBSD we need at least to have it in buildbot

Comment by Sergei Golubchik [ 2013-09-30 ]

According to the MariaDB port maintainer in FreeBSD, we should use FreeBSD 9.2 and 10.0 in buildbot.
If we pick only one, then 9.2

Comment by Sergei Golubchik [ 2019-08-06 ]

Daniel, could you please add a reasonably recent FreeBSD VM to buildbot? To the main group, not experimental.

This makes us to test on FreeBSD, we getting "do not compile" bugs quite regularly. And it'll test with clang, which we don't have either.

If there are any old FreeBSD builders — please remove them.

Comment by Daniel Bartholomew [ 2019-08-06 ]

We do have some old FreeBSD 11 builders. I'll get them removed and then add a new FreeBSD 12.0 builder.

I assume we're only interested in amd64, correct?

Comment by Daniel Bartholomew [ 2019-08-06 ]

Removed old FreeBSD 11 builder:

https://github.com/MariaDB/mariadb.org-tools/commit/bb175bbf3795

Comment by Daniel Bartholomew [ 2019-08-08 ]

FreeBSD 12 VMs created

Now working on tweaking the build VM and working on defining build steps that are repeatable (and therefore can be automated in buildbot)

Comment by Sergei Golubchik [ 2019-08-08 ]

Ideally, we want to build from ports. These are my notes from few years ago when I tried to build 10.0 from ports:

once, in writable vm

sudo rm -v /usr/ports/distfiles/*
sudo pkg install bison vim-lite cmake gmake perl5.22 boost-libs Judy libxml2

to build

cd /usr/ports/distfiles/
sudo fetch http://hasky.askmonty.org/archive/pack/10.0/build-8249/kvm-tarbake-jaunty-x86/mariadb-10.0.20.tar.gz
cd /usr/ports/databases/mariadb100-server/
sudo make PORTVERSION=10.0.20 BATCH=yes OPTIONS_SET="OQGRAPH" makesum install

to test after build

cd work/mariadb-10.0.20/
sudo cmake -DINSTALL_MYSQLTESTDIR=foo .
sudo gmake
cd /usr/local/share
sudo cp -r /usr/ports/databases/mariadb100-server/work/mariadb-10.0.20/mysql-test .
cd mysql-test
sudo mkdir -p plugin/foo
perl mtr --vardir=/tmp/var

Comment by Daniel Bartholomew [ 2019-08-08 ]

I've tweaked the build-VM and I've gotten it to a point where the following succeeds for 10.1 through 10.4:

# Start the VM:
ezvm freebsd12-amd64-build
 
# Choose one of these:
cd /usr/ports/databases/mariadb101-server
cd /usr/ports/databases/mariadb102-server
cd /usr/ports/databases/mariadb103-server
cd /usr/ports/databases/mariadb104-server
 
# Build:
sudo portsnap fetch update
# Need to use DISABLE_VULNERABILITIES on the following line because it will
# refuse to build the current version in the ports tree (e.g. 10.4.6), because
# there are disclosed CVE vulnerabilities for that version...
sudo make -DBATCH DISABLE_VULNERABILITIES=yes install clean
echo 'mysql_enable="YES"' | sudo tee -a /etc/rc.conf
sudo service mysql-server start
sudo mysql -e "SELECT @@VERSION"
sudo mariadb -e "SELECT @@VERSION"  # if we built 10.4.x

Using your notes I'll work next on using our tarballs instead of the ones in the ports tree.

Comment by Daniel Bartholomew [ 2019-08-12 ]

Status update:

The following sequence works for building 10.1:

ezvm freebsd12-amd64-build
if [ ! -d /usr/ports/distfiles/ ];then sudo mkdir -v /usr/ports/distfiles/ && cd $_ ; fi
sudo fetch http://hasky.askmonty.org/archive/10.1/build-27886/kvm-tarbake-jaunty-x86/mariadb-10.1.42.tar.gz
cd /usr/ports/databases/mariadb101-client
sudo make PORTVERSION=10.1.42 BATCH=yes makesum install
cd /usr/ports/databases/mariadb101-server
sudo make PORTVERSION=10.1.42 BATCH=yes makesum install

And a mostly similar sequence works for 10.3:

ezvm freebsd12-amd64-build
if [ ! -d /usr/ports/distfiles/ ];then sudo mkdir -v /usr/ports/distfiles/ && cd $_ ; fi
sudo fetch http://hasky.askmonty.org/archive/10.3/build-27878/kvm-tarbake-jaunty-x86/mariadb-10.3.18.tar.gz
cd /usr/ports/databases/mariadb103-client
sudo make PORTVERSION=10.3.18 BATCH=yes makesum install
cd /usr/ports/databases/galera
sudo make BATCH=yes makesum install
cd /usr/ports/databases/mariadb103-server
sudo make PORTVERSION=10.3.18 BATCH=yes makesum install

For whatever reason, 10.3 won't compile unless I build galera first.

10.2 and 10.4 don't build. 10.2 fails to cleanly compile mariadb102-client but I can force it to complete with by adding MAKE_JOBS_UNSAFE=yes to the make line for mariadb102-client, and on mariadb102-server it fails almost immediately with the following error: => FreeBSD patch patch-plugin_auth__ed25519_CMakeLists.txt failed to apply cleanly.

10.4 on the other hand fails with a use of undeclared identifier 'uint' error while compiling the auth_pam plugin.

For 10.1 and 10.3, I did the following after compiling to run mtr tests:

cd work/mariadb-*/
sudo cmake -DINSTALL_MYSQLTESTDIR=foo .
sudo gmake
cd /usr/local/share
sudo cp -r /usr/ports/databases/mariadb*-server/work/mariadb*/mysql-test .
cd mysql-test
sudo mkdir -p plugin/foo
perl mtr --vardir=/tmp/var

10.1 dies almost immediately with a Died at lib/mtr_misc.pl line 72. error.

10.3 actually runs tests, but fails the rpl.temporal_row-9560 test. So it is farthest along, but still not 100% there yet.

Comment by Daniel Bartholomew [ 2019-08-12 ]

Build sequence for 10.2:

ezvm freebsd12-amd64-build
if [ ! -d /usr/ports/distfiles/ ];then sudo mkdir -v /usr/ports/distfiles/ && cd $_ ; fi
sudo fetch http://hasky.askmonty.org/archive/10.2/build-27870/kvm-tarbake-jaunty-x86/mariadb-10.2.27.tar.gz
cd /usr/ports/databases/mariadb102-client
sudo make PORTVERSION=10.2.27 BATCH=yes makesum install
# Previous line fails unless I add `MAKE_JOBS_UNSAFE=yes`
cd /usr/ports/databases/mariadb102-server
sudo make PORTVERSION=10.2.27 BATCH=yes makesum install
# this fails with patch error

Build sequence for 10.4:

ezvm freebsd12-amd64-build
if [ ! -d /usr/ports/distfiles/ ];then sudo mkdir -v /usr/ports/distfiles/ && cd $_ ; fi
sudo fetch http://hasky.askmonty.org/archive/10.4/build-27874/kvm-tarbake-jaunty-x86/mariadb-10.4.8.tar.gz
cd /usr/ports/databases/mariadb104-client
sudo make PORTVERSION=10.4.8 BATCH=yes makesum install
cd /usr/ports/databases/mariadb104-server
sudo make PORTVERSION=10.4.8 BATCH=yes makesum install
# Fails while compiling auth_pam plugin

Comment by Sergei Golubchik [ 2022-02-22 ]

because port files (namely, patches) are tightly coupled to the server code, we should maintain our own version of the port, where all files (server's and port's) are changed in sync. Port maintainer can then use our version (either verbatim or as a guideline) when upgrading MariaDB.

Then the procedure should be amended by adding something like

sudo rm -rf /usr/ports/databases/mariadb104-*
sudo tar x -c /usr/ports/databases mariadb-10.4.8.tar.gz 'mariadb-10.4.8/freebsd/*'

which will unpack our port files for the subsequent make command to use.

For */freebsd/* files to exist, they need to be added to the source tree. Let's start from a separate branch bb-10.3-freebsd and have buildbot use the port build procedure only for *-freebsd branches.

Also, the VM likely needs to be upgraded to 12.3 or 13.0 but let's first get the build working.

Comment by Sergei Golubchik [ 2022-02-23 ]

spil, could you, please, comment on the above? I've just realized that if we'll have the port files inside the mariadb source tree, it'll mean that they won't depend on FreeBSD version.

Can we assume that mariadb port files are basically the same in all supported FreeBSD version? Will we need some FreeBSD-version-specific checks in the Makefile or somewhere?

Comment by Elena Stepanova [ 2022-04-04 ]

because port files (namely, patches) are tightly coupled to the server code, we should maintain our own version of the port, where all files (server's and port's) are changed in sync.

We need this already if we want CI with ports.

For example, a patch for wsrep_sst_mariabackup.sh in 10.3-10.5 ports doesn't apply after MDEV-27524.
I've made it work for now by "patching the patch" directly in the buildbot step, but of course it's not sustainable and meaningless.

Otherwise, 10.3+ builds from ports / main MTR tests have been added to buildbot with a few extra tweaks:

  • a patch for MDEV-15795 is needed for 10.3-10.4. It's been fixed in 10.5+. Buildbot now adds a one-line version of the patch to ports at runtime, but to continue, we need either to backport the fix to 10.3-10.4, or add it to ports for real, or give up on 10.3-10.4 and only run 10.5+. Otherwise MTR fails almost inevitably with weird errors which are in fact illegal instruction aborts;
  • there are no ports for 10.7+. Currently buildbot re-uses 10.6 with a few version replacements, and it works for now, but I'm not sure it will last long;
  • for 10.4, mysqltest binary is not installed, so buildbot copies it to /usr/local/bin. Same for replace binary and mysql_client_test on 10.5;
  • the build requires galera. Buildbot installs a binary package available in FreeBSD (galera or galera26). It's not strictly necessary as it can apparently build it as a dependency, but it saves time;
  • additionally buildbot patches Makefile in the server ports to set DINSTALL_MYSQLTESTDIR=mysql-test. It is not necessary, but it makes the build produce a proper mysql-test/plugin directory, with actual suites in it, which I think is better than faking an empty one.

The buildbot runs FreeBSD 13.0 for all 10.3+ branches and FreeBSD 12.3 for main 10.3+ branches unless we decide otherwise.
The builders are currently in experimental, waiting for MDEV-28224 to be merged up to all versions.

With MDEV-28224 fix in place, 10-20 MTR tests fail for each version, the failures need to be addressed separately, most of them seem technical at the first glance.


MTR failures as of April 13:
10.3
MDEV-28303
MDEV-28304
MDEV-28309
MDEV-23920
MDEV-27727
MDEV-24058
10.4
MDEV-28303
MDEV-27724
MDEV-28309
MDEV-23920
MDEV-27727
MDEV-24058
10.5,10.6,10.7
MDEV-28303
MDEV-27724
MDEV-23920
MDEV-27727

Comment by Bernard Spil [ 2022-04-10 ]

serg First off: lame excuses: Apologies for a delay in responses. Paid work, holidays and a nice bit of viral infections are eating my available time on porting. I wake up mostly on the quarterly security updates :/.

You mean akin to the /debian/* structure? If that is what make the Debian packages that would be swell!

Can we assume that mariadb port files are basically the same in all supported FreeBSD version? Will we need some FreeBSD-version-specific checks in the Makefile or somewhere?

We sure can! And I would be all for it! There's issues with the current build infra where FreeBSD behaves very different from Linux packaging. We'd need to resolve these:

1. FreeBSD builds the "parts" separately. I.e. it should actually build `databases/mariadb-connector-c`, then build `databases/mariadb[0-9]-client` which depends on the correct connector-c port and then build `databases/mariadb[0-9]-server' port which depends on the correct mariadb-client port. If this requires a versioned `mariadb-connector-c` port, I believe it does, this WILL happen. I'm insufficiently skilled in CMake to rip apart these parts to properly make them depend out-of-source to e.g. `/usr/local/lib/`. I believe the Linux distros build the whole thing (libraries/client/server) and then split the resulting files in separate packages: FreeBSD fails on this feature. Many kloc of CMake code make MariaDB not an easy entry to CMake (GUIDE ME!)
2. FreeBSD ports must stay away from bundled software. Any library (e.g. any of the compression libraries lzo, lzma, zstd) must be consumed as a dependency, not built from the MariaDB tarball. The recent releases seem to deal with these dependencies a lot better.
3. VM's will depend on the supported FreeBSD versions and architectures indeed. Currently that would be 12.4 and 13.0. CI would be appreciated.

FWIW. I managed to reduce the number of patches required for MariaDB significantly by ignoring/commenting the server/client specific files in the package. You can clearly see this when you compare the number of patches required at the expense of maintaining "what files are client, which are server?" in the pkg-list.
https://github.com/freebsd/freebsd-ports/tree/main/databases/mysql80-server/files
https://github.com/freebsd/freebsd-ports/tree/main/databases/mariadb105-server/files

I very much hope this doesn't sound like an insurmountable list of requirements to you. I could really do with some help here! In return you can count on me to support you with all the FreeBSD port intricacies.

Cheers, Bernard.

MDEV-11791

Comment by Sergei Golubchik [ 2022-05-05 ]
  1. *-client port uses *-server port. only applies a few patches on top. I think we'll be able to keep *-client very source-code-independent, and only put the *-server port files into the server repo
  2. yes, that's not a problem
  3. now we have 12.3 and 10.3 as far as I can see. I hope port files won't depend on freebsd version
Comment by Marko Mäkelä [ 2022-09-21 ]

The https://github.com/freebsd/freebsd-ports/blob/main/databases/mariadb106-server/Makefile will no longer work on MariaDB Server 10.7 or later starting with this merge because there will be no files matching storage/innobase/*.cmake. Before 10.7 and MDEV-12933, there would be some files for detecting various compression libraries.

I had a quick look at the patch- files in https://github.com/freebsd/freebsd-ports/tree/main/databases/mariadb106-server/files and I think that we should simply try to apply them to the MariaDB code base. patch-tpool_CMakeLists.txt seems to miss some condition, so that the addition would only apply to FreeBSD.

spil, how could we best proceed with the patch- files? Would it be possible to submit them as pull requests?

Comment by Elena Stepanova [ 2022-09-21 ]

I have added a workaround for the innobase cmake files problem above, just one more time.
But unless we start making some progress in regard to integrating the FreeBSD patches into the code base, next time something diverges I'll start disabling the builder for the diverging versions. It is really one of most meaningless tests that we have in the buildbot: it is meant to test that the tree in question builds with FreeBSD ports, yet we patch the ports at runtime every time it stops building; and for 10.7+ we fake the ports entirely, as they don't exist. So it isn't testing anything.

Generated at Thu Feb 08 08:58:43 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.