aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: b324eb385b81690ffc51e17612dad093be031c1c (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
# dist-upgrade

Update a Slackware `-current` system with `slackpkg`, then verify the initrd
still matches the newly installed kernel and still contains the modules the
system needs to boot.

The script wraps the standard `-current` routine (`update`, `install-new`,
`upgrade-all`, `clean-system`, `new-config`) and adds three initrd checks so a
stale or incomplete initrd cannot silently leave you with an unbootable system.

## Usage

    sudo ./dist-upgrade          # unattended
    sudo ./dist-upgrade -i       # interactive, slackpkg prompts normally

Options:

- `-i`, `--interactive` run slackpkg with its normal prompts
- `-h`, `--help` print usage
- `--self-test` run the internal logic checks and exit (no root needed)

Environment:

- `INITRD` initrd to inspect (default `/boot/initrd-generic.img`)
- `LOG` append the non-interactive run, slackpkg output included, to this file
  (default `/var/log/dist-upgrade.log`; set it empty to disable)
- `R8125_DIR` SBo `r8125` SlackBuild directory used for the driver rebuild

A logrotate rule for that log ships in `logrotate.d/dist-upgrade`; install it
to `/etc/logrotate.d/`.

## What it does

1. Snapshots the current initrd's kernel version and module list.
2. Runs `slackpkg update`, `install-new`, `upgrade-all`, `clean-system`,
   `new-config`.
3. Checks:
   - the initrd's kernel version against the newest installed kernel,
   - the modules `mkinitrd_command_generator.sh` says are needed against the
     initrd's contents,
   - the module set against the pre-upgrade snapshot (notices modules lost).
4. If the `r8125` package is installed and the newest kernel has no `r8125`
   module, rebuilds it from the SBo SlackBuild in `R8125_DIR` (default
   `/var/lib/sbopkg/SBo-git/network/r8125`) and installs it with `upgradepkg`.
   The tree is used as-is; sync it first if the new kernel needs a newer
   driver.
5. Lists any leftover `.new` config files; an unattended run also suggests
   `slackpkg new-config` to merge them.
6. Reports whether a reboot is recommended.

A non-interactive run is appended to `LOG`, with a timestamped header per run,
so an unattended upgrade can be reviewed afterwards. Interactive runs are not
logged: slackpkg's TUI needs the terminal, and redirecting it through the log
breaks the curses interface.

If slackpkg upgrades itself mid-run (exit status 50) the script re-executes
once from the top to finish the operation, exactly as slackpkg's own message
asks. A second occurrence aborts with a message instead of looping.

Unattended mode runs the package commands with `-batch=on -default_answer=y`.
`clean-system` is the exception: unattended it only lists packages that are not
part of the official Slackware set and removes nothing, so third-party or
local packages are never deleted silently. When it does find such packages, the
closing recap reminds you to re-run with `-i` to review and remove them.

## Requirements

Slackware `-current`, run as root. Needs `slackpkg`, `cpio` and `gzip`; `zstd`
and `xz` are used only if the initrd is compressed with them. The `r8125`
rebuild needs `wget` and the new kernel's `/lib/modules/<ver>/build` tree.
The module bootability check uses Slackware's own
`/usr/share/mkinitrd/mkinitrd_command_generator.sh` when present.

## Testing

    bash -n dist-upgrade
    ./dist-upgrade --self-test

`--self-test` builds a small gzip/cpio initrd in a temp dir and round-trips it
through the reader, alongside checks of the module/version parsers.

## License

GPLv2 (version 2 only). See [LICENSE](LICENSE).

## Development Approach

This project is developed using AI-assisted tools. Code is generated with the help of AI based on human-provided specifications, design decisions, and iterative feedback.

All contributions are reviewed, tested, and curated by the maintainer before being included in the codebase. AI is used as a productivity and exploration tool, while human oversight remains central to all decisions.

The goal is to combine the flexibility of AI-assisted development with standard open-source practices such as transparency, review, and accountability.