# eb-local.lmodcache ::::{zig:module} eb-local.lmodcache :file: src/lmodcache.zig :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig `eb-local lmod-cache`: write the spider cache Lmod trusts. Lmod treats a timestamp newer than `spiderT.lua` as a stale cache and then ignores the modules that file names. The cache is written only after `spider` succeeds, and the timestamp is then set one second older than the cache file. :::: ## Types ::::{zig:type} eb-local.lmodcache.Target :signature: pub const Target = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L112 One CPU target tree to refresh when walking `--prefix`. :::{zig:field} eb-local.lmodcache.Target.archdir :signature: archdir: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L113 ::: :::{zig:field} eb-local.lmodcache.Target.modulepath :signature: modulepath: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L114 ::: :::{zig:field} eb-local.lmodcache.Target.cache_dir :signature: cache_dir: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L115 ::: :::{zig:field} eb-local.lmodcache.Target.timestamp :signature: timestamp: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L116 ::: :::: ::::{zig:type} eb-local.lmodcache.Options :signature: pub const Options = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L120 Names the directories, cache paths and spider command for `lmod-cache`. :::{zig:field} eb-local.lmodcache.Options.modulepath :signature: modulepath: []const u8 = "" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L121 ::: :::{zig:field} eb-local.lmodcache.Options.cache_dir :signature: cache_dir: []const u8 = "" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L122 ::: :::{zig:field} eb-local.lmodcache.Options.timestamp :signature: timestamp: []const u8 = "" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L123 ::: :::{zig:field} eb-local.lmodcache.Options.spider :signature: spider: []const u8 = "" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L125 Empty means the program `spider` on `PATH`. ::: :::{zig:field} eb-local.lmodcache.Options.prefix :signature: prefix: []const u8 = "" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L127 Walk `software/…//modules/all` when set (absolute). ::: :::{zig:field} eb-local.lmodcache.Options.eessi_version :signature: eessi_version: []const u8 = "" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L129 When set with `--prefix`, only `versions//software`. ::: :::{zig:field} eb-local.lmodcache.Options.update_cmd :signature: update_cmd: []const u8 = "" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L131 Path to Lmod's `update_lmod_system_cache_files`; resolved from `prefix` when empty. ::: :::{zig:field} eb-local.lmodcache.Options.dry_run :signature: dry_run: bool = false :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L132 ::: :::{zig:field} eb-local.lmodcache.Options.verify :signature: verify: bool = false :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L133 ::: :::: ## Functions :::{zig:function} eb-local.lmodcache.moduleDirs :signature: pub fn moduleDirs(a: std.mem.Allocator, spec: []const u8) ![]const []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L137 Directories in a colon-separated module path, empty segments dropped. ::: :::{zig:function} eb-local.lmodcache.spiderArgv :signature: pub fn spiderArgv(a: std.mem.Allocator, spider: []const u8, dirs: []const []const u8) ![]const []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L150 `spider -o spiderT` and one argument per module directory. ::: :::{zig:function} eb-local.lmodcache.olderThan :signature: pub fn olderThan(cache: std.Io.Timestamp) std.Io.Timestamp :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L160 One second before the cache file, which is what makes Lmod trust it. ::: :::{zig:function} eb-local.lmodcache.modulepathForArch :signature: pub fn modulepathForArch(a: std.mem.Allocator, archdir: []const u8, accel_alls: []const []const u8) ![]const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L663 Colon-separated paths for `archdir`, with accelerator trees prepended like EESSI's script. ::: :::{zig:function} eb-local.lmodcache.discoverTargets :signature: pub fn discoverTargets(a: std.mem.Allocator, opts: Options) ![]Target :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L761 Discover CPU targets under `prefix`, matching EESSI's `update_lmod_caches.sh` layout. ::: :::{zig:function} eb-local.lmodcache.runUpdate :signature: pub fn runUpdate(io: std.Io, a: std.mem.Allocator, update_cmd: []const u8, target: Target) u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L832 Run Lmod's `update_lmod_system_cache_files` for one target. ::: :::{zig:function} eb-local.lmodcache.run :signature: pub fn run(io: std.Io, a: std.mem.Allocator, env: *const std.process.Environ.Map, opts: Options) u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/lmodcache.zig#L1233 Write `cache_dir/spiderT.lua` from spider's stdout, then the timestamp. A spider that cannot start, exits non-zero, or writes nothing leaves both files as they were. Returns the process exit status. :::