Skip to content

MDEV-40786 make mariadb-plugin great - #5597

Open
MooSayed1 wants to merge 3 commits into
MariaDB:mainfrom
MooSayed1:MDEV-40786
Open

MooSayed1 wants to merge 3 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 with a common interface for RPM, DEB and binary tarball installations:

mariadb-plugin search [<plugin_name>]
mariadb-plugin install <plugin_name>
mariadb-plugin uninstall <plugin_name>
  • Selects the install layout at build time and checks the tool’s installation location at runtime.
  • RPM/DEB operations use dnf, zypper or apt-get, preserving prompts and exit status. RPM Provides aliases support uniform plugin names; uninstall resolves the actual installed package. Native search shows names, descriptions and installation status.
  • Tarball install accepts --file=<archive.tar.gz> or downloads a compatible archive from plugins.index through libcurl. Downloads require SHA-256 verification; local archives optionally accept --sha256. Both use private archive snapshots.
  • Internal gzip/tar extraction validates paths and entry types, rejects links and overwrites, and records files/directories in <basedir>/.mariadb-plugin/<name>.list for rollback and uninstall. Uninstall validates manifests and retains them after removal failures so the operation can be retried.
  • Tarball search fetches only metadata, matches server series/platform/architecture, and returns sorted names, descriptions and installation status with optional substring filtering. Status comes from local manifests, not server plugin state.
  • Installation prints SQL/configuration activation instructions without editing configuration. --dry-run previews operations; remote install with --dry-run fetches only the index.
  • Preserves deprecated <plugin> ENABLE|DISABLE syntax, fixes option-value routing, and rejects legacy --dry-run. Updates the manual and CLI tests.

Tarball search/downloads currently require --base-url. The metadata remains a key/value prototype pending alignment with the agreed YAML/publisher contract. Remote install/search are temporarily unsupported on Windows; Windows ZIP support and broader platform verification remain pending. The shared PATH-helper fix is outside this PR.

Release Notes

mariadb-plugin gains search, install and uninstall for native packages and tarballs, including repository downloads, checksum verification and dry-run previews. Legacy ENABLE|DISABLE syntax is deprecated.

How can this PR be tested?

Run main.mariadb-plugin for argument validation, option handling and legacy routing. On Windows, main.mariadb-plugin-win checks unsupported remote operations. These tests do not perform downloads, extraction or package mutations.

Real RPM/DEB installation/removal checks belong in Buildbot’s installation/upgrade builders. Earlier manual checks covered Debian trixie, Fedora 42/dnf 5 and openSUSE Tumbleweed.

For tarballs, use a disposable installed-style layout and a controlled repository:

mariadb-plugin search provider --base-url=<repository-url>
mariadb-plugin install <name> --base-url=<repository-url> --dry-run
mariadb-plugin install <name> --base-url=<repository-url>
mariadb-plugin uninstall <name> --dry-run
mariadb-plugin uninstall <name>
mariadb-plugin install <name> --file=<archive.tar.gz> --sha256=<checksum>

Local checks have covered CLI MTR, man-page rendering, STANDALONE/RPM/DEB builds, a 47-check download helper, and search/manifest regressions including invalid manifests, FIFO rejection and rollback. The helpers are development tools outside this PR. After the latest update, the Linux build and CLI MTR were rerun successfully; full functional and cross-platform verification is not claimed.

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 3 times, most recently from 802ef38 to f649218 Compare September 6, 2026 17:43
@MooSayed1
MooSayed1 force-pushed the MDEV-40786 branch 2 times, most recently from cf416ba to 0086164 Compare September 13, 2026 00:50
@MooSayed1
MooSayed1 marked this pull request as ready for review September 13, 2026 01:20
Uninstall removes a plugin from a tarball installation using its
manifest, <basedir>/.mariadb-plugin/<name>.list: remove the listed
files and empty recorded directories, then the manifest itself.
Paths are validated before deletion, and failed file removals keep
the manifest so uninstall can be retried.

Install reads the plugin tarball itself and checks entries before
extraction: 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
recorded in the manifest for rollback and uninstall. --file=PATH
supplies a local tarball and --sha256=HEX verifies it. Installation
prints activation instructions without editing server configuration.

Add index-based downloads with system libcurl and --base-url.
Verify downloaded archives against the index's SHA-256. Keep local
and downloaded archives in private temporary files for verification
and extraction.

Resolve file operations through checked parent directories, fix
command routing, reject legacy --dry-run, and propagate native search
errors. Improve libcurl build integration.

Add tarball search using the same repository index and compatibility
checks as install. List matching plugin names with descriptions and
installed status from local manifests, without downloading archives or
changing the installation. Retain author and license metadata.

Reject invalid or ambiguous metadata before printing search results.
Validate manifest identity before uninstall and reject non-regular
manifests without blocking, while preserving partial-install rollback.

Tests cover tarball search filtering, compatible-build selection,
metadata validation, installed status, manifest safety, rollback,
metadata-only network access and CLI regressions.
Document package and tarball operations, activation instructions,
repository requirements and manifest-based uninstall.

Cover search option rejection, trailing-hyphen search terms,
option-value routing and deprecated dry-run rejection in MTR.
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