forked from wrenn/wrenn
Fix build recipe execution and flatten reliability
- Set HOME in bctx.EnvVars when USER switches so ~ expands correctly in subsequent RUN/WORKDIR steps instead of resolving to /root - Run /bin/sync inside the guest before FlattenRootfs destroys the VM, preventing pip-installed files from being captured as 0-byte due to unflushed page cache - Wrap healthcheck command with su <user> so it runs with the template's default user context (correct HOME, correct UID) - Export Shellescape from the recipe package for use in build service - Add code-runner-beta recipe (Jupyter server with ipykernel --sys-prefix) and replace old python-interpreter-v0-beta
This commit is contained in:
@ -115,8 +115,11 @@ func expandEnv(s string, vars map[string]string) string {
|
||||
})
|
||||
}
|
||||
|
||||
// shellescape wraps s in single quotes, escaping any embedded single quotes.
|
||||
// Shellescape wraps s in single quotes, escaping any embedded single quotes.
|
||||
// This is POSIX-safe for paths, env values, and shell commands.
|
||||
func shellescape(s string) string {
|
||||
func Shellescape(s string) string {
|
||||
return "'" + strings.ReplaceAll(s, "'", `'\''`) + "'"
|
||||
}
|
||||
|
||||
// shellescape is the package-internal alias for Shellescape.
|
||||
func shellescape(s string) string { return Shellescape(s) }
|
||||
|
||||
@ -193,6 +193,15 @@ func execUser(
|
||||
entry := execRawShell(ctx, st.Raw, sandboxID, phase, step, 30*time.Second, execFn, script)
|
||||
if entry.Ok {
|
||||
bctx.User = username
|
||||
// Update HOME so ~ expands correctly in subsequent RUN/WORKDIR steps.
|
||||
if bctx.EnvVars == nil {
|
||||
bctx.EnvVars = make(map[string]string)
|
||||
}
|
||||
if username == "root" {
|
||||
bctx.EnvVars["HOME"] = "/root"
|
||||
} else {
|
||||
bctx.EnvVars["HOME"] = "/home/" + username
|
||||
}
|
||||
}
|
||||
return entry, entry.Ok
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user