summaryrefslogtreecommitdiffstats
path: root/content/en/slackware/mkhint/index.md
blob: e2d1c2056ce5f23eb28fc7274344104588cdf575 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
+++
title    = "mkhint"
tagline  = "Manage slackrepo hint files: bump versions, recompute checksums, track upstream releases."
status   = "active"
repo_url = "https://git.danix.xyz/mkhintfile"
tags     = ["bash", "slackware", "slackrepo", "packaging"]

[menus.main]
  name   = "hintfiles helper"
  parent = "slackware"
  weight = 10
+++

**mkhint** is a single Bash script that takes the tedium out of maintaining
[slackrepo](https://idlemoor.github.io/slackrepo/) *hint files*. A hint file
overrides build details for an SBo package: which version to build, where to
download the source, and the checksums to verify it. Keeping those in sync by
hand, across dozens of packages, is exactly the kind of repetitive work a
script should own.

## What it does

- **Update a hint** `-f package -v 2.0.1`: bump the version everywhere in the
  file, re-download the source from `DOWNLOAD` / `DOWNLOAD_x86_64`, and recompute
  `MD5SUM` / `MD5SUM_x86_64`. The old file is backed up to `.bak` first.
- **Create a hint** `-n package`: generate a new hint from the matching
  repository `.info` file, stripping the fields slackrepo does not want and
  defaulting `ARCH` to `x86_64`. With no `.info`, it writes an empty skeleton.
- **List** `-l`: print every hint with its `HintVer` (version in the hint) next
  to the `SBOVer` (version in the repo `.info`), highlighting the rows where the
  two are byte-equal so you can spot hints that have become redundant with
  upstream. Passing names (`-l foo bar`) skips the table and shows each named
  hint side by side with its `.info` instead.
- **Review** `-R`: walk only those matched hints, showing each hint side by
  side with its `.info` (`git diff --no-index`, falling back to `diff -y`), and
  prompt to keep, delete, or skip. Passing names (`-R foo bar`) reviews the named
  hints regardless of version match.
- **Fix -current** `-F`: sweep the whole repository and, for every package whose
  `REQUIRES` names a phantom dep (one unneeded on slackware-current, listed once
  in `~/.config/mkhint/phantom-deps`), ensure the hint carries the matching
  `DELREQUIRES`. Idempotent, so run it after each weekly repo regeneration.
  `-n` applies the same list when creating a hint.
- **Check** `-C [package...]`: query
  [nvchecker](https://github.com/lilydjwg/nvchecker) for the latest upstream
  version of one, several, or all hints; report what is outdated; update accepted
  packages with `nvtake`; and finish with a single `slackrepo update` prompt for
  everything that changed.
- **Housekeeping** `-d package` / `-c`: delete a hint and its backup, or clean
  every `.bak` from the hint directory in one go.

## Command reference

```text
mkhint - Manage hint files for slackrepo scripts

Usage:
  ./mkhint --version VERSION --hintfile FILE    Update existing hint file
  ./mkhint --version VERSION --new FILE         Create new hint file
  ./mkhint --new FILE                           Create new hint file (no version)
  ./mkhint --hintfile FILE                      Update hint, suggest latest version via nvchecker
  ./mkhint --check [FILE...]                     Check all (or named) hints for upstream updates
  ./mkhint --fix-current                        Sweep repo, add DELREQUIRES for -current phantom deps
  ./mkhint --list                               List hint files
  ./mkhint --review                             Review hints matching SBo version, keep/delete each
  ./mkhint --review FILE...                      Review named hints (any version), keep/delete each
  ./mkhint --clean                              Remove .bak files from HINT_DIR
  ./mkhint --no-dl --hintfile FILE              Update hint, skip downloads, add NODOWNLOAD=yes
  ./mkhint --no-dl --new FILE                   Create hint with NODOWNLOAD=yes
  ./mkhint --help                               Show this help

Options:
  --version, -v VERSION    New version string (required for --hintfile)
  --hintfile, -f FILE      Path to existing hint file (required with --version)
  --new, -n FILE           Create new hint file (required with --version or standalone)
  --list, -l [FILE...]     List all hint files; FILE... = side-by-side hint vs .info
  --review, -R [FILE...]   Review hints; no args = matched only, FILE... = named hints (any version)
  --clean, -c              Remove all .bak files from HINT_DIR
  --check, -C [FILE...]    Check hints for upstream updates via nvchecker, update interactively
  --fix-current, -F        Add/merge DELREQUIRES for -current phantom deps across the whole repo
  --delete, -d FILE        Delete a hint file (and .bak if present)
  --no-dl, -N              Skip downloads; add NODOWNLOAD=yes to hint file (use with -f or -n)
  --help, -h               Show this help message
```

## How it works

mkhint is plain Bash with three small dependencies, each doing one job:

- `wget` downloads archives so their MD5 can be computed,
- `nvchecker` (and its companion `nvtake`) tracks upstream versions,
- `jq` parses nvchecker's JSON output.

Everything else is shell. Paths to the repository and the hint directory are
two variables at the top of the script. The bash-completion file mirrors them,
so `-f`, `-n`, `-d`, and `-C` autocomplete package names from the right
directory, and `-v` even suggests the current version pulled straight from the
named hint file.

Multiline `DOWNLOAD` entries (a package with several source URLs) are handled
carefully: the first URL is always re-fetched because the version changed,
while each continuation URL is offered interactively so unchanged sources keep
their existing checksum instead of being downloaded again for nothing.

A SlackBuild version string cannot contain `-` (it would break `PRGNAM`
parsing), so an upstream release like `2026-06-02` is packaged as `2026_06_02`.
mkhint normalizes upstream versions (`-` becomes `_`) before comparing, so
these read as the same version and no spurious up- or downgrade is offered; the
underscore form is what gets written to the hint.

The `-F` / `--fix-current` sweep and the phantom-dep handling in `-n` both read
`~/.config/mkhint/phantom-deps`, one dep per line (`#` comments allowed). This
covers deps that SBo SlackBuilds need on Slackware stable but not on
slackware-current, where the system already ships them, for example `rust-opt`
or `google-go-lang`. slackrepo strips such a dep with `DELREQUIRES` in the hint;
mkhint writes and merges that line for you. A missing list makes both features
no-ops.

## Why it exists

Maintaining a personal SBo overlay means a steady trickle of version bumps.
Each one is the same dance: edit the version string, fetch the new tarball,
recompute the checksum, hope you did not fat-finger a digit. mkhint turns that
dance into one command, and the `--check` / `--list` / `--review` trio turns
"which of my hints are now stale or pointless?" from a manual audit into a
glance. It is the kind of small, sharp tool Slackware encourages: no daemon,
no database, no framework, just a script that does one annoying job well.

## Quick start

```bash
sudo cp mkhint /usr/local/bin/mkhint
sudo cp mkhint.bash-completion /etc/bash-completion.d/mkhint

# update an existing hint to a known version
mkhint -f mypackage -v 2.0.1

# create a new hint from the repo .info
mkhint -n mypackage

# see what upstream has moved on
mkhint --check
```

Edit the `REPO_DIR` and `HINT_DIR` paths at the top of the script (and in the
completion file) to match your setup before first use.

{{< actions use="repo" url="https://git.danix.xyz/mkhintfile/" desc="Browse the source" caption="I hope you find it useful. If you maintain your own slackrepo overlay, mkhint might save you the same tedium it saves me. Patches and ideas are welcome." >}}