Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ Currently psh is only tested in the following environments:
- Ubuntu
- Debian
- PopOs!
- Arch Linux
- CachyOS
- EndeavourOS
- Manjaro
- Windows Subsystem for Linux 2 (WSL2)
- macOS

Expand Down
2 changes: 2 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ yes_no_abort_dialog "Do you want to install psh? (y/n): " "${start_arg_run_unatt
# Import the right package manager depending on current distribution
if [[ "$detected_os" = "Debian GNU/Linux" || "$detected_os" = "Ubuntu" || "$detected_os" = "Pop!_OS" ]]; then
source "lib/distdep/deb_based/package_management.sh"
elif [[ "$detected_os" = "Arch Linux" || "$detected_os" = "CachyOS Linux" || "$detected_os" = "EndeavourOS" || "$detected_os" = "Manjaro Linux" ]]; then
source "lib/distdep/arch_based/package_management.sh"
elif [[ "$detected_os" = "Darwin" ]]; then
source "lib/distdep/darwin_based/package_management.sh"
else
Expand Down
68 changes: 68 additions & 0 deletions lib/distdep/arch_based/package_management.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash

#
# Copyright 2025 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 "${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 -S --noconfirm "${package_install_arguments[@]}"
else
pacman -S --noconfirm "${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
}