Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions COMPAT.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on the same invocations.
| `eb` | `eb --last-log [--tmp-logdir=TMP_LOGDIR] --output-style=basic`, and the same without `--output-style` when that fails or prints nothing; the last line printed is the log |
| stdout | `Failed build log: LOGDIR/NAME.failed.ebout.log`, `Failed command output: LOGDIR/NAME.failed.command-{out,err}.txt`, `Failed meson test log: LOGDIR/NAME.failed.meson-testlog.txt`, `Failed command output not kept: EASYBUILD_TMPDIR is not set.`, `Failed command output not kept: PATH is not under EASYBUILD_TMPDIR.`, `Failed command output not kept: PATH belongs to another user.`, `No EasyBuild log to keep for NAME.`, `No EasyBuild log to keep for NAME: eb is not on PATH.`, `No EasyBuild log to keep for NAME: eb --last-log exited N.`, `No EasyBuild log to keep for NAME: PATH is another build's log.`, `eb-keep-logs rotate: N files compressed, M runs deleted under ROOT`, with `1 file` and `1 run` for a count of one; LOGDIR in these lines without its trailing slashes |
| files | kept files closed to others (command streams mode 0600), their resolved paths appended to `LOGDIR/.licensed-logs` unless already listed; on a failure, `NAME.stdout.log`, a TMP_LOGDIR below LOGDIR and the regular files directly in it closed to others, a symbolic link left as it is; `rotate` writes `FILE.gz` with the file's mode and updates `.licensed-logs` to the `.gz` path |
| run ages | days from the local midnight of the date in the run's name, as `date -d YYYYMMDD` computes it, including TZ rules, except in the two cases of `TZ` and `TZDIR` under unintended differences; a run whose local midnight does not exist is skipped |
| run ages | days from the local midnight of the date in the run's name, as `date -d YYYYMMDD` computes it, including TZ rules, except for the zones under unintended differences; a run whose local midnight does not exist is skipped |
| the run in progress | `rotate` neither compresses nor deletes the run that holds its stdout or stderr, when either is a regular file, or `EB_PIPELINE_LOG_DIR` |

## Deliberate differences
Expand All @@ -38,13 +38,17 @@ on the same invocations.
| a log larger than 1 GiB | scanned | copied, not checked for another build and not scanned for the command output or meson paths, with a message on stderr |
| a meson testlog larger than 1 GiB | kept unless its summary shows every test passing | kept without reading the summary, with a message on stderr |
| a log with NUL bytes | `grep` reports a binary match and the scan finds nothing | scanned as text |
| `date` not GNU's, as on Ubuntu from 25.10, where `date` is uutils' and GNU's is `gnudate` | run ages follow that `date`; uutils' 0.10.0 reads as UTC some `TZ` rule strings that glibc reads, such as one after a `:` or one without an end rule: `TZ=CET-1CEST,M3.5.0 date -d 20261101 +%s` prints 1793491200 | run ages as GNU `date` gives them, whatever `date` is: 1793484000, as `gnudate` prints |

## Unintended differences

The Zig build differs here without meaning to; each is a bug in the Zig build.
The Zig build does not mean to differ from the shell script in these cases,
each shown by a command. Any other difference from the shell script that is
not listed above is a bug in the Zig build.

