aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-09-25 13:46:21 +0900
committerOphestra <cat@gensokyo.uk>2025-09-25 13:51:54 +0900
commitae2df2c450dd655b93a950124b6ab16e2b4d967b (patch)
tree849ab40049228e17891351d97097f8c9d0e18c10 /cmd
parent6e3f34f2ecfe0f3cd024a6e73bf6560080feac53 (diff)
internal: remove sys package
This package is replaced by container/stub. Remove and replace it with unexported implementation for the upcoming test suite rewrite. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/hakurei/command.go11
-rw-r--r--cmd/hakurei/main.go3
-rw-r--r--cmd/hakurei/parse.go5
-rw-r--r--cmd/hakurei/print.go8
4 files changed, 13 insertions, 14 deletions
diff --git a/cmd/hakurei/command.go b/cmd/hakurei/command.go
index 0600a559..1671902e 100644
--- a/cmd/hakurei/command.go
+++ b/cmd/hakurei/command.go
@@ -18,7 +18,6 @@ import (
"hakurei.app/internal/app"
"hakurei.app/internal/app/state"
"hakurei.app/internal/hlog"
- "hakurei.app/internal/sys"
"hakurei.app/system"
"hakurei.app/system/dbus"
)
@@ -43,7 +42,7 @@ func buildCommand(ctx context.Context, out io.Writer) command.Command {
config := tryPath(args[0])
config.Args = append(config.Args, args[1:]...)
- app.Main(ctx, std, config)
+ app.Main(ctx, config)
panic("unreachable")
})
@@ -79,7 +78,7 @@ func buildCommand(ctx context.Context, out io.Writer) command.Command {
passwd *user.User
passwdOnce sync.Once
passwdFunc = func() {
- us := strconv.Itoa(sys.MustUid(std, flagIdentity))
+ us := strconv.Itoa(app.HsuUid(new(app.Hsu).MustID(), flagIdentity))
if u, err := user.LookupId(us); err != nil {
hlog.Verbosef("cannot look up uid %s", us)
passwd = &user.User{
@@ -163,7 +162,7 @@ func buildCommand(ctx context.Context, out io.Writer) command.Command {
}
}
- app.Main(ctx, std, config)
+ app.Main(ctx, config)
panic("unreachable")
}).
Flag(&flagDBusConfigSession, "dbus-config", command.StringFlag("builtin"),
@@ -219,7 +218,9 @@ func buildCommand(ctx context.Context, out io.Writer) command.Command {
{
var flagShort bool
c.NewCommand("ps", "List active instances", func(args []string) error {
- printPs(os.Stdout, time.Now().UTC(), state.NewMulti(std.Paths().RunDirPath.String()), flagShort, flagJSON)
+ var sc hst.Paths
+ app.CopyPaths(&sc, new(app.Hsu).MustID())
+ printPs(os.Stdout, time.Now().UTC(), state.NewMulti(sc.RunDirPath.String()), flagShort, flagJSON)
return errSuccess
}).Flag(&flagShort, "short", command.BoolFlag(false), "Print instance id")
}
diff --git a/cmd/hakurei/main.go b/cmd/hakurei/main.go
index b71f50c8..2b9193b6 100644
--- a/cmd/hakurei/main.go
+++ b/cmd/hakurei/main.go
@@ -15,7 +15,6 @@ import (
"hakurei.app/container"
"hakurei.app/internal"
"hakurei.app/internal/hlog"
- "hakurei.app/internal/sys"
)
var (
@@ -27,8 +26,6 @@ var (
func init() { hlog.Prepare("hakurei") }
-var std sys.State = new(sys.Std)
-
func main() {
// early init path, skips root check and duplicate PR_SET_DUMPABLE
container.TryArgv0(hlog.Output{}, hlog.Prepare, internal.InstallOutput)
diff --git a/cmd/hakurei/parse.go b/cmd/hakurei/parse.go
index 56ff83e1..897382ea 100644
--- a/cmd/hakurei/parse.go
+++ b/cmd/hakurei/parse.go
@@ -11,6 +11,7 @@ import (
"syscall"
"hakurei.app/hst"
+ "hakurei.app/internal/app"
"hakurei.app/internal/app/state"
"hakurei.app/internal/hlog"
)
@@ -87,7 +88,9 @@ func tryShort(name string) (config *hst.Config, entry *state.State) {
if likePrefix && len(name) >= 8 {
hlog.Verbose("argument looks like prefix")
- s := state.NewMulti(std.Paths().RunDirPath.String())
+ var sc hst.Paths
+ app.CopyPaths(&sc, new(app.Hsu).MustID())
+ s := state.NewMulti(sc.RunDirPath.String())
if entries, err := state.Join(s); err != nil {
log.Printf("cannot join store: %v", err)
// drop to fetch from file
diff --git a/cmd/hakurei/print.go b/cmd/hakurei/print.go
index 387b5c25..938517b8 100644
--- a/cmd/hakurei/print.go
+++ b/cmd/hakurei/print.go
@@ -12,8 +12,8 @@ import (
"time"
"hakurei.app/hst"
+ "hakurei.app/internal/app"
"hakurei.app/internal/app/state"
- "hakurei.app/internal/sys"
"hakurei.app/system/dbus"
)
@@ -21,10 +21,8 @@ func printShowSystem(output io.Writer, short, flagJSON bool) {
t := newPrinter(output)
defer t.MustFlush()
- info := &hst.Info{
- Paths: std.Paths(),
- User: sys.MustGetUserID(std),
- }
+ info := &hst.Info{User: new(app.Hsu).MustID()}
+ app.CopyPaths(&info.Paths, info.User)
if flagJSON {
printJSON(output, short, info)