-
-
Save cookiengineer/94265370d66ea73f4782f80c231e126c to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# Save this file as /usr/bin/apt-pac and chmod +x it. | |
case "$1" in | |
autoremove) | |
pacman -Rns $(pacman -Qdtq); | |
;; | |
clean) | |
if [ "$2" == "--force" ]; then | |
pacman -Scc; | |
else | |
echo "Use \"apt-pac clean --force\" to remove all packages from cache."; | |
pacman -Sc; | |
fi; | |
;; | |
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) | |
if [ "$2" == "--force" ]; then | |
pacman -Syy; | |
else | |
echo "Use \"apt-pac update --force\" to force-update packages index."; | |
pacman -Sy; | |
fi; | |
;; | |
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 ""; | |
echo "Command-specific flags:"; | |
echo -e "\t--force can be used with clean, update to emulate same behaviour as aptitude."; | |
echo ""; | |
;; | |
esac; |
Added some features I regularly used over the last months: clean
, changelog
, download
and policy
.
lol, awesome idea :))
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
@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
.
@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!
About this bit:
update)
pacman -Syy;
;;
It is absolutely unnecessary to force refresh all repos, as it puts an additional (even if little) strain on the mirrors for no benefit, unless the user knows that their databases are broken, at which point one could run pacman -Syy
by themselves. I know, the additional load is minuscule, but this little change is minuscule too, so why not? lol
Also I'm not sure about separate -Sy
and -Su
commands, as -Sy
updates local repo listings but not packages, which counts as a partial upgrade which is not supported by Arch Linux and could cause all kinds of fun stuff with dependencies. Though, I'm not sure myself how to convert apt's separate update
and upgrade
things to still provide a good result and not cause a partial upgrade. I dunno, at least add a disclaimer comment please?
I dunno, at least add a disclaimer comment please?
Disclaimer: It's just a goddamn gist, not an AUR package and neither (hopefully) a git repository.
Do whatever you like with it.
I will, and I appreciate your work on this. I'm just more worried about other people not reading these comments, copying the entire thing and doing -Syy
without -Su
and potentially screwing up their system this way.
I mean, can't gists be edited? Is it too much effort to at least remove that one extra y
?
@Architector4 I updated the gist to reflect the same behaviour, while hiding the force-clean and force-update behind a --force
flag. I think this is the best compromise in this case.
Oh, that's good. Thanks!
Love it! This definitely higher the accessibility to new users in a Arch-like distro!