You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
152 lines
4.4 KiB
152 lines
4.4 KiB
#!/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
|
|
|
|
PREFIX=""
|
|
target_env="$MSYSTEM"
|
|
cmd=""
|
|
|
|
if [ "$1" == "-t" ]
|
|
then
|
|
shift
|
|
target_env="${1^^}" #make uppercase
|
|
shift
|
|
|
|
case "$target_env" in
|
|
MSYS|msys|ALL|all)
|
|
PREFIX=""
|
|
;;
|
|
MINGW64|mingw64)
|
|
PREFIX="mingw-w64-x86_64-"
|
|
;;
|
|
UCRT64|ucrt64)
|
|
PREFIX="mingw-w64-ucrt-x86_64-"
|
|
;;
|
|
CLANG64|clang64)
|
|
PREFIX="mingw-w64-clang-x86_64-"
|
|
;;
|
|
MINGW64|mingw64)
|
|
PREFIX="mingw-w64-i686-"
|
|
;;
|
|
CLANG32|clang32)
|
|
PREFIX="mingw-w64-clang-i686-"
|
|
;;
|
|
CLANGARM64|clangarm64)
|
|
PREFIX="mingw-w64-clang-aarch64-"
|
|
;;
|
|
*)
|
|
echo "ERROR: Unknown environment '$target_env' given."
|
|
exit
|
|
;;
|
|
esac
|
|
else
|
|
if [ "$MSYSTEM" != "MSYS" ]
|
|
then
|
|
PREFIX="$MINGW_PACKAGE_PREFIX""-"
|
|
fi
|
|
fi
|
|
|
|
cmd="$1" # catch first arguments with $1
|
|
shift # drop the first argument from "$@"
|
|
|
|
case "$cmd" in
|
|
update)
|
|
# Update local package repo/cache
|
|
echo "Updating package index ..."
|
|
pacman -Sy
|
|
echo "$(pacman -Qu | wc -l) packages can be upgraded."
|
|
;;
|
|
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 '$@' from '$target_env' ..."
|
|
pacman -S "$PREFIX$@"
|
|
;;
|
|
remove)
|
|
# Remove package - keep dependencies
|
|
echo "Removing '$@' from '$target_env' ..."
|
|
pacman -R "$PREFIX$@"
|
|
echo ""
|
|
echo "If you want to remove unused dependencies, run 'aptman autoremove'"
|
|
echo "or consider 'aptman purge [PKG]' next time."
|
|
;;
|
|
autoremove)
|
|
# Remove orphaned packages
|
|
echo "Removing orphaned packages ..."
|
|
pacman -Qdtq | pacman -Rs -
|
|
;;
|
|
purge)
|
|
# Remove package, dependencies and all of the config files
|
|
echo "Removing '$@', configurations and dependencies from '$target_env' ..."
|
|
pacman -Rns "$PREFIX$@"
|
|
;;
|
|
check)
|
|
# Check & potentially fix broken dependencies
|
|
echo "Checking & (potentially fixing) broken dependencies ..."
|
|
pacman -Dk
|
|
;;
|
|
search)
|
|
# Search for available packages
|
|
echo "Searching packages for '$@' in '$target_env' ..."
|
|
if [ "$PREFIX" ]
|
|
then
|
|
pacman -Ss "$@" "$PREFIX"
|
|
else
|
|
pacman -Ss "$@"
|
|
fi
|
|
;;
|
|
show)
|
|
# Show info for a package
|
|
echo "Showing info for '$PREFIX$@' ..."
|
|
pacman -Si "$PREFIX$@"
|
|
;;
|
|
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 "autoremove - Uninstalling orphaned packages"
|
|
echo "purge - Uninstall package, dependencies 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
|