🗃️ Committing everything that changed 🗃️
Some checks failed
almalinux-8 / almalinux-8 (push) Waiting to run
almalinux-9-dev / almalinux-9-dev (push) Waiting to run
almalinux-9 / almalinux-9 (push) Waiting to run
almalinux-latest / almalinux-latest (push) Waiting to run
almalinux-10-dev / almalinux-10-dev (push) Failing after 6m1s
almalinux-10 / almalinux-10 (push) Failing after 6m9s
almalinux-8-dev / almalinux-8-dev (push) Has been cancelled

rootfs/usr/local/bin/pkmgr
This commit is contained in:
casjay 2024-12-28 14:56:26 -05:00
parent cc8ea0ddd7
commit 39644cde2c
Signed by untrusted user who does not match committer: jason
GPG Key ID: 1AB309F42A764145

View File

@ -1,17 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env sh
# shellcheck shell=bash # shellcheck shell=sh
# shellcheck disable=SC2016 # shellcheck disable=SC2016
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[ -n "$_DEBUG" ] && _DEBUG_OPTIONS="-x"
[ "$1" = "--debug" ] && _DEBUG_OPTIONS="-x" && shift 1
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
set -e $_DEBUG_OPTIONS
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
USER_UID="$(id -u)" USER_UID="$(id -u)"
USER_GID="$(id -g)" USER_GID="$(id -g)"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[ -f "/etc/pkmgr/options.conf" ] && . "/etc/pkmgr/options.conf"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if [ -x "$(command -v apt 2>/dev/null)" ]; then if [ -x "$(command -v apt 2>/dev/null)" ]; then
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
pkmgr_cmd="apt" pkmgr_cmd="apt"
@ -19,6 +12,7 @@ if [ -x "$(command -v apt 2>/dev/null)" ]; then
pkmgr_mkcache_cmd="$pkmgr_cmd update" pkmgr_mkcache_cmd="$pkmgr_cmd update"
pkmgr_update_cmd="$pkmgr_cmd upgrade -yy" pkmgr_update_cmd="$pkmgr_cmd upgrade -yy"
pkmgr_install_cmd="$pkmgr_cmd install -yy $PKMGR_OPTS" pkmgr_install_cmd="$pkmgr_cmd install -yy $PKMGR_OPTS"
pkmgr_install_post="$pkmgr_cmd --fix-broken install"
elif [ -x "$(command -v apt-get 2>/dev/null)" ]; then elif [ -x "$(command -v apt-get 2>/dev/null)" ]; then
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
pkmgr_cmd="apt-get" pkmgr_cmd="apt-get"
@ -26,6 +20,7 @@ elif [ -x "$(command -v apt-get 2>/dev/null)" ]; then
pkmgr_mkcache_cmd="$pkmgr_cmd update" pkmgr_mkcache_cmd="$pkmgr_cmd update"
pkmgr_update_cmd="$pkmgr_cmd upgrade -yy" pkmgr_update_cmd="$pkmgr_cmd upgrade -yy"
pkmgr_install_cmd="$pkmgr_cmd install -yy $PKMGR_OPTS" pkmgr_install_cmd="$pkmgr_cmd install -yy $PKMGR_OPTS"
pkmgr_install_post="$pkmgr_cmd --fix-broken install"
elif [ -x "$(command -v dnf 2>/dev/null)" ]; then elif [ -x "$(command -v dnf 2>/dev/null)" ]; then
pkmgr_cmd="dnf" pkmgr_cmd="dnf"
pkmgr_clean_cmd="$pkmgr_cmd clean all" pkmgr_clean_cmd="$pkmgr_cmd clean all"
@ -90,13 +85,34 @@ pip)
case "$1" in case "$1" in
install) install)
shift 1 shift 1
$pip_bin -m $pip_opts "$@" pkg_list="$*"
for pkg in $pkg_list; do
$pip_bin -m pip $pip_opts "$pkg"
done
;; ;;
*) *)
$pip_bin "$@" for pkg in "$@"; do
$pip_bin -m pip "$pkg"
done
;; ;;
esac esac
exit $? exit
;;
install)
shift 1
[ -n "$1" ] || exit 0
[ "$USER_UID" -eq 0 ] || [ "$USER" = "root" ] || pkmgr_install_cmd="sudo $pkmgr_install_cmd"
if [ -f "$1" ]; then
install_list="$(cat "$1")"
else
install_list="$*"
fi
for pkg in $install_list; do
echo "installing packages command: $pkmgr_install_cmd $pkg"
$pkmgr_install_cmd $pkg
[ -n "$pkmgr_install_post" ] && eval $pkmgr_install_post
done
exit
;; ;;
update | upgrade) update | upgrade)
shift $# shift $#
@ -114,20 +130,6 @@ clean)
$pkmgr_clean_cmd $pkmgr_clean_cmd
exit $? exit $?
;; ;;
install)
shift 1
[ -n "$1" ] || exit 0
[ "$USER_UID" -eq 0 ] || [ "$USER" = "root" ] || pkmgr_install_cmd="sudo $pkmgr_install_cmd"
if [ -f "$1" ]; then
install_list="$(cat "$1")"
echo 'installing packages from file with command: '$pkmgr_install_cmd' "$(<"$1")"'
else
install_list="$*"
echo "installing packages command: $pkmgr_install_cmd $install_list"
fi
$pkmgr_install_cmd $install_list
exit $?
;;
*) *)
[ -n "$1" ] || exit 0 [ -n "$1" ] || exit 0
[ "$USER_UID" -eq 0 ] || [ "$USER" = "root" ] || pkmgr_cmd="sudo $pkmgr_cmd" [ "$USER_UID" -eq 0 ] || [ "$USER" = "root" ] || pkmgr_cmd="sudo $pkmgr_cmd"