-
-
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; |
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!
@cookiengineer What about a
get
argument that runspacman -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!