- 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.
198 lines
6.5 KiB
Bash
Executable File
198 lines
6.5 KiB
Bash
Executable File
#!/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/>.
|
|
#
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
# Includes
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
. /usr/lib/rx3/base.bash
|
|
|
|
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
# Global Variables
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
declare -g VERSION="1.0.0"
|
|
declare -g NAME="URPMI Setup"
|
|
declare -g HELP="usage: urpmi-setup [ [-d | --distrib <Distrib>] [-m | --mirror-mga <Mirror_List>] [-r | --mirror-rx3 <Mirror_List>] ] | [-h | --help] | [-V | --version] [-T | --test] [-u | --update] [-v | --verbose]"
|
|
|
|
declare -g DISTRIB_DEF="9"
|
|
declare -g MIRRORLIST_MGA_DEF='http://mirror.xor.rx3/mageia/distrib/${DISTRIB}/x86_64 https://mirror.rx3.net/mageia/distrib/${DISTRIB}/x86_64 ftp://ftp.proxad.net/mirrors/mageia.org/distrib/${DISTRIB}/x86_64 http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/${DISTRIB}/x86_64'
|
|
declare -g MIRRORLIST_RX3_DEF='http://mirror.xor.rx3/rx3/distrib/${DISTRIB}/x86_64 https://mirror.rx3.net/rx3/distrib/${DISTRIB}/x86_64'
|
|
|
|
declare -g EXIT_CODE=0
|
|
declare -g MODE="DEFAULT"
|
|
declare -g DISTRIB=""
|
|
declare -g MIRRORLIST_MGA=""
|
|
declare -g MIRRORLIST_RX3=""
|
|
declare -g UPDATE="FALSE"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
# US Arg Parse
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
function us_args_parse()
|
|
{
|
|
tmp_args=$(getopt -o d:hm:r:Tuv --long distrib:,help,mirror-mga:,mirror-rx3:,test,update,verbose -- "$@")
|
|
|
|
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
|
|
|
|
# Options
|
|
-d|--distrib) shift; DISTRIB="$1"; shift;;
|
|
-m|--mirror-mga) shift; MIRRORLIST_MGA="$1"; shift;;
|
|
-r|--mirror-rx3) shift; MIRRORLIST_RX3="$1"; shift;;
|
|
|
|
# Mode switches
|
|
-h|--help) MODE="HELP"; shift;;
|
|
-V|--version) MODE="VERSION"; shift;;
|
|
|
|
# Global options
|
|
-T|--test) DRY_RUN="TRUE"; shift;;
|
|
-u|--update) UPDATE="TRUE"; shift;;
|
|
-v|--verbose) VERBOSE="TRUE"; shift;;
|
|
|
|
#
|
|
--) shift; break;;
|
|
*) echo "args_parse internal error [$1] !"; exit 1;;
|
|
esac
|
|
done
|
|
|
|
if [[ ${DISTRIB} == "" ]]
|
|
then
|
|
DISTRIB=${DISTRIB_DEF}
|
|
fi
|
|
|
|
if [[ "${MIRRORLIST_MGA}" == "" ]]
|
|
then
|
|
eval MIRRORLIST_MGA=\"${MIRRORLIST_MGA_DEF}\"
|
|
fi
|
|
|
|
if [[ "${MIRRORLIST_RX3}" == "" ]]
|
|
then
|
|
eval MIRRORLIST_RX3=\"${MIRRORLIST_RX3_DEF}\"
|
|
fi
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
# US Version Print
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
us_version_print()
|
|
{
|
|
version_print
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
# US Help Print
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
us_help_print()
|
|
{
|
|
version_print
|
|
help_print
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
# Main
|
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
orig_args=("$@")
|
|
|
|
us_args_parse "$@"
|
|
|
|
|
|
case "${MODE}" in
|
|
|
|
"EXIT")
|
|
exit ${EXIT_CODE}
|
|
;;
|
|
|
|
"HELP")
|
|
us_help_print
|
|
exit ${EXIT_CODE}
|
|
;;
|
|
|
|
"VERSION")
|
|
us_version_print
|
|
exit ${EXIT_CODE}
|
|
;;
|
|
esac
|
|
|
|
|
|
|
|
echo_error "${NAME}: Mode: [${MODE}] Verbose: [${VERBOSE}] Dry_Run: [${DRY_RUN}] Distrib: [${DISTRIB}] MirrorList_MGA: [${MIRRORLIST_MGA}] MirrorList_RX3: [${MIRRORLIST_RX3}] Update: [${UPDATE}]"
|
|
|
|
cmd_exec 'urpmi.removemedia -a'
|
|
cmd_exec 'rm -f /var/cache/urpmi/mirrors.cache'
|
|
cmd_exec 'urpmi.addmedia --distrib --mirrorlist "'"${MIRRORLIST_MGA}"'"'
|
|
cmd_exec 'urpmi.addmedia --distrib --mirrorlist "'"${MIRRORLIST_RX3}"'"'
|
|
|
|
for arch in "" "32bit "
|
|
do
|
|
for media in "Core" "Nonfree" "Tainted"
|
|
do
|
|
for type in "Release" "Updates"
|
|
do
|
|
cmd_exec 'urpmi.update --no-ignore "'"${media}"' '"${arch}""${type}"'"'
|
|
done
|
|
done
|
|
done
|
|
|
|
cmd_exec 'urpmi.update -a'
|
|
|
|
if [[ "${UPDATE}" == "TRUE" ]]
|
|
then
|
|
cmd_exec 'urpmi --force --auto-update'
|
|
fi
|
|
|
|
exit ${EXIT_CODE}
|