Skip to content

MDEV-40786 make mariadb-plugin great - #5597

Draft
MooSayed1 wants to merge 1 commit into
MariaDB:mainfrom
MooSayed1:MDEV-40786
Draft

MDEV-40786 make mariadb-plugin great#5597
MooSayed1 wants to merge 1 commit into
MariaDB:mainfrom
MooSayed1:MDEV-40786

Conversation

@MooSayed1

@MooSayed1 MooSayed1 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

The Jira issue number for this PR is: MDEV-40786

Description

First step of turning the mariadb-plugin tool into a plugin package
manager, as described in the MDEV. This covers the package-manager half:
RPM and DEB installations. The binary tarball half comes later, as it
needs the plugin metadata on the download site.

mariadb-plugin search [<plugin_name>]
mariadb-plugin install <plugin_name>
mariadb-plugin uninstall <plugin_name>

The legacy <plugin> ENABLE|DISABLE syntax is kept for backward
compatibility: it is recognized on the raw arguments, before any option
parsing, and continues through the original code path unchanged. A command
word wins over the keywords, so search enable searches for "enable"
instead of taking the deprecated path.

Plugin names are normalized to lower case and validated against
[a-z0-9_-] (max 64 chars), since they are used to build package names.

Install-method detection. The install layout (RPM, DEB, tarball) is
compiled in from INSTALL_LAYOUT, as it cannot be derived from the path:
RPM and DEB share the same directories. At runtime the tool locates itself
through argv[0] (my_path() + my_realpath(), which also resolves the
legacy mysql_plugin symlink) and verifies it belongs to that
installation: on RPM/DEB the binary must sit in the compiled-in bindir, on
a tarball the plugin directory must exist under the basedir. A build tree
is therefore not accepted.

Delegation. On RPM and DEB installations install and uninstall
delegate to the system package manager, so plugin files stay owned by it
and dependency resolution, signature checks and upgrades keep working.
apt-get is used on DEB; on RPM dnf is preferred and zypper used when
dnf is absent. Commands run through fork()/execvp() with an argument
vector, never a shell, and inherit the standard streams, so the package
manager prompts the user itself and its exit code is passed through
unchanged. Non-root invocations are rejected before anything is spawned.

uninstall on RPM first resolves the real package name with
rpm -q --whatprovides, because dnf 5 does not accept Provides names for
removal (dnf 4 and zypper do); this also gives a clear message when the
plugin is not installed.

Uniform naming. RPM packages keep their own names
(MariaDB-rocksdb-engine) and get the uniform name as a Provides,
generated per plugin component in cmake/plugin.cmake. DEB packages
already carry it. So the tool knows one naming rule and zero package names.

Search. The distribution's package index is queried for everything
providing mariadb-plugin-* and printed uniformly as plugin name,
installed/available, and description. dnf search ignores Provides, so
repoquery is used; zypper never reports which capability matched, so a
second zypper info --provides call recovers the uniform name. An optional
term filters by substring. Needs no root; exits non-zero when nothing
matches.

--dry-run prints the commands install and uninstall would run,
with the package name resolved, without running them and without needing
root. Long-only, as -n is taken by the legacy --no-defaults.

Still to come: the binary tarball engine (download, checksum, unpack,
file manifest) and tarball search, which needs the plugin index on the
download site.

Release Notes

mariadb-plugin gains search, install and uninstall subcommands. On
RPM and DEB installations they delegate to the system package manager, with
plugins named uniformly as mariadb-plugin-<name> everywhere. A
--dry-run option shows what would be run. The legacy ENABLE|DISABLE
syntax still works and is now deprecated.

How can this PR be tested?

main.mariadb-plugin covers the command line: unknown commands, argument
counts, plugin name validation, and that ENABLE|DISABLE still reaches the
old code path. The delegation itself cannot run under mtr, since the tool
only acts when it runs from the location it was installed to, so it belongs
to the install/upgrade builders.

Manually, with a binary built for the matching layout and placed in the real
bindir:

mariadb-plugin search                 # plugin name, installed/available, description
mariadb-plugin search provider        # filtered
mariadb-plugin --dry-run install rocksdb
mariadb-plugin install rocksdb
mariadb-plugin uninstall rocksdb

Tested in containers:

  • Debian trixie against the real Debian repos: all 16 real
    mariadb-plugin-* packages listed, and mariadb-plugin-rocksdb
    installed and removed through the tool.
  • Fedora 42 (dnf 5) and openSUSE Tumbleweed (zypper) against a local
    repository of packages built from this branch, so they carry the
    generated Provides: install resolves the uniform name, uninstall
    resolves the real package name, and search lists them.
  • Non-root, and running an RPM/DEB-layout binary from the wrong directory,
    both produce a single clear error.

Basing the PR against the correct MariaDB version

This is a new feature, so this PR targets main.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Aug 26, 2026
@gkodinov gkodinov self-assigned this Aug 26, 2026

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this. This is nowhere near close to being ready for review. Converting to draft until it's actually delivering towards the specification in the jira.

@gkodinov
gkodinov marked this pull request as draft August 26, 2026 08:20
@gkodinov gkodinov added MariaDB Foundation Pull requests created by MariaDB Foundation and removed External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. labels Aug 26, 2026
@gkodinov gkodinov assigned MooSayed1 and unassigned gkodinov Aug 26, 2026
@MooSayed1
MooSayed1 force-pushed the MDEV-40786 branch 5 times, most recently from 6385c9a to a54ebba Compare August 31, 2026 02:18
Add search, install, and uninstall subcommands to mariadb-plugin with
input validation and case normalization, while keeping legacy ENABLE and
DISABLE syntax functional for backward compatibility.

Bake the installation layout into the binary at compile time (RPM, DEB,
or tarball), as it cannot be derived from the path alone since RPM and
DEB use the same directory, and verify the executable path at runtime
via argv[0] and mysys path helpers to ensure package managers and
tarball directories target the correct installation.

Delegate install and uninstall to the system package manager on RPM and
DEB installations, so that plugin files stay owned by it. The plugin
name maps to the uniform package name mariadb-plugin-<name>. Commands
run through fork and execvp with an argument vector, never a shell, and
inherit the standard streams, so the package manager prompts the user
itself and its exit code is passed through.

RPM packages are named differently, so they get the uniform name as a
Provides, derived from the plugin component in cmake/plugin.cmake. DEB
packages already carry it.

On RPM, uninstall resolves the real package name with rpm --whatprovides,
because dnf 5 does not accept Provides names for removal.

Search lists the plugins the installation can install: the plugin name,
installed or available, and the description, filtered by an optional
search term. The distribution's package index is queried for everything
providing mariadb-plugin-* (repoquery for dnf, apt-cache, zypper search
plus info --provides) and each output is parsed into the same uniform
format, so the user always sees plugin names, not the distribution's
package names.

Add a --dry-run option that prints the commands install and uninstall
would run instead of running them, with the package name resolved, and
without requiring root. It is long only, as -n is taken by the legacy
--no-defaults option.

Test the command line handling in main.mariadb-plugin: unknown commands,
argument counts, plugin name validation and that the deprecated
ENABLE|DISABLE syntax still reaches the old code path. Installing and
removing packages is not testable there, as the tool acts only when it
runs from the location it was installed to.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

MariaDB Foundation Pull requests created by MariaDB Foundation

Development

Successfully merging this pull request may close these issues.

2 participants