homebrew.sh

Feature:
-mask ‘Updating pkg/cask’ if no update awailable

Bugfix:
-display multiples versions (i e python@3.9)
This commit is contained in:
2021-01-11 09:34:16 +01:00
parent 9a9bf77fb7
commit e6c7db1711

View File

@@ -106,6 +106,14 @@ get_info_pkg() {
installed=$(echo "$info" | jq -r '.[] | select(.name == "'${pkg}'") | (.installed)' | jq -r '.[].version') installed=$(echo "$info" | jq -r '.[] | select(.name == "'${pkg}'") | (.installed)' | jq -r '.[].version')
pinned=$(echo "$info" | jq -r '.[] | select(.name == "'${pkg}'") | (.pinned)') pinned=$(echo "$info" | jq -r '.[] | select(.name == "'${pkg}'") | (.pinned)')
# Python@3.9 : multiples versions
ins=""
for i in $installed
do
ins=$i
done
installed=$ins
if [ "$pinned" = "true" ]; then if [ "$pinned" = "true" ]; then
pinned_v=$(echo "$upd_package" | jq -r '.[] | select(.name == "'${pkg}'") | (.pinned_version)') pinned_v=$(echo "$upd_package" | jq -r '.[] | select(.name == "'${pkg}'") | (.pinned_version)')
@@ -195,11 +203,12 @@ fi
touch /tmp/checkpoint touch /tmp/checkpoint
# Updating packages # Updating packages
echo -e "\n🍺 ${underline}Updating packages...${reset}\n"
[ -n "$upd_pkg_notpinned" ] && echo -e "${red}Pinned: $upd_pkg_pinned . It won't be updated!'${reset}\n"
if [ -n "$upd_pkg_notpinned" ]; then if [ -n "$upd_pkg_notpinned" ]; then
echo -e "\n🍺 ${underline}Updating packages...${reset}\n"
[ -n "$pkg_pinned" ] && echo -e "${red}Pinned: $upd_pkg_pinned . It won't be updated!'${reset}\n"
if [ "$no_distract" = false ]; then if [ "$no_distract" = false ]; then
a=$(echo -e "Do you wanna run ${bold}brew upgrade "$upd_pkg_notpinned"${reset} ? (y/n/a) ") a=$(echo -e "Do you wanna run ${bold}brew upgrade "$upd_pkg_notpinned"${reset} ? (y/n/a) ")
# yes/no/all # yes/no/all
@@ -290,6 +299,9 @@ fi
#Casks update #Casks update
echo -e "🍺 ${underline}Search for casks update...${reset}\n" echo -e "🍺 ${underline}Search for casks update...${reset}\n"
[ -n "$casks_latest_not_pinned" ] && echo -e "Some Casks have ${italic}auto_updates true${reset} or ${italic}version :latest${reset}. Homebrew Cask cannot track versions of those apps."
[ -n "$casks_latest_not_pinned" ] && echo -e "Edit this script and change the setting ${italic}latest=false${reset} to ${italic}true${reset}\n"
# Find infos about updated casks # Find infos about updated casks
nb_casks_upd=$(echo "$upd_casks" | wc -w | xargs) nb_casks_upd=$(echo "$upd_casks" | wc -w | xargs)
if [ "$nb_casks_upd" -gt 0 ]; then if [ "$nb_casks_upd" -gt 0 ]; then
@@ -305,41 +317,40 @@ if [ "$nb_casks_upd" -gt 0 ]; then
else else
[ "$nb_casks_upd" -gt 1 ] && echo -e "${box} $nb_casks_upd ${reset} ${array[@]/%/s}: ${bold}$upd_casks${reset}" || echo -e "${box} $nb_casks_upd ${reset} ${array[@]}: ${bold}$upd_casks${reset}" [ "$nb_casks_upd" -gt 1 ] && echo -e "${box} $nb_casks_upd ${reset} ${array[@]/%/s}: ${bold}$upd_casks${reset}" || echo -e "${box} $nb_casks_upd ${reset} ${array[@]}: ${bold}$upd_casks${reset}"
fi fi
fi
# Updating casks
echo -e "\n🍺 ${underline}Updating casks...${reset}\n"
[ "${#cask_to_not_update[@]}" -gt 0 ] && echo -e "${red}Do not update: ${cask_to_not_update[@]} . It won't be updated!'${reset}\n"
[ -n "$casks_latest_not_pinned" ] && echo -e "Some Casks have ${italic}auto_updates true${reset} or ${italic}version :latest${reset}. Homebrew Cask cannot track versions of those apps."
[ -n "$casks_latest_not_pinned" ] && echo -e "Edit this script and change the setting ${italic}latest=false${reset} to ${italic}true${reset}\n"
if [ -n "$casks_not_pinned" ]; then # Updating casks
echo -e "\n🍺 ${underline}Updating casks...${reset}\n"
if [ "$no_distract" = false ]; then [ "${#cask_to_not_update[@]}" -gt 0 ] && echo -e "${red}Do not update: ${cask_to_not_update[@]} . It won't be updated!'${reset}\n"
a=$(echo -e "Do you wanna run ${bold}brew upgrade $casks_not_pinned${reset} ? (y/n/a) ")
# yes/no/all
read -p "$a" choice
if [ "$choice" == "y" ] || [ "$choice" == "Y" ] || [ "$choice" == "a" ] || [ "$choice" == "A" ]; then
echo "" if [ -n "$casks_not_pinned" ]; then
for i in $casks_not_pinned;
do if [ "$no_distract" = false ]; then
if [ "$choice" == "y" ] || [ "$choice" == "Y" ]; then a=$(echo -e "Do you wanna run ${bold}brew upgrade $casks_not_pinned${reset} ? (y/n/a) ")
# --cask required for Cask like 'docker'. It can be a formula or a cask. # yes/no/all
echo "$i" | xargs -p -n 1 brew upgrade --cask read -p "$a" choice
echo ""
elif [ "$choice" == "a" ] || [ "$choice" == "A" ]; then if [ "$choice" == "y" ] || [ "$choice" == "Y" ] || [ "$choice" == "a" ] || [ "$choice" == "A" ]; then
echo "$i" | xargs -n 1 brew upgrade --cask echo ""
echo "" for i in $casks_not_pinned;
fi do
done if [ "$choice" == "y" ] || [ "$choice" == "Y" ]; then
# --cask required for Cask like 'docker'. It can be a formula or a cask.
echo "$i" | xargs -p -n 1 brew upgrade --cask
echo ""
elif [ "$choice" == "a" ] || [ "$choice" == "A" ]; then
echo "$i" | xargs -n 1 brew upgrade --cask
echo ""
fi
done
else
echo -e "OK, let's continue..."
fi
else else
echo -e "OK, let's continue..." echo "$casks_not_pinned" | xargs -n 1 brew upgrade --cask
fi fi
else
echo "$casks_not_pinned" | xargs -n 1 brew upgrade --cask
fi fi
else else