mirror of
https://github.com/kuhyx/scripts.git
synced 2026-11-11 13:07:41 +01:00
fix: make pacman wrapper work with yay
This commit is contained in:
parent
de7575f703
commit
c8902471df
@ -11,7 +11,17 @@ CYAN='\033[0;36m'
|
|||||||
BOLD='\033[1m'
|
BOLD='\033[1m'
|
||||||
NC='\033[0m' # No Color
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
# Define paths for both pacman and pacman.orig
|
||||||
PACMAN_BIN="/usr/bin/pacman"
|
PACMAN_BIN="/usr/bin/pacman"
|
||||||
|
PACMAN_ORIG_BIN="/usr/bin/pacman.orig.real"
|
||||||
|
|
||||||
|
# Detect if script is being called as pacman.orig
|
||||||
|
SCRIPT_NAME=$(basename "$0")
|
||||||
|
if [[ "$SCRIPT_NAME" == "pacman.orig" ]]; then
|
||||||
|
IS_PACMAN_ORIG=true
|
||||||
|
else
|
||||||
|
IS_PACMAN_ORIG=false
|
||||||
|
fi
|
||||||
|
|
||||||
# Function to display help
|
# Function to display help
|
||||||
function show_help() {
|
function show_help() {
|
||||||
@ -55,17 +65,23 @@ function display_operation() {
|
|||||||
# Function to check if user is trying to install specific packages that require confirmation
|
# Function to check if user is trying to install specific packages that require confirmation
|
||||||
function check_for_steam() {
|
function check_for_steam() {
|
||||||
# List of packages that require confirmation
|
# List of packages that require confirmation
|
||||||
local restricted_packages=("steam" "freetube-bin")
|
local restricted_packages=("steam" "freetube-bin" "seamonkey-bin" "seamonkey")
|
||||||
|
|
||||||
# Check if the command is an installation command
|
# Check if the command is an installation command
|
||||||
if [[ "$1" == "-S" || "$1" == "-Sy" || "$1" == "-Syu" || "$1" == "-Syyu" ]]; then
|
if [[ "$1" == "-S" || "$1" == "-Sy" || "$1" == "-Syu" || "$1" == "-Syyu" || "$1" == "-U" ]]; then
|
||||||
# Check all arguments
|
# Check all arguments
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
|
# Fix the comment that was accidentally merged with code
|
||||||
# Check if argument matches any restricted package
|
# Check if argument matches any restricted package
|
||||||
for package in "${restricted_packages[@]}"; do
|
for package in "${restricted_packages[@]}"; do
|
||||||
if [[ "$arg" == "$package" ]]; then
|
if [[ "$arg" == "$package" ]]; then
|
||||||
return 0 # Restricted package found
|
return 0 # Restricted package found
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check if the argument is a path containing the restricted package
|
||||||
|
if [[ "$arg" == *"$package"*".pkg.tar."* ]]; then
|
||||||
|
return 0 # Restricted package found in path
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
@ -164,7 +180,7 @@ if [[ "$1" == "--help-wrapper" ]]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if trying to install steam
|
# Check if trying to install restricted packages
|
||||||
if check_for_steam "$@"; then
|
if check_for_steam "$@"; then
|
||||||
prompt_for_math_solution
|
prompt_for_math_solution
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
@ -175,14 +191,20 @@ fi
|
|||||||
# Display operation
|
# Display operation
|
||||||
display_operation "$1"
|
display_operation "$1"
|
||||||
|
|
||||||
# Echo the command that's about to be executed
|
# Determine which binary to use
|
||||||
echo -e "${GREEN}Executing:${NC} $PACMAN_BIN $@"
|
if [[ "$IS_PACMAN_ORIG" == true ]]; then
|
||||||
|
echo -e "${GREEN}Executing via pacman.orig:${NC} $PACMAN_ORIG_BIN $@"
|
||||||
|
EXEC_BIN="$PACMAN_ORIG_BIN"
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}Executing:${NC} $PACMAN_BIN $@"
|
||||||
|
EXEC_BIN="$PACMAN_BIN"
|
||||||
|
fi
|
||||||
|
|
||||||
# Record start time for statistics
|
# Record start time for statistics
|
||||||
start_time=$(date +%s)
|
start_time=$(date +%s)
|
||||||
|
|
||||||
# Execute the real pacman command
|
# Execute the real pacman command
|
||||||
"$PACMAN_BIN" "$@"
|
"$EXEC_BIN" "$@"
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
|
|
||||||
# Record end time for statistics
|
# Record end time for statistics
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user