Commit 68d21193 authored by Ivan Mazhukin's avatar Ivan Mazhukin Committed by Vitaly Lipatov

epm play: add --list-updates (eterbug #18624)

parent 0c05f623
...@@ -298,6 +298,82 @@ __epm_play_install_one() ...@@ -298,6 +298,82 @@ __epm_play_install_one()
__epm_play_run "$prescription" --run "$@" || fatal "There was some error during run $prescription script." __epm_play_run "$prescription" --run "$@" || fatal "There was some error during run $prescription script."
fi fi
} }
__get_latest_package_version()
{
local pkg="$1"
local ver
[ -n "$pkg" ] || return 1
ver="$(epm tool eget -q -O- "https://eepm.ru/app-versions/$pkg" 2>/dev/null)"
if [ -n "$ver" ] ; then
echo "$ver"
return 0
fi
return 1
}
__list_available_updates()
{
local installed_table pkg app installed latest cmp header_printed updates_found line
installed_table="$(__get_installed_table)"
[ -n "$installed_table" ] || return 0
updates_found=0
while IFS= read -r line ; do
[ -n "$line" ] || continue
set -- $line
pkg="$1"
app="$2"
[ -n "$pkg" ] || continue
[ -n "$app" ] || continue
installed="$(epm print version for package "$pkg" 2>/dev/null | head -n1)"
[ -n "$installed" ] || continue
latest="$(__get_latest_package_version "$pkg")"
[ -n "$latest" ] || continue
cmp="$(epm print compare package version "$latest" "$installed" 2>/dev/null)"
[ "$cmp" = "1" ] || continue
updates_found=1
if [ -z "$quiet" ] && [ -z "$short" ] && [ -z "$header_printed" ] ; then
echo "Applications with available updates:"
header_printed=1
fi
if [ -n "$short" ] ; then
echo "$app"
continue
fi
if [ -n "$quiet" ] ; then
printf "%s %s %s\n" "$app" "$installed" "$latest"
else
printf " %-25s %s -> %s\n" "$app" "$installed" "$latest"
fi
done <<EOF
$installed_table
EOF
if [ "$updates_found" -eq 0 ] && [ -z "$short" ] && [ -z "$quiet" ] ; then
echo "All installed applications are up to date."
fi
}
__epm_play_install() __epm_play_install()
...@@ -503,6 +579,10 @@ case "$1" in ...@@ -503,6 +579,10 @@ case "$1" in
exit exit
;; ;;
--list-updates)
__list_available_updates
exit
;;
--latest) --latest)
shift shift
export latest="true" export latest="true"
......
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