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=""
|
command=""
|
||||||
more_arguments=false
|
more_arguments=false
|
||||||
su_needed=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
|
# If sudo is needed and necessary (and installed), prepend it, if not installed throw error
|
||||||
check_sudo() {
|
check_sudo() {
|
||||||
@@ -14,7 +15,7 @@ check_sudo() {
|
|||||||
if command -v "sudo" &>/dev/null; then
|
if command -v "sudo" &>/dev/null; then
|
||||||
command="sudo $command"
|
command="sudo $command"
|
||||||
else
|
else
|
||||||
echo "sudo command needed but not found" > /dev/stderr
|
echo "\`sudo\` command needed but not found" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
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 //')
|
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
|
# Check if reflector was actually used to generate the mirrorlist
|
||||||
if [ "$command_args" = "" ]; then
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
su_needed=true
|
su_needed=true
|
||||||
elif [ "$command_args" = "ignored" ]; then
|
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="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
|
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
|
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..."
|
echo "$pkg is already ignored, skipping..."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
command="tee"
|
command="tee"
|
||||||
command_args="-a /etc/pacman.d/ignorepkg"
|
command_args="-a $ignoredpkgs_file"
|
||||||
su_needed=true
|
su_needed=true
|
||||||
echo "IgnorePkg = $pkg" | execute_command &>/dev/null
|
echo "IgnorePkg = $pkg" | execute_command &>/dev/null
|
||||||
done
|
done
|
||||||
exit 0
|
exit 0
|
||||||
elif [ "$command_args" = "unignore" ]; then
|
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
|
for pkg in "${@}"; do
|
||||||
command="sed"
|
command="sed"
|
||||||
su_needed=true
|
su_needed=true
|
||||||
check_sudo
|
check_sudo
|
||||||
$command -i "/IgnorePkg = $pkg/d" /etc/pacman.d/ignorepkg
|
$command -i "/IgnorePkg = $pkg/d" $ignoredpkgs_file
|
||||||
done
|
done
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@@ -92,7 +109,7 @@ case "$command_args" in
|
|||||||
# Update the cache
|
# Update the cache
|
||||||
su_needed=true
|
su_needed=true
|
||||||
command_args="-Fy"
|
command_args="-Fy"
|
||||||
execute_command "${@}"
|
execute_command
|
||||||
|
|
||||||
su_needed=false
|
su_needed=false
|
||||||
command_args="-F"
|
command_args="-F"
|
||||||
@@ -101,7 +118,7 @@ case "$command_args" in
|
|||||||
# Update the cache
|
# Update the cache
|
||||||
su_needed=true
|
su_needed=true
|
||||||
command_args="-Fy"
|
command_args="-Fy"
|
||||||
execute_command "${@}"
|
execute_command
|
||||||
|
|
||||||
su_needed=false
|
su_needed=false
|
||||||
command_args="-Fl"
|
command_args="-Fl"
|
||||||
|
|||||||
Reference in New Issue
Block a user