jcloude/debugging/mariadb.build.md
2025-12-23 19:56:26 +08:00

5.6 KiB

Guide to Building and Hosting MariaDB Ubuntu Packages

We are building MariaDB 10.6.16 with some changes for Ubuntu 20.04

We need to build this on Ubuntu 20.04 itself. But to host the repository we need a newer release. We will use 23.10 and build MariaDB inside a container.

We'll use Reprepro to create a Ubuntu repository. Older releases of reprepro do not work well with ddeb packages (debug symbols).

At the end, we'll have our MariaDB 10.6.16+ packages for Ubuntu 20.04 hosted on packages.jingrow.cloud.


Build Ubuntu Packages

Prepare Build Container

  1. Create jingrow user and install docker from https://docs.docker.com/engine/install/ubuntu/

  2. Use mariadb.build.Dockerfile to create our build container

docker build -t mariadb-build:10.6 .

References: https://mariadb.com/kb/en/building-mariadb-on-ubuntu/ https://mariadb.com/kb/en/Build_Environment_Setup_for_Linux/


Clone MariaDB

git clone --branch mariadb-10.6.16 http://git.jingrow.com/MariaDB/server.git /home/jingrow/mariadb/server

Fetch git submodules

cd server
git clean -dffx
git reset --hard HEAD
git submodule update --init --recursive

Cherry-pick interesting changes

git cherry-pick bb511def1d316ffbdd815f2fc99d0a5813671814

References:


Build Ubuntu Packages

Run the build inside a container. We'll have the packages placed in /home/jingrow/mariadb

docker run --rm -v /home/jingrow/mariadb:/mariadb -w /mariadb/server -it mariadb-build:10.6 bash ./debian/autobake.sh

Tip: Temporarily resize this server to allocate as many CPU cores as you can. More the cores the faster the build.

References: https://mariadb.com/kb/en/building-mariadb-on-ubuntu/


Host Ubuntu Repository

Setup OpenPGP

We need to sign the packages with OpenPGP

  1. Create a OpenPGP key for Frappe Developers <developers@framework.jingrow.com>. This is an interactive step. Refer framework.jingrow.com/app/jingrow-asset for Paasphrase.
gpg --full-gen-key

Once completed we should have something like

$ gpg --list-secret-key --with-subkey-fingerprint
/home/jingrow/.gnupg/pubring.kbx
-------------------------------
sec   rsa4096 2024-01-29 [SC]
      2AADEF02BE446B0FA3B0AC3DF38C274AC216D014
uid           [ultimate] Frappe Developers <developers@framework.jingrow.com>

Export the public key in the repository directory

mkdir -p /home/jingrow/repository
gpg --armor --output /home/jingrow/repository/jingrow.gpg.key --export-options export-minimal --export 2AADEF02BE446B0FA3B0AC3DF38C274AC216D014

Setup Reprepro

Create the directory structure that looks like our urls (https://packages.jingrow.cloud/mariadb/10.6)

Reprepro needs two config files conf/distributions and conf/options

mkdir -p /home/jingrow/repository/mariadb/10.6/conf
echo "Origin: MariaDB
Label: MariaDB
Codename: focal
Architectures: amd64 source
Components: main
DDebComponents: main
Limit: 3
Description: MariaDB Repository
SignWith: 2AADEF02BE446B0FA3B0AC3DF38C274AC216D014" > /home/jingrow/repository/mariadb/10.6/conf/distributions
echo "verbose
basedir /home/jingrow/repository/mariadb/10.6
ask-passphrase" > /home/jingrow/repository/mariadb/10.6/conf/options

The tree structure should now look like

$ tree /home/jingrow/repository/
/home/jingrow/repository/
├── jingrow.gpg.key
└── mariadb
    └── 10.6
        └── conf
            ├── distributions
            └── options

4 directories, 3 files

Download and install a newer reprepro release

curl -skO "http://ftp.debian.org/debian/pool/main/r/reprepro/reprepro_5.4.3-1_amd64.deb"
apt-get install -y --no-install-recommends "./reprepro_5.4.3-1_amd64.deb"

Prepare the repository

Build the repository from the .changes file in /home/jingrow/mariadb

reprepro -Vb /home/jingrow/repository/mariadb/10.6 --ignore=wrongsourceversion include focal /home/jingrow/mariadb/*.changes

References:

Publish the repository with NGINX

apt install nginx
usermod -aG jingrow www-data
echo "server {
    listen 80;
    server_name packages.jingrow.cloud;

    location / {
        root /home/jingrow/repository;
        autoindex on;
    }

    location ~ /(.*)/conf {
        deny all;
    }

    location ~ /(.*)/db {
        deny all;
    }
}" > /home/jingrow/nginx.conf
ln -s /home/jingrow/nginx.conf /etc/nginx/conf.d/packages.jingrow.cloud.conf

Setup TLS for packages.jingrow.cloud

snap install --classic certbot
certbot --nginx --agree-tos --email developers@framework.jingrow.com --domains packages.jingrow.cloud

Install patched MariaDB

Fetch OpenPGP key

wget -O - https://packages.jingrow.cloud/jingrow.gpg.key | apt-key add -

Setup repository and install as usual

echo "deb https://packages.jingrow.cloud/mariadb/10.6 focal main" > /etc/apt/sources.list.d/mariadb.list"
apt update
apt install mariadb-server

For debug symbols fetch from main/debug

echo "deb https://packages.jingrow.cloud/mariadb/10.6 focal main main/debug" > /etc/apt/sources.list.d/mariadb.list"
apt update
apt install mariadb-server mariadb-server-core-10.6-dbgsym