From a45ec57c5565c974fccbb95c038c15dd60eaada6 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sun, 5 Jul 2026 20:09:34 +0200 Subject: feat: slackrepo build for new packages, update for existing --- mkhint | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) (limited to 'mkhint') diff --git a/mkhint b/mkhint index 792b781..5a48e18 100755 --- a/mkhint +++ b/mkhint @@ -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: //-*.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 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 `; 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 } -- cgit v1.2.3