2023-12-23 20:14:22 -07:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# A base package installer for many systems!
|
|
|
|
# Supported package managers:
|
|
|
|
# - apt (debian/ubuntu)
|
|
|
|
# - dnf (fedora/redhat)
|
|
|
|
# - pacman (arch/endeavour)
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
PACKAGE_MANAGERS = {
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": {
|
|
|
|
"name": "apk",
|
|
|
|
"install_cmd": ["apk", "add"],
|
|
|
|
"check_installed": ["apk", "info", "--installed"],
|
|
|
|
},
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": {
|
|
|
|
"name": "apt",
|
|
|
|
"install_cmd": ["apt", "install"],
|
|
|
|
"check_installed": ["dpkg", "-s"], # Must return 0
|
|
|
|
},
|
|
|
|
"dnf": {
|
|
|
|
"name": "dnf",
|
|
|
|
"install_cmd": ["dnf", "install"],
|
|
|
|
"check_installed": ["dnf", "list"],
|
|
|
|
},
|
|
|
|
"pacman": {
|
|
|
|
"name": "pacman",
|
|
|
|
"install_cmd": ["pacman", "-S"],
|
|
|
|
"check_installed": ["pacman", "-Qi"],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
PACKAGES = [
|
|
|
|
{
|
|
|
|
"global_name": "alacritty",
|
|
|
|
"executable_name": "alacritty",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "alacritty",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "alacritty",
|
|
|
|
"dnf": "alacritty",
|
|
|
|
"pacman": "alacritty",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "bat",
|
|
|
|
"executable_name": "bat",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "bat",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "bat",
|
|
|
|
"dnf": "bat",
|
|
|
|
"pacman": "bat",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "bash",
|
|
|
|
"executable_name": "bash",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "bash",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "bash",
|
|
|
|
"dnf": "bash",
|
|
|
|
"pacman": "bash",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "bash-completion",
|
|
|
|
"apt": "bash-completion",
|
|
|
|
"dnf": "bash-completion",
|
|
|
|
"pacman": "bash-completion",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "calc",
|
|
|
|
"executable_name": "calc",
|
|
|
|
"apt": "calc",
|
|
|
|
"dnf": "calc",
|
|
|
|
"pacman": "calc",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "curl",
|
|
|
|
"executable_name": "curl",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "curl",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "curl",
|
|
|
|
"dnf": "curl",
|
|
|
|
"pacman": "curl",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "dust",
|
|
|
|
"executable_name": "dust",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "dust",
|
2023-12-23 20:14:22 -07:00
|
|
|
"pacman": "dust",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "exa -> eza",
|
|
|
|
"executable_name": "exa",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "exa",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "exa",
|
|
|
|
"dnf": "eza",
|
|
|
|
"pacman": "eza",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "fd-find",
|
|
|
|
"executable_name": "fd",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "fd",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "fd-find",
|
|
|
|
"dnf": "fd-find",
|
|
|
|
"pacman": "fd",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "foliate",
|
|
|
|
"executable_name": "foliate",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "foliate",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "foliate",
|
|
|
|
"dnf": "foliate",
|
|
|
|
"pacman": "foliate",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "fuzzel",
|
|
|
|
"executable_name": "fuzzel",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "fuzzel",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "fuzzel",
|
|
|
|
"dnf": "fuzzel",
|
|
|
|
"pacman": "fuzzel",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "fzf",
|
|
|
|
"executable_name": "fzf",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "fzf",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "fzf",
|
|
|
|
"dnf": "fzf",
|
|
|
|
"pacman": "fzf",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "gawk",
|
|
|
|
"executable_name": "gawk",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "gawk",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "gawk",
|
|
|
|
"dnf": "gawk",
|
|
|
|
"pacman": "gawk",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "git",
|
|
|
|
"executable_name": "git",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "git",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "git",
|
|
|
|
"dnf": "git",
|
|
|
|
"pacman": "git",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "git-lfs",
|
|
|
|
"executable_name": "git-lfs",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "git-lfs",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "git-lfs",
|
|
|
|
"dnf": "git-lfs",
|
|
|
|
"pacman": "git-lfs",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "grim",
|
|
|
|
"executable_name": "grim",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "grim",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "grim",
|
|
|
|
"dnf": "grim",
|
|
|
|
"pacman": "grim",
|
|
|
|
},
|
2024-04-30 23:43:49 -06:00
|
|
|
{
|
|
|
|
"global_name": "kanshi",
|
|
|
|
"executable_name": "kanshictl",
|
|
|
|
"apk": "kanshi",
|
|
|
|
"apt": "kanshi",
|
|
|
|
"dnf": "kanshi",
|
|
|
|
"pacman": "kanshi",
|
|
|
|
},
|
2023-12-23 20:14:22 -07:00
|
|
|
{
|
|
|
|
"global_name": "pass",
|
|
|
|
"executable_name": "pass",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "pass",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "pass",
|
|
|
|
"dnf": "pass",
|
|
|
|
"pacman": "pass",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "slurp",
|
|
|
|
"executable_name": "slurp",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "slurp",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "slurp",
|
|
|
|
"dnf": "slurp",
|
|
|
|
"pacman": "slurp",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "swappy",
|
|
|
|
"executable_name": "swappy",
|
|
|
|
"dnf": "swappy",
|
|
|
|
"pacman": "swappy",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "imv",
|
|
|
|
"executable_name": "imv",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "imv",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "imv",
|
|
|
|
"dnf": "imv",
|
|
|
|
"pacman": "imv",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "jq",
|
|
|
|
"executable_name": "jq",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "jq",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "jq",
|
|
|
|
"dnf": "jq",
|
|
|
|
"pacman": "jq",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "Meslo Nerd font",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "font-meslo-nerd",
|
2023-12-23 20:14:22 -07:00
|
|
|
"pacman": "ttf-meslo-nerd",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "mmv",
|
|
|
|
"executable_name": "mmv",
|
|
|
|
"apt": "mmv",
|
|
|
|
"dnf": "mmv",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "mpv",
|
|
|
|
"executable_name": "mpv",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "mpv",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "mpv",
|
|
|
|
"dnf": "mpv",
|
|
|
|
"pacman": "mpv",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "neofetch",
|
|
|
|
"executable_name": "neofetch",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "neofetch",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "neofetch",
|
|
|
|
"dnf": "neofetch",
|
|
|
|
"pacman": "neofetch",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "neovim",
|
|
|
|
"executable_name": "nvim",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "neovim",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "neovim",
|
|
|
|
"dnf": "neovim",
|
|
|
|
"pacman": "neovim",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "pynvim",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "py3-pynvim",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "python3-pynvim",
|
|
|
|
"dnf": "python3-neovim",
|
|
|
|
"pacman": "python-pynvim",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "ripgrep",
|
|
|
|
"executable_name": "rg",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "ripgrep",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "ripgrep",
|
|
|
|
"dnf": "ripgrep",
|
|
|
|
"pacman": "ripgrep",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "socat",
|
|
|
|
"executable_name": "socat",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "socat",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "socat",
|
|
|
|
"dnf": "socat",
|
|
|
|
"pacman": "socat",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "sway",
|
|
|
|
"executable_name": "sway",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "sway",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "sway",
|
|
|
|
"dnf": "sway",
|
|
|
|
"pacman": "sway",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "swaybg",
|
|
|
|
"executable_name": "swaybg",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "swaybg",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "swaybg",
|
|
|
|
"dnf": "swaybg",
|
|
|
|
"pacman": "swaybg",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "swaylock",
|
|
|
|
"executable_name": "swaylock",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "swaylock",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "swaylock",
|
|
|
|
"dnf": "swaylock",
|
|
|
|
"pacman": "swaylock",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "tealdeer",
|
|
|
|
"executable_name": "tldr",
|
|
|
|
"apt": "tealdeer",
|
|
|
|
"dnf": "tealdeer",
|
|
|
|
"pacman": "tealdeer",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "tmux",
|
|
|
|
"executable_name": "tmux",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "tmux",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "tmux",
|
|
|
|
"dnf": "tmux",
|
|
|
|
"pacman": "tmux",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "udisks2",
|
|
|
|
"executable_name": "udisksctl",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "udisks2",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "udisks2",
|
|
|
|
"dnf": "udisks2",
|
|
|
|
"pacman": "udisks2",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "vifm",
|
|
|
|
"executable_name": "vifm",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "vifm",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "vifm",
|
|
|
|
"dnf": "vifm",
|
|
|
|
"pacman": "vifm",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "viu",
|
|
|
|
"executable_name": "viu",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "viu",
|
2023-12-23 20:14:22 -07:00
|
|
|
"pacman": "viu",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "wl-clipboard",
|
|
|
|
"executable_name": "wl-copy",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "wl-clipboard",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "wl-clipboard",
|
|
|
|
"dnf": "wl-clipboard",
|
|
|
|
"pacman": "wl-clipboard",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "wlsunset",
|
|
|
|
"executable_name": "wlsunset",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "wlsunset",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "wlsunset",
|
|
|
|
"dnf": "wlsunset",
|
|
|
|
"pacman": "wlsunset",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "wtype",
|
|
|
|
"executable_name": "wtype",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "wtype",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "wtype",
|
|
|
|
"dnf": "wtype",
|
|
|
|
"pacman": "wtype",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "ydotool",
|
|
|
|
"executable_name": "ydotool",
|
|
|
|
"apt": "ydotool",
|
|
|
|
"dnf": "ydotool",
|
|
|
|
"pacman": "ydotool",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "zathura-pdf-mupdf",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "zathura-pdf-mupdf",
|
2023-12-23 20:14:22 -07:00
|
|
|
"dnf": "zathura-pdf-mupdf",
|
|
|
|
"pacman": "zathura-pdf-mupdf",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"global_name": "zathura",
|
|
|
|
"executable_name": "zathura",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apk": "zathura",
|
2023-12-23 20:14:22 -07:00
|
|
|
"apt": "zathura",
|
|
|
|
"dnf": "zathura",
|
|
|
|
"pacman": "zathura",
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
WEB_INSTALLS = [
|
|
|
|
{
|
|
|
|
"name": "git prompt for bash",
|
|
|
|
"dest": f"{os.environ['HOME']}/.git-prompt.bash",
|
|
|
|
"url": "https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Git completion for bash",
|
|
|
|
"dest": f"{os.environ['HOME']}/.git-completion.bash",
|
|
|
|
"url": "https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Fzf completion for bash",
|
|
|
|
"dest": f"{os.environ['HOME']}/.fzf.bash",
|
|
|
|
"url": "https://raw.githubusercontent.com/junegunn/fzf/master/shell/completion.bash",
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2023-12-23 20:14:22 -07:00
|
|
|
|
2023-12-23 20:14:22 -07:00
|
|
|
def extra_installs():
|
|
|
|
rustup_cmd = [
|
2023-12-23 20:14:22 -07:00
|
|
|
"bash",
|
|
|
|
"-c",
|
|
|
|
"curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh",
|
2023-12-23 20:14:22 -07:00
|
|
|
]
|
|
|
|
|
|
|
|
tmp_cmds = [
|
|
|
|
[
|
|
|
|
"git",
|
|
|
|
"clone",
|
|
|
|
"--depth",
|
|
|
|
"1",
|
|
|
|
"https://github.com/tmux-plugins/tpm",
|
|
|
|
f"{os.environ['HOME']}/.config/tmux/plugins/tpm",
|
|
|
|
],
|
|
|
|
[f"{os.environ['HOME']}/.config/tmux/plugins/tpm/tpm"],
|
|
|
|
[f"{os.environ['HOME']}/.config/tmux/plugins/tpm/bin/install_plugins"],
|
|
|
|
[f"{os.environ['HOME']}/.config/tmux/plugins/tpm/tpm"],
|
|
|
|
]
|
|
|
|
|
|
|
|
if not shutil.which("rustc") and prompt_user("rustup"):
|
|
|
|
subprocess.call(rustup_cmd)
|
|
|
|
|
2023-12-23 20:14:22 -07:00
|
|
|
has_tmp = os.path.exists(f"{os.environ['HOME']}/.config/tmux/plugins/tpm/tpm")
|
2023-12-23 20:14:22 -07:00
|
|
|
|
|
|
|
if not has_tmp and prompt_user("tmp, tmux's package manager"):
|
|
|
|
success = subprocess.call(tmp_cmds[0]) == 0
|
|
|
|
|
|
|
|
if success:
|
|
|
|
success = subprocess.call(tmp_cmds[1]) == 0
|
|
|
|
if success:
|
|
|
|
success = subprocess.call(tmp_cmds[2]) == 0
|
|
|
|
if success:
|
|
|
|
success = subprocess.call(tmp_cmds[3]) == 0
|
|
|
|
|
|
|
|
|
|
|
|
def find_package_manager():
|
|
|
|
global PACKAGE_MANAGERS
|
|
|
|
|
2023-12-23 20:14:22 -07:00
|
|
|
if shutil.which("apk"):
|
|
|
|
return PACKAGE_MANAGERS["apk"]
|
|
|
|
elif shutil.which("apt"):
|
2023-12-23 20:14:22 -07:00
|
|
|
return PACKAGE_MANAGERS["apt"]
|
|
|
|
elif shutil.which("dnf"):
|
|
|
|
return PACKAGE_MANAGERS["dnf"]
|
|
|
|
elif shutil.which("pacman"):
|
|
|
|
return PACKAGE_MANAGERS["pacman"]
|
|
|
|
else:
|
|
|
|
raise Exception("Supported package manager not found")
|
|
|
|
|
2023-12-23 20:14:22 -07:00
|
|
|
|
2023-12-23 20:14:22 -07:00
|
|
|
def check_installed(pkg, apt):
|
2023-12-23 20:14:22 -07:00
|
|
|
if pkg.get("executable_name") and shutil.which(pkg["executable_name"]):
|
2023-12-23 20:14:22 -07:00
|
|
|
return "true"
|
2023-12-23 20:14:22 -07:00
|
|
|
elif not pkg.get(apt["name"]):
|
2023-12-23 20:14:22 -07:00
|
|
|
return "unavailable"
|
|
|
|
|
|
|
|
check_cmd = list(apt["check_installed"])
|
2023-12-23 20:14:22 -07:00
|
|
|
check_cmd.append(pkg[apt["name"]])
|
2023-12-23 20:14:22 -07:00
|
|
|
|
|
|
|
check = subprocess.Popen(
|
|
|
|
check_cmd,
|
|
|
|
stdin=subprocess.DEVNULL,
|
|
|
|
stdout=subprocess.DEVNULL,
|
|
|
|
stderr=subprocess.DEVNULL,
|
|
|
|
)
|
|
|
|
|
|
|
|
check.wait()
|
|
|
|
if check.returncode == 0:
|
|
|
|
return "true"
|
|
|
|
else:
|
|
|
|
return "false"
|
|
|
|
|
2023-12-23 20:14:22 -07:00
|
|
|
|
2023-12-23 20:14:22 -07:00
|
|
|
def prompt_user(pkg_name):
|
|
|
|
while True:
|
|
|
|
user_in = input(f"Install {pkg_name}? (Y/n) ")
|
|
|
|
|
2023-12-23 20:14:22 -07:00
|
|
|
if user_in == "" or user_in[0].lower() == "y":
|
2023-12-23 20:14:22 -07:00
|
|
|
return True
|
2023-12-23 20:14:22 -07:00
|
|
|
elif user_in[0].lower() == "n":
|
2023-12-23 20:14:22 -07:00
|
|
|
return False
|
|
|
|
|
2023-12-23 20:14:22 -07:00
|
|
|
|
2023-12-23 20:14:22 -07:00
|
|
|
def install_package(apt, package):
|
2023-12-23 20:14:22 -07:00
|
|
|
install_cmd = list(apt["install_cmd"])
|
|
|
|
install_cmd.append(package[apt["name"]])
|
2023-12-23 20:14:22 -07:00
|
|
|
|
|
|
|
install = subprocess.call(install_cmd)
|
|
|
|
|
2023-12-23 20:14:22 -07:00
|
|
|
return install == 0
|
2023-12-23 20:14:22 -07:00
|
|
|
|
|
|
|
|
|
|
|
def install_packages(apt):
|
|
|
|
global PACKAGES
|
|
|
|
|
|
|
|
for package in PACKAGES:
|
2023-12-23 20:14:22 -07:00
|
|
|
pkg_name = package["global_name"]
|
2023-12-23 20:14:22 -07:00
|
|
|
installed = check_installed(package, apt)
|
|
|
|
|
|
|
|
if installed == "unavailable":
|
|
|
|
print(f"≠ Cannot install {pkg_name} with {apt['name']}")
|
|
|
|
elif installed == "true":
|
|
|
|
print(f"✓ Already installed {pkg_name}")
|
|
|
|
elif prompt_user(pkg_name):
|
|
|
|
if install_package(apt, package):
|
|
|
|
print(f"★ Newly installed {pkg_name}")
|
|
|
|
else:
|
|
|
|
print(f"✗ Failed to install {pkg_name}")
|
|
|
|
else:
|
|
|
|
print(f"φ Not installing {pkg_name}")
|
|
|
|
|
2023-12-23 20:14:22 -07:00
|
|
|
|
2023-12-23 20:14:22 -07:00
|
|
|
def web_installs():
|
|
|
|
global WEB_INSTALLS
|
|
|
|
|
|
|
|
for package in WEB_INSTALLS:
|
2023-12-23 20:14:22 -07:00
|
|
|
if not os.path.exists(package["dest"]) and prompt_user(package["name"]):
|
2023-12-23 20:14:23 -07:00
|
|
|
subprocess.call([
|
2023-12-23 20:14:22 -07:00
|
|
|
"curl",
|
|
|
|
"--output",
|
2023-12-23 20:14:22 -07:00
|
|
|
package["dest"],
|
|
|
|
package["url"],
|
2023-12-23 20:14:23 -07:00
|
|
|
])
|
2023-12-23 20:14:22 -07:00
|
|
|
|
|
|
|
|
2023-12-23 20:14:22 -07:00
|
|
|
if __name__ == "__main__":
|
2023-12-23 20:14:22 -07:00
|
|
|
try:
|
|
|
|
apt = find_package_manager()
|
|
|
|
print(f"Identified `{apt['name']}` as system package manager")
|
|
|
|
|
|
|
|
install_packages(apt)
|
|
|
|
|
|
|
|
if shutil.which("curl"):
|
|
|
|
web_installs()
|
|
|
|
extra_installs()
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
print("\nExiting installation. Feel free to restart where you left off")
|