Add subcmd checkdeps

This commit is contained in:
clsty
2025-10-30 12:15:21 +08:00
parent 60a0dcfdcf
commit 0ac39d4356
3 changed files with 69 additions and 1 deletions
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Check whether pkgs exist in AUR or repos of Arch.
#
# Do NOT abuse this since it consumes extra bandwidth from AUR server.
pkglistfile=$(mktemp)
pkglistfile_orig=${LIST_FILE_PATH}
mkdir -p ./cache
pkglistfile_orig_s=./cache/dependencies_stripped.conf
remove_bashcomments_emptylines $pkglistfile_orig $pkglistfile_orig_s
cat $pkglistfile_orig_s | sed "s_\ _\n_g" > $pkglistfile
echo "The non-existent pkgs in $pkglistfile_orig are listed as follows."
# Borrowed from https://bbs.archlinux.org/viewtopic.php?pid=1490795#p1490795
comm -23 <(sort -u $pkglistfile) <(sort -u <(wget -q -O - https://aur.archlinux.org/packages.gz | gunzip) <(pacman -Ssq))
echo "End of list. If nothing appears, then all pkgs exist."
rm $pkglistfile
+48
View File
@@ -0,0 +1,48 @@
# Handle args for subcmd: exp-uninstall
# shellcheck shell=bash
showhelp(){
echo -e "Syntax: $0 checkdeps [OPTIONS]...
Experimental unintallation.
Options:
-h, --help Show this help message
--file A file in plain text containing package names
"
}
# `man getopt` to see more
para=$(getopt \
-o h \
-l help,file: \
-n "$0" -- "$@")
[ $? != 0 ] && echo "$0: Error when getopt, please recheck parameters." && exit 1
#####################################################################################
## getopt Phase 1
# ignore parameter's order, execute options below first
eval set -- "$para"
while true ; do
case "$1" in
-h|--help) showhelp;exit;;
--) break ;;
*) shift ;;
esac
done
#####################################################################################
## getopt Phase 2
eval set -- "$para"
while true ; do
case "$1" in
## Ones with parameter
--file)
if [[ -f "$2" ]];
then echo "Using list file \"$2\".";LIST_FILE_PATH="$2";shift 2
else echo "Wrong argument for $1.";exit 1
fi;;
## Ending
--) break ;;
*) echo -e "$0: Wrong parameters.";exit 1;;
esac
done
+2 -1
View File
@@ -24,6 +24,7 @@ Subcommands:
exp-uninstall (Experimental) Uninstall illogical-impulse.
exp-update (Experimental) Update illogical-impulse without fully reinstall.
exp-update-old (Experimental) exp-update but use behaves like old version.
checkdeps (For dev only) Check whether pkgs exist in AUR or repos of Arch.
help Show this help message.
For each <subcommand>, use -h for details:
@@ -34,7 +35,7 @@ case $1 in
# Global help
help|--help|-h)showhelp_global;exit;;
# Correct subcommand
install|exp-uninstall|exp-update|exp-update-old)
install|exp-uninstall|exp-update|exp-update-old|checkdeps)
SUBCMD_NAME=$1
SUBCMD_DIR=./sdata/subcmd-$1
shift;;