container: use absolute for pathname
All checks were successful
Test / Flake checks (push) Successful in 1m26s
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 1m59s
Test / Hakurei (push) Successful in 2m58s
Test / Hpkg (push) Successful in 3m45s
Test / Sandbox (race detector) (push) Successful in 4m11s
Test / Hakurei (race detector) (push) Successful in 4m47s
All checks were successful
Test / Flake checks (push) Successful in 1m26s
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 1m59s
Test / Hakurei (push) Successful in 2m58s
Test / Hpkg (push) Successful in 3m45s
Test / Sandbox (race detector) (push) Successful in 4m11s
Test / Hakurei (race detector) (push) Successful in 4m47s
This is simultaneously more efficient and less error-prone. This change caused minor API changes in multiple other packages. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"hakurei.app/container"
|
||||
"hakurei.app/container/seccomp"
|
||||
@@ -56,18 +55,18 @@ type appInfo struct {
|
||||
// store path to nixGL source
|
||||
NixGL string `json:"nix_gl,omitempty"`
|
||||
// store path to activate-and-exec script
|
||||
Launcher string `json:"launcher"`
|
||||
Launcher *container.Absolute `json:"launcher"`
|
||||
// store path to /run/current-system
|
||||
CurrentSystem string `json:"current_system"`
|
||||
CurrentSystem *container.Absolute `json:"current_system"`
|
||||
// store path to home-manager activation package
|
||||
ActivationPackage string `json:"activation_package"`
|
||||
}
|
||||
|
||||
func (app *appInfo) toFst(pathSet *appPathSet, argv []string, flagDropShell bool) *hst.Config {
|
||||
func (app *appInfo) toHst(pathSet *appPathSet, pathname *container.Absolute, argv []string, flagDropShell bool) *hst.Config {
|
||||
config := &hst.Config{
|
||||
ID: app.ID,
|
||||
|
||||
Path: argv[0],
|
||||
Path: pathname,
|
||||
Args: argv,
|
||||
|
||||
Enablements: app.Enablements,
|
||||
@@ -77,9 +76,9 @@ func (app *appInfo) toFst(pathSet *appPathSet, argv []string, flagDropShell bool
|
||||
DirectWayland: app.DirectWayland,
|
||||
|
||||
Username: "hakurei",
|
||||
Shell: shellPath,
|
||||
Shell: pathShell,
|
||||
Data: pathSet.homeDir,
|
||||
Dir: path.Join("/data/data", app.ID),
|
||||
Dir: pathDataData.Append(app.ID),
|
||||
|
||||
Identity: app.Identity,
|
||||
Groups: app.Groups,
|
||||
@@ -92,22 +91,22 @@ func (app *appInfo) toFst(pathSet *appPathSet, argv []string, flagDropShell bool
|
||||
Device: app.Device,
|
||||
Tty: app.Tty || flagDropShell,
|
||||
MapRealUID: app.MapRealUID,
|
||||
Filesystem: []*hst.FilesystemConfig{
|
||||
{Src: path.Join(pathSet.nixPath, "store"), Dst: "/nix/store", Must: true},
|
||||
{Src: pathSet.metaPath, Dst: path.Join(hst.Tmp, "app"), Must: true},
|
||||
{Src: container.FHSEtc + "resolv.conf"},
|
||||
{Src: container.FHSSys + "block"},
|
||||
{Src: container.FHSSys + "bus"},
|
||||
{Src: container.FHSSys + "class"},
|
||||
{Src: container.FHSSys + "dev"},
|
||||
{Src: container.FHSSys + "devices"},
|
||||
Filesystem: []hst.FilesystemConfig{
|
||||
{Src: pathSet.nixPath.Append("store"), Dst: pathNixStore, Must: true},
|
||||
{Src: pathSet.metaPath, Dst: hst.AbsTmp.Append("app"), Must: true},
|
||||
{Src: container.AbsFHSEtc.Append("resolv.conf")},
|
||||
{Src: container.AbsFHSSys.Append("block")},
|
||||
{Src: container.AbsFHSSys.Append("bus")},
|
||||
{Src: container.AbsFHSSys.Append("class")},
|
||||
{Src: container.AbsFHSSys.Append("dev")},
|
||||
{Src: container.AbsFHSSys.Append("devices")},
|
||||
},
|
||||
Link: [][2]string{
|
||||
{app.CurrentSystem, container.FHSRun + "current-system"},
|
||||
{container.FHSRun + "current-system/sw/bin", "/bin"},
|
||||
{container.FHSRun + "current-system/sw/bin", container.FHSUsrBin},
|
||||
Link: []hst.LinkConfig{
|
||||
{pathCurrentSystem, app.CurrentSystem.String()},
|
||||
{pathBin, pathSwBin.String()},
|
||||
{container.AbsFHSUsrBin, pathSwBin.String()},
|
||||
},
|
||||
Etc: path.Join(pathSet.cacheDir, "etc"),
|
||||
Etc: pathSet.cacheDir.Append("etc"),
|
||||
AutoEtc: true,
|
||||
},
|
||||
ExtraPerms: []*hst.ExtraPermConfig{
|
||||
@@ -141,6 +140,14 @@ func loadAppInfo(name string, beforeFail func()) *appInfo {
|
||||
beforeFail()
|
||||
log.Fatal("application identifier must not be empty")
|
||||
}
|
||||
if bundle.Launcher == nil {
|
||||
beforeFail()
|
||||
log.Fatal("launcher must not be empty")
|
||||
}
|
||||
if bundle.CurrentSystem == nil {
|
||||
beforeFail()
|
||||
log.Fatal("current-system must not be empty")
|
||||
}
|
||||
|
||||
return bundle
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user