From 686d8642c1ffd944b58776260cf46bfc808fbf0c Mon Sep 17 00:00:00 2001 From: "Arnaud G. GIBERT" Date: Sat, 14 Mar 2026 20:32:41 +0100 Subject: [PATCH] - Add local repo support, - Add MariaDB meta package, - New args parsing system with test and verbose options, - Add RPM Specs file. --- .gitignore | 2 + COPYING | 1 + ReleaseNotes.txt | 13 +- SPECS/mpm.spec | 120 ++++++++++++++ etc/mpm.conf~ | 25 --- sbin/mpm | 225 +++++++++++++++++++------- var/www/mpm-repository/emacs-nox.mpm~ | 3 - var/www/mpm-repository/emacs.mpm~ | 3 - var/www/mpm-repository/mariadb.mpm | 3 + var/www/mpm-repository/net_tools.mpm | 3 + var/www/mpm-repository/postgres.mpm | 3 + 11 files changed, 313 insertions(+), 88 deletions(-) create mode 100644 .gitignore create mode 120000 COPYING create mode 100644 SPECS/mpm.spec delete mode 100644 etc/mpm.conf~ delete mode 100644 var/www/mpm-repository/emacs-nox.mpm~ delete mode 100644 var/www/mpm-repository/emacs.mpm~ create mode 100644 var/www/mpm-repository/mariadb.mpm create mode 100644 var/www/mpm-repository/net_tools.mpm create mode 100644 var/www/mpm-repository/postgres.mpm diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..556bc65 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +*.old diff --git a/COPYING b/COPYING new file mode 120000 index 0000000..fe7151e --- /dev/null +++ b/COPYING @@ -0,0 +1 @@ +GNU_GPL-3.0.txt \ No newline at end of file diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index c13f3bf..c9a411a 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,5 +1,16 @@ ------------------------------------------------------------------------------------------------------------------------------------ -MPM V 1.0.0-1 - A. GIBERT - 2024/10/04 +MPM V 1.1.0 - A. GIBERT - 2026/03/14 +------------------------------------------------------------------------------------------------------------------------------------ + +- Add local repo support, +- Add MariaDB meta package, +- New args parsing system with test and verbose options, +- Add RPM Specs file. + + + +------------------------------------------------------------------------------------------------------------------------------------ +MPM V 1.0.0 - A. GIBERT - 2024/10/04 ------------------------------------------------------------------------------------------------------------------------------------ - Initial release: help, list & install commands implemented. diff --git a/SPECS/mpm.spec b/SPECS/mpm.spec new file mode 100644 index 0000000..e58a55f --- /dev/null +++ b/SPECS/mpm.spec @@ -0,0 +1,120 @@ +%define name mpm +%define version 1.1.0 +%define release %mkrel 1rx3 + +%global debug_package %{nil} + +%global _webdir %{_localstatedir}/www +%global _webcgi %{_webdir}/cgi-bin +%global _webhtml %{_webdir}/html + + + +Name: %{name} +Version: %{version} +Release: %{release} +Summary: Meta Package Manager - Client tool +License: GPL +URL: https://git.rx3.org/gitea/rx3/%{name} + +Source0: https://git.rx3.org/gitea/rx3/%{name}/archive/%{name}-%{version}.tar.gz + +Distribution: Rx3 Free Software +Vendor: Rx3 +Packager: Arnaud G. GIBERT + +BuildArch: noarch + +%description +MPM is a Meta Package Manager, based upon URPMI and RPM packages. +This is the client tool. + + + +%package server +Summary: Meta Package Manager - Server repository +Requires: apache + +%description server +MPM is a Meta Package Manager, based upon URPMI and RPM packages. +This is the server repository. + + + +#----------------------------------------------------------------------------------------------------------------------------------- +# Prep +#----------------------------------------------------------------------------------------------------------------------------------- + +%prep +%setup -q -n %{name} + + + + + +#----------------------------------------------------------------------------------------------------------------------------------- +# Build +#----------------------------------------------------------------------------------------------------------------------------------- + +%build + + + + + +#----------------------------------------------------------------------------------------------------------------------------------- +# Install +#----------------------------------------------------------------------------------------------------------------------------------- + +%install +# Client +install -D -pm 644 etc/%{name}.conf %{buildroot}%{_sysconfdir}/%{name}.conf +install -D -pm 755 sbin/%{name} %{buildroot}%{_sbindir}/%{name} + +# Server +cd var/www/%{name}-repository +for file in *.mpm +do + install -D -pm 644 ${file} %{buildroot}%{_webhtml}/%{name}-repository/${file} +done + + + + + +#----------------------------------------------------------------------------------------------------------------------------------- +# Check +#----------------------------------------------------------------------------------------------------------------------------------- + +%check + + + + + +#----------------------------------------------------------------------------------------------------------------------------------- +# Files +#----------------------------------------------------------------------------------------------------------------------------------- + +%files +%doc ReadMe.txt ReleaseNotes.txt ToDo.txt +%license GNU_GPL-3.0.txt +%config(noreplace) %{_sysconfdir}/%{name}.conf +%{_sbindir}/%{name} + + + +%files server +%{_webhtml}/%{name}-repository/* + + + + + +#----------------------------------------------------------------------------------------------------------------------------------- +# ChangeLog +#----------------------------------------------------------------------------------------------------------------------------------- + +%changelog +* Sat Mar 14 2026 Arnaud G. GIBERT - 1.1.0-1rx3.mga9 +- Create initial SPEC file for 1.1.0 on Mageia 9 diff --git a/etc/mpm.conf~ b/etc/mpm.conf~ deleted file mode 100644 index e569b25..0000000 --- a/etc/mpm.conf~ +++ /dev/null @@ -1,25 +0,0 @@ -#-------------------------------------------------------------------------------# -# -# MPM (Meta Package Manager) -# Copyright (C) 2024 Arnaud G. GIBERT -# mailto:arnaud@rx3.net -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -#------------------------------------------------------------------------------- - - -# Default MPM repository -MPM_REPO="https://www.rx3.net/mpm-repository" diff --git a/sbin/mpm b/sbin/mpm index 76eb3d8..cb0a33a 100755 --- a/sbin/mpm +++ b/sbin/mpm @@ -2,7 +2,7 @@ #-------------------------------------------------------------------------------# # # MPM (Meta Package Manager) -# Copyright (C) 2024 Arnaud G. GIBERT +# Copyright (C) 2024-2026 Arnaud G. GIBERT # mailto:arnaud@rx3.net # # This program is free software; you can redistribute it and/or @@ -33,51 +33,162 @@ else MPM_REPO="https://www.rx3.net/mpm-repository" fi -VERSION=1.0.0 +VERSION=1.1.0 -#------------------------------------------------------------------------------- -# MPM Help -#------------------------------------------------------------------------------- -function mpm_help() + +#----------------------------------------------------------------------------------------------------------------------------------- +# Exec CMD +#----------------------------------------------------------------------------------------------------------------------------------- + +exec_cmd() { - echo "MPM Version: [${VERSION}]" - echo "Repository URL: [${MPM_REPO}]" - echo "usage: mpm [--help | -h] | [--list | -l] | [--install | -i ]" + cmd="$1" + + + if [[ "${verbose}" == "true" ]] + then + echo "${cmd}" 1>&2 + fi + + if [[ "${dry_run}" != "true" ]] + then + eval "${cmd}" + fi } -#------------------------------------------------------------------------------- + + +#----------------------------------------------------------------------------------------------------------------------------------- +# MPM Help +#----------------------------------------------------------------------------------------------------------------------------------- + +function mpm_version_print() +{ + echo "MPM Version: [${VERSION}]" +} + + + + + +#----------------------------------------------------------------------------------------------------------------------------------- +# MPM Help +#----------------------------------------------------------------------------------------------------------------------------------- + +function mpm_help_print() +{ + mpm_version_print + echo "Repository URL: [${MPM_REPO}]" + echo "usage: mpm [-h | --help] | [-V | --version] | [-l | --list] | [-i | --install ] [-T | --test] [-v | --verbose] [-r | --repo ]" +} + + + + + +#----------------------------------------------------------------------------------------------------------------------------------- +# Arg Parse +#----------------------------------------------------------------------------------------------------------------------------------- + +function mpm_args_parse() +{ + mode="default" + verbose="false" + dry_run="false" + + + tmp_args=$(getopt -o hi:lr:TvV --long help,install:,list,repo:,test,verbose,version -- "$@") + + if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi + + # Note the quotes around `$tmp_args': they are essential! + eval set -- "${tmp_args}" + + while true ; do + case "$1" in + # Path options + -r|--repo) shift; MPM_REPO="$1"; shift;; + + # Options + + # Mode switches + -h|--help) mode="exit"; mpm_help_print; shift;; + -i|--install) shift; mode="install"; mpm_name="$1"; shift;; + -l|--list) mode="list"; shift;; + -V|--version) mode="exit"; mpm_version_print; shift;; + + # Global options + -T|--test) dry_run="true"; shift;; + -v|--verbose) verbose="true"; shift;; + + # + --) shift; break;; + *) echo "args_parse internal error [$1] !"; exit 1;; + esac + done + + if [[ "${mode}" == "default" ]] + then + echo "Help, Install, List or Version should invoked!" + + mode="exit" + mpm_help_print + + exit 1 + fi +} + + + + + +#----------------------------------------------------------------------------------------------------------------------------------- # MPM Meta Package List -#------------------------------------------------------------------------------- +#----------------------------------------------------------------------------------------------------------------------------------- function mpm_mpkg_list() { - echo "$(curl -L 2>/dev/null "${MPM_REPO}" | grep -e '\.mpm' | sed -e 's/.*href="//' -e 's/\.mpm".*//')" + if [[ "${MPM_REPO}" =~ ^https?:// ]] + then + echo "$(curl -L 2>/dev/null "${MPM_REPO}" | grep -e '\.mpm' | sed -e 's/.*href="//' -e 's/\.mpm".*//')" + else + echo "$(ls ${MPM_REPO}/*.mpm | sed -e "s%^${MPM_REPO}/%%" -e 's/\.mpm$//')" + fi } -#------------------------------------------------------------------------------- + + +#----------------------------------------------------------------------------------------------------------------------------------- # MPM Meta Package Tag Read -#------------------------------------------------------------------------------- +#----------------------------------------------------------------------------------------------------------------------------------- function mpm_mpkg_tag_read() { mpkg="$1" tag="$2" - echo "$(curl -L 2>/dev/null "${MPM_REPO}/${mpkg}.mpm" | grep -e "${tag}: " | sed -e "s/^${tag}: //")" + if [[ "${MPM_REPO}" =~ ^https?:// ]] + then + echo "$(curl -L 2>/dev/null "${MPM_REPO}/${mpkg}.mpm" | grep -e "${tag}: " | sed -e "s/^${tag}: //")" + else + echo "$(cat 2>/dev/null "${MPM_REPO}/${mpkg}.mpm" | grep -e "${tag}: " | sed -e "s/^${tag}: //")" + fi } -#------------------------------------------------------------------------------- + + +#----------------------------------------------------------------------------------------------------------------------------------- # MPM Meta Package Description -#------------------------------------------------------------------------------- +#----------------------------------------------------------------------------------------------------------------------------------- function mpm_mpkg_desc() { @@ -88,9 +199,11 @@ function mpm_mpkg_desc() -#------------------------------------------------------------------------------- + + +#----------------------------------------------------------------------------------------------------------------------------------- # MPM Meta Package List -#------------------------------------------------------------------------------- +#----------------------------------------------------------------------------------------------------------------------------------- function mpm_mpkg_pkglist() { @@ -101,29 +214,33 @@ function mpm_mpkg_pkglist() -#------------------------------------------------------------------------------- + + +#----------------------------------------------------------------------------------------------------------------------------------- # MPM List -#------------------------------------------------------------------------------- +#----------------------------------------------------------------------------------------------------------------------------------- function mpm_list() { - echo " MPM Name + MPM Description + Package List " - echo "--------------------+---------------------------------+------------------------------------------------" + echo " MPM Name | MPM Description | Package List " + echo "---------------------+----------------------------------+---------------------------------------------------------------------------" mpm_mpkg_list | while read mpkg do desc="$(mpm_mpkg_desc $mpkg)" pkglist="$(mpm_mpkg_pkglist $mpkg)" - printf "%20s: %-32s [%s]\n" "${mpkg}" "${desc}" "${pkglist}" + printf "%20s | %-32s | %s\n" "${mpkg}" "${desc}" "${pkglist}" done } -#------------------------------------------------------------------------------- + + +#----------------------------------------------------------------------------------------------------------------------------------- # MPM Install -#------------------------------------------------------------------------------- +#----------------------------------------------------------------------------------------------------------------------------------- function mpm_install { @@ -158,46 +275,42 @@ function mpm_install fi echo "installing MPM: [$mpkg]:[${pkglist}]" - - urpmi --force ${pkglist} + + exec_cmd "urpmi --force ${pkglist}" } -#------------------------------------------------------------------------------- + + +#----------------------------------------------------------------------------------------------------------------------------------- # MPM Main -#------------------------------------------------------------------------------- +#----------------------------------------------------------------------------------------------------------------------------------- -case "${command}" +shopt -s extglob + +mpm_args_parse "$@" + + + +if [[ ${mode} == "exit" ]] +then + exit 0 +fi + + + +echo "mode: [${mode}] verbose: [${verbose}] dry_run: [${dry_run}] Repo_URL: [${MPM_REPO}]" 1>&2 + +case "${mode}" in - "--help" | "-h") - mpm_help - ;; - - "--list" | "-l") + "list") mpm_list ;; - "--install" | "-i") - mpm_install $arg - ;; - - *) - if [[ "${command}" == "" ]] - then - echo "missing mandatory command!" - else - - echo "unknown command [${command}]!" - fi - - echo - mpm_help - - exit 1 - ;; - - + "install") + mpm_install "${mpm_name}" + ;; esac exit 0 diff --git a/var/www/mpm-repository/emacs-nox.mpm~ b/var/www/mpm-repository/emacs-nox.mpm~ deleted file mode 100644 index c244df3..0000000 --- a/var/www/mpm-repository/emacs-nox.mpm~ +++ /dev/null @@ -1,3 +0,0 @@ -# -PKG_DESC: Emacs No X-Windows -PKG_LIST: emacs-nox hunspell-en diff --git a/var/www/mpm-repository/emacs.mpm~ b/var/www/mpm-repository/emacs.mpm~ deleted file mode 100644 index 61aded3..0000000 --- a/var/www/mpm-repository/emacs.mpm~ +++ /dev/null @@ -1,3 +0,0 @@ -# -PKG_DESC: Emacs with X-Windows -PKG_LIST: emacs lib64vulkan-loader1 lib64jack0 lib64opencl1 pipewire-media-session lib64proxy-webkit hunspell-en diff --git a/var/www/mpm-repository/mariadb.mpm b/var/www/mpm-repository/mariadb.mpm new file mode 100644 index 0000000..fb80618 --- /dev/null +++ b/var/www/mpm-repository/mariadb.mpm @@ -0,0 +1,3 @@ +# +PKG_DESC: MariaDB/MySQL Client +PKG_LIST: mariadb-client diff --git a/var/www/mpm-repository/net_tools.mpm b/var/www/mpm-repository/net_tools.mpm new file mode 100644 index 0000000..8c7e9eb --- /dev/null +++ b/var/www/mpm-repository/net_tools.mpm @@ -0,0 +1,3 @@ +# +PKG_DESC: Network tools for investigations +PKG_LIST: net-tools bind-utils netkit-telnet tcpdump diff --git a/var/www/mpm-repository/postgres.mpm b/var/www/mpm-repository/postgres.mpm new file mode 100644 index 0000000..1647eef --- /dev/null +++ b/var/www/mpm-repository/postgres.mpm @@ -0,0 +1,3 @@ +# +PKG_DESC: PostgreSQL Client +PKG_LIST: postgresql15