void.sh: overhaul script, add new stuff

Use a list structure instead of install commands.
This commit is contained in:
Érico Rolim 2020-05-15 22:27:22 -03:00
parent 8e54c85904
commit 20b746e704
1 changed files with 214 additions and 359 deletions

View File

@ -1,369 +1,224 @@
#!/usr/bin/env bash
# _
# ___ _ __ (_) ___ ___ _ __ _ __
# / _ \| '__|| | / __| / _ \ | '_ \ | '__|
# | __/| | | || (__ | (_) || | | || |
# \___||_| |_| \___| \___/ |_| |_||_|
#
# _
# ___ _ __(_) ___ ___ _ __ _ __
# / _ \ '__| |/ __/ _ \| '_ \| '__|
# | __/ | | | (_| (_) | | | | |
# \___|_| |_|\___\___/|_| |_|_|
#
# install script for Void based systems
function base () {
xbps-install \
chrony \
elogind \
iwd \
vsv
}
function base_desc () {
echo "Install base system utilities."
}
function luks () {
xbps_install cryptsetup
}
function luks_desc () {
echo "Install support for LUKS."
}
function uefi_bundle () {
xbps-install \
binutils \
gummiboot \
sbsigntool
}
function uefi_bundle_desc () {
echo "Install tools for creating UEFI bundles."
}
function disk_tools () {
xbps-install fscrypt udisks2
}
function disk_tools_desc () {
echo "Install fscrypt and UDisks2"
}
function refind () {
xbps-install refind
}
function refind_desc () {
echo "Install rEFInd boot manager. Necessary when it's the only system on a device."
}
function zfs () {
xbps-install zfs zfsbootmenu
}
function zfs_desc () {
echo "Install support for ZFS."
}
function security () {
xbps-install apparmor
}
function security_desc () {
echo "Install security related packages."
}
function popcorn () {
xbps-install PopCorn
}
function popcorn_desc () {
echo "Install PopCorn usage statistics."
}
function term () {
xbps-install \
bat \
bmon \
curl \
fd \
fish-shell \
gnupg2 \
htop \
mdcat \
neovim \
python3 \
p7zip \
ranger \
ripgrep \
starship \
stow \
tmux \
xtools \
xz \
zstd \
zip \
bsdunzip \
bsdtar
}
function term_desc () {
echo "Install basic terminal utilities."
}
function intel () {
xbps-install \
intel-gpu-tools \
libva-intel-driver \
intel-media-driver \
mesa-intel-dri
}
function intel_desc () {
echo "Install packages for media decode and GPU stuff in Intel-land."
}
function fonts () {
xbps-install \
font-awesome5 \
font-fira-ttf \
font-ibm-plex-ttf \
liberation-fonts-ttf \
noto-fonts-ttf \
noto-fonts-emoji \
ttf-bitstream-vera
}
function fonts_desc () {
echo "Basic fonts necessary for browsing the web and normal GUIs."
}
function themes () {
xbps-install \
breeze \
breeze-gtk \
breeze-snow-cursor-theme \
papirus-icon-theme
}
function themes_desc () {
echo "Color and mouse themes for a good color setup."
}
function wm () {
xbps-install \
Waybar \
alacritty \
brightnessctl \
fzf \
grim \
jq \
mako \
redshift \
slurp \
sway \
swayidle \
swaylock \
wl-clipboard \
wofi
fonts
themes
}
function wm_desc () {
echo "Install the SwayWM and supporting packages."
}
function audio () {
xbps-install \
alsa-utils \
playerctl \
pulseaudio \
pavucontrol
}
function audio_desc () {
echo "Install PulseAudio and alsa."
}
function media () {
audio
xbps-install \
bluez \
elisa \
mpv \
mpv-mpris \
spotifyd \
spotify-tui \
youtube-dl
}
function media_desc () {
echo "Install the Elisa player, mpv, and spotify CLI programs."
}
function dev () {
xbps-install \
clang \
cmake \
make \
meson \
ninja \
git \
go \
rustup \
tokei
}
function dev_desc () {
echo "Install the CLang compiler, some build systems, the Go compiler, and rustup."
}
function emacs () {
xbps-install \
emacs-gtk2 \
hunspell \
hunspell-en_US \
hunspell-pt_BR
}
function emacs_desc () {
echo "(deprecated) Install the GUI version of Emacs."
}
function qt5 () {
xbps-install \
qt5-wayland \
qt5ct \
konversation \
qutebrowser \
pdf.js
}
function qt5_desc () {
echo "Install Qt5 for Wayland, plus Qutebrowser and Konversation."
}
function mozilla () {
xbps-install firefox thunderbird
}
function mozzila_desc () {
echo "Install Firefox and Thunderbird."
}
function office () {
xbps-install \
libreoffice \
libreoffice-i18n-en-US \
libreoffice-i18n-pt-BR
}
function office_desc () {
echo "Install Libreoffice."
}
function pdf () {
xbps-install zathura zathura-pdf-poppler
}
function pdf_desc () {
echo "Install Zathura."
}
function flatpak () {
sudo xbps-install \
flatpak \
xdg-desktop-portal \
xdg-desktop-portal-gtk \
xdg-user-dirs \
xdg-user-dirs-gtk \
xdg-utils
}
function flatpak_desc () {
echo "Install Flatpak and supporting packages."
}
function embedded () {
sudo xbps-install \
arduino-cli \
cross-arm-none-eabi \
cross-arm-none-eabi-gdb \
python3-pyserial \
openocd \
screen \
sdcc
}
function embedded_desc () {
echo "Install embedded toolchain and programmer/debugger software."
}
function kicad () {
xbps-install \
kicad \
kicad-footprints \
kicad-library \
kicad-packages3D \
kicad-symbols \
kicad-templates
}
function kicad_desc () {
echo "Install KiCad EDA and its resource packages."
}
function nonfree () {
xbps-install void-repo-nonfree
xbps-install -S intel-ucode
}
function nonfree_desc () {
echo "Install nonfree repo and Intel microcode."
}
function ate () {
xbps-install \
tcc \
gtk+3-devel \
vte3-devel
}
function ate_desc () {
echo "Install the packages necessary to use ate compiled by TCC."
}
MOST_PACKAGES="base term intel fonts themes wm audio media
dev qt5 mozzila pdf popcorn"
COMPLEMENT_PACKAGES="uefi_bundle disk_tools luks zfs security
refind emacs office flatpak embedded kicad ate nonfree"
function install_most () {
for target in $MOST_PACKAGES
do
$target
done
}
function install_most_desc () {
echo "Install [ ${MOST_PACKAGES} ]"
}
# package installer for Void Linux
bold=$(tput bold)
normal=$(tput sgr0)
function print_help () {
echo "${bold}Usage${normal}: ./void.sh <package-collection>"
echo ""
echo "These are the available package collections inside:"
echo ""
for target in $MOST_PACKAGES $COMPLEMENT_PACKAGES
do
echo "- ${bold}${target}${normal}: $(${target}_desc)"
done
echo ""
echo "These are the available bundles:"
echo ""
for bundle in install_most
do
echo "- ${bold}${bundle}${normal}: $(${bundle}_desc)"
done
function print-bold() {
printf "%s%s%s" "${bold}" "$1" "${normal}"
}
# Run function from script:
# https://stackoverflow.com/questions/8818119/how-can-i-run-a-function-from-a-script-in-command-line
# Check if the function exists (bash specific)
if declare -f "$1" > /dev/null
then
xbps-install -S
# call first argument
"$1"
else
if [ -z $1 ]
then
print_help
else
echo "${1} is not a package collection"
echo ""
print_help
exit 1
fi
fi
function print-item() {
printf -- "- %s:" "$(print-bold $1)"
}
base="chrony elogind iwd vsv"
base_desc="$(print-item base) Install base system utilities."
luks="cryptsetup"
luks_desc="$(print-item luks) Install support for LUKS."
uefi_bundle="binutils gummiboot sbsigntool"
uefi_bundle_desc="$(print-item uefi_bundle) Install tools for creating UEFI bundles."
disk_tools="fscrypt udisks2"
disk_tools_desc="$(print-item disk_tools) Install fscrypt and UDisks2."
su_disk_tools="autofs hdparm"
su_disk_tools_desc="$(print-item su_disk_tools) Install AutoFS and hdparm"
refind="refind"
refind_desc="$(print-item refind) Install the rEFInd boot manager."
zfs="zfs zfsbootmenu"
zfs_desc="$(print-item zfs) Install support for ZFS."
security="apparmor"
security_desc="$(print-item security) Install security related packages."
popcorn="PopCorn"
popcorn_desc="$(print-item popcorn) Install PopCorn usage statistics."
term="bat bmon curl fd fish-shell gnupg2 htop mdcat neovim python3 p7zip ranger
ripgrep starship stow tmux xtools vsv usbutils xz zstd zip bsdunzip bsdtar
parallel"
term_desc="$(print-item term) Install basic terminal utilities."
ssh="fuse-sshfs rsync"
ssh_desc="$(print-item ssh) Install SSH utilities."
intel="intel-gpu-tools libva-intel-driver intel-media-driver mesa-intel-dri"
intel_desc="$(print-item intel) Install packages for media decode and GPU stuff in Intel-land."
fonts="font-awesome5 font-fira-ttf font-ibm-plex-ttf liberation-fonts-ttf
noto-fonts-ttf noto-fonts-emoji ttf-bitstream-vera"
fonts_desc="$(print-item fonts) Basic fonts necessary for browsing the web and normal GUIs."
themes="breeze breeze-gtk breeze-snow-cursor-theme papirus-icon-theme"
themes_desc="$(print-item themes) Color and mouse themes for a good color setup."
wm="Waybar alacritty brightnessctl fzf grim jq mako redshift slurp sway swayidle
swaylock wl-clipboard wofi go"
wm_desc="$(print-item wm) Install SwayWM and supporting packages. Depends on fonts and themes."
audio="alsa-utils playerctl pulseaudio pavucontrol"
audio_desc="$(print-item audio) Install PulseAudio and alsa."
media="bluez mpv mpv-mpris spotifyd spotify-tui youtube-dl"
media_desc="$(print-item media) Install the Elisa player, mpv, and spotify CLI programs."
dev="clang cmake make meson ninja git rustup tokei valgrind"
dev_desc="$(print-item dev) Install the CLang compiler, some build systems and rustup."
emacs="emacs-gtk3 hunspell hunspell-en_US hunspell-pt_BR shellcheck"
emacs_desc="$(print-item emacs) Install the GUI version of Emacs."
qt5="qt5-wayland qt5ct konversation qutebrowser pdf.js"
qt5_desc="$(print-item qt5) Install Qt5 for Wayland, plus Qutebrowser and Konversation."
elisa="elisa"
elisa_desc="$(print-item elisa) Install the Elisa music player."
mozilla="firefox thunderbird"
mozzila_desc="$(print-item mozilla) Install Firefox and Thunderbird."
office="libreoffice libreoffice-i18n-en-US libreoffice-i18n-pt-BR"
office_desc="$(print-item office) Install Libreoffice."
pdf="zathura zathura-pdf-poppler"
pdf_desc="$(print-item pdf) Install Zathura."
flatpak="flatpak xdg-desktop-portal xdg-desktop-portal-gtk xdg-user-dirs xdg-user-dirs-gtk xdg-utils"
flatpak_desc="$(print-item flatpak) Install Flatpak and supporting packages."
embedded="arduino-cli cross-arm-none-eabi cross-arm-none-eabi-gdb python3-pyserial openocd screen sdcc"
embedded_desc="$(print-item embedded) Install embedded toolchain and programmer/debugger software."
kicad="kicad kicad-footprints kicad-library kicad-packages3D kicad-symbols kicad-templates"
kicad_desc="$(print-item kicad) Install KiCad EDA and its resource packages."
[ -z "$NO_NONFREE" ] && nonfree="intel-ucode nvidia"
nonfree_desc="$(print-item nonfree) Install nonfree pacakges: intel-ucode and nvidia."
ate="tcc gtk+3-devel vte3-devel pkgconf"
ate_desc="$(print-item ate) Install the packages necessary to use ate compiled by TinyCC."
void_docs="mdBook mdbook-linkcheck vmdfmt"
void_docs_desc="$(print-item void_docs) Install development tools for Void Docs."
xbps_devel="zlib-devel libressl-devel libarchive-devel"
xbps_devel_desc="$(print-item xbps_devel) Install development dependencies for XBPS."
base_env="$base $term $ssh $intel $fonts $themes $wm $audio $media $qt5 $popcorn
$mozilla $pdf $emacs $security $su_disk_tools"
base_env_desc="$(print-item base_env) [ base term ssh intel fonts themes wm audio
media qt5 popcorn mozilla pdf emacs security su_disk_tools ]"
all="$base_env $luks $uefi_bundle $disk_tools $refind $zfs $dev $elisa $office
$flatpak $embedded $kicad $ate $nonfree $void_docs $xbps_devel"
all_desc="$(print-item all) [ base_env luks uefi_bundle disk_tools refind
zfs dev elisa office flatpak embedded kicad ate nonfree void_docs xbps_devel ]"
function print_help () {
cat <<EOF
$(print-bold Usage): $0 collection [collections...]
These are the available package collections:
$base_desc
$luks_desc
$uefi_bundle_desc
$disk_tools_desc
$su_disk_tools_desc
$refind_desc
$zfs_desc
$security_desc
$popcorn_desc
$term_desc
$ssh_desc
$intel_desc
$fonts_desc
$themes_desc
$wm_desc
$audio_desc
$media_desc
$dev_desc
$emacs_desc
$qt5_desc
$elisa_desc
$mozzila_desc
$office_desc
$pdf_desc
$flatpak_desc
$embedded_desc
$kicad_desc
$nonfree_desc
$ate_desc
$void_docs_desc
$xbps_devel_desc
These are the available bundles:
$base_env_desc
$all_desc
Recommended individual apps:
$(print-item bolt)
$(print-item cscope)
$(print-item lolcat-c)
$(print-item sl)
$(print-item podman)
$(print-item riot-desktop)
$(print-item sent)
$(print-bold "Environment variables:")
- ADDITIONAL_PACKAGES: env variable for individual packages
- NO_NONFREE: to disable nonfree repo
- YES: don't ask for confirmation
EOF
exit
}
[ -n "$YES" ] && FLAGS="-y"
function check-nonfree() {
if [ -z "$NO_NONFREE" ] ; then
if xbps-query void-repo-nonfree >/dev/null ; then
xbps-install $FLAGS -S void-repo-nonfree
xbps-install -S
fi
else
echo "Non-free packages are disabled"
fi
}
if [ -z "$1" ] ; then
print_help
else
xbps-install -S
xbps-install $FLAGS -u xbps
check-nonfree
echo "Collections: $@"
for coll in "$@"
do
if [ -z "${!coll}" ] ; then
echo "$coll doesn't exist"
exit
fi
packages+=" ${!coll}"
done
packages+=" $ADDITIONAL_PACKAGES"
echo "Packages: $packages"
xbps-install $FLAGS $packages
fi