- Base library:

- Rename default.bash to base.bash,
    - Normalise some function names: version_print(), help_print(), str_quote(), str_escape(), echo_line(), echo_error() & cmd_exec()
    - Normalise some global variables: VERBOSE & DRY_RUN,
    - Add default options: errexit, pipefail & nounset,
    - Add GPL headers,
- ISL:
    - Move ISL functions to isl command,
    - Add bash completion,
- URPMI-Setup:
    - Add urpmi-setup command.
This commit is contained in:
2026-03-28 17:54:27 +01:00
parent 97c05c4606
commit cc7eda3588
13 changed files with 1093 additions and 245 deletions

63
etc/bash_completion.d/isl Normal file
View File

@@ -0,0 +1,63 @@
#!/bin/bash
#-----------------------------------------------------------------------------------------------------------------------------------
#
# ISL: Image Stack Log
#
# Copyright (C) 2026 Arnaud G. GIBERT
# mailto:arnaud@rx3.net
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; If not, see
# <https://www.gnu.org/licenses/>.
#
#-----------------------------------------------------------------------------------------------------------------------------------
# -*- mode: shell; sh-basic-offset: 4; indent-tabs-mode: nil; -*-
_isl() {
local cur prev opts sub_opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="--help -h --version -V --test -T --verbose -v --add -a --cat -c --dump -d --top -t"
sub_opts="--reverse -r --inline -i --image -m"
# Check if we're completing a sub-option
case "${COMP_WORDS[1]}" in
--cat|-c|--dump|-d|--top|-t)
COMPREPLY=( $(compgen -W "${sub_opts}" -- "${cur}") )
return 0
;;
esac
# Top-level completion
case "${prev}" in
--add|-a)
COMPREPLY=( $(compgen -f -- "${cur}") ) # Complete with filenames/URLs
return 0
;;
--cat|-c|--dump|-d|--top|-t)
COMPREPLY=( $(compgen -W "${sub_opts}" -- "${cur}") )
return 0
;;
*)
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
esac
}
complete -F _isl isl

View File

@@ -0,0 +1,98 @@
#!/bin/bash
#-----------------------------------------------------------------------------------------------------------------------------------
#
# URPMI Setup
#
# Copyright (C) 2026 Arnaud G. GIBERT
# mailto:arnaud@rx3.net
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; If not, see
# <https://www.gnu.org/licenses/>.
#
#-----------------------------------------------------------------------------------------------------------------------------------
# -*- mode: shell; sh-basic-offset: 4; indent-tabs-mode: nil; -*-
_urpmi_setup() {
local cur prev opts distrib_opts mirror_opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Supported distributions (customize as needed)
distrib_opts="9 10 cauldron"
# Example mirror lists (customize as needed)
mirror_opts_mga="https://mirror.rx3.net/mageia/distrib/${DISTRIB}/x86_64 ftp://ftp.proxad.net/mirrors/mageia.org/distrib/${DISTRIB}/x86_64"
mirror_opts_rx3="http://mirror.xor.rx3/rx3/distrib/${DISTRIB}/x86_64 https://mirror.rx3.net/rx3/distrib/${DISTRIB}/x86_64"
# Check if --help or --version is already used
local has_help_or_version=false
local has_dmr=false # -d, -m, or -r
for arg in "${COMP_WORDS[@]}"; do
case "$arg" in
--help|-h|--version|-V)
has_help_or_version=true
;;
--distrib|-d|--mirror-mga|-m|--mirror-rx3|-r)
has_dmr=true
;;
esac
done
# If --help or --version is used, only suggest -v, -T, and -u
if $has_help_or_version; then
opts="--test -T --update -u --verbose -v"
# If -d, -m, or -r is used, exclude --help and --version
elif $has_dmr; then
opts="--test -T --update -u --verbose -v --distrib -d --mirror-mga -m --mirror-rx3 -r"
# Otherwise, show all options
else
opts="--help -h --version -V --distrib -d --mirror-mga -m --mirror-rx3 -r --test -T --update -u --verbose -v"
fi
case "${prev}" in
--distrib|-d)
COMPREPLY=( $(compgen -W "${distrib_opts}" -- "${cur}") )
return 0
;;
--mirror-mga|-m)
COMPREPLY=( $(compgen -W "${mirror_opts_mga}" -- "${cur}") )
return 0
;;
--mirror-rx3|-r)
COMPREPLY=( $(compgen -W "${mirror_opts_rx3}" -- "${cur}") )
return 0
;;
--mirror-mga|-m|--mirror-rx3|-r)
COMPREPLY=( $(compgen -W "${mirror_opts}" -- "${cur}") )
return 0
;;
*)
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
esac
}
complete -F _urpmi_setup urpmi-setup

View File

@@ -1,5 +1,29 @@
#!/bin/bash
#-----------------------------------------------------------------------------------------------------------------------------------
#
# Rx3 Base Profile
#
# Copyright (C) 2000-2026 Arnaud G. GIBERT
# mailto:arnaud@rx3.net
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; If not, see
# <https://www.gnu.org/licenses/>.
#
#-----------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------
# Global Variable
#-----------------------------------------------------------------------------------------------------------------------------------
@@ -11,6 +35,7 @@ export EDITOR=emacs
#-----------------------------------------------------------------------------------------------------------------------------------
# CatVal
#-----------------------------------------------------------------------------------------------------------------------------------
@@ -29,29 +54,7 @@ export -f cateval
# Print
#-----------------------------------------------------------------------------------------------------------------------------------
print()
{
if [[ "$1" == "-i" ]]
then
shift
str="%s"'\\n'
else
str="%s"'\n'
fi
printf "${str}" "$*"
}
export -f print
# File Enable
#-----------------------------------------------------------------------------------------------------------------------------------
@@ -81,15 +84,17 @@ export -f file_enable
#-----------------------------------------------------------------------------------------------------------------------------------
# Include
#-----------------------------------------------------------------------------------------------------------------------------------
. /usr/lib/rx3/isl.bash
# None
#-----------------------------------------------------------------------------------------------------------------------------------
# Aliases
#-----------------------------------------------------------------------------------------------------------------------------------