Enhance package manager update script to include nixos-rebuild and reorganize flatpak check
This commit is contained in:
26
scripts/p.sh
26
scripts/p.sh
@@ -52,8 +52,11 @@ p() (
|
|||||||
if [[ ${packageManagers[@]} =~ "nix" ]]; then
|
if [[ ${packageManagers[@]} =~ "nix" ]]; then
|
||||||
printf "%b\n" "${YELLOW}Updating nix...${ENDCOLOR}"
|
printf "%b\n" "${YELLOW}Updating nix...${ENDCOLOR}"
|
||||||
nix-channel --update
|
nix-channel --update
|
||||||
sudo nix-channel --update
|
|
||||||
nix-collect-garbage --delete-older-than 7d
|
nix-collect-garbage --delete-older-than 7d
|
||||||
|
if command -v nixos-rebuild >/dev/null 2>&1; then
|
||||||
|
sudo nix-channel --update
|
||||||
|
sudo nixos-rebuild switch
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [[ ${packageManagers[@]} =~ "brew" ]]; then
|
if [[ ${packageManagers[@]} =~ "brew" ]]; then
|
||||||
printf "%b\n" "${YELLOW}Updating brew...${ENDCOLOR}"
|
printf "%b\n" "${YELLOW}Updating brew...${ENDCOLOR}"
|
||||||
@@ -98,15 +101,6 @@ p() (
|
|||||||
checkP() {
|
checkP() {
|
||||||
app_name=$(echo "$1" | tr '[:upper:]' '[:lower:]')
|
app_name=$(echo "$1" | tr '[:upper:]' '[:lower:]')
|
||||||
app_name=$(echo "$app_name" | tr " " -)
|
app_name=$(echo "$app_name" | tr " " -)
|
||||||
|
|
||||||
if [[ ${packageManagers[@]} =~ "flatpak" ]]; then
|
|
||||||
flatpak_apps=$(flatpak list --columns=application)
|
|
||||||
echo $flatpak_apps | grep -iq $app_name
|
|
||||||
flatpak_success=$?
|
|
||||||
if [[ $flatpak_success == 0 ]]; then
|
|
||||||
printf "%b\n" "${GREEN}${BOLD}Flatpak:${ENDCOLOR}${GREEN} $(echo "$flatpak_apps" | tr ' ' '\n' | grep -i "$app_name")${ENDCOLOR}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# Some package names are different from the command name
|
# Some package names are different from the command name
|
||||||
case "$app_name" in
|
case "$app_name" in
|
||||||
neovim)
|
neovim)
|
||||||
@@ -128,13 +122,23 @@ p() (
|
|||||||
commandName="$app_name"
|
commandName="$app_name"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
if [[ ${packageManagers[@]} =~ "flatpak" ]]; then
|
||||||
|
flatpak_apps=$(flatpak list --columns=application)
|
||||||
|
echo $flatpak_apps | grep -iq $app_name
|
||||||
|
flatpak_success=$?
|
||||||
|
if [[ $flatpak_success == 0 ]]; then
|
||||||
|
printf "%b\n" "${GREEN}${BOLD}Flatpak:${ENDCOLOR}${GREEN} $(echo "$flatpak_apps" | tr ' ' '\n' | grep -i "$app_name")${ENDCOLOR}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
which "$commandName" &>/dev/null
|
which "$commandName" &>/dev/null
|
||||||
distro_success=$?
|
distro_success=$?
|
||||||
if [[ $distro_success == 0 ]]; then
|
if [[ $distro_success == 0 ]]; then
|
||||||
printf "%b\n" "${GREEN}${BOLD}Distro:${ENDCOLOR}${GREEN} $app_name is installed.${ENDCOLOR}"
|
printf "%b\n" "${GREEN}${BOLD}Distro:${ENDCOLOR}${GREEN} $app_name is installed.${ENDCOLOR}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $flatpak_success != 0 && $nix_success != 0 && $brew_success != 0 && $distro_success != 0 ]]; then
|
if [[ $flatpak_success != 0 && $distro_success != 0 ]]; then
|
||||||
printf "%b\n" "${YELLOW}$app_name not installed.${ENDCOLOR}"
|
printf "%b\n" "${YELLOW}$app_name not installed.${ENDCOLOR}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user