diff options
| author | Danilo M. <danix@danix.xyz> | 2026-07-05 20:09:34 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-07-05 20:09:34 +0200 |
| commit | a45ec57c5565c974fccbb95c038c15dd60eaada6 (patch) | |
| tree | 3d7732f33779f105153d710060973c36381b0c8b /mkhint | |
| parent | 10407e9d48cd64ca85723bd7b444846b9633fc57 (diff) | |
| download | mkhintfile-a45ec57c5565c974fccbb95c038c15dd60eaada6.tar.gz mkhintfile-a45ec57c5565c974fccbb95c038c15dd60eaada6.zip | |
feat: slackrepo build for new packages, update for existing
Diffstat (limited to 'mkhint')
| -rwxr-xr-x | mkhint | 48 |
1 files changed, 37 insertions, 11 deletions
@@ -26,6 +26,14 @@ NVCHECKER_CONFIG="$HOME/.config/nvchecker/nvchecker.toml" # Missing file = empty list = phantom-dep handling is a no-op. PHANTOM_DEPS_FILE="$HOME/.config/mkhint/phantom-deps" +# Built-package repository (slackrepo output tree: <cat>/<pkg>/<pkg>-*.txz). +PACKAGES_DIR="/repo/" + +# ponytail: sourced config, defaults above win when file absent. A syntax-broken +# config aborts under `set -e` — acceptable for a single-user tool. +MKHINT_CONFIG="$HOME/.config/mkhint/config" +[[ -f "$MKHINT_CONFIG" ]] && source "$MKHINT_CONFIG" + # create the temp dir if not existing if [[ ! -d $TMP_DIR ]]; then mkdir $TMP_DIR @@ -820,14 +828,31 @@ update_hint_file() { echo; echo "==========================================" } -# Prompt to run slackrepo update after a hint file update -prompt_slackrepo() { +# True if a built package (.txz) for <pkg> exists in the repo. +pkg_in_repo() { local pkg="$1" + compgen -G "${PACKAGES_DIR%/}/*/${pkg}/${pkg}-*.txz" >/dev/null 2>&1 +} + +# Prompt to run `slackrepo <action> <pkgs...>`; no-op on empty list. +run_slackrepo() { + local action="$1"; shift + [[ $# -eq 0 ]] && return 0 local answer - read -r -p "Run 'slackrepo update $pkg'? [Y/n] " answer + read -r -p "Run 'slackrepo $action $*'? [Y/n] " answer answer="${answer:-Y}" if [[ "$answer" =~ ^[Yy]$ ]]; then - slackrepo update "$pkg" + slackrepo "$action" "$@" + fi +} + +# Single-package dispatch: update if already built, else build. +prompt_slackrepo() { + local pkg="$1" + if pkg_in_repo "$pkg"; then + run_slackrepo update "$pkg" + else + run_slackrepo build "$pkg" fi } @@ -995,14 +1020,15 @@ check_updates() { fi done - # Single slackrepo prompt for everything updated + # Split updated packages: existing → update, new → build. if [[ ${#updated[@]} -gt 0 ]]; then - local answer - read -r -p "Run 'slackrepo update ${updated[*]}'? [Y/n] " answer - answer="${answer:-Y}" - if [[ "$answer" =~ ^[Yy]$ ]]; then - slackrepo update "${updated[@]}" - fi + local -a existing=() fresh=() + local up + for up in "${updated[@]}"; do + if pkg_in_repo "$up"; then existing+=("$up"); else fresh+=("$up"); fi + done + run_slackrepo update "${existing[@]}" + run_slackrepo build "${fresh[@]}" fi } |
