Skip to content

Commit

Permalink
Merge branch 'main' of github.com:sylabs/singularity into add/test-cu…
Browse files Browse the repository at this point in the history
…stom-shell
  • Loading branch information
vsoch committed Jun 15, 2022
2 parents 7454d7f + 58d0c18 commit 80c3668
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
### Bug Fixes

- Fix compilation on `mipsel`.
- Fix test code that implied `%test -c <shell>` was supported - it is not.

## 3.10.0 \[2022-05-17\]

Expand Down
8 changes: 5 additions & 3 deletions e2e/imgbuild/regressions.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2019-2021, Sylabs Inc. All rights reserved.
// Copyright (c) 2019-2022, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.
Expand Down Expand Up @@ -219,7 +219,9 @@ func (c *imgBuildTests) issue4943(t *testing.T) {
)
}

// Test -c section parameter is correctly handled.
// Test %post -c section parameter is correctly handled. We use `-c /bin/busybox
// sh` for this test, and can observe the `/proc/$$/cmdline` to check that was
// used to invoke the post script.
func (c *imgBuildTests) issue4967(t *testing.T) {
image := filepath.Join(c.env.TestDir, "issue_4967.sif")

Expand All @@ -233,7 +235,7 @@ func (c *imgBuildTests) issue4967(t *testing.T) {
}),
e2e.ExpectExit(
0,
e2e.ExpectOutput(e2e.ContainMatch, "function foo"),
e2e.ExpectOutput(e2e.ContainMatch, "/bin/busybox sh /.post.script"),
),
)
}
Expand Down
12 changes: 4 additions & 8 deletions e2e/testdata/regressions/issue_4967.def
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
bootstrap: docker
from: alpine:3.10
bootstrap: library
from: alpine:3.11.5

%post
apk add --update-cache bash

%test -c /bin/bash
function foo { echo "function foo"; }
foo
%post -c /bin/busybox sh
cat /proc/$$/cmdline | tr '\000' ' '
6 changes: 3 additions & 3 deletions internal/pkg/build/build.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2019-2020, Sylabs Inc. All rights reserved.
// Copyright (c) 2019-2022, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.
Expand Down Expand Up @@ -373,7 +373,7 @@ func (b *Build) Full(ctx context.Context) error {

// build each stage one after the other
for i, stage := range b.stages {
if err := stage.runSectionScript("pre", stage.b.Recipe.BuildData.Pre); err != nil {
if err := stage.runHostScript("pre", stage.b.Recipe.BuildData.Pre); err != nil {
return err
}

Expand Down Expand Up @@ -426,7 +426,7 @@ func (b *Build) Full(ctx context.Context) error {
}
}

if err := stage.runSectionScript("setup", stage.b.Recipe.BuildData.Setup); err != nil {
if err := stage.runHostScript("setup", stage.b.Recipe.BuildData.Setup); err != nil {
return err
}

Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/build/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func (s *stage) Assemble(path string) error {
return s.a.Assemble(s.b, path)
}

// runSetupScript executes the stage's pre script on host.
func (s *stage) runSectionScript(name string, script types.Script) error {
// runHostScript executes the stage's pre or setup script on host.
func (s *stage) runHostScript(name string, script types.Script) error {
if s.b.RunSection(name) && script.Script != "" {
if syscall.Getuid() != 0 {
return fmt.Errorf("attempted to build with scripts as non-root user or without --fakeroot")
Expand Down

0 comments on commit 80c3668

Please sign in to comment.