points/bin/versions_check

161 lines
3.8 KiB
Plaintext
Raw Normal View History

2024-02-22 18:37:43 +01:00
#!/bin/zsh
#
# zsh colors
#
autoload colors && colors
# Proxy
#
proxy=$(systemctl list-sockets --quiet "*proxy*" | head -1 | cut -d' ' -f1)
if [ -n "${proxy}" ]; then
echo "${bg[yellow]}${fg[black]} Using proxy ${fg_bold[black]}${proxy} \n"
export ALL_PROXY="${proxy}"
fi
2024-02-22 18:37:43 +01:00
# asdf, direnv, python & lastversion
#
# - https://github.com/dvershinin/lastversion
#
cd $(dirname $0)
eval $(asdf exec direnv export zsh)
# Debian Package
2024-02-22 18:37:43 +01:00
#
function debian
{
program=$1
repository=$2
apt_name=${3:-$1}
current_version="0.0.0"
2024-02-22 18:37:43 +01:00
echo "\n${bg[red]}${fg[black]}>>>> ${program} ${reset_color}"
# Already installed
#
if (( ${+commands[$program]} )); then
echo "\n${bg[cyan]} Installed ${reset_color}"
2024-02-22 18:37:43 +01:00
prog_out=$(${program} --version)
2024-02-22 18:37:43 +01:00
# Extract version from program's output
current_version=$(lastversion format "${prog_out}")
2024-02-22 18:37:43 +01:00
# Highlight program's version
echo ${prog_out} | grep --colour=always -F "${current_version}"
2024-02-22 18:37:43 +01:00
\ls -lh =${program}
fi
# Repository
#
echo "\n${bg[cyan]} ${repository} ${reset_color}"
# Retrieve latest repository version
repo_version=$(lastversion ${repository} --newer-than ${current_version})
# Check last result code
if [ $? -eq 0 ]; then
echo "${fg[red]}${repo_version}${fg[cyan]} > ${current_version}${reset_color}\n"
echo -n ${repository}/releases
echo "${fg[cyan]}"
lastversion ${repository} --filter="${filter}" --assets
else
echo "${fg[green]}${repo_version}"
fi
echo -n ${reset_color}
2024-02-22 18:37:43 +01:00
# Debian Package
apt_list=$(apt list ${apt_name} 2>/dev/null)
deb_version=$(lastversion format "${apt_list}" 2>/dev/null)
2024-02-22 18:37:43 +01:00
if [ $? -eq 0 ]; then
echo "\n${bg[cyan]} Debian package ${reset_color}"
deb_version=$(lastversion "${deb_version}" --newer-than ${current_version})
if [ $? -eq 0 ]; then
echo "${fg[red]}${deb_version} ${fg[cyan]} > ${current_version}${reset_color}\n"
2024-02-22 18:37:43 +01:00
else
echo "${fg[green]}${deb_version}"
2024-02-22 18:37:43 +01:00
fi
echo -n ${reset_color}
fi
2024-02-22 18:37:43 +01:00
echo
}
# Archive
#
function archive
{
program=$1
repository=$2
2024-06-19 19:06:32 +02:00
current_version=${3:-"0.0.0"}
echo "\n${bg[red]}${fg[black]}>>>> ${program} ${reset_color}"
# Already installed
#
if (( ${+commands[$program]} )); then
echo "\n${bg[cyan]} Installed ${reset_color}"
prog_out=$(${program} --version)
# Extract version from program's output
current_version=$(lastversion format "${prog_out} | head -1 )" 2>/dev/null)
if [ -e ${current_version} ]; then
current_version=$(lastversion format "${prog_out} | grep -o "version=[0-9.]\+")")
fi
2024-02-22 18:37:43 +01:00
# Highlight program's version
echo ${prog_out} | grep --colour=always -F "${current_version}"
\ls -lh =${program}
2024-02-22 18:37:43 +01:00
fi
# Repository
#
echo "\n${bg[cyan]} ${repository} ${reset_color}"
# Retrieve latest repository version
repo_version=$(lastversion ${repository} --newer-than ${current_version})
# Check last result code
if [ $? -eq 0 ]; then
echo "${fg[red]}${repo_version}${fg[cyan]} > ${current_version}${reset_color}\n"
echo -n ${repository}/releases
echo "${fg[cyan]}"
lastversion ${repository} --filter="${filter}" --assets
else
echo "${fg[green]}${repo_version}"
fi
echo ${reset_color}
2024-02-22 18:37:43 +01:00
}
###
filter=amd64\\.deb
2024-02-22 18:37:43 +01:00
debian bat "https://github.com/sharkdp/bat"
debian delta "https://github.com/dandavison/delta" git-delta
2024-02-22 18:37:43 +01:00
debian lsd "https://github.com/lsd-rs/lsd"
filter=Linux_x86_64
archive lazygit https://github.com/jesseduffield/lazygit
archive nvim https://github.com/neovim/neovim
2024-06-19 19:06:32 +02:00
# Fonts
setopt nullglob
fonts=( $(echo /opt/fonts/**/*NerdFont* $HOME/.fonts/**/*NerdFont*) )
if (( ${#fonts} )); then
font_version=$(lastversion format "$(strings ${fonts[1]} | grep -o "Nerd Fonts [0-9.]\\+")")
fi
filter="(JetBrainsMono|NerdFontsSymbolsOnly).tar.xz"
archive "Nerd Fonts" https://github.com/ryanoasis/nerd-fonts "${font_version}"