Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
APT-PAC - pacman with APT syntax
#!/bin/bash
# Save this file as /usr/bin/apt-pac and chmod +x it.
case "$1" in
autoremove)
pacman -Rns $(pacman -Qdtq);
;;
clean)
# XXX: pacman -Scc will remove all packages
# but we want to keep backups of current ones
pacman -Sc;
;;
changelog)
pacman -Qc "$2";
;;
download)
pacman -Sw "$2";
;;
install)
pacman -S "$2";
;;
policy)
cat /etc/pacman.d/mirrorlist | grep "^[^#]";
;;
rdepends)
pacman -Sii "$2";
;;
remove)
pacman -Rs "$2";
;;
search)
pacman -Ss "$2";
;;
show)
pacman -Qi "$2";
;;
update)
pacman -Syy;
;;
upgrade)
pacman -Su;
;;
*|help)
echo "";
echo "aptpac - pacman wrapper for apt-get syntax";
echo "";
echo "";
echo "APT commands:";
echo "";
echo -e "\tautoremove, clean, update, upgrade, policy";
echo "";
echo "Package-specific commands:";
echo "";
echo -e "\tchangelog, download, install, rdepends, remove, search, show";
echo "";
;;
esac;
@danger89

This comment has been minimized.

Copy link

commented Nov 8, 2016

Love it! This definitely higher the accessibility to new users in a Arch-like distro!

@cookiengineer

This comment has been minimized.

Copy link
Owner Author

commented Jan 5, 2017

Added some features I regularly used over the last months: clean, changelog, download and policy.

@materemias

This comment has been minimized.

Copy link

commented Feb 22, 2017

lol, awesome idea :))

@famewolf

This comment has been minimized.

Copy link

commented Jul 15, 2018

Any chance for a "dpkg -l " equivalent so I can use grep to see what packages are already installed vs whats available?

famewolf@hp810-135qe ~/Downloads/linux $ dpkg -l | grep opera
ii  eject                                                       2.1.5+deb1+cvs20081104-13.1ubuntu0.16.04.1               amd64        ejects CDs and operates CD-Changers under Linux
ii  libboost-filesystem1.58.0:amd64                             1.58.0+dfsg-5ubuntu3.1                                   amd64        filesystem operations (portable paths, iteration over directories, etc) in C++
ii  libcrypt-passwdmd5-perl                                     1.3-10                                                   all          interoperable MD5-based crypt() for perl
ii  libostree-1-1:amd64                                         2017.12-0alexlarsson1~xenial                             amd64        content-addressed filesystem for operating system binaries (library)
ii  opera-stable                                                54.0.2952.54                                             amd64        Fast and secure web browser
@cookiengineer

This comment has been minimized.

Copy link
Owner Author

commented Sep 24, 2018

@famewolf I think you might want to use pacman -Qs or similar which shows a per-line output of all (locally) installed packages.

Example:

# similar to dpkg -l | grep chromium
pacman -Qs chromium;

If you want less information and only a "confirmation" that a package with that name is installed, you can also use pacman -Qqs chromium, so it will only show the equivalent package name per-line, so you can also sort and head/tail the output directly.

The idea behind pacman -Ss chromium and pacman -Qs chromium is that Q queries the locally installed database whereas S queries the local package cache (of all mirrors, basically) that is updated/synced via pacman -Sy.

@lucasrdrgs

This comment has been minimized.

Copy link

commented Apr 17, 2019

@cookiengineer What about a get argument that runs pacman -Syu <package>? I've forked your script and added that to solve some dependency issues and I think it is quite handy. Nice script by the way!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.