From 42ea9e4bf77b658a44beeb5a51c2ac242723ff6b Mon Sep 17 00:00:00 2001 From: "Arnaud G. GIBERT" Date: Mon, 20 Apr 2026 16:11:05 +0200 Subject: [PATCH] - Migrate to rx3 base library. - Support rx3-base 1.1.2. --- ReleaseNotes.txt | 9 + SPECS/mpm.spec | 8 +- etc/bash_completion.d/mpm | 98 ++++-- etc/mpm.conf | 1 + sbin/mpm | 278 +++++++++--------- .../html/mpm-repository/emacs-nox.mpm | 0 .../www => www}/html/mpm-repository/emacs.mpm | 0 .../html/mpm-repository/mariadb.mpm | 0 .../html/mpm-repository/net_tools.mpm | 0 .../html/mpm-repository/postgres.mpm | 0 10 files changed, 225 insertions(+), 169 deletions(-) rename {var/www => www}/html/mpm-repository/emacs-nox.mpm (100%) rename {var/www => www}/html/mpm-repository/emacs.mpm (100%) rename {var/www => www}/html/mpm-repository/mariadb.mpm (100%) rename {var/www => www}/html/mpm-repository/net_tools.mpm (100%) rename {var/www => www}/html/mpm-repository/postgres.mpm (100%) diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index d95af2b..791d964 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,3 +1,12 @@ +------------------------------------------------------------------------------------------------------------------------------------ +MPM V 1.1.2 - A. GIBERT - 2026/04/20 +------------------------------------------------------------------------------------------------------------------------------------ + +- Migrate to rx3 base library. +- Support rx3-base 1.1.2. + + + ------------------------------------------------------------------------------------------------------------------------------------ MPM V 1.1.1 - A. GIBERT - 2026/03/21 ------------------------------------------------------------------------------------------------------------------------------------ diff --git a/SPECS/mpm.spec b/SPECS/mpm.spec index bbc92b1..c6df04d 100644 --- a/SPECS/mpm.spec +++ b/SPECS/mpm.spec @@ -1,6 +1,7 @@ #----------------------------------------------------------------------------------------------------------------------------------- # # MPM (Meta Package Manager) +# # Copyright (C) 2024-2026 Arnaud G. GIBERT # mailto:arnaud@rx3.net # @@ -23,7 +24,7 @@ %define name mpm -%define version 1.1.1 +%define version 1.1.2 %define release %mkrel 1rx3 %global debug_package %{nil} @@ -97,7 +98,7 @@ install -D -pm 644 etc/bash_completion.d/%{name} %{buildroot}%{_sysconfdir}/bas install -D -pm 755 sbin/%{name} %{buildroot}%{_sbindir}/%{name} # Server -cd var/www/html/%{name}-repository +cd www/html/%{name}-repository for file in *.mpm do install -D -pm 644 ${file} %{buildroot}%{_webhtml}/%{name}-repository/${file} @@ -142,6 +143,9 @@ done #----------------------------------------------------------------------------------------------------------------------------------- %changelog +* Mon Apr 20 2026 Arnaud G. GIBERT - 1.1.2-1rx3.mga9 +- Update to 1.1.2 + * Sat Mar 21 2026 Arnaud G. GIBERT - 1.1.1-1rx3.mga9 - Update to 1.1.1 - Add bash completion support diff --git a/etc/bash_completion.d/mpm b/etc/bash_completion.d/mpm index dad3c34..3a284c9 100644 --- a/etc/bash_completion.d/mpm +++ b/etc/bash_completion.d/mpm @@ -1,57 +1,95 @@ #!/bin/bash #----------------------------------------------------------------------------------------------------------------------------------- # -# MPM (Meta Package Manager) +# MPM (Meta Package Manager) Bash Completion +# # Copyright (C) 2024-2026 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 is free software: you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) 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. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser 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. +# You should have received a copy of the GNU Lesser General Public +# License along with this program; If not, see +# . # #----------------------------------------------------------------------------------------------------------------------------------- -# -*- mode: shell; sh-basic-offset: 4; indent-tabs-mode: nil; -*- - -# Bash completion script for mpm command +#----------------------------------------------------------------------------------------------------------------------------------- +# MPM Completion +#----------------------------------------------------------------------------------------------------------------------------------- _mpm_completion() { - local cur prev opts + local cur="${COMP_WORDS[COMP_CWORD]}" + local prev="${COMP_WORDS[COMP_CWORD-1]}" + local opts="-h --help -V --version -v --verbose -T --test -l --list -i --install -r --repo" + + local pos=0 + local i + COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - opts="--help -h --list -l --install -i" - # If no option is provided yet, suggest all options - if [[ ${COMP_CWORD} == 1 ]]; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - fi - - # Handle option-specific completions - if [[ ${cur} == -* ]]; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + # Count non-option positional arguments already provided + for (( i=1; i/dev/null | awk 'NR>2 {gsub(/:$/, "", $1); print $1}') - COMPREPLY=( $(compgen -W "${mpm_names}" -- ${cur}) ) + -i|--install) + local mpm_names + mpm_names="$(mpm --list 2>/dev/null | awk 'NR>2 { gsub(/^ +/, "", $1); print $1 }')" + COMPREPLY=( $(compgen -W "${mpm_names}" -- "${cur}") ) + return 0 + ;; + -r|--repo) + COMPREPLY=() return 0 ;; esac + + # Complete positional arguments + case "${pos}" in + 0) + COMPREPLY=( $(compgen -W "-h --help -V --version -v --verbose -T --test -l --list -i --install -r --repo" -- "${cur}") ) + ;; + *) + COMPREPLY=() + ;; + esac + + return 0 } -complete -F _mpm_completion mpm + + +complete -o filenames -F _mpm_completion mpm diff --git a/etc/mpm.conf b/etc/mpm.conf index dc505fa..24cccaf 100644 --- a/etc/mpm.conf +++ b/etc/mpm.conf @@ -1,6 +1,7 @@ #----------------------------------------------------------------------------------------------------------------------------------- # # MPM (Meta Package Manager) +# # Copyright (C) 2024-2026 Arnaud G. GIBERT # mailto:arnaud@rx3.net # diff --git a/sbin/mpm b/sbin/mpm index 3289b8e..eac6f6c 100755 --- a/sbin/mpm +++ b/sbin/mpm @@ -2,139 +2,133 @@ #----------------------------------------------------------------------------------------------------------------------------------- # # MPM (Meta Package Manager) +# # Copyright (C) 2024-2026 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 is free software: you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) 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. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser 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. +# You should have received a copy of the GNU Lesser General Public +# License along with this program; If not, see +# . # #----------------------------------------------------------------------------------------------------------------------------------- -command="$1" -arg="$2" +#----------------------------------------------------------------------------------------------------------------------------------- +# Includes +#----------------------------------------------------------------------------------------------------------------------------------- + +: "${RX3_LIB_DIR:=/usr/lib/rx3}" +. "${RX3_LIB_DIR}/base.bash" + + + + + +#----------------------------------------------------------------------------------------------------------------------------------- +# Global Variables +#----------------------------------------------------------------------------------------------------------------------------------- + +declare -g VERSION="1.1.2" +declare -g NAME="mpm" +declare -g HELP="usage: [-h | --help] | [-V | --version] | [-l | --list] | [-i | --install ] [-T | --test] [-v | --verbose] [-r | --repo ]" + +declare -g MODE="DEFAULT" +declare -g VERBOSE="FALSE" +declare -g DRY_RUN="FALSE" +declare -g RETVAL=0 + +declare -g MPM_REPO="https://www.rx3.net/mpm-repository" +declare -g MPM_NAME="" if [[ -f /etc/mpm.conf ]] then . /etc/mpm.conf -else - MPM_REPO="https://www.rx3.net/mpm-repository" fi -VERSION=1.1.1 - -# Exec CMD +#----------------------------------------------------------------------------------------------------------------------------------- +# Version Print #----------------------------------------------------------------------------------------------------------------------------------- -exec_cmd() +mpm_version_print() { - cmd="$1" - - - if [[ "${verbose}" == "true" ]] - then - echo "${cmd}" 1>&2 - fi - - if [[ "${dry_run}" != "true" ]] - then - eval "${cmd}" - fi + version_print } -# MPM Version Print +#----------------------------------------------------------------------------------------------------------------------------------- +# Help Print #----------------------------------------------------------------------------------------------------------------------------------- -function mpm_version_print() -{ - echo "MPM Version: [${VERSION}]" -} - - - - - -# MPM Help -#----------------------------------------------------------------------------------------------------------------------------------- - -function mpm_help_print() +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 ]" + echo_error "Repository URL: [${MPM_REPO}]" + help_print } +#----------------------------------------------------------------------------------------------------------------------------------- # Arg Parse #----------------------------------------------------------------------------------------------------------------------------------- -function mpm_args_parse() +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 -n "${NAME}" -- "$@") - - tmp_args=$(getopt -o hi:lr:TvV --long help,install:,list,repo:,test,verbose,version -- "$@") + if [ $? != 0 ]; then echo_error "Terminating..." >&2; exit 1; fi - 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;; + while true + do + case "$1" in + # Path options + -r|--repo) MPM_REPO="$2"; shift; shift;; - # Options + # Mode switches + -h|--help) MODE="EXIT"; mpm_help_print; shift;; + -i|--install) MODE="INSTALL"; MPM_NAME="$2"; shift; shift;; + -l|--list) MODE="LIST"; shift;; + -V|--version) MODE="EXIT"; mpm_version_print; shift;; - # 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;; - # Global options - -T|--test) dry_run="true"; shift;; - -v|--verbose) verbose="true"; shift;; - - # - --) shift; break;; - *) echo "args_parse internal error [$1] !"; exit 1;; - esac + # End of options + --) shift; break;; + *) echo_error "args_parse internal error [$1]!"; exit 1;; + esac done - - if [[ "${mode}" == "default" ]] + + if [[ "${MODE}" == "DEFAULT" ]] then - echo "Help, Install, List or Version should invoked!" + MODE="EXIT" - mode="exit" + echo_error "Help, Install, List or Version should be invoked!" mpm_help_print - + exit 1 fi } @@ -143,16 +137,17 @@ function mpm_args_parse() -# MPM Meta Package List +#----------------------------------------------------------------------------------------------------------------------------------- +# Meta Package List #----------------------------------------------------------------------------------------------------------------------------------- -function mpm_mpkg_list() +mpm_mpkg_list() { if [[ "${MPM_REPO}" =~ ^https?:// ]] then - echo "$(curl -L 2>/dev/null "${MPM_REPO}" | grep -e '\.mpm' | sed -e 's/.*href="//' -e 's/\.mpm".*//')" + cmd_exec curl -L "${MPM_REPO}" 2>/dev/null | grep -e '\.mpm' | sed -e 's/.*href="//' -e 's/\.mpm".*//' else - echo "$(ls ${MPM_REPO}/*.mpm | sed -e "s%^${MPM_REPO}/%%" -e 's/\.mpm$//')" + ls "${MPM_REPO}"/*.mpm | sed -e "s%^${MPM_REPO}/%%" -e 's/\.mpm$//' fi } @@ -160,19 +155,20 @@ function mpm_mpkg_list() -# MPM Meta Package Tag Read +#----------------------------------------------------------------------------------------------------------------------------------- +# Meta Package Tag Read #----------------------------------------------------------------------------------------------------------------------------------- -function mpm_mpkg_tag_read() +mpm_mpkg_tag_read() { - mpkg="$1" - tag="$2" - + local mpkg="$1" + local tag="$2" + if [[ "${MPM_REPO}" =~ ^https?:// ]] then - echo "$(curl -L 2>/dev/null "${MPM_REPO}/${mpkg}.mpm" | grep -e "${tag}: " | sed -e "s/^${tag}: //")" + cmd_exec curl -L "${MPM_REPO}/${mpkg}.mpm" 2>/dev/null | grep -e "${tag}: " | sed -e "s/^${tag}: //" else - echo "$(cat 2>/dev/null "${MPM_REPO}/${mpkg}.mpm" | grep -e "${tag}: " | sed -e "s/^${tag}: //")" + grep -e "${tag}: " "${MPM_REPO}/${mpkg}.mpm" 2>/dev/null | sed -e "s/^${tag}: //" fi } @@ -180,12 +176,13 @@ function mpm_mpkg_tag_read() -# MPM Meta Package Description +#----------------------------------------------------------------------------------------------------------------------------------- +# Meta Package Description #----------------------------------------------------------------------------------------------------------------------------------- -function mpm_mpkg_desc() +mpm_mpkg_desc() { - mpkg="$1" + local mpkg="$1" mpm_mpkg_tag_read "${mpkg}" "PKG_DESC" } @@ -194,12 +191,13 @@ function mpm_mpkg_desc() -# MPM Meta Package List +#----------------------------------------------------------------------------------------------------------------------------------- +# Meta Package Package List #----------------------------------------------------------------------------------------------------------------------------------- -function mpm_mpkg_pkglist() +mpm_mpkg_pkglist() { - mpkg="$1" + local mpkg="$1" mpm_mpkg_tag_read "${mpkg}" "PKG_LIST" } @@ -208,18 +206,23 @@ function mpm_mpkg_pkglist() -# MPM List +#----------------------------------------------------------------------------------------------------------------------------------- +# List #----------------------------------------------------------------------------------------------------------------------------------- -function mpm_list() +mpm_list() { + local mpkg + local desc + local pkglist + echo " MPM Name | MPM Description | Package List " echo "---------------------+----------------------------------+---------------------------------------------------------------------------" - - mpm_mpkg_list | while read mpkg + + mpm_mpkg_list | while read -r mpkg do - desc="$(mpm_mpkg_desc $mpkg)" - pkglist="$(mpm_mpkg_pkglist $mpkg)" + desc="$(mpm_mpkg_desc "${mpkg}")" + pkglist="$(mpm_mpkg_pkglist "${mpkg}")" printf "%20s | %-32s | %s\n" "${mpkg}" "${desc}" "${pkglist}" done @@ -229,77 +232,78 @@ function mpm_list() -# MPM Install +#----------------------------------------------------------------------------------------------------------------------------------- +# Install #----------------------------------------------------------------------------------------------------------------------------------- -function mpm_install +mpm_install() { - mpkg=$1 + local mpkg="$1" + local pkglist + if [[ "${mpkg}" == "" ]] then - echo "missing required mpkg name" - mpm_help - - exit 1 - fi - - - mpm_mpkg_list | grep -e "^${mpkg}$" -e "^${mpkg} " -e " ${mpkg}$" -e " ${mpkg} " 2>&1 >/dev/null - - if [[ "$?" == 1 ]] - then - echo "mpkg [${mpkg}] not found!" + echo_error "Missing required mpkg name!" exit 1 fi - - pkglist="$(mpm_mpkg_pkglist $mpkg)" - + mpm_mpkg_list | grep -qe "^${mpkg}$" -e "^${mpkg} " -e " ${mpkg}$" -e " ${mpkg} " + + if [[ "$?" == "1" ]] + then + echo_error "mpkg [${mpkg}] not found!" + + exit 1 + fi + + pkglist="$(mpm_mpkg_pkglist "${mpkg}")" + if [[ "${pkglist}" == "" ]] then - echo "package list is empty!" - + echo_error "Package list is empty!" + exit 1 fi - echo "installing MPM: [$mpkg]:[${pkglist}]" + echo "Installing MPM: [${mpkg}]:[${pkglist}]" - exec_cmd "urpmi --force ${pkglist}" + cmd_exec urpmi --force ${pkglist} } -# MPM Main #----------------------------------------------------------------------------------------------------------------------------------- - -shopt -s extglob +# Main +#----------------------------------------------------------------------------------------------------------------------------------- mpm_args_parse "$@" -if [[ ${mode} == "exit" ]] +if [[ "${MODE}" == "EXIT" ]] then exit 0 fi +echo_error "Mode: [${MODE}] Verbose: [${VERBOSE}] Dry_Run: [${DRY_RUN}] Repo_URL: [${MPM_REPO}]" - -echo "mode: [${mode}] verbose: [${verbose}] dry_run: [${dry_run}] Repo_URL: [${MPM_REPO}]" 1>&2 - -case "${mode}" -in - "list") +case "${MODE}" in + LIST) mpm_list ;; - - "install") - mpm_install "${mpm_name}" - ;; + + INSTALL) + mpm_install "${MPM_NAME}" + ;; + + *) + mpm_help_print + RETVAL=1 + ;; esac -exit 0 +exit ${RETVAL} diff --git a/var/www/html/mpm-repository/emacs-nox.mpm b/www/html/mpm-repository/emacs-nox.mpm similarity index 100% rename from var/www/html/mpm-repository/emacs-nox.mpm rename to www/html/mpm-repository/emacs-nox.mpm diff --git a/var/www/html/mpm-repository/emacs.mpm b/www/html/mpm-repository/emacs.mpm similarity index 100% rename from var/www/html/mpm-repository/emacs.mpm rename to www/html/mpm-repository/emacs.mpm diff --git a/var/www/html/mpm-repository/mariadb.mpm b/www/html/mpm-repository/mariadb.mpm similarity index 100% rename from var/www/html/mpm-repository/mariadb.mpm rename to www/html/mpm-repository/mariadb.mpm diff --git a/var/www/html/mpm-repository/net_tools.mpm b/www/html/mpm-repository/net_tools.mpm similarity index 100% rename from var/www/html/mpm-repository/net_tools.mpm rename to www/html/mpm-repository/net_tools.mpm diff --git a/var/www/html/mpm-repository/postgres.mpm b/www/html/mpm-repository/postgres.mpm similarity index 100% rename from var/www/html/mpm-repository/postgres.mpm rename to www/html/mpm-repository/postgres.mpm