diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-07-07 21:14:57 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-07-07 21:14:57 +0900 |
| commit | aa5e77ef277d5cb144e4841f3c1ab41282faac01 (patch) | |
| tree | 97e041708fd63ecb53c17c23f4bf81616848b84b /cmd | |
| parent | 76360979f9b7898c1e331914b6037b01eab79807 (diff) | |
internal/rosa: populate mirror snapshot
This produces the same structure served by the dynamic server.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/mbf/main.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/cmd/mbf/main.go b/cmd/mbf/main.go index 471b595a..a6c74a0f 100644 --- a/cmd/mbf/main.go +++ b/cmd/mbf/main.go @@ -568,6 +568,47 @@ func main() { }, ) + c.NewCommand( + "snapshot", + "Populate an empty directory with a static mirror snapshot", + func(args []string) error { + if len(args) != 1 { + return errors.New("snapshot requires 1 argument") + } + + var key ed25519.PrivateKey + if p, err := os.ReadFile(filepath.Join(cm.base, "ed25519")); err != nil { + return err + } else if len(p) != ed25519.PrivateKeySize { + return errors.New("invalid private key") + } else { + key = p + } + + var m rosa.Mirror + if base, err := os.OpenRoot(cm.base); err != nil { + return err + } else { + m = rosa.NewMirror(msg, base.FS(), key) + } + + retry: + root, err := os.OpenRoot(args[0]) + if err != nil { + if os.IsNotExist(err) { + if err = os.MkdirAll(args[0], 0755); err != nil { + return err + } + goto retry + } + return err + } + + go func() { <-ctx.Done(); _ = root.Close() }() + return m.Populate(root) + }, + ) + { var ( flagGentoo string |
