dotfiles/os/apt_utils.fish

54 lines
1.5 KiB
Fish
Raw Normal View History

2024-01-30 20:18:54 -08:00
#!/usr/bin/env fish
source "$DOT/script/utils.fish"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2024-01-31 20:15:12 -08:00
function apt_package_is_installed -a pkg
2024-02-03 12:05:02 -08:00
dpkg -s "$pkg" &>/dev/null
2024-01-30 20:18:54 -08:00
end
2024-01-31 20:15:12 -08:00
function apt_install -a pkg_readable_name pkg args
2024-02-03 12:05:02 -08:00
if ! package_is_installed "$pkg"
execute \
"sudo apt-get install --allow-authenticated -qqy $args $pkg" "$pkg_readable_name"
# suppress output ─┘│
# assume "yes" as the answer to all prompts ──┘
else
print_success "$pkg_readable_name"
end
2024-01-30 20:18:54 -08:00
end
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2024-01-31 20:15:12 -08:00
function apt_add_key -a key
2024-02-03 12:05:02 -08:00
wget -q0 - "$key" | sudo apt-key add - &>/dev/null
# │└─ write output to file
# └─ don't show output
2024-01-30 20:18:54 -08:00
end
2024-01-31 20:15:12 -08:00
function apt_add_ppa -a ppa
2024-02-03 12:05:02 -08:00
sudo add-apt-repository -y ppa:"$ppa" &>/dev/null
2024-01-30 20:18:54 -08:00
end
2024-01-31 20:15:12 -08:00
function apt_add_to_source_list -a source list
2024-02-03 12:05:02 -08:00
sudo sh -c "printf 'deb $source' >> '/etc/apt/sources.list.d/$list'"
2024-01-30 20:18:54 -08:00
end
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function apt_update
2024-02-03 12:05:02 -08:00
execute "sudo apt-get update -qqy" "APT (update)"
2024-01-30 20:18:54 -08:00
end
function apt_upgrade
2024-02-03 12:05:02 -08:00
execute \
"export DEBIAN_FRONTEND=\"noninteractive\" \
2024-01-30 20:18:54 -08:00
&& sudo apt-get -o Dpkg::Options::=\"--force-confnew\" upgrade -qqy" \
2024-02-03 12:05:02 -08:00
"APT (upgrade)"
2024-01-30 20:18:54 -08:00
end
function apt_autoremove
2024-02-03 12:05:02 -08:00
execute "sudo apt-get autoremove -qqy" "APT (autoremove)"
2024-01-30 20:18:54 -08:00
end