diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-10-09 05:04:08 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-10-09 05:18:19 +0900 |
| commit | 87b5c30ef6d5b7b8a10d6a5a8610054c403923e6 (patch) | |
| tree | 805116c39a623bb30fc532af47ea3ed78b7304c0 /cmd | |
| parent | df9b77b077d967d35082adb8ab3b00dd67d7bc97 (diff) | |
message: relocate from container
This package is quite useful. This change allows it to be imported without importing container.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/hakurei/command.go | 4 | ||||
| -rw-r--r-- | cmd/hakurei/command_test.go | 4 | ||||
| -rw-r--r-- | cmd/hakurei/main.go | 3 | ||||
| -rw-r--r-- | cmd/hakurei/parse.go | 8 | ||||
| -rw-r--r-- | cmd/hakurei/print.go | 4 | ||||
| -rw-r--r-- | cmd/hpkg/main.go | 4 | ||||
| -rw-r--r-- | cmd/hpkg/paths.go | 4 | ||||
| -rw-r--r-- | cmd/hpkg/proc.go | 4 | ||||
| -rw-r--r-- | cmd/hpkg/with.go | 8 |
9 files changed, 22 insertions, 21 deletions
diff --git a/cmd/hakurei/command.go b/cmd/hakurei/command.go index e3356470..213cc416 100644 --- a/cmd/hakurei/command.go +++ b/cmd/hakurei/command.go @@ -15,17 +15,17 @@ import ( "time" "hakurei.app/command" - "hakurei.app/container" "hakurei.app/container/check" "hakurei.app/container/fhs" "hakurei.app/hst" "hakurei.app/internal" "hakurei.app/internal/app" "hakurei.app/internal/app/state" + "hakurei.app/message" "hakurei.app/system/dbus" ) -func buildCommand(ctx context.Context, msg container.Msg, early *earlyHardeningErrs, out io.Writer) command.Command { +func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErrs, out io.Writer) command.Command { var ( flagVerbose bool flagJSON bool diff --git a/cmd/hakurei/command_test.go b/cmd/hakurei/command_test.go index d22249f3..d29485de 100644 --- a/cmd/hakurei/command_test.go +++ b/cmd/hakurei/command_test.go @@ -7,7 +7,7 @@ import ( "testing" "hakurei.app/command" - "hakurei.app/container" + "hakurei.app/message" ) func TestHelp(t *testing.T) { @@ -69,7 +69,7 @@ Flags: for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { out := new(bytes.Buffer) - c := buildCommand(t.Context(), container.NewMsg(nil), new(earlyHardeningErrs), out) + c := buildCommand(t.Context(), message.NewMsg(nil), new(earlyHardeningErrs), out) if err := c.Parse(tc.args); !errors.Is(err, command.ErrHelp) && !errors.Is(err, flag.ErrHelp) { t.Errorf("Parse: error = %v; want %v", err, command.ErrHelp) diff --git a/cmd/hakurei/main.go b/cmd/hakurei/main.go index 5cc8224d..dcea40c0 100644 --- a/cmd/hakurei/main.go +++ b/cmd/hakurei/main.go @@ -13,6 +13,7 @@ import ( "syscall" "hakurei.app/container" + "hakurei.app/message" ) var ( @@ -31,7 +32,7 @@ func main() { log.SetPrefix("hakurei: ") log.SetFlags(0) - msg := container.NewMsg(log.Default()) + msg := message.NewMsg(log.Default()) early := earlyHardeningErrs{ yamaLSM: container.SetPtracer(0), diff --git a/cmd/hakurei/parse.go b/cmd/hakurei/parse.go index 14b9c167..3d15f665 100644 --- a/cmd/hakurei/parse.go +++ b/cmd/hakurei/parse.go @@ -10,13 +10,13 @@ import ( "strings" "syscall" - "hakurei.app/container" "hakurei.app/hst" "hakurei.app/internal/app" "hakurei.app/internal/app/state" + "hakurei.app/message" ) -func tryPath(msg container.Msg, name string) (config *hst.Config) { +func tryPath(msg message.Msg, name string) (config *hst.Config) { var r io.Reader config = new(hst.Config) @@ -49,7 +49,7 @@ func tryPath(msg container.Msg, name string) (config *hst.Config) { return } -func tryFd(msg container.Msg, name string) io.ReadCloser { +func tryFd(msg message.Msg, name string) io.ReadCloser { if v, err := strconv.Atoi(name); err != nil { if !errors.Is(err, strconv.ErrSyntax) { msg.Verbosef("name cannot be interpreted as int64: %v", err) @@ -68,7 +68,7 @@ func tryFd(msg container.Msg, name string) io.ReadCloser { } } -func tryShort(msg container.Msg, name string) (config *hst.Config, entry *state.State) { +func tryShort(msg message.Msg, name string) (config *hst.Config, entry *state.State) { likePrefix := false if len(name) <= 32 { likePrefix = true diff --git a/cmd/hakurei/print.go b/cmd/hakurei/print.go index 1a97b858..e013909d 100644 --- a/cmd/hakurei/print.go +++ b/cmd/hakurei/print.go @@ -11,10 +11,10 @@ import ( "text/tabwriter" "time" - "hakurei.app/container" "hakurei.app/hst" "hakurei.app/internal/app" "hakurei.app/internal/app/state" + "hakurei.app/message" ) func printShowSystem(output io.Writer, short, flagJSON bool) { @@ -56,7 +56,7 @@ func printShowInstance( if err := config.Validate(); err != nil { valid = false - if m, ok := container.GetErrorMessage(err); ok { + if m, ok := message.GetMessage(err); ok { mustPrint(output, "Error: "+m+"!\n\n") } } diff --git a/cmd/hpkg/main.go b/cmd/hpkg/main.go index bb3f8865..e3346bff 100644 --- a/cmd/hpkg/main.go +++ b/cmd/hpkg/main.go @@ -11,10 +11,10 @@ import ( "syscall" "hakurei.app/command" - "hakurei.app/container" "hakurei.app/container/check" "hakurei.app/container/fhs" "hakurei.app/hst" + "hakurei.app/message" ) var ( @@ -24,7 +24,7 @@ var ( func main() { log.SetPrefix("hpkg: ") log.SetFlags(0) - msg := container.NewMsg(log.Default()) + msg := message.NewMsg(log.Default()) if err := os.Setenv("SHELL", pathShell.String()); err != nil { log.Fatalf("cannot set $SHELL: %v", err) diff --git a/cmd/hpkg/paths.go b/cmd/hpkg/paths.go index e5c045a5..811c7b7a 100644 --- a/cmd/hpkg/paths.go +++ b/cmd/hpkg/paths.go @@ -7,10 +7,10 @@ import ( "strconv" "sync/atomic" - "hakurei.app/container" "hakurei.app/container/check" "hakurei.app/container/fhs" "hakurei.app/hst" + "hakurei.app/message" ) const bash = "bash" @@ -52,7 +52,7 @@ func lookPath(file string) string { var beforeRunFail = new(atomic.Pointer[func()]) -func mustRun(msg container.Msg, name string, arg ...string) { +func mustRun(msg message.Msg, name string, arg ...string) { msg.Verbosef("spawning process: %q %q", name, arg) cmd := exec.Command(name, arg...) cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr diff --git a/cmd/hpkg/proc.go b/cmd/hpkg/proc.go index 1bbf5b49..70889106 100644 --- a/cmd/hpkg/proc.go +++ b/cmd/hpkg/proc.go @@ -9,14 +9,14 @@ import ( "os" "os/exec" - "hakurei.app/container" "hakurei.app/hst" "hakurei.app/internal" + "hakurei.app/message" ) var hakureiPath = internal.MustHakureiPath() -func mustRunApp(ctx context.Context, msg container.Msg, config *hst.Config, beforeFail func()) { +func mustRunApp(ctx context.Context, msg message.Msg, config *hst.Config, beforeFail func()) { var ( cmd *exec.Cmd st io.WriteCloser diff --git a/cmd/hpkg/with.go b/cmd/hpkg/with.go index df03a21d..cb86f502 100644 --- a/cmd/hpkg/with.go +++ b/cmd/hpkg/with.go @@ -5,15 +5,15 @@ import ( "os" "strings" - "hakurei.app/container" "hakurei.app/container/check" "hakurei.app/container/fhs" "hakurei.app/hst" + "hakurei.app/message" ) func withNixDaemon( ctx context.Context, - msg container.Msg, + msg message.Msg, action string, command []string, net bool, updateConfig func(config *hst.Config) *hst.Config, app *appInfo, pathSet *appPathSet, dropShell bool, beforeFail func(), ) { @@ -64,7 +64,7 @@ func withNixDaemon( func withCacheDir( ctx context.Context, - msg container.Msg, + msg message.Msg, action string, command []string, workDir *check.Absolute, app *appInfo, pathSet *appPathSet, dropShell bool, beforeFail func()) { mustRunAppDropShell(ctx, msg, &hst.Config{ @@ -102,7 +102,7 @@ func withCacheDir( }, dropShell, beforeFail) } -func mustRunAppDropShell(ctx context.Context, msg container.Msg, config *hst.Config, dropShell bool, beforeFail func()) { +func mustRunAppDropShell(ctx context.Context, msg message.Msg, config *hst.Config, dropShell bool, beforeFail func()) { if dropShell { if config.Container != nil { config.Container.Args = []string{bash, "-l"} |
