Compare commits
5 Commits
a6ffd1ea94
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 43a001e02b | |||
| 34f396534d | |||
| 8d8d4d8978 | |||
| 82b344bbce | |||
| 5cc5556c51 |
33
pman.sh
33
pman.sh
@@ -7,6 +7,7 @@ shift
|
||||
command=""
|
||||
more_arguments=false
|
||||
su_needed=false
|
||||
ignoredpkgs_file="/etc/pacman.d/ignorepkg"
|
||||
|
||||
# If sudo is needed and necessary (and installed), prepend it, if not installed throw error
|
||||
check_sudo() {
|
||||
@@ -14,7 +15,7 @@ check_sudo() {
|
||||
if command -v "sudo" &>/dev/null; then
|
||||
command="sudo $command"
|
||||
else
|
||||
echo "sudo command needed but not found" > /dev/stderr
|
||||
echo "\`sudo\` command needed but not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
@@ -42,31 +43,47 @@ elif [ "$command_args" = "reflector" ]; then
|
||||
command_args=$(cat /etc/pacman.d/mirrorlist 2>/dev/null | grep -e "With.*reflector" | sed 's/#.*reflector //')
|
||||
# Check if reflector was actually used to generate the mirrorlist
|
||||
if [ "$command_args" = "" ]; then
|
||||
echo "Error: reflector was not used to generate mirrorlist or mirrorlist location differ from standard"
|
||||
echo "Error: reflector was not used to generate mirrorlist or mirrorlist location differ from standard" >&2
|
||||
exit 1
|
||||
fi
|
||||
su_needed=true
|
||||
elif [ "$command_args" = "ignored" ]; then
|
||||
if [ ! -f "$ignoredpkgs_file" ]; then
|
||||
echo "Error: $ignoredpkgs_file does not exist, no packages ignored" >&2
|
||||
echo "use $0 ignore <pkgname> to start" >&2
|
||||
exit 1
|
||||
fi
|
||||
command="echo"
|
||||
command_args="$(cat /etc/pacman.d/ignorepkg | sed 's/IgnorePkg = //' | sort)"
|
||||
command_args="$(cat $ignoredpkgs_file | sed 's/IgnorePkg = //' | sort)"
|
||||
elif [ "$command_args" = "ignore" ]; then
|
||||
if [ ! -f "$ignoredpkgs_file" ]; then
|
||||
su_needed=true
|
||||
command="touch"
|
||||
command_args="$ignoredpkgs_file"
|
||||
execute_command
|
||||
fi
|
||||
for pkg in "${@}"; do
|
||||
if [ "$(grep -e "$pkg$" /etc/pacman.d/ignorepkg)" != "" ]; then
|
||||
if [ "$(grep -e "$pkg$" $ignoredpkgs_file)" != "" ]; then
|
||||
echo "$pkg is already ignored, skipping..."
|
||||
continue
|
||||
fi
|
||||
command="tee"
|
||||
command_args="-a /etc/pacman.d/ignorepkg"
|
||||
command_args="-a $ignoredpkgs_file"
|
||||
su_needed=true
|
||||
echo "IgnorePkg = $pkg" | execute_command &>/dev/null
|
||||
done
|
||||
exit 0
|
||||
elif [ "$command_args" = "unignore" ]; then
|
||||
if [ ! -f "$ignoredpkgs_file" ]; then
|
||||
echo "Error: $ignoredpkgs_file does not exist, no packages ignored" >&2
|
||||
echo "use $0 ignore <pkgname> to start" >&2
|
||||
exit 1
|
||||
fi
|
||||
for pkg in "${@}"; do
|
||||
command="sed"
|
||||
su_needed=true
|
||||
check_sudo
|
||||
$command -i "/IgnorePkg = $pkg/d" /etc/pacman.d/ignorepkg
|
||||
$command -i "/IgnorePkg = $pkg/d" $ignoredpkgs_file
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
@@ -92,7 +109,7 @@ case "$command_args" in
|
||||
# Update the cache
|
||||
su_needed=true
|
||||
command_args="-Fy"
|
||||
execute_command "${@}"
|
||||
execute_command
|
||||
|
||||
su_needed=false
|
||||
command_args="-F"
|
||||
@@ -101,7 +118,7 @@ case "$command_args" in
|
||||
# Update the cache
|
||||
su_needed=true
|
||||
command_args="-Fy"
|
||||
execute_command "${@}"
|
||||
execute_command
|
||||
|
||||
su_needed=false
|
||||
command_args="-Fl"
|
||||
|
||||
Reference in New Issue
Block a user