mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 09:13:37 +02:00
pkg-manager.sh: Replace by jw-pkg.py distro
Retire pkg-manager.sh and replace it by the cleaner "jw-pkg.sh distro" command, essentially providing the same functionality and nearly the same command-line interface. Not-so-fun-fact: jw-pkg > git diff --stat jw-devops/master ... 71 files changed, 732 insertions(+), 340 deletions(-) 400 LOC more. That's what the move from a shell script to the more maintainable Python versions costs. Still a good idea, and the enhanced extensibility might pay off in terms of LOC with other shell scripts in the future. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
45af308ae6
commit
b8e8ecf2f1
3 changed files with 11 additions and 181 deletions
|
|
@ -1,168 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
log()
|
||||
{
|
||||
echo $@ >&2
|
||||
}
|
||||
|
||||
err()
|
||||
{
|
||||
echo $@ >&2
|
||||
}
|
||||
|
||||
fatal()
|
||||
{
|
||||
err "Giving up: $@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
cat<<-EOT
|
||||
$myname cmd args
|
||||
EOT
|
||||
}
|
||||
|
||||
run()
|
||||
{
|
||||
log "Running ==== $@"
|
||||
"$@"
|
||||
}
|
||||
|
||||
cmd_dup()
|
||||
{
|
||||
local env opts global_opts
|
||||
local non_interactive
|
||||
|
||||
set -- `getopt 'y' $*`
|
||||
while [ "$1" != -- ] ; do
|
||||
case "$1" in
|
||||
-y)
|
||||
non_interactive=1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
[ "$sudo" ] && sudo="$sudo $env -S"
|
||||
|
||||
case $ID in
|
||||
opensuse|suse)
|
||||
[ "$non_interactive" = 1 ] && {
|
||||
opts="--force-resolution --auto-agree-with-licenses"
|
||||
global_opts="$global_opts --non-interactive --gpg-auto-import-keys --no-gpg-checks"
|
||||
}
|
||||
run $sudo zypper $global_opts dup $opts "$@"
|
||||
;;
|
||||
debian|ubuntu|raspbian)
|
||||
fatal "Tried to run distribution upgrade on unsupported platform \"$ID\""
|
||||
;;
|
||||
arch)
|
||||
fatal "Tried to run distribution upgrade on unsupported platform \"$ID\""
|
||||
;;
|
||||
centos)
|
||||
fatal "Tried to run distribution upgrade on unsupported platform \"$ID\""
|
||||
;;
|
||||
*)
|
||||
fatal "Tried to install on unsupported platform \"$ID\""
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
cmd_install()
|
||||
{
|
||||
local env opts global_opts
|
||||
local non_interactive
|
||||
|
||||
set -- `getopt 'y' $*`
|
||||
while [ "$1" != -- ] ; do
|
||||
case "$1" in
|
||||
-y)
|
||||
non_interactive=1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
[ "$sudo" ] && sudo="$sudo $env -S"
|
||||
|
||||
case $ID in
|
||||
opensuse|suse)
|
||||
[ "$non_interactive" = 1 ] && {
|
||||
opts="--force-resolution --auto-agree-with-licenses"
|
||||
global_opts="$global_opts --non-interactive --gpg-auto-import-keys --no-gpg-checks"
|
||||
}
|
||||
run $sudo zypper $global_opts install $opts "$@"
|
||||
;;
|
||||
debian|ubuntu|raspbian)
|
||||
[ "$non_interactive" = 1 ] && {
|
||||
global_opts="$global_opts -yq"
|
||||
env="$env DEBIAN_FRONTEND=noninteractive"
|
||||
}
|
||||
run $sudo apt-get $global_opts install "$@"
|
||||
;;
|
||||
arch)
|
||||
[ "$non_interactive" = 1 ] && {
|
||||
global_opts="$global_opts --noconfirm"
|
||||
env="$env DEBIAN_FRONTEND=noninteractive"
|
||||
}
|
||||
run $sudo pacman $global_opts -S --needed "$@"
|
||||
;;
|
||||
centos)
|
||||
run $sudo yum $global_opts install -y "$@"
|
||||
;;
|
||||
*)
|
||||
fatal "Tried to install on unsupported platform \"$ID\""
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
cmd_refresh()
|
||||
{
|
||||
local env opts global_opts
|
||||
local non_interactive
|
||||
|
||||
set -- `getopt 'y' $*`
|
||||
while [ "$1" != -- ] ; do
|
||||
case "$1" in
|
||||
-y)
|
||||
non_interactive=1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
[ "$sudo" ] && sudo="$sudo $env -S"
|
||||
|
||||
case $ID in
|
||||
opensuse|suse)
|
||||
[ "$non_interactive" = 1 ] && {
|
||||
global_opts="$global_opts --non-interactive --gpg-auto-import-keys --no-gpg-checks"
|
||||
}
|
||||
run $sudo zypper $global_opts refresh $opts "$@"
|
||||
;;
|
||||
debian|ubuntu|raspbian)
|
||||
run $sudo apt-get $global_opts update "$@"
|
||||
;;
|
||||
centos)
|
||||
run $sudo yum $global_opts clean expire-cache "$@"
|
||||
run $sudo yum $global_opts makecache "$@"
|
||||
;;
|
||||
*)
|
||||
fatal "Tried to update unsupported platform \"$ID\""
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# -- here we go
|
||||
myname=`basename $0`
|
||||
. /etc/os-release
|
||||
ID=${ID%%-*}
|
||||
[ "$EUID" ] || EUID=$(id -un)
|
||||
[ "$EUID" = 0 ] || sudo=/usr/bin/sudo
|
||||
cmd="$1"
|
||||
shift
|
||||
cmd_$cmd "$@"
|
||||
Loading…
Add table
Add a link
Reference in a new issue