diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-01-18 23:49:44 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-01-18 23:51:45 +0900 |
| commit | 4155adc16a7afbec5ca1c23a07ef850f92ab4008 (patch) | |
| tree | 342dadd88b06e50a3f36f494235949bb39a8db86 /internal/rosa/etc.go | |
| parent | 2a9525c77ab0d15f802c9277a13072311d147483 (diff) | |
internal/rosa: static etc artifact
This places configuration files with hardcoded content in /etc to silence test suites expecting them to be present.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/rosa/etc.go')
| -rw-r--r-- | internal/rosa/etc.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/internal/rosa/etc.go b/internal/rosa/etc.go new file mode 100644 index 00000000..9126bdd2 --- /dev/null +++ b/internal/rosa/etc.go @@ -0,0 +1,52 @@ +package rosa + +import ( + "os" + + "hakurei.app/internal/pkg" +) + +// cureEtc contains deterministic elements of /etc, made available as part of +// [Toolchain]. This silences test suites expecting certain standard files to be +// available in /etc. +type cureEtc struct{} + +// Cure writes hardcoded configuration to files under etc. +func (cureEtc) Cure(t *pkg.TContext) (err error) { + etc := t.GetWorkDir().Append("etc") + if err = os.MkdirAll(etc.String(), 0700); err != nil { + return + } + for _, f := range [][2]string{ + {"hosts", "127.0.0.1 localhost cure cure-net\n"}, + {"passwd", `root:x:0:0:System administrator:/proc/nonexistent:/bin/sh +cure:x:1023:1023:Cure:/usr/src:/bin/sh +nobody:x:65534:65534:Overflow user:/proc/nonexistent:/system/bin/false +`}, + {"group", `root:x:0: +cure:x:1023: +nobody:x:65534: +`}, + } { + if err = os.WriteFile( + etc.Append(f[0]).String(), + []byte(f[1]), + 0400, + ); err != nil { + return + } + } + return os.Chmod(etc.String(), 0500) +} + +// Kind returns the hardcoded [pkg.Kind] value. +func (cureEtc) Kind() pkg.Kind { return kindEtc } + +// Params is a noop. +func (cureEtc) Params(*pkg.IContext) {} + +// Dependencies returns a nil slice. +func (cureEtc) Dependencies() []pkg.Artifact { return nil } + +// String returns a hardcoded reporting name. +func (cureEtc) String() string { return "cure-etc" } |
