Skip to content

MDEV-40786 make mariadb-plugin great - #5597

Draft
MooSayed1 wants to merge 2 commits into
MariaDB:mainfrom
MooSayed1:MDEV-40786
Draft

MDEV-40786 make mariadb-plugin great#5597
MooSayed1 wants to merge 2 commits 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

Turns mariadb-plugin into a plugin package manager. Same interface on
RPM, DEB and tarball installations:

mariadb-plugin search [<plugin_name>]
mariadb-plugin install <plugin_name>
mariadb-plugin uninstall <plugin_name>
  • Legacy <plugin> ENABLE|DISABLE still works, unchanged, marked deprecated.
  • Install layout is compiled in from INSTALL_LAYOUT; at runtime the tool
    checks it runs from the installation it belongs to.
  • RPM/DEB: delegates to dnf/zypper/apt-get via fork()/execvp(), no
    shell, exit code passed through. Uniform name mariadb-plugin-<name>; RPM
    packages get it as a Provides (cmake/plugin.cmake). uninstall on RPM
    resolves the real name with rpm -q --whatprovides (dnf 5 needs it).
    search queries the package index and prints name, installed/available,
    description.
  • Tarball: install <name> --file=<tarball> reads the archive itself (zlib,
    no tar), refuses links, .., absolute paths, overwrites. Extraction is
    next. uninstall removes what <basedir>/.mariadb-plugin/<name>.list
    records. Download and tarball search wait for the download site.
  • --dry-run prints what would be done, no root needed.

Release Notes

mariadb-plugin gains search, install and uninstall, working the same
on RPM, DEB and tarball installations. --dry-run shows what would be done.
The legacy ENABLE|DISABLE syntax is deprecated but still works.

How can this PR be tested?

main.mariadb-plugin covers the command line. Delegation needs the binary in
its installed location, so it belongs to the install/upgrade builders.

Manually:

mariadb-plugin search provider
mariadb-plugin --dry-run install rocksdb
mariadb-plugin install rocksdb
mariadb-plugin uninstall rocksdb
mariadb-plugin install levenshtein --file=<tarball>     # tarball layout

Tested in containers: Debian trixie (real repos), Fedora 42 (dnf 5) and
openSUSE Tumbleweed (local repo built from this branch). Tarball: against
the foundry output built from bb-11.4-MDEV-40608, plus hostile archives.

Basing the PR against the correct MariaDB version

New feature, 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 6 times, most recently from a54ebba to caa1579 Compare August 31, 2026 20:56
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.
@MooSayed1
MooSayed1 force-pushed the MDEV-40786 branch 2 times, most recently from af18227 to 802ef38 Compare September 5, 2026 13:38
Uninstall removes a plugin from a tarball installation using its
manifest, <basedir>/.mariadb-plugin/<name>.list: delete exactly the
files and directories listed there, then the manifest itself. Every
path is validated first, and a corrupt manifest deletes nothing.

Install reads the plugin tarball itself and judges every entry before
writing anything: links, devices, absolute paths and ".." are refused,
setuid bits dropped, existing files never overwritten, and the CPack
top directory stripped when it is named like the archive. Files are
then written and recorded in the manifest as they land, so a failure
at any point is undone through that same manifest. --file=PATH names
the tarball until downloading exists, --sha256=HEX verifies it, and
the result is a hint how to enable the plugin, never a config edit.
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