From cf28453bef642fdf88a4022240e152932788ed04 Mon Sep 17 00:00:00 2001 From: Pratik Tripathy Date: Sun, 15 Sep 2024 16:19:44 +0530 Subject: [PATCH] feat(install): Use flatpack to install certail GUI apps that require frequent updates fix(install): Manual app installs that aren't available elsewhere --- scripts/install-brew-packages.sh | 19 +++++---- scripts/install-flatpak-packages.sh | 60 +++++++++++++++++++++++++++ scripts/install-os-packages.sh | 30 +++++++------- scripts/install.sh | 64 +++++++++++++++++++++++++++-- scripts/package-list-brew | 2 + scripts/package-list-flatpak | 14 +++++++ scripts/package-list-os | 25 +++++++++-- setup.sh | 3 -- 8 files changed, 186 insertions(+), 31 deletions(-) create mode 100755 scripts/install-flatpak-packages.sh create mode 100644 scripts/package-list-flatpak diff --git a/scripts/install-brew-packages.sh b/scripts/install-brew-packages.sh index 58ab91b..3887ff4 100755 --- a/scripts/install-brew-packages.sh +++ b/scripts/install-brew-packages.sh @@ -10,8 +10,10 @@ input_file_check() { } install_brew() { - yes | bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + if ! command -v brew > /dev/null 2>&1; then + yes | bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + fi # Required for installing fonts brew tap homebrew/linux-fonts @@ -30,7 +32,7 @@ install_brew_packages() { esac # Check if the package exists in the Homebrew repository - if brew search "$brew_package" | grep -q "^$brew_package\$"; then + if brew search "$brew_package" 2> /dev/null | grep -q "$brew_package"; then echo "Available: $brew_package" found_packages="$found_packages $brew_package" else @@ -39,15 +41,18 @@ install_brew_packages() { fi done < "$BREW_PACKAGE_FILE" - brew install $found_packages + # Install available brew packages + if ! brew install $found_packages; then + exit 1 + fi } print_summary() { # Print the list of packages that were not found - echo if [ -n "$2" ]; then - echo "The following $1 packages were not found in the repository:" - echo "$2" + echo + echo "The following $1 packages were not found in the repository:" | tee -a "$INSTALL_LOG_FILE" + echo "$2" | tee -a "$INSTALL_LOG_FILE" fi } diff --git a/scripts/install-flatpak-packages.sh b/scripts/install-flatpak-packages.sh new file mode 100755 index 0000000..ccfdef8 --- /dev/null +++ b/scripts/install-flatpak-packages.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env sh + +FLATPAK_PACKAGE_FILE=package-list-flatpak + +input_file_check() { + if [ ! -f "$FLATPAK_PACKAGE_FILE" ]; then + echo "File not found: $FLATPAK_PACKAGE_FILE" + exit 1 + fi +} + +setup_flatpak() { + sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo && echo "Flathub added to Flatpak" +} + +# Install packages listed on "flatpak-package-list" file +install_flatpak_packages() { + not_found_packages="" + found_packages="" + + # Read the package names from the file + while IFS= read -r flatpak_package; do + # Skip lines that start with # + case "$flatpak_package" in + \#*) continue ;; + esac + + # Check if the package exists in the flatpak repository + if flatpak search --columns=application "$flatpak_package" 2> /dev/null | grep -q "^$flatpak_package\$"; then + echo "Available: $flatpak_package" + found_packages="$found_packages $flatpak_package" + else + not_found_packages="$not_found_packages $flatpak_package" + echo "Unavailable: $flatpak_package" + fi + done < "$FLATPAK_PACKAGE_FILE" + + # Install available flatpak packages + if ! flatpak install -y --noninteractive $found_packages; then + exit 1 + fi +} + +print_summary() { + # Print the list of packages that were not found + if [ -n "$2" ]; then + echo + echo "The following $1 packages were not found in the repository:" | tee -a "$INSTALL_LOG_FILE" + echo "$2" | tee -a "$INSTALL_LOG_FILE" + fi +} + +main() { + input_file_check + setup_flatpak + install_flatpak_packages + print_summary "flatpak" "$not_found_packages" +} + +main "$@" diff --git a/scripts/install-os-packages.sh b/scripts/install-os-packages.sh index 2e1b777..9755700 100755 --- a/scripts/install-os-packages.sh +++ b/scripts/install-os-packages.sh @@ -8,18 +8,15 @@ setup() { # Detect package manager and set package manager commands if command -v apt-get > /dev/null 2>&1; then - OS_INSTALL_COMMAND="apt-get" + OS_INSTALL_COMMAND="apt-get install -y" OS_PKG_CHECK_COMMAND="apt-cache show" apt_setup elif command -v dnf > /dev/null 2>&1; then - OS_INSTALL_COMMAND="dnf" + OS_INSTALL_COMMAND="dnf install -y --allowerasing --skip-broken" OS_PKG_CHECK_COMMAND="dnf list available" dnf_setup - elif command -v yum > /dev/null 2>&1; then - OS_INSTALL_COMMAND="yum" - OS_PKG_CHECK_COMMAND="yum list available" else log "Unsupported package manager. This script supports apt, yum, and dnf." exit 1 @@ -34,14 +31,14 @@ dnf_setup() { echo "keepcache=True" | sudo tee -a /etc/dnf/dnf.conf > /dev/null # Enable RPM Fusion & Install media codecs - sudo dnf install -y https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm && sudo dnf groupupdate -y core multimedia --setop="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin sound-and-video - - sudo dnf update -y + sudo dnf install -y https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-"$(rpm -E %fedora)".noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-"$(rpm -E %fedora)".noarch.rpm && sudo dnf groupupdate -y core multimedia --setop="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin sound-and-video } apt_setup() { - sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install -y apt-transport-https - # Add PPAs here + # TODO: Enable non-free software in /etc/apt/sources.list + # Add "back-ports" in /etc/apt/sources.list + # Check how it affects Ubuntu + sudo apt-get update && sudo apt-get upgrade -y } input_file_check() { @@ -66,7 +63,7 @@ install_os_packages() { esac # Check if the package exists in the APT repository - if eval "$OS_PKG_CHECK_COMMAND" "$os_package" > /dev/null 2>&1; then + if eval "$OS_PKG_CHECK_COMMAND" "$os_package" 2> /dev/null | grep -q "$os_package"; then echo "Available: $os_package" os_found_packages="$os_found_packages $os_package" else @@ -75,15 +72,18 @@ install_os_packages() { fi done < "$OS_PACKAGE_FILE" - eval sudo "$OS_INSTALL_COMMAND" install -y "$os_found_packages" + # Install available packages + if ! eval sudo "$OS_INSTALL_COMMAND" "$os_found_packages"; then + exit 1 + fi } print_summary() { # Print the list of packages that were not found - echo if [ -n "$2" ]; then - echo "The following $1 packages were not found in the repository:" - echo "$2" + echo | tee -a "$INSTALL_LOG_FILE" + echo "The following $1 packages were not found in the repository:" | tee -a "$INSTALL_LOG_FILE" + echo "$2" | tee -a "$INSTALL_LOG_FILE" fi } diff --git a/scripts/install.sh b/scripts/install.sh index 7fe46a9..d08296a 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,12 +1,70 @@ #!/usr/bin/env sh -# TODO: -# - Needs manual installation: appimagelauncher, firefox, brave, vs-code, cursor, kitty, mattermost-desktop, skypedesktop, ulauncher, dotnet8, dotnet8-sdk8.0, aspnetcore-runtime-8.0, Jetbrains Toolbox, Obsidian, Postman, firefox, zen, zoho, zoho-workdrive, nala -# - Available on some, not on others; may need manual installation: libreoffice, sublime-text, kitty-terminfo, imagemagick +# All: +# - Jetbrains-Toolbox: https://www.jetbrains.com/toolbox-app/ +# - Sublime-Text: https://www.sublimetext.com/docs/linux_repositories.html +# - Appimagelauncher: https://github.com/TheAssassin/AppImageLauncher/releases +# - Zoho Mail: https://downloads.zohocdn.com/zmail-desktop/linux/zoho-mail-desktop-lite-x64-v1.6.4.AppImage +# - Zoho Workdrive: https://files-accl.zohopublic.com/public/wdbin/download/2014030a29db316e9cedd501f32270e8 +# - Cursor: https://downloader.cursor.sh/linux/appImage/x64 +# Debian & Ubuntu: +# - Ulauncher: https://ulauncher.io/#Download +# Debian: +# - Dotnet8: https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install + +# Jetbrains: check if scriptfile not available (because we use flatpak) has any issued with ulauncher + +kitty_term() { + curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin + + mkdir -p ~/.local/bin && ln -sf ~/.local/kitty.app/bin/kitty ~/.local/kitty.app/bin/kitten ~/.local/bin/ + mkdir -p ~/.local/share/applications && cp ~/.local/kitty.app/share/applications/kitty.desktop ~/.local/share/applications/ + cp ~/.local/kitty.app/share/applications/kitty-open.desktop ~/.local/share/applications/ + sed -i "s|Icon=kitty|Icon=$(readlink -f ~)/.local/kitty.app/share/icons/hicolor/256x256/apps/kitty.png|g" ~/.local/share/applications/kitty*.desktop + sed -i "s|Exec=kitty|Exec=$(readlink -f ~)/.local/kitty.app/bin/kitty|g" ~/.local/share/applications/kitty*.desktop + echo 'kitty.desktop' > ~/.config/xdg-terminals.list +} + +manual_installs(){ + kitty_term +} + +post_install() { + chsh -s "$(which zsh)" && echo "Default shell changed to zsh" + + # Time fix for Windows dual boot + timedatectl set-local-rtc 1 --adjust-system-clock && echo "Set Datetime" + + # Use brew-installed fonts current user + if [ -d /home/linuxbrew/.linuxbrew/share/fonts ]; then + ln -s /home/linuxbrew/.linuxbrew/share/fonts -t ~/.local/share && fc-cache -fv + fi + + rm -rf ~/.cache +} + +pre_install() { + export INSTALL_LOG_FILE="$(basename "$0")_$(date +"%Y%m%d_%H%M%S")_log.txt" + echo "Use the following command to view the list of software that was NOT installed:" + echo "cat $PWD/$INSTALL_LOG_FILE" + echo + + if [ -f ~/.profile ]; then + . ~/.profile + fi +} main() { + pre_install + ./install-os-packages.sh ./install-brew-packages.sh + ./install-flatpak-packages.sh + + manual_installs + post_install + + cat "$INSTALL_LOG_FILE" } main "$@" diff --git a/scripts/package-list-brew b/scripts/package-list-brew index ec46b5f..a8419e7 100644 --- a/scripts/package-list-brew +++ b/scripts/package-list-brew @@ -1,4 +1,5 @@ # Lines that start with # are ignored +# TIP: Only add commandline apps that aren't available/updated on OS repos bat bats-core dnscrypt-proxy @@ -34,5 +35,6 @@ tlrc tokei tree-sitter yt-dlp +zoxide zsh-autosuggestions zsh-syntax-highlighting diff --git a/scripts/package-list-flatpak b/scripts/package-list-flatpak new file mode 100644 index 0000000..a8f904e --- /dev/null +++ b/scripts/package-list-flatpak @@ -0,0 +1,14 @@ +# Lines that start with # are ignored +# TIP: Only add GUI apps that aren't available/updated on OS repos +com.brave.Browser +com.visualstudio.code +org.mozilla.firefox +org.libreoffice.libreoffice +com.mattermost.Desktop +md.obsidian.Obsidian +com.getpostman.Postman +com.jetbrains.Rider +#com.slack.Slack +com.skype.Client +dev.zed.zed +io.github.zen_browser.zen diff --git a/scripts/package-list-os b/scripts/package-list-os index c5f9731..d462edc 100644 --- a/scripts/package-list-os +++ b/scripts/package-list-os @@ -1,4 +1,14 @@ # Lines that start with # are ignored +# Below few are apt-only packages - non-free sources must be added before this +apt-transport-https +libavcodec-extra +nvidia-driver +synaptic +# Below few are dnf-only packages +akmod-nvidia +libva-nvidia-driver +xorg-x11-drv-nvidia-cuda +# Common bash bleachbit build-essential @@ -8,25 +18,32 @@ curl evolution-ews dolphin dolphin-plugins +aspnetcore-runtime-8.0 +dotnet-sdk-8.0 +dotnet-runtime-8.0 ffmpeg flameshot +flatpak +plasma-discover-backend-flatpak gcc gdb git gparted +gnupg +grub-customizer htop -#imagemagick kde-spectacle kdeconnect -kitty kitty-terminfo -libreoffice llvm make +nala net-tools okular +openssh-client python3 python3-pip +qbittorrent ripgrep simplescreenrecorder smplayer @@ -35,7 +52,9 @@ solaar syncthing tmux ufw +ulauncher vim +vim-enhanced vim-common vim-tiny vlc diff --git a/setup.sh b/setup.sh index baf8287..e046bce 100755 --- a/setup.sh +++ b/setup.sh @@ -35,8 +35,6 @@ place_dotfile_at_target_location() { } parse_input() { - # TODO: Accept input to execute install.sh script - while [ "${#}" -gt 0 ]; do case $1 in -i | --install) @@ -104,7 +102,6 @@ main() { )/scripts" setup_symlinks - echo "$install_file_location" if [ "$INSTALL" = "y" ]; then cd "$install_file_location" || exit