Commit b2c4caff authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm play: improve list and description out

parent 7e33ee9b
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2015, 2017, 2019, 2020 Etersoft # Copyright (C) 2015, 2017, 2019, 2020, 2022 Etersoft
# Copyright (C) 2015, 2017, 2019, 2020 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2015, 2017, 2019, 2020, 2022 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
# TODO # TODO
epm_vardir=/var/lib/eepm epm_vardir=/var/lib/eepm
__save_installed_app() __save_installed_app()
{ {
[ -d "$epm_vardir" ] || return 0 [ -d "$epm_vardir" ] || return 0
...@@ -48,6 +49,11 @@ __list_installed_app() ...@@ -48,6 +49,11 @@ __list_installed_app()
cat $epm_vardir/installed-app 2>/dev/null cat $epm_vardir/installed-app 2>/dev/null
} }
__get_app_description()
{
[ -x "$1" ] || return
$1 --description 2>/dev/null
}
__epm_play_run() __epm_play_run()
{ {
...@@ -89,6 +95,7 @@ EOF ...@@ -89,6 +95,7 @@ EOF
exit exit
fi fi
if [ "$1" = "--remove" ] ; then if [ "$1" = "--remove" ] ; then
shift shift
#__check_installed_app "$1" || warning "$1 is not installed" #__check_installed_app "$1" || warning "$1 is not installed"
...@@ -99,6 +106,7 @@ if [ "$1" = "--remove" ] ; then ...@@ -99,6 +106,7 @@ if [ "$1" = "--remove" ] ; then
exit exit
fi fi
if [ "$1" = "--update" ] ; then if [ "$1" = "--update" ] ; then
shift shift
if [ "$1" = "all" ] ; then if [ "$1" = "all" ] ; then
...@@ -111,7 +119,7 @@ if [ "$1" = "--update" ] ; then ...@@ -111,7 +119,7 @@ if [ "$1" = "--update" ] ; then
exit exit
fi fi
if [ -z "$1" ] ; then if [ -z "$1" ] ; then
fatal "run --update with 'all' or project name" fatal "run --update with 'all' or a project name"
fi fi
__check_installed_app "$1" || fatal "$1 is not installed" __check_installed_app "$1" || fatal "$1 is not installed"
prescription="$1" prescription="$1"
...@@ -120,6 +128,7 @@ if [ "$1" = "--update" ] ; then ...@@ -120,6 +128,7 @@ if [ "$1" = "--update" ] ; then
exit exit
fi fi
if [ "$1" = "--list" ] || [ "$1" = "--installed" ] ; then if [ "$1" = "--list" ] || [ "$1" = "--installed" ] ; then
shift shift
local i local i
...@@ -131,37 +140,42 @@ if [ "$1" = "--list" ] || [ "$1" = "--installed" ] ; then ...@@ -131,37 +140,42 @@ if [ "$1" = "--list" ] || [ "$1" = "--installed" ] ; then
fi fi
echo "Installed:" echo "Installed:"
for i in $(__list_installed_app) ; do for i in $(__list_installed_app) ; do
printf " %-20s - %s\n" "$i" "$($psdir/$i.sh --description 2>/dev/null)" local desc="$(__get_app_description $psdir/$i.sh)"
[ -n "$desc" ] || continue
printf " %-20s - %s\n" "$i" "$desc"
done done
exit exit
fi fi
[ "($DISTRVENDOR -a)" = "x86_64" ] && IGNOREi586='' || IGNOREi586=1 [ "$($DISTRVENDOR -a)" = "x86_64" ] && IGNOREi586='' || IGNOREi586=1
if [ "$1" = "--list-all" ] || [ -z "$*" ] ; then if [ "$1" = "--list-all" ] || [ -z "$*" ] ; then
echo "Run with a name of a play script to run:"
local i local i
local desc
if [ -n "$short" ] ; then if [ -n "$short" ] ; then
for i in $psdir/*.sh ; do for i in $psdir/*.sh ; do
# print all
#desc="$($i --description 2>/dev/null)"
#[ -z "$desc" ] && continue
local name=$(basename $i .sh) local name=$(basename $i .sh)
[ -n "$IGNOREi586" ] && rhas "$name" "^i586-" && continue [ -n "$IGNOREi586" ] && rhas "$name" "^i586-" && continue
rhas "$name" "^common" && continue
echo "$name" echo "$name"
done done
exit exit
fi fi
echo "Run with a name of a play script to run:"
for i in $psdir/*.sh ; do for i in $psdir/*.sh ; do
desc="$($i --description 2>/dev/null)" local desc="$(__get_app_description $i)"
[ -z "$desc" ] && continue [ -n "$desc" ] || continue
local name=$(basename $i .sh) local name=$(basename $i .sh)
[ -n "$IGNOREi586" ] && rhas "$name" "^i586-" && continue [ -n "$IGNOREi586" ] && rhas "$name" "^i586-" && continue
rhas "$name" "^common" && continue
printf " %-20s - %s\n" "$name" "$desc" printf " %-20s - %s\n" "$name" "$desc"
done done
echo echo
echo "run epm play --list to list installed only, or --remove to remove one, or --update to update [all] installed apps" echo "run epm play"
echo " --list - to list installed only"
echo " --list-all (default) - to list all app"
echo " --remove <app> - to remove app"
echo " --update <app|all> - to update app or all installed apps"
echo " --short (with --list) - list names only"
exit exit
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment