Following this series of blog posts started by Evgeniy Patlan:
we’ll show you how to build Percona Server for MongoDB for various operating systems¹ using Docker on your local Linux machine/build server. In this very case, we’ll build packages of Percona Server for MongoDB 4.4.9-10 version for Centos 8 and Debian 11 (bullseye).
This can be useful when you need to test your changes to the code for different RPMs/DEBs based platforms and make sure that all works as expected in different environments. In our case, this approach is used for building Percona Server for MongoDB packages/binary tarballs for all supported OSes.
You need to download the build script of the needed version to the “/mnt/psmdb-44” folder:
|
1 |
cd /mnt/psmdb-44/<br>wget https://raw.githubusercontent.com/percona/percona-server-mongodb/psmdb-4.4.9-10/percona-packaging/scripts/psmdb_builder.sh -O psmdb_builder.sh |
|
1 |
docker run -ti -u root -v /mnt/psmdb-44:/mnt/psmdb-44 centos:7 sh -c '<br>set -o xtrace<br>cd /mnt/psmdb-44<br>bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --install_deps=1<br>bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --repo=https://github.com/percona/percona-server-mongodb.git <br>--branch=release-4.4.9-10 --psm_ver=4.4.9 --psm_release=10 --mongo_tools_tag=100.4.1 --jemalloc_tag=psmdb-3.2.11-3.1 --get_sources=1<br>'<br> |
|
1 |
$ ls -la /mnt/psmdb-44/source_tarball/<br>total 88292<br>drwxr-xr-x. 2 root root 4096 Oct 1 10:58 .<br>drwxr-xr-x. 5 root root 4096 Oct 1 10:58 ..<br>-rw-r--r--. 1 root root 90398894 Oct 1 10:58 percona-server-mongodb-4.4.9-10.tar.gz |
Please note that for building generic source RPM/DEB, we still use the oldest supported RPM/DEB-based OS, in this case, Centos 7/ Ubuntu Xenial(16.04).
|
1 |
docker run -ti -u root -v /mnt/psmdb-44:/mnt/psmdb-44 centos:7 sh -c '<br>set -o xtrace<br>cd /mnt/psmdb-44<br>bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --install_deps=1<br>bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --repo=https://github.com/percona/percona-server-mongodb.git <br>--branch=release-4.4.9-10 --psm_ver=4.4.9 --psm_release=10 --mongo_tools_tag=100.4.1 --jemalloc_tag=psmdb-3.2.11-3.1 --build_src_rpm=1<br>' |
|
1 |
docker run -ti -u root -v /mnt/psmdb-44:/mnt/psmdb-44 ubuntu:xenial sh -c '<br>set -o xtrace<br>cd /mnt/psmdb-44<br>bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --install_deps=1<br>bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --repo=https://github.com/percona/percona-server-mongodb.git <br>--branch=release-4.4.9-10 --psm_ver=4.4.9 --psm_release=10 --mongo_tools_tag=100.4.1 --jemalloc_tag=psmdb-3.2.11-3.1 --build_src_deb=1<br>' |
|
1 |
$ ls -la /mnt/psmdb-44/srpm/<br>total 87480<br>drwxr-xr-x. 2 root root 4096 Oct 1 11:35 .<br>drwxr-xr-x. 6 root root 4096 Oct 1 11:35 ..<br>-rw-r--r--. 1 root root 89570312 Oct 1 11:35 percona-server-mongodb-4.4.9-10.generic.src.rpm<br><br>$ ls -la /mnt/psmdb-44/source_deb/<br>total 88312<br>drwxr-xr-x. 2 root root 4096 Oct 1 11:45 .<br>drwxr-xr-x. 7 root root 4096 Oct 1 11:45 ..<br>-rw-r--r--. 1 root root 10724 Oct 1 11:45 percona-server-mongodb_4.4.9-10.debian.tar.xz<br>-rw-r--r--. 1 root root 1528 Oct 1 11:45 percona-server-mongodb_4.4.9-10.dsc<br>-rw-r--r--. 1 root root 2075 Oct 1 11:45 percona-server-mongodb_4.4.9-10_source.changes<br>-rw-r--r--. 1 root root 90398894 Oct 1 11:45 percona-server-mongodb_4.4.9.orig.tar.gz |
|
1 |
docker run -ti -u root -v /mnt/psmdb-44:/mnt/psmdb-44 centos:8 sh -c '<br>set -o xtrace<br>cd /mnt/psmdb-44<br>bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --install_deps=1<br>bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --repo=https://github.com/percona/percona-server-mongodb.git <br>--branch=release-4.4.9-10 --psm_ver=4.4.9 --psm_release=10 --mongo_tools_tag=100.4.1 --jemalloc_tag=psmdb-3.2.11-3.1 --build_rpm=1<br>' |
|
1 |
docker run -ti -u root -v /mnt/psmdb-44:/mnt/psmdb-44 debian:bullseye sh -c '<br>set -o xtrace<br>cd /mnt/psmdb-44<br>bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --install_deps=1<br>bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --repo=https://github.com/percona/percona-server-mongodb.git <br>--branch=release-4.4.9-10 --psm_ver=4.4.9 --psm_release=10 --mongo_tools_tag=100.4.1 --jemalloc_tag=psmdb-3.2.11-3.1 --build_deb=1<br>' |
|
1 |
$ ls -la /mnt/psmdb-44/rpm/<br>total 1538692<br>drwxr-xr-x. 2 root root 4096 Oct 1 13:19 .<br>drwxr-xr-x. 9 root root 4096 Oct 1 13:19 ..<br>-rw-r--r--. 1 root root 8380 Oct 1 13:19 percona-server-mongodb-4.4.9-10.el8.x86_64.rpm<br>-rw-r--r--. 1 root root 19603132 Oct 1 13:19 percona-server-mongodb-debugsource-4.4.9-10.el8.x86_64.rpm<br>-rw-r--r--. 1 root root 16199100 Oct 1 13:19 percona-server-mongodb-mongos-4.4.9-10.el8.x86_64.rpm<br>-rw-r--r--. 1 root root 382301668 Oct 1 13:19 percona-server-mongodb-mongos-debuginfo-4.4.9-10.el8.x86_64.rpm<br>-rw-r--r--. 1 root root 37794568 Oct 1 13:19 percona-server-mongodb-server-4.4.9-10.el8.x86_64.rpm<br>-rw-r--r--. 1 root root 829718252 Oct 1 13:19 percona-server-mongodb-server-debuginfo-4.4.9-10.el8.x86_64.rpm<br>-rw-r--r--. 1 root root 13310328 Oct 1 13:19 percona-server-mongodb-shell-4.4.9-10.el8.x86_64.rpm<br>-rw-r--r--. 1 root root 218625728 Oct 1 13:19 percona-server-mongodb-shell-debuginfo-4.4.9-10.el8.x86_64.rpm<br>-rw-r--r--. 1 root root 30823056 Oct 1 13:19 percona-server-mongodb-tools-4.4.9-10.el8.x86_64.rpm<br>-rw-r--r--. 1 root root 27196024 Oct 1 13:19 percona-server-mongodb-tools-debuginfo-4.4.9-10.el8.x86_64.rpm<br><br>$ ls -la /mnt/psmdb-44/deb/<br>total 2335288<br>drwxr-xr-x. 2 root root 4096 Oct 1 13:16 .<br>drwxr-xr-x. 9 root root 4096 Oct 1 13:16 ..<br>-rw-r--r--. 1 root root 2301998432 Oct 1 13:16 percona-server-mongodb-dbg_4.4.9-10.bullseye_amd64.deb<br>-rw-r--r--. 1 root root 14872728 Oct 1 13:16 percona-server-mongodb-mongos_4.4.9-10.bullseye_amd64.deb<br>-rw-r--r--. 1 root root 35356944 Oct 1 13:16 percona-server-mongodb-server_4.4.9-10.bullseye_amd64.deb<br>-rw-r--r--. 1 root root 12274928 Oct 1 13:16 percona-server-mongodb-shell_4.4.9-10.bullseye_amd64.deb<br>-rw-r--r--. 1 root root 26784020 Oct 1 13:16 percona-server-mongodb-tools_4.4.9-10.bullseye_amd64.deb<br>-rw-r--r--. 1 root root 18548 Oct 4 13:16 percona-server-mongodb_4.4.9-10.bullseye_amd64.deb |
Now, the packages are ready to be installed for testing/working on Centos 8 and Debian 11.
As you can see from the above, the process of building packages for various operating systems is quite easy and doesn’t require lots of physical/virtual machines. All you need is the build script and Docker.
Also, as you may have noticed, all the build commands are similar to each other except the last passed argument, which defines the action that should be performed. Such an approach allows us to unify the build process and make it scripted so that the last argument can be passed as a parameter to the script. Surely all the rest arguments can and should also be passed as parameters in case you are going to automate the build process.
¹ Supported operating systems(version psmdb-4.4.9-10):
² In order to build Percona Server for MongoDB of another version, you need to use the build script of the proper version. For example, it is needed to build Percona Server for MongoDB of 4.2.7-7 version:
Complete the 2021 Percona Open Source Data Management Software Survey
Resources
RELATED POSTS