-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathpkgdel
More file actions
executable file
·36 lines (30 loc) · 769 Bytes
/
pkgdel
File metadata and controls
executable file
·36 lines (30 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
if test -z "$PACKLIST" ;then
if [[ -r $XDG_CONFIG_HOME/pkgsync/pkgsync.conf ]] ; then
# shellcheck disable=1091
source "$XDG_CONFIG_HOME"/pkgsync/pkgsync.conf
fi
fi
if test -z "$PACKLIST" ;then
echo 'PACKLIST not defined'
exit 1
fi
cd "$( dirname "$PACKLIST" )" || exit
pkgs=( "$@" )
while [[ -z "${pkgs[*]}" ]] ; do
read -rp "Enter package name: " pkgs
done
for pkg in "${pkgs[@]}" ; do
if ! pacman -Q "$pkg" &>/dev/null ; then
echo "Package $pkg not installed"
else
echo "Removing package $pkg"
sudo pacman -Rns "$pkg"
fi
if ! grep -xq "$pkg" "$PACKLIST" ; then
echo "Package $pkg not in $PACKLIST"
else
echo "Removing package $pkg from $PACKLIST"
sed -i "/^$pkg$/d" "$PACKLIST"
fi
done