diff options
| -rw-r--r-- | README.md | 40 | ||||
| -rwxr-xr-x | install.sh | 78 | ||||
| -rw-r--r-- | mkhint.1.gz | bin | 3980 -> 4162 bytes | |||
| -rw-r--r-- | mkhint.1.md | 8 |
4 files changed, 115 insertions, 11 deletions
@@ -6,21 +6,27 @@ Manage hint files for slackrepo scripts. Updates version strings and download ch ## Installation -### Script +The `install.sh` script installs the binary, bash completion, and man page. Run +it as root for a system-wide install, or as a normal user for a user-only +install under `~/.local`: ```bash -sudo cp mkhint /usr/local/bin/mkhint +./install.sh # system-wide (as root) or user-only (as normal user) +./install.sh uninstall # remove the installed files ``` -### Bash Completion +System paths: `/usr/local/bin/mkhint`, `/usr/local/man/man1/mkhint.1.gz`, and +the bash completion in whichever of `/etc/bash_completion.d` or +`/etc/bash-completion.d` exists (defaulting to the underscore form on +Slackware). User paths follow XDG: `~/.local/bin`, `~/.local/share/man/man1`, +and `~/.local/share/bash-completion/completions`. On Slackware `~/.local/bin` is +not on `PATH` by default; the script warns when the install dir is unreachable. -```bash -sudo cp mkhint.bash-completion /etc/bash-completion.d/mkhint -``` - -### Man Page +To install by hand instead: ```bash +sudo cp mkhint /usr/local/bin/mkhint +sudo cp mkhint.bash-completion /etc/bash_completion.d/mkhint sudo cp mkhint.1.gz /usr/local/man/man1/mkhint.1.gz ``` @@ -35,9 +41,21 @@ pandoc mkhint.1.md -s -t man -o mkhint.1 && gzip -9 -n -f mkhint.1 ### Dependencies -- `wget` — for downloading archives and calculating checksums -- `nvchecker` — for checking upstream versions (provides `nvchecker` and `nvtake`) -- `jq` — for parsing version check results +**Required:** + +- `slackrepo` — the tool whose hint files `mkhint` manages; dispatched after a version bump +- `wget` — downloading archives and calculating checksums +- `nvchecker` — checking upstream versions (provides both `nvchecker` and `nvtake`) +- `jq` — parsing version-check results and GitHub API responses (bundled-dep reconcile) + +**Optional (features degrade gracefully if absent):** + +- `git` — side-by-side diffs in `--review`, `--list <pkg>`, and `--info`; falls back to `diff -y` +- `less` — paging the README in `--info` when it is taller than the terminal +- `tput` — TTY color detection; output is plain without it + +`perl`, `awk`, `sed`, `grep`, `md5sum`, and other coreutils are part of a base +Slackware install and are assumed present. ### Configuration diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..0cb916d --- /dev/null +++ b/install.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# install.sh — install (or uninstall) mkhint, its bash completion, and man page. +# +# Run as root for a system-wide install, or as a normal user for a user-only +# install under ~/.local. Usage: +# +# ./install.sh system install if root, else user install +# ./install.sh uninstall remove the files from wherever they were installed +# +# Copyright (C) 2026 Danilo M. <danix@danix.xyz> +# Licensed under the GNU GPL v2 (see LICENSE). + +set -e + +SRC_DIR="$(cd "$(dirname "$0")" && pwd)" + +BIN_SRC="$SRC_DIR/mkhint" +COMP_SRC="$SRC_DIR/mkhint.bash-completion" +MAN_SRC="$SRC_DIR/mkhint.1.gz" + +# Pick paths based on privilege. +if [[ $EUID -eq 0 ]]; then + MODE="system" + BIN_DIR="/usr/local/bin" + MAN_DIR="/usr/local/man/man1" + # Slackware ships /etc/bash_completion.d (underscore); some distros use the + # hyphen. Install to whichever exists, defaulting to underscore. + if [[ -d /etc/bash-completion.d ]]; then + COMP_DIR="/etc/bash-completion.d" + else + COMP_DIR="/etc/bash_completion.d" + fi +else + MODE="user" + BIN_DIR="$HOME/.local/bin" + MAN_DIR="$HOME/.local/share/man/man1" + COMP_DIR="$HOME/.local/share/bash-completion/completions" +fi + +BIN_DST="$BIN_DIR/mkhint" +COMP_DST="$COMP_DIR/mkhint" +MAN_DST="$MAN_DIR/mkhint.1.gz" + +if [[ "$1" == "uninstall" ]]; then + echo "Uninstalling mkhint ($MODE)..." + rm -fv "$BIN_DST" "$COMP_DST" "$MAN_DST" + echo "Done." + exit 0 +fi + +if [[ -n "$1" ]]; then + echo "Unknown argument: $1" >&2 + echo "Usage: $0 [uninstall]" >&2 + exit 1 +fi + +# Sanity-check sources before touching the filesystem. +for f in "$BIN_SRC" "$COMP_SRC" "$MAN_SRC"; do + if [[ ! -f "$f" ]]; then + echo "Missing source file: $f" >&2 + exit 2 + fi +done + +echo "Installing mkhint ($MODE)..." +install -Dm755 "$BIN_SRC" "$BIN_DST" && echo " $BIN_DST" +install -Dm644 "$COMP_SRC" "$COMP_DST" && echo " $COMP_DST" +install -Dm644 "$MAN_SRC" "$MAN_DST" && echo " $MAN_DST" +echo "Done." + +# On Slackware ~/.local/bin is not on PATH by default; warn if the bin dir is +# not reachable so the user knows to fix it. +case ":$PATH:" in + *":$BIN_DIR:"*) ;; + *) echo + echo "NOTE: $BIN_DIR is not on your PATH." + echo " Add it, e.g.: export PATH=\"$BIN_DIR:\$PATH\"" ;; +esac diff --git a/mkhint.1.gz b/mkhint.1.gz Binary files differindex 9ca085c..75c4e10 100644 --- a/mkhint.1.gz +++ b/mkhint.1.gz diff --git a/mkhint.1.md b/mkhint.1.md index 28f294b..a3bffe2 100644 --- a/mkhint.1.md +++ b/mkhint.1.md @@ -41,6 +41,14 @@ After a version-changing update, **mkhint** dispatches **slackrepo** for the affected package: `slackrepo update` if the package is already built in the package repository, `slackrepo build` if it is not. +# REQUIREMENTS + +Required: **slackrepo**, **wget**, **nvchecker** (which also provides +**nvtake**), and **jq**. Optional: **git** (nicer side-by-side diffs, falls back +to `diff -y`), **less** (paging in **\--info**), and **tput** (color on a TTY). +Coreutils (**perl**, **awk**, **sed**, **grep**, **md5sum**) are assumed from a +base Slackware install. + # OPTIONS **\--set-version**, **-V** *VERSION* |
