Skip to content

Commit

Permalink
feat: update PSH to support Manjaro and Arch
Browse files Browse the repository at this point in the history
  • Loading branch information
pascal-zarrad committed Oct 22, 2022
1 parent c9a853a commit afe9ee1
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 43 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/stale.yml

This file was deleted.

13 changes: 9 additions & 4 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ In theory all configuration done by psh should work on any system that is compat
But as the installer uses ```apt```, you need any system that supports ```apt``` to use it.

Currently psh is only tested in the following environments:
* Ubuntu 18.04 (Windows Subsystem for Linux 1) (Take a look at "Note on WSL 1")
* Ubuntu 18.04 (Windows Subsystem for Linux 2)
* Ubuntu 18.04
* Debian 9
* Arch Linux
* Manjaro Linux
* Ubuntu 22.04 (Windows Subsystem for Linux 1) (Take a look at "Note on WSL 1")
* Ubuntu 22.04 (Windows Subsystem for Linux 2)
* Ubuntu 22.04
* Ubuntu 20.04 (Windows Subsystem for Linux 1) (Take a look at "Note on WSL 1")
* Ubuntu 20.04 (Windows Subsystem for Linux 2)
* Ubuntu 20.04
* Debian 11

You can find further information in the wiki under [Compatibility](https://github.com/pascal-zarrad/psh/wiki/Compatibility).

Expand Down
39 changes: 31 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ echo "PSH - VERSION: ${PSH_VERSION}"
# Dependencies that need to be installed with root privileges through apt-get
readonly DEPENDENCIES=(
"zsh"
"fonts-powerline"
"git"
"curl"
"imagemagick"
Expand Down Expand Up @@ -122,9 +121,33 @@ print_message "If you have sudo installed, the installer will automatically try
print_message ""
yes_no_abort_dialog "Do you want to install psh for ${start_arg_install_for_user_parameter}? (y/n): " "${start_arg_run_unattended_parameter}"

# We currently only support debian based systems, so just source package management functions
# using apt.
source "lib/distdep/deb_based/package_management.sh"
if [ -f /etc/os-release ]; then
# shellcheck source=/dev/null
source /etc/os-release
detected_os=$NAME
elif type lsb_release >/dev/null 2>&1; then
# shellcheck source=/dev/null
detected_os=$(lsb_release -si)
elif [ -f /etc/lsb-release ]; then
# shellcheck source=/dev/null
source /etc/lsb-release
detected_os=$DISTRIB_ID
elif [ -f /etc/debian_version ]; then
detected_os=Debian
else
print_error "Could not detect a valid distribution!"
exit 1
fi

# Import the right package manager depending on current distribution
if [[ "$detected_os" = "Debian GNU/Linux" || "$detected_os" = "Ubuntu" ]]; then
source "lib/distdep/deb_based/package_management.sh"
elif [[ "$detected_os" = "Arch Linux" || "$detected_os" = "Manjaro Linux" ]]; then
source "lib/distdep/arch_based/package_management.sh"
else
print_error "Your current distribution '$detected_os' is not supported!"
exit 1
fi

# Analyse which dependencies are already installed
print_message ""
Expand Down Expand Up @@ -170,17 +193,17 @@ if [ -n "${package_install_command// }" ]
else
print_message ""
print_error "Sudo is not installed and you're not root."
print_error "All missing dependencies have to be installed manually using apt."
print_error "We generated the required apt command for you:"
print_error "${COLOR_CYAN}apt install $package_install_command"
print_error "All missing dependencies have to be installed manually."
print_error "We generated the package list for you:"
print_error "${COLOR_CYAN}$package_install_command"
exit 1
fi
else
install_apt_packages $sudo_installed $start_arg_run_unattended_parameter "$package_install_command"
fi
fi

print_success "Installed all apt dependencies for psh!"
print_success "Installed all system dependencies for psh!"
print_message ""

# Install antigen to ~/.antigen/antigen.sh
Expand Down
69 changes: 69 additions & 0 deletions lib/distdep/arch_based/package_management.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

#
# Copyright 2022 Pascal Zarrad
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#==================================================================
# Script Name : psh-package-management
# Description : Sript that contains functions to work with
# packages on arch based systems.
# Args : -
# Author : Pascal Zarrad
# Email : P.Zarrad@outlook.de
#==================================================================

# Check which dependencies are installed and which not
#
# @param $@ All dependencies that should be checked
function packages_installed() {
local dependencies=("$@")
local not_installed=()
for dependency in "${dependencies[@]}"
do
if ! pacman -Qi "$dependency" > /dev/null; then
not_installed=("${not_installed[@]}" "${dependency}")
fi
done
echo "${not_installed[@]}"
}

# Install dependencies. Use sudo if available.
#
# @param $1 Defines whether to prefix the commands with sudo or not
# @param $2 Defines if the unattended mode is being used
# @param $3 The pace separated packages that need to be installed
function install_apt_packages() {
local use_sudo="${1}"
local start_arg_run_unattended="${2}"
local package_install_command="${3}"
IFS=' ' read -r -a package_install_arguments <<< "$package_install_command"
print_message "The installer has to install the following packages through pacman (using sudo if available): "
print_message "During package installation, an pacman update is done automatically!"
print_message "${COLOR_CYAN}${package_install_command}${COLOR_RESET}"
yes_no_abort_dialog "Do you want to continue? (y/n): " "${start_arg_run_unattended}"
if [ "$use_sudo" -eq 1 ]
then
sudo pacman --noconfirm -Syu "${package_install_arguments[@]}"
else
pacman --noconfirm -Syu "${package_install_arguments[@]}"
fi
install_result="$?"
if [ "$install_result" -ne 0 ]; then
print_error "An error occured during installation of dependencies."
print_error "Please take a look at the problem and revolve the problem manually!"
exit 1
fi
}
12 changes: 3 additions & 9 deletions plugins/wsl-gpg/plugin.sh → plugins/gpg-tty/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@
#

#==================================================================
# Script Name : wsl-gpg
# Script Name : gpg-tty
# Description : Plugin that puts a export into the .zshrc to use
# the terminal for the gpg password prompt on wsl.
# the terminal for the gpg password prompt.
# Args : -
# Author : Pascal Zarrad
# Email : P.Zarrad@outlook.de
#==================================================================

# This fix is only for WSL where gpg is unable to find a spot to prompt for
# the password, so we add a environment variable to fix that.
if grep -q "Microsoft" "/proc/version" || grep -q ".*microsoft-standard*." "/proc/version"
then
write_zshrc "export GPG_TTY=\$(tty)"
echo "Applied wsl-gpg fix to support gpg on wsl!"
fi
write_zshrc "export GPG_TTY=\$(tty)"

0 comments on commit afe9ee1

Please sign in to comment.