Add self-update command to refresh miaur from Git

Introduce `miaur self-update` / `--self-update` that clones RepoUrl@Branch,
detects user vs system install prefix, and reinstalls in place. Configurable
via conf/env; supports --noconfirm, --repo-url, and --branch.

Co-authored-by: Frank Vitrano <WHC2006@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-07-23 14:44:24 +00:00
co-authored by Frank Vitrano
parent bba71040d6
commit a4f4767c47
11 changed files with 293 additions and 8 deletions
+57 -2
View File
@@ -36,6 +36,7 @@ Pacman operations extended with AUR support:
Additional operations:
miaur {-G --getpkgbuild} [packages]
miaur {-B --build} [directories]
miaur self-update Update miaur from Git
With no arguments, miaur runs 'miaur -Syu'.
@@ -49,6 +50,7 @@ Common commands:
miaur -G <package> Download a PKGBUILD
miaur -Gp <package> Print a PKGBUILD
miaur -Bi . Build and install a local PKGBUILD
miaur self-update Update miaur itself
Options:
-a, --aur Assume targets are from the AUR
@@ -63,6 +65,7 @@ Options:
--sudoloop Keep sudo credentials alive (default)
--nosudoloop Disable the sudo keep-alive loop
--noconfirm Bypass any confirmation prompts
--self-update Same as: miaur self-update
EOF
}
@@ -76,11 +79,14 @@ strip_miaur_opts() {
case "$arg" in
--aur | --repo | --skipreview | --review | --cleanafter | --nocleanafter | \
--removemake | --noremovemake | --noremovermake | --bottomup | --topdown | \
--sudoloop | --nosudoloop | --noconfirm) ;;
--sudoloop | --nosudoloop | --noconfirm | --self-update) ;;
--clonedir | --mflags | --mode)
i=$((i + 1))
;;
--clonedir=* | --mflags=* | --mode=*) ;;
--clonedir=* | --mflags=* | --mode=* | --repo-url=* | --branch=*) ;;
--repo-url | --branch)
i=$((i + 1))
;;
*)
printf '%s\n' "$arg"
;;
@@ -97,6 +103,40 @@ parse_args() {
return 0
fi
# Subcommand: self-update [--noconfirm] [--repo-url URL] [--branch NAME]
if [[ $1 == self-update || $1 == --self-update ]]; then
OP=selfupdate
local -a raw=("$@")
local i=1
while ((i < ${#raw[@]})); do
local arg=${raw[$i]}
case "$arg" in
--noconfirm) MIAUR_NOCONFIRM=1 ;;
--repo-url)
i=$((i + 1))
MIAUR_REPO=${raw[$i]:-}
[[ -n $MIAUR_REPO ]] || die "--repo-url requires a URL"
;;
--repo-url=*) MIAUR_REPO=${arg#*=} ;;
--branch)
i=$((i + 1))
MIAUR_BRANCH=${raw[$i]:-}
[[ -n $MIAUR_BRANCH ]] || die "--branch requires a name"
;;
--branch=*) MIAUR_BRANCH=${arg#*=} ;;
-h | --help)
print_help
exit 0
;;
*)
die "unknown self-update option: $arg"
;;
esac
i=$((i + 1))
done
return 0
fi
# No leading dash → interactive search
if [[ $1 != -* ]]; then
OP=interactive
@@ -117,6 +157,9 @@ parse_args() {
printf 'miaur v%s\n' "$MIAUR_VERSION"
exit 0
;;
--self-update)
OP=selfupdate
;;
--aur)
OP_AUR_ONLY=1
MIAUR_MODE=aur
@@ -153,6 +196,18 @@ parse_args() {
MIAUR_MODE=${raw[$i]:-}
;;
--mode=*) MIAUR_MODE=${arg#*=} ;;
--repo-url)
i=$((i + 1))
MIAUR_REPO=${raw[$i]:-}
[[ -n $MIAUR_REPO ]] || die "--repo-url requires a URL"
;;
--repo-url=*) MIAUR_REPO=${arg#*=} ;;
--branch)
i=$((i + 1))
MIAUR_BRANCH=${raw[$i]:-}
[[ -n $MIAUR_BRANCH ]] || die "--branch requires a name"
;;
--branch=*) MIAUR_BRANCH=${arg#*=} ;;
--sync) OP=S ;;
--query) OP=Q ;;
--remove)