diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e5b6e8..b1e4177 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: ci -# build (x86_64 and aarch64) -> test -> bundle -> release. +# version checker tests -> build (x86_64 and aarch64) -> test -> bundle -> release. # # The test suite runs against the binaries that were just compiled, so it # cannot run before the build. Gating therefore sits on the bundle: nothing is @@ -31,8 +31,17 @@ concurrency: cancel-in-progress: true jobs: + version-check-tests: + name: version checker tests + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v5 + - run: python3 tests/test_check_versions.py + build: name: build + needs: version-check-tests uses: ./.github/workflows/build.yml test: diff --git a/README.md b/README.md index 3a5695c..7774f78 100644 --- a/README.md +++ b/README.md @@ -376,9 +376,9 @@ delicate, and every one of them runs against the Fil-C binary. | Utility | Upstream suite | Result under Fil-C | | --- | --- | --- | | GNU tar | Autotest, 226 files | 208 pass, 36 skip | -| curl | 1664 enabled cases | 1664 pass | +| curl | 1712 enabled cases | 1712 pass | | GNU Wget | `tests/` + `testenv/`, 136 cases | 134 pass, 2 skip | -| tmux | `regress/`, 35 cases (git only) | 35 pass | +| tmux | `regress/`, 174 cases (git only) | 174 pass | | gzip | 34 cases | 33 pass, 1 skip | | XZ Utils | 21 cases | 21 pass | | Zstandard | `playTests.sh` and fuzzers | all pass | @@ -432,7 +432,7 @@ also proves the terminal descriptions compiled into the binary are what let it run where the scratch image has no terminfo on disk. tmux's release tarball ships no tests either, but unlike nano its suite does -exist: the 35 scripts in `regress/` live only in the git tree. The build fetches +exist: the 174 scripts in `regress/` live only in the git tree. The build fetches the same tag a second time as a source archive and takes only that directory, which is how the unRAR build gets its fixture corpus, and runs the tests against the binary already built. Two further checks cover what a headless suite cannot. @@ -443,8 +443,18 @@ pane. Separately, every terminfo database on the build image is moved aside and a session is started with none, which proves the compiled-in descriptions rather than the builder's own database are doing the work. -Four details are easy to get wrong. curl's suite silently skips its 62 HTTPS -cases unless `stunnel4` is installed, and zstd's re-links the CLI, so it needs +tmux has three libc compatibility fixes scoped to Fil-C. Time-expanded strings +escape conversion specifications musl does not recognize, so literal tmux pane +IDs such as `%0` behave as they do with glibc instead of blanking a status line. +Plain `ctime` expansion rejects years outside musl's printable range before its +`asctime_r` abort path, while custom time formats keep working. Finally, panes +with equal sort keys use pane-list order rather than musl's unstable `qsort` +permutation. Exact upstream regressions and focused format checks cover all +three paths. The sixel-enabled build also adjusts the suite's primary device +attributes expectation to include the sixel capability it deliberately enables. + +Four details are easy to get wrong. curl's suite silently skips its HTTPS cases +unless `stunnel4` is installed, and zstd's re-links the CLI, so it needs the same flags as the build or it fails to link rather than testing anything. Wget's HTTPS tests name their server `WgetTestingServer` and map it to localhost through `HOSTALIASES`, a glibc feature the musl client ignores; the @@ -690,21 +700,21 @@ than content-addressed image digests. | bzip2 source | 1.0.8 | `ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269` | | XZ Utils source | 5.8.4 | `4ce24038fd4221e0d13bc1a2de7a4db56e90b92b3bf75321f6c14be73f65de4b` | | Zstandard source | 1.5.7 | `eb33e51f49a15e023950cd7825ca74a4a2b43db8354825ac24fc1b7ee09e6fa3` | -| curl source | 8.22.0 | `f7ef3ae8a22e521f289803fe93543eb64c329b58aa73a9e224dfd915a2a5f4f7` | +| curl source | 8.23.0 | `8dadd7d2536a314f982ad05a651b713f426bf7d02cc2c76cffb9796f2218e6c5` | | GNU Wget source | 1.25.0 | `766e48423e79359ea31e41db9e5c289675947a7fcf2efdcedb726ac9d0da3784` | | OpenSSL source (curl, git, OpenSSH) | 4.0.3 | `325b5c806167c13b40b1ffeadfe0248197c00eccc4cf123ec1e28d2d2fd216d9` | | OpenSSL source (wget) | 3.6.5 | `a2157c2830efdec3788939b00c9b0638306d3f0bbb76dc4832ee503bb397df98` | | zlib source | 1.3.2 | `bb329a0a2cd0274d05519d61c667c062e06990d72e125ee2dfa8de64f0119d16` | -| libunistring source | 1.4.2 | `5b46e74377ed7409c5b75e7a96f95377b095623b689d8522620927964a41499c` | +| libunistring source | 1.5 | `fe89007a8a414ae4790b816b86859e877d3ab135db3c37f06541ff7e85ac344b` | | libidn2 source | 2.3.8 | `f557911bf6171621e1f72ff35f5b1825bb35b52ed45325dcdee931e5d3c0787a` | | libpsl source | 0.23.3 | `93941f85a1e7bd593fa94f299233cb5dfc91cd144fd9a78a6ceb75001c5b03be` | | PCRE2 source | 10.49 | `929f0b20e62879252a15886b06c89f1edef61a363cbd5826fb041080a5e557ae` | -| c-ares source | 1.34.8 | `c222b6d681096f9444d2c4863d2c1174019e27cacca0a4a5c114d36dd7d7bf78` | -| GNU nano source | 9.1 | `5f47764274cb7532349ce0aa20ec10f1e8e851a6e9fa3eb66812c43d196db042` | +| c-ares source | 1.34.9 | `9364b70a12eb59a06830fb488d9357f90100dff0d98b23ea3593a183d43e6f2f` | +| GNU nano source | 9.2 | `05ecb99247b782e8a5b3a25ed4101dd034b0236902f7449bc9795b717642f7e9` | | ncurses source | 6.6 | `355b4cbbed880b0381a04c46617b7656e362585d52e9cf84a67e2009b749ff11` | -| file source | 5.46 | `c9cc77c7c560c543135edc555af609d5619dbef011997e988ce40a3d75d86088` | -| tmux source | 3.7c | `7c60cae9a0e25288e2e24750aafc9e8800fc7fd4555e447e1b29ee4201cfb3bf` | -| tmux tests (git tag) | 3.7c | `5e7b0f533b66e5633e2b72a9d483f9534a343ab7011eb2621b6309dfba553daa` | +| file source | 5.48 | `ed14656883b23a364b4057c05595d93252da9bc473d30106519519d0da141283` | +| tmux source | 3.8 | `e79c699c7e949dccd0a4a125e17b8d1261e311b16979dbc8eb34542f3966d82e` | +| tmux tests (git tag) | 3.8 | `f873f9379c9cf30d3d66b642a955118c4fbb0019d046d13e6012340811e5dcb7` | | libevent source | 2.1.13 | `f7e9383b8c0baa81b687e5b5eecc01beefaf1b19b64151d95ed61647fe7a315c` | | utf8proc source | 2.12.0 | `a393fbef160835fb315bc3e91ba8d86f7a73a7cec9e6198b6c60b848b498bfeb` | | Git source | 2.56.0 | `26c56c296b38c0695b26fa95f475f1d01704d2d38e73465ca30b0b2f5dc789d3` | @@ -879,7 +889,8 @@ recovery. │ ├── Dockerfile │ └── patches/ ├── tmux/ -│ └── Dockerfile +│ ├── Dockerfile +│ └── patches/ ├── unrar/ │ ├── Dockerfile │ └── patches/ @@ -892,6 +903,7 @@ recovery. │ └── patches/ └── tests/ ├── run-tests.sh + ├── test_check_versions.py ├── lib.sh ├── make-seed.py ├── make-corpus.sh @@ -969,9 +981,10 @@ curl 8.19.0 8.21.0 OUTDATED The `COMPONENTS` table is explicit rather than discovered from Dockerfile arguments. Every upstream has a different release source, so each registered component uses its project's authoritative release API or listing: GitHub, -GNU, Sourceware, RARLab, or the OpenBSD CDN. A new maintained release pin needs -a table entry and an upstream-specific lookup or it will not receive freshness -reports. +Sourceware, RARLab, the OpenBSD CDN, or astron.com's `file` archive. GNU +lookups use canonical `ftp.gnu.org` first, with its mirror redirector as a +bounded fallback. A new maintained release pin needs a table entry and an +upstream-specific lookup or it will not receive freshness reports. The check never stops at the first problem. A component whose upstream is unreachable, or whose listing has changed shape, is reported as an error and @@ -980,6 +993,7 @@ It runs locally the same way, where it does exit nonzero if anything is behind, so it works as a plain command as well as a source of comment text: ```sh +python3 tests/test_check_versions.py python3 check-versions.py ``` @@ -1203,6 +1217,12 @@ Fil-C tree, is dynamic and installs into a prefix that already holds ncurses and libevent, so the static link and the terminfo question are this build's own work rather than something inherited from it. +Three tmux source paths are patched for Fil-C's musl libc: unknown `strftime` +conversions are preserved literally, plain `ctime` rejects years its fixed +buffer cannot print, and pane sorts make equal-key list order explicit instead +of relying on libc `qsort` stability. Each patch has a focused assertion or an +upstream regression that fails without it. + OpenSSH locks Fil-C's collector and allocator threads before installing its preauthentication seccomp filter, then allows the runtime's `sched_yield` and `MAP_NORESERVE` use. Violations kill the whole process because leaving other @@ -1219,8 +1239,10 @@ tests, and live default key exchange cover them. ### Updating a dependency -Run `python3 check-versions.py` to see which pins are behind; the `versions` -workflow runs the same check when a pull request is opened and comments if any +Run `python3 tests/test_check_versions.py` to verify the lookup logic, then +`python3 check-versions.py` to see which pins are behind. The `ci` workflow +runs the unit tests on every pull-request update and main push; the `versions` +workflow runs the live check when a pull request is opened and comments if any are. 1. Change the version and checksum arguments near the top of its Dockerfile. diff --git a/check-versions.py b/check-versions.py index 002bafc..1c0bba5 100755 --- a/check-versions.py +++ b/check-versions.py @@ -10,6 +10,7 @@ continues: a single unreachable host must not hide a stale pin somewhere else. Every component is always in the table. """ +import http.client import json import os import re @@ -25,20 +26,25 @@ # --------------------------------------------------------------------- fetching -def _get(url, headers=None): +def _get(url, headers=None, *, timeout=TIMEOUT, retries=RETRIES): last = None - for attempt in range(RETRIES): + for attempt in range(retries): try: req = urllib.request.Request(url, headers={"User-Agent": UA, **(headers or {})}) - with urllib.request.urlopen(req, timeout=TIMEOUT) as resp: + with urllib.request.urlopen(req, timeout=timeout) as resp: return resp.read() - except (urllib.error.URLError, TimeoutError, OSError) as exc: + except ( + urllib.error.URLError, + http.client.HTTPException, + TimeoutError, + OSError, + ) as exc: last = exc raise RuntimeError(f"{url}: {last}") -def get_text(url, headers=None): - return _get(url, headers).decode("utf-8", "replace") +def get_text(url, headers=None, *, timeout=TIMEOUT, retries=RETRIES): + return _get(url, headers, timeout=timeout, retries=retries).decode("utf-8", "replace") def get_json(url): @@ -90,8 +96,10 @@ def newest(versions): def github_latest(repo, strip="", underscores=False, series=None): """Newest non-prerelease tag for a GitHub repository. - Prefers the release marked "latest"; falls back to the tag list for - projects that publish releases without setting that flag. + Checks releases and tags together. Projects can publish a stable tag before + creating its GitHub release, so trusting only the latest-release pointer can + leave a newer tag unnoticed. Tags attached to prerelease or draft releases + are excluded even when their names look like stable numeric versions. `series` restricts the answer to one release line, for example "3." to stay within OpenSSL 3.x. A pin deliberately held back still needs its own line @@ -104,26 +112,44 @@ def norm(tag): tag = tag[len(strip):] return tag.replace("_", ".") if underscores else tag - try: - tag = get_json(f"https://api.github.com/repos/{repo}/releases/latest")["tag_name"] - version = norm(tag) - if is_stable(version) and (series is None or version.startswith(series)): - return version - except RuntimeError: - pass # no "latest" release marked, or transient; try the tag list - - tags = get_json(f"https://api.github.com/repos/{repo}/tags") - names = (norm(t["name"]) for t in tags) + releases = get_json(f"https://api.github.com/repos/{repo}/releases?per_page=100") + excluded_tags = { + release["tag_name"] + for release in releases + if release.get("draft") or release.get("prerelease") + } + versions = [ + norm(release["tag_name"]) + for release in releases + if release["tag_name"] not in excluded_tags + ] + + tags = get_json(f"https://api.github.com/repos/{repo}/tags?per_page=100") + names = (norm(t["name"]) for t in tags if t["name"] not in excluded_tags) if series is not None: names = (n for n in names if n.startswith(series)) - return newest(names) + versions = [v for v in versions if v.startswith(series)] + versions.extend(names) + return newest(versions) def gnu_ftp(name, directory=None): # libidn2 releases live in the gnu/libidn/ directory alongside libidn's, so # the listing to read and the file prefix to match are not always the same. - html = get_text(f"https://ftp.gnu.org/gnu/{directory or name}/") - return newest(re.findall(rf"{re.escape(name)}-(\d+(?:\.\d+)+)\.tar\.", html)) + directory = directory or name + last = None + for url in ( + f"https://ftp.gnu.org/gnu/{directory}/", + f"https://ftpmirror.gnu.org/{directory}/", + ): + try: + html = get_text(url, timeout=10, retries=1) + return newest( + re.findall(rf"{re.escape(name)}-(\d+(?:\.\d+)+)\.tar\.", html) + ) + except RuntimeError as exc: + last = exc + raise RuntimeError(f"GNU listings failed: {last}") def sourceware_bzip2(): @@ -131,6 +157,11 @@ def sourceware_bzip2(): return newest(re.findall(r"bzip2-(\d+(?:\.\d+)+)\.tar\.gz", html)) +def astron_file(): + html = get_text("https://astron.com/pub/file/") + return newest(re.findall(r"file-(\d+(?:\.\d+)+)\.tar\.gz", html)) + + def rarlab_unrar(): # rarlab has no API. The current UnRAR source is linked from the add-ons # page and the main download page; take whichever gives the higher version. @@ -203,6 +234,8 @@ def openbsd_openssh(): ("libevent", "tmux/Dockerfile", "LIBEVENT_VERSION", libevent_latest), ("utf8proc", "tmux/Dockerfile", "UTF8PROC_VERSION", lambda: github_latest("JuliaStrings/utf8proc", "v")), ("ncurses", "tmux/Dockerfile", "NCURSES_VERSION", lambda: gnu_ftp("ncurses")), + ("nano", "nano/Dockerfile", "NANO_VERSION", lambda: gnu_ftp("nano")), + ("file", "nano/Dockerfile", "FILE_VERSION", astron_file), ("git", "git/Dockerfile", "GIT_VERSION", lambda: github_latest("git/git", "v")), ("expat", "git/Dockerfile", "EXPAT_VERSION", expat_latest), ("openssh", "openssh-server/Dockerfile", "OPENSSH_VERSION", openbsd_openssh), diff --git a/curl/Dockerfile b/curl/Dockerfile index 9c4adc1..632a75a 100644 --- a/curl/Dockerfile +++ b/curl/Dockerfile @@ -7,8 +7,8 @@ ARG ZLIB_VERSION=1.3.2 ARG ZLIB_SHA256=bb329a0a2cd0274d05519d61c667c062e06990d72e125ee2dfa8de64f0119d16 ARG OPENSSL_VERSION=4.0.3 ARG OPENSSL_SHA256=325b5c806167c13b40b1ffeadfe0248197c00eccc4cf123ec1e28d2d2fd216d9 -ARG CURL_VERSION=8.22.0 -ARG CURL_SHA256=f7ef3ae8a22e521f289803fe93543eb64c329b58aa73a9e224dfd915a2a5f4f7 +ARG CURL_VERSION=8.23.0 +ARG CURL_SHA256=8dadd7d2536a314f982ad05a651b713f426bf7d02cc2c76cffb9796f2218e6c5 FROM ubuntu:24.04 AS build @@ -177,8 +177,8 @@ RUN binary=/src/src/curl \ # ends of every connection rather than only on the client. # # stunnel is what makes the TLS cases runnable. Without it curl's suite skips -# 62 HTTPS tests and still reports success, which for a network client would -# leave the most important paths untested while looking healthy. +# HTTPS tests and still reports success, which for a network client would leave +# the most important paths untested while looking healthy. # # The run is checked two ways. runtests.pl must succeed, and a floor is placed # under the number of cases that actually ran, because a configuration change diff --git a/git/Dockerfile b/git/Dockerfile index 5610193..e4d6212 100644 --- a/git/Dockerfile +++ b/git/Dockerfile @@ -7,8 +7,8 @@ ARG ZLIB_VERSION=1.3.2 ARG ZLIB_SHA256=bb329a0a2cd0274d05519d61c667c062e06990d72e125ee2dfa8de64f0119d16 ARG OPENSSL_VERSION=4.0.3 ARG OPENSSL_SHA256=325b5c806167c13b40b1ffeadfe0248197c00eccc4cf123ec1e28d2d2fd216d9 -ARG CURL_VERSION=8.22.0 -ARG CURL_SHA256=f7ef3ae8a22e521f289803fe93543eb64c329b58aa73a9e224dfd915a2a5f4f7 +ARG CURL_VERSION=8.23.0 +ARG CURL_SHA256=8dadd7d2536a314f982ad05a651b713f426bf7d02cc2c76cffb9796f2218e6c5 ARG PCRE2_VERSION=10.49 ARG PCRE2_SHA256=929f0b20e62879252a15886b06c89f1edef61a363cbd5826fb041080a5e557ae ARG EXPAT_VERSION=2.9.0 diff --git a/nano/Dockerfile b/nano/Dockerfile index 27a1dbc..732b283 100644 --- a/nano/Dockerfile +++ b/nano/Dockerfile @@ -5,10 +5,10 @@ ARG FILC_X86_64_SHA256=60bfbe8ee63d7e462394aa8d5e44fee675de892bcf800d9cc80d86378 ARG FILC_AARCH64_SHA256=142987830090df8c0cffa0bbcad32a930f661683f8c5073b21986e39aa7209f2 ARG NCURSES_VERSION=6.6 ARG NCURSES_SHA256=355b4cbbed880b0381a04c46617b7656e362585d52e9cf84a67e2009b749ff11 -ARG FILE_VERSION=5.46 -ARG FILE_SHA256=c9cc77c7c560c543135edc555af609d5619dbef011997e988ce40a3d75d86088 -ARG NANO_VERSION=9.1 -ARG NANO_SHA256=5f47764274cb7532349ce0aa20ec10f1e8e851a6e9fa3eb66812c43d196db042 +ARG FILE_VERSION=5.48 +ARG FILE_SHA256=ed14656883b23a364b4057c05595d93252da9bc473d30106519519d0da141283 +ARG NANO_VERSION=9.2 +ARG NANO_SHA256=05ecb99247b782e8a5b3a25ed4101dd034b0236902f7449bc9795b717642f7e9 FROM ubuntu:24.04 AS build @@ -114,7 +114,7 @@ RUN curl -fsSL ${FETCH_RETRY} -o /tmp/file.tar.gz \ && rm /tmp/file.tar.gz # --datadir sets the database path compiled into the library, but `make install` -# would also write the 5.46-format magic.mgc to that path, replacing the build +# would also write the 5.48-format magic.mgc to that path, replacing the build # image's system database with one its own `file` (5.45) cannot read -- which # then reports every binary as "data" and breaks the provenance checks below. # Staging the install and copying only the pieces nano links against keeps the diff --git a/nano/patches/0001-disable-x87-control-word-assembly-under-fil-c.patch b/nano/patches/0001-disable-x87-control-word-assembly-under-fil-c.patch index 049cc3f..50546e1 100644 --- a/nano/patches/0001-disable-x87-control-word-assembly-under-fil-c.patch +++ b/nano/patches/0001-disable-x87-control-word-assembly-under-fil-c.patch @@ -9,7 +9,7 @@ unnecessary. --- a/lib/fpucw.h +++ b/lib/fpucw.h -@@ -65,7 +65,8 @@ extern "C" { +@@ -67,7 +67,8 @@ extern "C" { /* Inline assembler like this works only with GNU C and clang. */ diff --git a/tests/test_check_versions.py b/tests/test_check_versions.py new file mode 100644 index 0000000..9970350 --- /dev/null +++ b/tests/test_check_versions.py @@ -0,0 +1,166 @@ +#!/usr/bin/env python3 +import importlib.util +import re +import unittest +from pathlib import Path +from unittest import mock + + +ROOT = Path(__file__).resolve().parents[1] +SPEC = importlib.util.spec_from_file_location( + "check_versions", ROOT / "check-versions.py" +) +VERSIONS = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(VERSIONS) + + +class GitHubLatestTests(unittest.TestCase): + def test_numeric_prerelease_tag_does_not_override_stable_release(self): + def response(url): + if "/releases?" in url: + return [ + {"tag_name": "26.05", "draft": False, "prerelease": True}, + {"tag_name": "26.04", "draft": False, "prerelease": False}, + ] + if "/tags?" in url: + return [{"name": "26.05"}, {"name": "26.04"}] + self.fail(f"unexpected URL: {url}") + + with mock.patch.object(VERSIONS, "get_json", side_effect=response): + self.assertEqual(VERSIONS.github_latest("example/project"), "26.04") + + def test_unreleased_stable_tag_is_considered(self): + def response(url): + if "/releases?" in url: + return [ + {"tag_name": "26.04", "draft": False, "prerelease": False} + ] + if "/tags?" in url: + return [{"name": "26.05"}, {"name": "26.04"}] + self.fail(f"unexpected URL: {url}") + + with mock.patch.object(VERSIONS, "get_json", side_effect=response): + self.assertEqual(VERSIONS.github_latest("example/project"), "26.05") + + def test_series_restricts_releases_and_tags(self): + def response(url): + if "/releases?" in url: + return [ + {"tag_name": "openssl-4.0.4", "draft": False, "prerelease": False}, + {"tag_name": "openssl-3.6.6", "draft": False, "prerelease": True}, + {"tag_name": "openssl-3.6.5", "draft": False, "prerelease": False}, + ] + if "/tags?" in url: + return [ + {"name": "openssl-4.0.5"}, + {"name": "openssl-3.6.6"}, + {"name": "openssl-3.6.5"}, + ] + self.fail(f"unexpected URL: {url}") + + with mock.patch.object(VERSIONS, "get_json", side_effect=response): + self.assertEqual( + VERSIONS.github_latest( + "openssl/openssl", strip="openssl-", series="3." + ), + "3.6.5", + ) + + +class GnuLatestTests(unittest.TestCase): + class Response: + def __init__(self, body): + self.body = body.encode() + + def __enter__(self): + return self + + def __exit__(self, *args): + return False + + def read(self): + return self.body + + def test_canonical_uses_short_budget_before_mirror_fallback(self): + calls = [] + + def urlopen(request, timeout): + calls.append((request.full_url, timeout)) + if request.full_url == "https://ftp.gnu.org/gnu/gzip/": + raise VERSIONS.http.client.BadStatusLine("bad response") + return self.Response("gzip-1.15.tar.xz") + + with mock.patch.object(VERSIONS.urllib.request, "urlopen", side_effect=urlopen): + self.assertEqual(VERSIONS.gnu_ftp("gzip"), "1.15") + + self.assertEqual( + calls, + [ + ("https://ftp.gnu.org/gnu/gzip/", 10), + ("https://ftpmirror.gnu.org/gzip/", 10), + ], + ) + + def test_malformed_canonical_listing_uses_mirror(self): + responses = iter( + [self.Response("no release archives here"), self.Response("nano-9.2.tar.xz")] + ) + + with mock.patch.object( + VERSIONS.urllib.request, + "urlopen", + side_effect=lambda *_args, **_kwargs: next(responses), + ) as urlopen: + self.assertEqual(VERSIONS.gnu_ftp("nano"), "9.2") + + self.assertEqual(urlopen.call_count, 2) + + +class RegistrationTests(unittest.TestCase): + def test_every_maintained_version_argument_is_registered(self): + found = set() + for dockerfile in ROOT.glob("*/Dockerfile"): + found.update( + re.findall( + r"^ARG ([A-Z0-9_]+_VERSION)=", + dockerfile.read_text(), + flags=re.MULTILINE, + ) + ) + + registered = {component[2] for component in VERSIONS.COMPONENTS} + intentionally_unregistered = {"FILC_VERSION", "SEVENZIP_ARCHIVE_VERSION"} + self.assertEqual(found - registered - intentionally_unregistered, set()) + + def test_shared_pins_stay_synchronized(self): + groups = { + "CURL_VERSION": ["curl/Dockerfile", "git/Dockerfile"], + "ZLIB_VERSION": [ + "curl/Dockerfile", + "git/Dockerfile", + "openssh-server/Dockerfile", + "wget/Dockerfile", + ], + "OPENSSL_VERSION": [ + "curl/Dockerfile", + "git/Dockerfile", + "openssh-server/Dockerfile", + ], + "PCRE2_VERSION": ["git/Dockerfile", "wget/Dockerfile"], + "NCURSES_VERSION": ["nano/Dockerfile", "tmux/Dockerfile"], + } + for argument, paths in groups.items(): + with self.subTest(argument=argument): + values = { + re.search( + rf"^ARG {argument}=(.+)$", + (ROOT / path).read_text(), + flags=re.MULTILINE, + ).group(1) + for path in paths + } + self.assertEqual(len(values), 1) + + +if __name__ == "__main__": + unittest.main() diff --git a/tmux/Dockerfile b/tmux/Dockerfile index c1eba76..a164bfa 100644 --- a/tmux/Dockerfile +++ b/tmux/Dockerfile @@ -9,11 +9,11 @@ ARG LIBEVENT_VERSION=2.1.13 ARG LIBEVENT_SHA256=f7e9383b8c0baa81b687e5b5eecc01beefaf1b19b64151d95ed61647fe7a315c ARG UTF8PROC_VERSION=2.12.0 ARG UTF8PROC_SHA256=a393fbef160835fb315bc3e91ba8d86f7a73a7cec9e6198b6c60b848b498bfeb -ARG TMUX_VERSION=3.7c -ARG TMUX_SHA256=7c60cae9a0e25288e2e24750aafc9e8800fc7fd4555e447e1b29ee4201cfb3bf +ARG TMUX_VERSION=3.8 +ARG TMUX_SHA256=e79c699c7e949dccd0a4a125e17b8d1261e311b16979dbc8eb34542f3966d82e # The release tarball ships no tests. The suite lives only in the git tree, so # the same tag is fetched a second time for it; see the test stage below. -ARG TMUX_TESTS_SHA256=5e7b0f533b66e5633e2b72a9d483f9534a343ab7011eb2621b6309dfba553daa +ARG TMUX_TESTS_SHA256=f873f9379c9cf30d3d66b642a955118c4fbb0019d046d13e6012340811e5dcb7 FROM ubuntu:24.04 AS build @@ -147,11 +147,15 @@ RUN make -j"$(nproc)" \ && install -Dm644 libutf8proc.pc /deps/lib/pkgconfig/libutf8proc.pc WORKDIR /src +COPY patches /tmp/patches RUN curl -fsSL ${FETCH_RETRY} -o /tmp/tmux.tar.gz \ "https://github.com/tmux/tmux/releases/download/${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz" \ && echo "${TMUX_SHA256} /tmp/tmux.tar.gz" | sha256sum -c - \ && tar --strip-components=1 -xzf /tmp/tmux.tar.gz \ && rm /tmp/tmux.tar.gz +RUN patch --batch --forward -p1 < /tmp/patches/0001-print-unknown-strftime-conversions-literally-under-fil-c.patch \ + && patch --batch --forward -p1 < /tmp/patches/0002-reject-years-ctime-cannot-print-under-fil-c.patch \ + && patch --batch --forward -p1 < /tmp/patches/0004-keep-equal-panes-in-list-order-under-fil-c.patch # sixel adds in-pane image support and utf8proc replaces tmux's built-in width # tables with the fuller ones above. systemd integration is deliberately absent: @@ -183,6 +187,16 @@ RUN binary=/src/tmux \ && "${binary}" -V > /tmp/tmux.version \ && grep -Fq "tmux ${TMUX_VERSION}" /tmp/tmux.version +# tmux 3.8's regression suite added scripts that drive the binary through Perl +# and Python. util-linux supplies setpriv, used to run the socket-permission +# regression as a non-root user. These remain test-only inputs. +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + perl \ + python3 \ + util-linux \ + && rm -rf /var/lib/apt/lists/* + # tmux's release tarball ships no tests: its suite lives only in the git tree. # The same tag is fetched again as a source archive and only regress/ is taken # from it, which is how the unRAR build gets its fixture corpus. Both downloads @@ -194,8 +208,9 @@ RUN curl -fsSL ${FETCH_RETRY} -o /tmp/tmux-tests.tar.gz \ && mkdir -p /tmp/tmux-tests \ && tar -C /tmp/tmux-tests --strip-components=1 -xzf /tmp/tmux-tests.tar.gz \ && cp -a /tmp/tmux-tests/regress /src/regress \ + && patch --batch --forward -d /src -p1 < /tmp/patches/0003-make-da-test-sixel-aware.patch \ && rm -rf /tmp/tmux-tests /tmp/tmux-tests.tar.gz \ - && test "$(find /src/regress -maxdepth 1 -name '*.sh' | wc -l)" -ge 30 + && test "$(find /src/regress -maxdepth 1 -name '*.sh' | wc -l)" -ge 170 # The suite is the gate: no artifact is produced unless every case passes. The # tests drive a real server, so each one is given a clean socket and a generous @@ -219,9 +234,9 @@ RUN curl -fsSL ${FETCH_RETRY} -o /tmp/tmux-tests.tar.gz \ # runner for the entire two-hour job budget, printing nothing, because the case # itself had already passed and only the cleanup was stuck. When the kill does # time out the socket is unlinked so the next case starts a fresh server rather -# than queueing behind the wedged one. The whole suite finishes in about three -# minutes on four processors, so a deadline well above that ends a stall with a -# message instead of letting it consume the job. +# than queueing behind the wedged one. tmux 3.8's larger suite takes roughly 25 +# minutes on a small runner, so a one-hour deadline ends a stall with a message +# instead of consuming the job. # # Clear every socket rather than the one most cases use. Four cases open a # second server on -Ltest2, and tty-keys kills both at its own first line with @@ -250,7 +265,7 @@ RUN set -e; \ dump_filc() { \ found=0; \ for f in /src/regress/filc-log-*.txt /tmp/filc-log-*.txt; do \ - [ -f "${f}" ] || continue; found=1; echo "== ${f}"; cat "${f}"; \ + [ -s "${f}" ] || continue; found=1; echo "== ${f}"; cat "${f}"; \ done; \ if [ "${found}" -eq 0 ]; then \ echo "(no Fil-C panic log: nothing aborted on a safety violation)"; \ @@ -263,9 +278,20 @@ RUN set -e; \ rm -f "${sock}" 2>/dev/null || true; \ done; \ }; \ - deadline=$(( $(date +%s) + 1500 )); \ - pass=0; fail=0; flaky=""; failed=""; stalled=""; \ + if ! setpriv --reuid=65534 --regid=65534 --clear-groups \ + env TERM=screen HOME=/tmp TEST_TMUX=/src/tmux FILC_LOG_TO_FILE=1 \ + sh -c 'cd /tmp && exec timeout -k 10 120 sh /src/regress/server-socket-error.sh' \ + > /tmp/regress-server-socket-error.sh.log 2>&1; then \ + echo "--- server-socket-error.sh (failed as uid 65534) ---"; \ + cat /tmp/regress-server-socket-error.sh.log; \ + echo "--- Fil-C panic log ---"; dump_filc; \ + exit 1; \ + fi; \ + echo "server-socket-error.sh passed as uid 65534"; \ + deadline=$(( $(date +%s) + 3600 )); \ + pass=1; fail=0; flaky=""; failed=""; stalled=""; \ for t in *.sh; do \ + [ "${t}" = server-socket-error.sh ] && continue; \ if [ "$(date +%s)" -ge "${deadline}" ]; then \ echo "tmux regress: deadline exceeded with ${t} still to run"; exit 1; \ fi; \ @@ -300,9 +326,47 @@ RUN set -e; \ done; \ if [ -n "${flaky}" ]; then echo "tmux regress: passed on retry:${flaky}"; fi; \ if [ -n "${stalled}" ]; then echo "tmux regress: stalled, tolerated:${stalled}"; fi; \ + if [ -n "${failed}" ]; then echo "tmux regress: failed:${failed}"; fi; \ echo "tmux regress: ${pass} passed, ${fail} failed"; \ test "${fail}" -eq 0; \ - test "${pass}" -ge 30 + test "${pass}" -ge 170 + +# These focused checks keep the libc format compatibility behavior visible even +# if upstream later reorganizes its regression scripts. The custom time format +# at year 10000 must keep working: only ctime's fixed-width output is rejected. +RUN set -e; \ + export TERM=screen HOME=/root TZ=UTC FILC_LOG_TO_FILE=1; \ + dump_filc() { \ + found=0; \ + for f in /src/filc-log-*.txt; do \ + [ -s "${f}" ] || continue; found=1; echo "== ${f}"; cat "${f}"; \ + done; \ + if [ "${found}" -eq 0 ]; then echo "(no Fil-C panic log)"; fi; \ + }; \ + fail() { echo "FAIL: $*" >&2; dump_filc >&2; exit 1; }; \ + t() { timeout -k 5 30 /src/tmux -Lformat-compat -f /dev/null "$@"; }; \ + expect() { \ + expected="$1"; shift; \ + actual="$(t "$@")" || fail "tmux $*"; \ + if [ "${actual}" != "${expected}" ]; then \ + printf 'FAIL: tmux %s: expected <%s>, got <%s>\n' \ + "$*" "${expected}" "${actual}" >&2; \ + dump_filc >&2; \ + exit 1; \ + fi; \ + }; \ + rm -f /src/filc-log-*.txt; \ + t new-session -d || fail "tmux new-session -d"; \ + expect "50%" display-message -p '50%'; \ + expect "a%0]b" display-message -p 'a%0]b'; \ + expect 1 display-message -p '#{e|%%|:7,3}'; \ + t set-option -g @y9999 253402300799 || fail "tmux set-option @y9999"; \ + t set-option -g @y10000 253402300800 || fail "tmux set-option @y10000"; \ + expect "[Fri Dec 31 23:59:59 9999]" display-message -p '[#{t:@y9999}]'; \ + expect "[]" display-message -p '[#{t:@y10000}]'; \ + expect "[zz]" display-message -p '[#{t/f/zz:@y10000}]'; \ + expect alive display-message -p alive; \ + timeout -k 5 15 /src/tmux -Lformat-compat -f /dev/null kill-server || true # The suite runs headless, so it never exercises the path a real client takes: # attaching hands the terminal's file descriptors to the server over a unix diff --git a/tmux/patches/0001-print-unknown-strftime-conversions-literally-under-fil-c.patch b/tmux/patches/0001-print-unknown-strftime-conversions-literally-under-fil-c.patch new file mode 100644 index 0000000..dca10e0 --- /dev/null +++ b/tmux/patches/0001-print-unknown-strftime-conversions-literally-under-fil-c.patch @@ -0,0 +1,63 @@ +From: fil-c-utils maintainers +Subject: [PATCH] Print unknown strftime conversions literally under Fil-C + +musl's strftime returns 0 for any conversion specification it does not +recognise; glibc copies such a specification through literally. tmux runs +every time-expanded format (display-message, status lines, titles) +through strftime before #{} expansion, so a stray % empties the whole +string: the trailing % that %% leaves in #{e|%%|:7,3}, or a pane ID such +as %0 in #[range=pane|%0]. When strftime fails, double the % of each +specification musl does not accept and retry, which prints it as glibc +does (without glibc's width padding of such literals). + +--- a/format.c ++++ b/format.c +@@ -494 +494,47 @@ +- return (strftime(s, max, fmt, tm)); ++#ifdef __FILC__ ++ const char *cp, *spec; ++ char *copy, *out; ++ size_t n; ++ ++ /* ++ * musl's strftime fails on any conversion it does not know, including ++ * a trailing lone %, where glibc copies it literally. Formats are run ++ * through strftime before #{} expansion, so a stray % such as the %% ++ * left in #{e|%%|:...} or a pane ID like %0 in a status line would ++ * otherwise empty the whole string. Double the % of each such ++ * conversion and try again. ++ */ ++ n = strftime(s, max, fmt, tm); ++ if (n != 0 || *fmt == '\0') ++ return (n); ++ out = copy = xmalloc(2 * strlen(fmt) + 1); ++ for (cp = fmt; *cp != '\0'; cp++) { ++ if (*cp != '%') { ++ *out++ = *cp; ++ continue; ++ } ++ spec = cp++; ++ if (*cp == '-' || *cp == '_' || *cp == '0') ++ cp++; ++ if (*cp == '+') ++ cp++; ++ while (isdigit((u_char)*cp)) ++ cp++; ++ if (*cp == 'E' || *cp == 'O') ++ cp++; ++ if (*cp == '\0' || ++ strchr("aAbBcCdDeFgGhHIjklmMnpPrRsStTuUVwWxXyYzZ%", *cp) == NULL) ++ *out++ = '%'; ++ while (spec != cp) ++ *out++ = *spec++; ++ if (*cp == '\0') ++ break; ++ *out++ = *cp; ++ } ++ *out = '\0'; ++ n = strftime(s, max, copy, tm); ++ free(copy); ++ return (n); ++#else ++ return (strftime(s, max, fmt, tm)); ++#endif diff --git a/tmux/patches/0002-reject-years-ctime-cannot-print-under-fil-c.patch b/tmux/patches/0002-reject-years-ctime-cannot-print-under-fil-c.patch new file mode 100644 index 0000000..fb2e2a9 --- /dev/null +++ b/tmux/patches/0002-reject-years-ctime-cannot-print-under-fil-c.patch @@ -0,0 +1,27 @@ +From: fil-c-utils maintainers +Subject: [PATCH] Reject years ctime cannot print under Fil-C + +musl's asctime_r deliberately crashes when its ISO C format would not fit +the 26-byte buffer, which is any year outside -999..9999; under Fil-C that +is a null-pointer write panic that kills the server. glibc returns NULL +with EOVERFLOW for exactly those years, so #{t:...} expands to nothing; +check the local year first and do the same. + +--- a/format.c ++++ b/format.c +@@ -4748,2 +4748,13 @@ ++#ifdef __FILC__ ++ /* ++ * musl's asctime_r aborts if the result does ++ * not fit in 26 bytes, so check the year it ++ * would print first (glibc fails instead). ++ */ ++ if (localtime_r(&t, &tm) == NULL || ++ tm.tm_year < -999 - 1900 || ++ tm.tm_year > 9999 - 1900) ++ return (NULL); ++#endif +- if (ctime_r(&t, s) == NULL) +- return (NULL); ++ if (ctime_r(&t, s) == NULL) ++ return (NULL); diff --git a/tmux/patches/0003-make-da-test-sixel-aware.patch b/tmux/patches/0003-make-da-test-sixel-aware.patch new file mode 100644 index 0000000..d15da18 --- /dev/null +++ b/tmux/patches/0003-make-da-test-sixel-aware.patch @@ -0,0 +1,16 @@ +From: Nicholas Marriott +Subject: [PATCH] Fix DA test with sixel enabled + +Backport upstream commit 58eb73a6d1bac0919f3f264c057e4c7b4348f9e4, +using the tmux 3.8 sixel_support format variable. A sixel-capable terminal +advertises private mode 4 in its primary device attributes response. + +--- a/regress/input-replies.sh ++++ b/regress/input-replies.sh +@@ -63 +63,5 @@ +-query "da-primary" '^[[?1;2c' '\033[c' 7 '' ++if [ "$($TMUX display-message -p '#{sixel_support}')" = 1 ]; then ++ query "da-primary" '^[[?1;2;4c' '\033[c' 9 '' ++else ++ query "da-primary" '^[[?1;2c' '\033[c' 7 '' ++fi diff --git a/tmux/patches/0004-keep-equal-panes-in-list-order-under-fil-c.patch b/tmux/patches/0004-keep-equal-panes-in-list-order-under-fil-c.patch new file mode 100644 index 0000000..9279469 --- /dev/null +++ b/tmux/patches/0004-keep-equal-panes-in-list-order-under-fil-c.patch @@ -0,0 +1,42 @@ +From: fil-c-utils maintainers +Subject: [PATCH] Keep equal panes in pane list order under Fil-C + +Every tiled pane has the same z-index and panes usually share a title, so +sort_pane_cmp returns 0 for them and their order is left to qsort. glibc +(merge sort) and the BSDs (insertion sort for short arrays) keep such +panes in input order, which for every caller is pane list order, and +regress/format-modifiers.sh asserts that for both #{P/z:} (3012) and +#{P/zr:} (0123). musl's smoothsort is not stable and gives 3102. Break +the tie by pane index after any reversal, reproducing the stable order. + +--- a/sort.c ++++ b/sort.c +@@ -243,7 +243,21 @@ +- if (result == 0) +- result = strcmp(a->screen->title, b->screen->title); +- +- if (sort_crit->reversed) +- result = -result; +- return (result); +-} ++ if (result == 0) ++ result = strcmp(a->screen->title, b->screen->title); ++ ++ if (sort_crit->reversed) ++ result = -result; ++#ifdef __FILC__ ++ /* ++ * Panes can still compare equal (every tiled pane has the same ++ * z-index and usually the same title). glibc's merge sort and the BSD ++ * insertion sort keep them in pane list order whichever the direction, ++ * which is what the regression tests expect; musl's smoothsort is not ++ * stable, so make that order explicit, after any reversal. ++ */ ++ if (result == 0) { ++ window_pane_index(a, &ai); ++ window_pane_index(b, &bi); ++ result = sort_number_cmp(ai, bi); ++ } ++#endif ++ return (result); ++} diff --git a/wget/Dockerfile b/wget/Dockerfile index 7167f27..aedb105 100644 --- a/wget/Dockerfile +++ b/wget/Dockerfile @@ -16,16 +16,16 @@ ARG ZLIB_SHA256=bb329a0a2cd0274d05519d61c667c062e06990d72e125ee2dfa8de64f0119d16 # OpenSSL 4. ARG OPENSSL_VERSION=3.6.5 ARG OPENSSL_SHA256=a2157c2830efdec3788939b00c9b0638306d3f0bbb76dc4832ee503bb397df98 -ARG LIBUNISTRING_VERSION=1.4.2 -ARG LIBUNISTRING_SHA256=5b46e74377ed7409c5b75e7a96f95377b095623b689d8522620927964a41499c +ARG LIBUNISTRING_VERSION=1.5 +ARG LIBUNISTRING_SHA256=fe89007a8a414ae4790b816b86859e877d3ab135db3c37f06541ff7e85ac344b ARG LIBIDN2_VERSION=2.3.8 ARG LIBIDN2_SHA256=f557911bf6171621e1f72ff35f5b1825bb35b52ed45325dcdee931e5d3c0787a ARG PCRE2_VERSION=10.49 ARG PCRE2_SHA256=929f0b20e62879252a15886b06c89f1edef61a363cbd5826fb041080a5e557ae ARG LIBPSL_VERSION=0.23.3 ARG LIBPSL_SHA256=93941f85a1e7bd593fa94f299233cb5dfc91cd144fd9a78a6ceb75001c5b03be -ARG CARES_VERSION=1.34.8 -ARG CARES_SHA256=c222b6d681096f9444d2c4863d2c1174019e27cacca0a4a5c114d36dd7d7bf78 +ARG CARES_VERSION=1.34.9 +ARG CARES_SHA256=9364b70a12eb59a06830fb488d9357f90100dff0d98b23ea3593a183d43e6f2f ARG WGET_VERSION=1.25.0 ARG WGET_SHA256=766e48423e79359ea31e41db9e5c289675947a7fcf2efdcedb726ac9d0da3784