From da2fc0a94673cea92965c677861eb88b46ec8eca Mon Sep 17 00:00:00 2001 From: Max mal Richtig Date: Mon, 8 Jan 2024 18:13:01 +0100 Subject: [PATCH] Working simple wrapper around pacman --- README.md | 5 ++- aptman | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 aptman diff --git a/README.md b/README.md index 7a8dd93..3f98526 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ # AptMan -A thin (and sane) wrapper around pacman \ No newline at end of file +## An `apt`-like `pacman` wrapper + +A thin wrapper that translates humanly understandable "apt-like" commands +to the enigma-esque syntax that is 'pacman'. diff --git a/aptman b/aptman new file mode 100644 index 0000000..99331e8 --- /dev/null +++ b/aptman @@ -0,0 +1,96 @@ +#!/bin/bash + +############################################################################# +## +## A thin wrapper that translates humanly understandable "apt-like" commands +## to the enigma-esque syntax that is used by 'pacman'. +## +############################################################################# + +if ! command -v pacman &> /dev/null +then + echo "ERROR: 'pacman' could not be found." + echo "Make sure it is installed and in your PATH!" + exit 1 +fi + + +cmd="$1" +shift # drop the first argument from "$@" + + +# catch first arguments with $1 +case "$cmd" in + update) + # Update local package repo/cache + echo "Updating package index ..." + pacman -Sy + ;; + upgrade) + # Perform package upgrade + echo "Installing package upgrades ..." + pacman -Syu + ;; + upgradeable) + # Show which pacakges have an upgrade available + echo "Listing up upgradeable packages ..." + pacman -Qu + ;; + install|reinstall) + # (re)Install a package and its dependencies + echo "Installing '$@' ..." + pacman -S "$@" + ;; + remove) + # Remove package and its dependencies + echo "Removing '$@' and dependencies ..." + pacman -Rs "$@" + ;; + purge) + # Remove package, dependencies and all of the config files + echo "Removing '$@', configurations and dependencies ..." + pacman -Rns "$@" + ;; + check) + # Check & potentially fix broken dependencies + echo "Checking & (potentially fixing) broken dependencies ..." + pacman -Dk + ;; + search) + # Search for available packages + echo "Searching packages for '$@' ..." + pacman -Ss "$@" + ;; + show) + # Show info for a package + echo "Showing info for '$@' ..." + pacman -Si "$@" + ;; + clean) + # Clean up pacman cache + # --> All the cached packages that are not installed, and unused sync database + echo "Cleaning up pacman cache ..." + pacman -Sc + ;; + cleaner) + # Clean up pacman caches HARDER + # --> To remove ALL files from the cache directory + echo "Cleaning up pacman cache REALLY HARD ..." + pacman -Scc + ;; + *) + # else + echo "Usage: aptman [...]" + echo "---------------------------------------" + echo "update - Update packages" + echo "upgrade - Install upgrades" + echo "upgradeable - List upgradeable packages" + echo "install | reinstall - (re)Install packages" + echo "remove - Uninstall package" + echo "purge - Uninstall package and clean config" + echo "check - Check for broken dependencies" + echo "search - Search package" + echo "show - Show package info" + echo "clean | cleaner - Clean up pacman cache" + ;; +esac