aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/exec.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-04-15 15:48:03 +0900
committerOphestra <cat@gensokyo.uk>2026-04-15 15:49:21 +0900
commit3352bb975bca696c8c4d2ed2f129c97514e013a4 (patch)
tree0a40ae148c8cbf0cbaa4a76e92acf43d09a2bc3f /internal/pkg/exec.go
parentf7f48d57e9260f4e076e47013318714a52527b2f (diff)
internal/pkg: job count in container environment
This exposes preferred job count to the container initial process. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg/exec.go')
-rw-r--r--internal/pkg/exec.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/internal/pkg/exec.go b/internal/pkg/exec.go
index 4865c71a..7760668a 100644
--- a/internal/pkg/exec.go
+++ b/internal/pkg/exec.go
@@ -27,6 +27,11 @@ import (
// AbsWork is the container pathname [TContext.GetWorkDir] is mounted on.
var AbsWork = fhs.AbsRoot.Append("work/")
+// EnvJobs is the name of the environment variable holding a decimal
+// representation of the preferred job count. Its value must not affect cure
+// outcome.
+const EnvJobs = "CURE_JOBS"
+
// ExecPath is a slice of [Artifact] and the [check.Absolute] pathname to make
// it available at under in the container.
type ExecPath struct {
@@ -397,7 +402,7 @@ const SeccompPresets = std.PresetStrict &
func (a *execArtifact) makeContainer(
ctx context.Context,
msg message.Msg,
- flags int,
+ flags, jobs int,
hostNet bool,
temp, work *check.Absolute,
getArtifact GetArtifactFunc,
@@ -432,8 +437,8 @@ func (a *execArtifact) makeContainer(
z.Hostname = "cure-net"
}
z.Uid, z.Gid = (1<<10)-1, (1<<10)-1
-
- z.Dir, z.Env, z.Path, z.Args = a.dir, a.env, a.path, a.args
+ z.Dir, z.Path, z.Args = a.dir, a.path, a.args
+ z.Env = slices.Concat(a.env, []string{EnvJobs + "=" + strconv.Itoa(jobs)})
z.Grow(len(a.paths) + 4)
for i, b := range a.paths {
@@ -563,6 +568,7 @@ func (c *Cache) EnterExec(
z, err = e.makeContainer(
ctx, c.msg,
c.flags,
+ c.jobs,
hostNet,
temp, work,
func(a Artifact) (*check.Absolute, unique.Handle[Checksum]) {
@@ -602,7 +608,7 @@ func (a *execArtifact) cure(f *FContext, hostNet bool) (err error) {
msg := f.GetMessage()
var z *container.Container
if z, err = a.makeContainer(
- ctx, msg, f.cache.flags, hostNet,
+ ctx, msg, f.cache.flags, f.GetJobs(), hostNet,
f.GetTempDir(), f.GetWorkDir(),
f.GetArtifact,
f.cache.Ident,