Build Percona Server for MySQL From SourcesLately, the number of questions about how to build Percona software has been increased. More and more people try to add their own patches, add some modifications, and build software by themselves. But this raises the question of how to do this in the same way as Percona does, as sometimes the compiler flag can make a drastic impact on the final binary.

First of all, let’s talk about the stages of compiling software.

I would say that at the beginning you need to prepare the build environment, install all the needed dependencies, and so on. For each version, the dependency list would be different. How do you get the correct dependency list? You can get all build requirements from the spec file (on rpm-based systems) or from the control file( on deb-based systems).

The next stage is to get the source code of Percona Server for MySQL. You can do it in different ways:

  • Get source tarball from the website

We publish source tarball for each release we issue and you can easily get it for any released version (this is the link for the latest 8.0.22 version).

  • Download tarball from GitHub

Here is the link: https://github.com/percona/percona-server/releases/tag/Percona-Server-8.0.22-13

Once you have prepared the build environment, you need to decide what result you should get: binary tarball, rpm, or deb package.

So everything looks easy. But what is the way we use, internally, to prepare our release packages? As I mentioned earlier, each compiler option can make a significant effect.

Everyone tries to make life easier and automate all tasks. It is great, as automation is one of the keys to success as you can work on other tasks once the release build is in progress. So we have created a builder script that is used for making builds. It can be found in the Percona Server GitHub repo and can be used by anyone to make his own builds.

This script can install all needed dependencies for the build environment, create binary tarballs, source RPMs and debs, RPMs, debs itself, and the binary tarball. So it covers all build cycles. So how do you use it?

The script has various params:

So let’s see how we can make the build process easier:

1. Download build script:

2. Create a build directory where you are going to perform all build actions:

3. Install dependencies(please note root permissions are required):

4. Download source code:

– From Percona repo (it is used by default):

– From your own repo and branch:

5. Prepare src rpm:

Please note if you already have your source tarball, just create a directory named source_tarball in the build directory and put it into it.

6. Prepare source deb:

Please note if you already have your source tarball, just create a directory named source_tarball in the build directory and put it into it.

7. Prepare rpm:

8. Prepare deb:

9. Prepare tarball:

So as you can see, the build procedure becomes easier and you don’t need to think about what dependencies are needed, what cmake params should be used, etc. This build script will make everything for you and will use all build flags (if you didn’t change them in your sources) that we use for release builds.

3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Francisco Miguel Biete Banon

This a great help, thank you!. Could we make some minor tweaks?
The repo is quite big, could we clone only the branch we are going to use as base? (git clone -b branch –single-branch)
Could we add RHEL8 support to the script? It looks like is not contemplating it (not disabling mysql module and pulling jemalloc v5).
I would also like to see future blog posts about the following steps: how to format code prior contributions, what to do when your contribution is ready, what to expect during reviews…

snikolaev

Wouldn’t it be easier to just share the Dockerfiles that are perhaps used in your CI to build each new version? Like it’s e.g. done in Manticore Search – https://github.com/manticoresoftware/manticoresearch/tree/master/dist/build_dockers

With the script there’s still a higher risk of an issue since you don’t control what is in the system before you run the script. With an image/container you know for sure the environment will be 100% the way it’s supposed to be.