Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for uninstall packages and option for all graphics front-end #119

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
packer-postinstallerf
======

Bash wrapper CLI for pacman and AUR.

This is a fork from https://github.com/keenerd/packer compatible for all graphical front-end.

Features
======

Added support for "uninstall" and "local install" packages

Added support option for all graphics front-end
49 changes: 48 additions & 1 deletion packer
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ usage() {
echo 'usage: packer [option] [package] [package] [...]'
echo
echo ' -S - installs package'
echo ' -L - install locally package, requires specific path'
echo ' -Lc - install locally package, with graphical autentication, requires specific path'
echo ' -D - uninstall package'
echo ' -Dc - uninstall package with graphical autentication'
echo ' -Syu|-Su - updates all packages, also takes -uu and -yy options'
echo ' -Ss|-Ssq - searches for package'
echo ' -Si - outputs info for package'
Expand Down Expand Up @@ -85,6 +89,19 @@ runasroot() {
fi
}


runasrootgui() {
if [[ $UID -eq 0 ]]; then
"$@"
elif zenity --password | sudo -S -v &>/dev/null && sudo -l "$@" &>/dev/null; then
sudo -E "$@"
else
echo -n "root "
zenity --password | su -c "$(printf '%q ' "$@")"
fi
}


# Source makepkg.conf file
sourcemakepkgconf() {
. "$makepkgconf"
Expand Down Expand Up @@ -506,12 +523,16 @@ nap() {
done
}

# Argument parsing
# Argument parsing
[[ $1 ]] || usage
packageargs=()
while [[ $1 ]]; do
case "$1" in
'-S') option=install ;;
'-L') option=localinstall ;;
'-Lc') option=localinstall-gui ;;
'-D') option=remove ;;
'-Dc') option=remove-gui ;;
'-Ss') option=search ;;
'-Ssq'|'-Sqs') option=search ; quiet='1' ;;
'-Si') option=info ;;
Expand Down Expand Up @@ -550,6 +571,32 @@ if [[ $option = install ]]; then
exit
fi

# Install (-L) local
if [[ $option = localinstall ]]; then
runasroot $PACMAN -U "${packageargs[@]}"
exit
fi

# Install (-Lc) local with graphical autentication
if [[ $option = localinstall-gui ]]; then
runasrootgui $PACMAN -U --noconfirm "${packageargs[@]}"
exit
fi

# Remove (-D)
if [[ $option = remove ]]; then
runasroot $PACMAN -Rs "${PACOPTS[@]}" "${packageargs[@]}"
exit
fi

# Remove (-Dc) with graphical autentication
if [[ $option = remove-gui ]]; then
# zenity --password | sudo -S pacman -R --noconfirm "${packageargs[@]}"
runasrootgui $PACMAN -Rs --noconfirm "${packageargs[@]}"
exit
fi


# Update (-Su) handling
if [[ $option = update ]]; then
getignoredpackages
Expand Down
Loading