| case | shell script | Zig build |
|---|---|---|
| `EB_KEEP_LOGS_NOW` set but empty | the current time | refused, exit 2: `eb-keep-logs: EB_KEEP_LOGS_NOW must be seconds since the epoch, not ''` |
| `TZDIR` set but empty, `TZ` naming a zone file | the file under `/usr/share/zoneinfo`, as `date` reads it | the name is looked up relative to the working directory, so the zone is UTC unless a file of that name is there |
| `TZ` with a leading `:` that names no file, such as `:CET-1CEST,M3.5.0,M10.5.0/3` | the rule string after the `:`, as `date` reads it | UTC |
| `TZ` a rule string with daylight saving time but no rules, such as `NZST-12NZDT`, where `TZDIR` holds a `posixrules` file | glibc takes the changes from that file's transitions (New York's on most systems), moved by the difference between its offsets and the string's, and after the last of them uses the file's own rule and offsets: `TZ=NZST-12NZDT date -d 20260309 +%s` prints 1772971200, in standard time | the second Sunday in March to the first Sunday in November, at 02:00, in every year, as glibc has it without `posixrules`: 1772967600, in daylight time |
| `TZ` a rule string with an `Mm.w.d` rule whose month is not 1 to 12, or not given, such as `CET-1CEST,M13.1.0,M10.5.0/3` | glibc reads days from outside its table of months, which C leaves undefined: `TZ=CET-1CEST,M13.1.0,M10.5.0/3 date -d 20260701 +%s` prints 1782860400 | the rule falls on 1 January: 1782856800 |
| a zone file with leap seconds, as the `right/` zones and `zic -L` have | glibc counts them, 27 by 2026: `TZ=right/UTC date -d 20261101 +%s` prints 1793491227 | leap seconds are not counted: 1793491200 |
| a zone file whose first time type is daylight saving time, that has no transitions and a footer whose offsets are not those of its first standard time type, or whose footer glibc cannot read; no file of tzdata's is one, but `zic` writes the first kind for a zone that starts in daylight saving time | glibc uses the first standard time type before the first transition and when there are none, and UTC after the last transition when it cannot read the footer: `printf 'Zone X 1:00 1:00 CEST 2000\n\t1:00 - CET\n' > /tmp/x.zi && zic -d /tmp/z /tmp/x.zi && TZ=/tmp/z/X date -d 19990701 +%s` prints 930783600, in standard time | the first time type before the first transition, and the footer when there are no transitions, as RFC 8536 has it; after the last transition, its offset when the footer cannot be read: 930780000, in daylight time |
4 changes: 4 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,19 @@ pub fn build(b: *std.Build) void {
// The shell suite of the old implementation, run against this binary.
// It and the differential run below run in the build root: their script
// paths are relative, and zig build may be started in a subdirectory.
// Both run every time, as the cache sees neither their scripts nor the
// date and tzdata of the host, which the suite compares with.
const suite = b.addSystemCommand(&.{ "bash", "-c", "TOOL_BIN=\"$0\" exec bash tests/test_eb_keep_logs.sh" });
suite.addArtifactArg(exe);
suite.setCwd(b.path("."));
suite.expectExitCode(0);
suite.has_side_effects = true;
// The same invocations through the shell implementation and this one.
const diff = b.addSystemCommand(&.{ "bash", "-c", "TOOL_BIN=\"$0\" exec bash tests/differential.sh" });
diff.addArtifactArg(exe);
diff.setCwd(b.path("."));
diff.expectExitCode(0);
diff.has_side_effects = true;

const test_step = b.step("test", "Run the unit tests, the command-line suite and the differential run");
test_step.dependOn(&b.addRunArtifact(unit).step);
Expand Down
1 change: 1 addition & 0 deletions changelog.d/+compat-date.doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
COMPAT.md lists a `date` other than GNU's among the deliberate differences: the shell script's run ages follow that `date`, and uutils' `date`, Ubuntu's from 25.10, reads as UTC some `TZ` rule strings that glibc reads, where the Zig build's run ages are GNU `date`'s whatever `date` is.
2 changes: 1 addition & 1 deletion changelog.d/+compat-unintended.doc.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
COMPAT.md lists three differences between the Zig build and the shell script that are bugs, not choices: an empty `EB_KEEP_LOGS_NOW` is refused instead of meaning the current time, an empty `TZDIR` leaves a zone name relative to the working directory, and a `TZ` with a leading `:` that names no file is UTC. Its rows on `EB_KEEP_LOGS_NOW` and on run ages no longer claim more than the Zig build does.
COMPAT.md has a section for differences between the Zig build and the shell script that are not choices, each with a command that shows it: a `TZ` rule string without rules where `TZDIR` holds a `posixrules` file, a rule month glibc reads out of bounds, zone files with leap seconds, and zone files unlike any of tzdata's. Its rows on `EB_KEEP_LOGS_NOW` and on run ages no longer claim more than the Zig build does.
2 changes: 1 addition & 1 deletion changelog.d/+doc-comments.doc.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Every `pub` declaration has a doc comment, whose first sentence is the summary the API pages list, and the comment at the top of `src/localtime.zig` names the two cases in which the zone is read differently from glibc: an empty `TZDIR`, and a `TZ` with a leading `:` that names no file.
Every `pub` declaration has a doc comment, whose first sentence is the summary the API pages list.
1 change: 1 addition & 0 deletions changelog.d/+mtime-comment.doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The comments on `runAgeDays` in `src/main.zig` and on `_run_age_days` in the shell script give the right reason a run's age comes from its name, not its directory's mtime: compressing the run's logs moves the mtime, where a chmod changes only the ctime.
1 change: 1 addition & 0 deletions changelog.d/+now-empty.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`rotate` takes an empty `EB_KEEP_LOGS_NOW` as unset and dates runs against the current time, as the shell script does, instead of refusing it with exit 2.
1 change: 1 addition & 0 deletions changelog.d/+suite-gnu-date.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`zig build test` passes where `date` is not GNU's, as on Ubuntu from 25.10, where uutils' `date` failed three checks of the command-line suite: the suite takes a run's local midnight under `TZ` from GNU `date` (`gnudate` there) and runs the tool with that `date`, and where there is no GNU `date` it skips those checks, saying so on stderr. A failed check of the suite or a difference in the differential run is printed on stderr, which `zig build test` shows, instead of on stdout, which it drops, and both run on every `zig build test`, as its cache sees neither their scripts nor the host's `date` and tzdata.
1 change: 1 addition & 0 deletions changelog.d/+tz-colon-rule.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When a `TZ` with a leading `:` names no zone file, as `:CET-1CEST,M3.5.0,M10.5.0/3` does, `rotate` reads the POSIX rule string after the `:`, as the shell script's `date` does, instead of dating runs in UTC.
1 change: 1 addition & 0 deletions changelog.d/+tz-rule-glibc.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`rotate` reads a malformed `TZ` rule string as far as the shell script's `date` reads it, instead of dating runs in UTC: text after the rules is ignored, a missing end rule is the first Sunday in November, and a rule cut short keeps what was read of it, as glibc keeps it. Rules also apply as glibc applies them, with the changes of the year in UTC, and up to 1970 with the changes of 1970.
1 change: 1 addition & 0 deletions changelog.d/+tzdir-empty.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`rotate` takes an empty `TZDIR` as unset and finds the zone `TZ` names under `/usr/share/zoneinfo`, as the shell script's `date` does, instead of looking it up relative to the working directory and dating runs in UTC when no file of that name is there.
2 changes: 1 addition & 1 deletion docs/orgmode/explanation/local-time.org
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ The Zig build has to give the same ages without =date=: it is one static binary
- Days are 86,400 seconds long, as in the shell script, so for an hour around the midnight after a daylight saving change a run's age is a day off the calendar: just after midnight following the change to summer time, a run from two days before counts as one day old.
- A run dated in the future is younger than 0 days and is left alone, except one dated less than a day ahead, which counts as 0 days old.
- Only the date is checked: =HHMMSS= has to be six digits, not a time that exists.
- The zone is read as glibc reads it except in two cases, an empty =TZDIR= and a =TZ= with a leading =:= that names no file, which [[file:../reference/compatibility.org][Compatibility]] lists under unintended differences.
- A few zones give a midnight other than =date='s, as [[file:../reference/compatibility.org][Compatibility]] lists: among them a =TZ= rule string with daylight saving time but no rules, where the system has a =posixrules= file, and the =right/= zones, which count leap seconds.

** Further reading

Expand Down
18 changes: 9 additions & 9 deletions docs/orgmode/reference/cli.org
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ eb-keep-logs --help | --version

** Environment

| Variable | Command | Meaning |
|-----------------------+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| =PATH= | =failed= | Where =eb= is looked up. =eb= runs with the environment =failed= got. |
| =EASYBUILD_TMPDIR= | =failed= | A failed command's output is copied only from below this directory, both paths resolved. Unset or empty, it is not copied. |
| =EB_KEEP_LOGS_NOW= | =rotate= | The time =rotate= takes as now, in seconds since the epoch. When set, it must be an integer; an empty value is refused too, where the shell script takes the current time. |
| =EB_PIPELINE_LOG_DIR= | =rotate= | The run that holds this path is left alone: it is the run eb-pipeline writes into. Unset, empty, or a path that does not exist, it changes nothing. |
| =TZ= | =rotate= | The time zone of the local midnight: unset, =/etc/localtime=; empty, UTC; otherwise a zone file, by name under =TZDIR= or by absolute path, or a POSIX rule string such as =CET-1CEST,M3.5.0,M10.5.0/3=. A value starting with =:= is a zone file only, where the shell script's =date= reads a rule string after the =:= too. A zone that cannot be read is UTC. |
| =TZDIR= | =rotate= | The directory of zone files, =/usr/share/zoneinfo= when unset. Set but empty, a zone name is looked up relative to the working directory, where the shell script's =date= uses =/usr/share/zoneinfo=. |
| Variable | Command | Meaning |
|-----------------------+----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| =PATH= | =failed= | Where =eb= is looked up. =eb= runs with the environment =failed= got. |
| =EASYBUILD_TMPDIR= | =failed= | A failed command's output is copied only from below this directory, both paths resolved. Unset or empty, it is not copied. |
| =EB_KEEP_LOGS_NOW= | =rotate= | The time =rotate= takes as now, in seconds since the epoch: an integer. Unset or empty, it is the current time. |
| =EB_PIPELINE_LOG_DIR= | =rotate= | The run that holds this path is left alone: it is the run eb-pipeline writes into. Unset, empty, or a path that does not exist, it changes nothing. |
| =TZ= | =rotate= | The time zone of the local midnight: unset, =/etc/localtime=; empty, UTC; otherwise, with a leading =:= dropped, a zone file, by name under =TZDIR= or by absolute path, or else a POSIX rule string such as =CET-1CEST,M3.5.0,M10.5.0/3=, as the shell script's =date= reads it, a malformed one as far as glibc reads it. A zone that cannot be read is UTC; [[file:compatibility.org][Compatibility]] lists the zones =date= reads otherwise. |
| =TZDIR= | =rotate= | The directory of zone files, =/usr/share/zoneinfo= when unset or empty. |

** Exit status

Expand All @@ -70,7 +70,7 @@ eb-keep-logs --help | --version
| =ROOT ROOT is not a directory= | =ROOT= does not name a directory that can be opened. |
| =OPTION needs a number of days= | =--compress-after= is missing, or a value is missing, empty, not decimal digits or too large. |
| =--delete-after must be later than --compress-after= | =--delete-after= is not larger than =--compress-after=. |
| =EB_KEEP_LOGS_NOW must be seconds since the epoch, not 'VALUE'= | =EB_KEEP_LOGS_NOW= is set, and is not an integer. |
| =EB_KEEP_LOGS_NOW must be seconds since the epoch, not 'VALUE'= | =EB_KEEP_LOGS_NOW= is neither empty nor an integer. |
| =cannot read ROOT ROOT=, =cannot read ROOT ROOT: ERROR= | =ROOT= could not be listed. |
| =cannot read the arguments= | The arguments could not be read into memory. |

Expand Down
4 changes: 3 additions & 1 deletion eb-keep-logs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ cmd_failed() {
}

# Days since a run directory's name, YYYYMMDD_HHMMSS; empty when the name is
# not a run directory. The name, not the mtime: a later chmod moves the mtime.
# not a run directory. The name, not the mtime: compressing the run's logs
# moves the mtime of the directory they are in, where a chmod changes only
# the ctime.
_run_age_days() {
local base date now start
base=$(basename "$1")
Expand Down
Loading
Loading