How to Manually Build Percona Server for MySQL RPM Packages

In this blog, we’ll look at how to manually build Percona Server for MySQL RPM packages.

Several customers and other people from the open source community have asked us how they could make their own Percona Server for MySQL RPM binaries from scratch.

This request is often made by companies that want to add custom patches to our release. To do this, you need to make some modifications to the
percona-server.spec file in the source tree, and some preparation is necessary.

This post covers how you can make your own RPMs from GIT or source tarball so that you can build RPMs from your own modified branch, or by applying patches. In this example, we’ll build Percona Server 5.7.16-10.

Making your own RPMs is not a recommended practice, and should rarely be necessary.

Prepare the Source

Using GIT Repository

We can fetch percona/percona-server from GitHub (or your own fork). As we build Percona Server 5.7.16-10, we create a new branch based on the tag of that version:

Making Changes with Patch Files

If you need to make any changes to the source code, you can either use your own GitHub fork or you can apply patches. If you use the former, then you can skip this section.

Why Patches?

Why would we want to use patch files? Because you won’t need to maintain your own fork. You can just build the RPM with the Percona Server source tarball and the patch file.

Create Patch Files

If you do not want to use your own fork in GitHub, you can also create some patch files and modify the RPM spec file to include them.

Create your changes to the source files

Use
diff to create the
patch file:

Generate Patch

Shell

1

$diff-ru FILE-orig FILE>|~/custom.patch

Add Patch to RPM Spec File

In order for the patch to be applied during the building of the RPM, edit the
./build-ps/percona-server.spec file and add the two lines that are highlighted:

Add Patch File to Spec File

Shell

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

...

Source91:filter-requires.sh

Patch0:mysql-5.7-sharedlib-rename.patch

Patch1:custom.patch

BuildRequires:cmake>=2.8.2

...

%prep

%setup-q-T-a0-a10-c-n%{src_dir}

pushd%{src_dir}

%patch0-p1

%patch1-p1

%build

...

Note that you have to number the patches, in this case I gave it the name
patch1.

Creating New Source Tarball

If you use your own GitHub fork, or you made manual changes to the source (and you’re not using patch files), you should use that to create your own source tarball.

First, change the Percona Server version number. In this case, we are naming it
10custom to indicate this is not a standard build. You can adapt as you wish, just make sure the
VERSION file looks something like this:

Now you have the tarball in your source directory, but we won’t use it yet. We need to add some TokuDB submodules to it first. The make dist also kept the uncompressed directory, which we will use to create the tarball again when the TokuDB parts are included:

Related

Evgeniy joined Percona in April 2016. He is working as a Build/Release Engineer. Previously he was working for more than 8 years for PortaOne Inc. where he changed roles from support engineer to build/release engineer.