From 699c30056b6f278077fe21aad3d7f7336a7cc783 Mon Sep 17 00:00:00 2001 From: Yaya Date: Tue, 22 Mar 2022 14:39:37 +0000 Subject: [PATCH] gitlab-runner: 14.8.2 -> 14.9.0 --- .../gitlab-runner/default.nix | 7 +- .../gitlab-runner/fix-shell-path.patch | 28 +++---- .../gitlab-runner/remove-bash-test.patch | 80 +++++++++++++++++++ 3 files changed, 98 insertions(+), 17 deletions(-) create mode 100644 pkgs/development/tools/continuous-integration/gitlab-runner/remove-bash-test.patch diff --git a/pkgs/development/tools/continuous-integration/gitlab-runner/default.nix b/pkgs/development/tools/continuous-integration/gitlab-runner/default.nix index 6dc0a7d30ee1..6caccc45e97a 100644 --- a/pkgs/development/tools/continuous-integration/gitlab-runner/default.nix +++ b/pkgs/development/tools/continuous-integration/gitlab-runner/default.nix @@ -1,7 +1,7 @@ { lib, buildGoModule, fetchFromGitLab, fetchurl }: let - version = "14.8.2"; + version = "14.9.0"; in buildGoModule rec { inherit version; @@ -14,17 +14,18 @@ buildGoModule rec { "-X ${commonPackagePath}.REVISION=v${version}" ]; - vendorSha256 = "1aa04hbavr0bclddp5adjwwj21sp46gbhjydxc3w7vs1siw0ivq2"; + vendorSha256 = "0ag3pmcrxksgikdcvl9rv2s3kn7l0dj41pf2m9dq0g2a1j45nydn"; src = fetchFromGitLab { owner = "gitlab-org"; repo = "gitlab-runner"; rev = "v${version}"; - sha256 = "1zwr09lrrc3xx3sp00vs30ks0n77d7v0xkz0mz9jy2qdls9nfmrv"; + sha256 = "0qqwg2k50cq7bc7k1389knrjq6xdbmlxd5kavyj7pg4sfapa3i8l"; }; patches = [ ./fix-shell-path.patch + ./remove-bash-test.patch ]; prePatch = '' diff --git a/pkgs/development/tools/continuous-integration/gitlab-runner/fix-shell-path.patch b/pkgs/development/tools/continuous-integration/gitlab-runner/fix-shell-path.patch index 4a3d37be09cd..b70b95e7be0b 100644 --- a/pkgs/development/tools/continuous-integration/gitlab-runner/fix-shell-path.patch +++ b/pkgs/development/tools/continuous-integration/gitlab-runner/fix-shell-path.patch @@ -1,5 +1,5 @@ diff --git a/shells/bash.go b/shells/bash.go -index bd99eca1a..9873dff6b 100644 +index 18d608445..f158ffc0b 100644 --- a/shells/bash.go +++ b/shells/bash.go @@ -3,6 +3,7 @@ package shells @@ -10,16 +10,16 @@ index bd99eca1a..9873dff6b 100644 "path" "runtime" "strconv" -@@ -300,7 +301,11 @@ func (b *BashShell) GetConfiguration(info common.ShellScriptInfo) (*common.Shell - if info.User != "" { - script.Command = "su" - if runtime.GOOS == "linux" { -- script.Arguments = append(script.Arguments, "-s", "/bin/"+b.Shell) -+ shellPath, err := exec.LookPath(b.Shell) -+ if err != nil { -+ shellPath = "/bin/" + b.Shell -+ } -+ script.Arguments = append(script.Arguments, "-s", shellPath) - } - script.Arguments = append( - script.Arguments, +@@ -307,7 +308,11 @@ func (b *BashShell) GetConfiguration(info common.ShellScriptInfo) (*common.Shell + + script.Command = "su" + if runtime.GOOS == OSLinux { +- script.Arguments = []string{"-s", "/bin/" + b.Shell, info.User, "-c", script.CmdLine} ++ shellPath, err := exec.LookPath(b.Shell) ++ if err != nil { ++ shellPath = "/bin/" + b.Shell ++ } ++ script.Arguments = []string{"-s", shellPath, info.User, "-c", script.CmdLine} + } else { + script.Arguments = []string{info.User, "-c", script.CmdLine} + } diff --git a/pkgs/development/tools/continuous-integration/gitlab-runner/remove-bash-test.patch b/pkgs/development/tools/continuous-integration/gitlab-runner/remove-bash-test.patch new file mode 100644 index 000000000000..5bffd0f4f75e --- /dev/null +++ b/pkgs/development/tools/continuous-integration/gitlab-runner/remove-bash-test.patch @@ -0,0 +1,80 @@ +diff --git a/shells/bash_test.go b/shells/bash_test.go +index b8a48f85e..0e3173fc3 100644 +--- a/shells/bash_test.go ++++ b/shells/bash_test.go +@@ -4,12 +4,9 @@ + package shells + + import ( +- "runtime" + "testing" + + "github.com/stretchr/testify/assert" +- "github.com/stretchr/testify/require" +- "gitlab.com/gitlab-org/gitlab-runner/common" + ) + + func TestBash_CommandShellEscapesLegacy(t *testing.T) { +@@ -84,62 +81,3 @@ func TestBash_CheckForErrors(t *testing.T) { + }) + } + } +- +-func TestBash_GetConfiguration(t *testing.T) { +- tests := map[string]struct { +- info common.ShellScriptInfo +- cmd string +- args []string +- os string +- }{ +- `bash`: { +- info: common.ShellScriptInfo{Shell: "bash", Type: common.NormalShell}, +- cmd: "bash", +- }, +- `bash -l`: { +- info: common.ShellScriptInfo{Shell: "bash", Type: common.LoginShell}, +- cmd: "bash", +- args: []string{"-l"}, +- }, +- `su -s /bin/bash foobar -c bash`: { +- info: common.ShellScriptInfo{Shell: "bash", User: "foobar", Type: common.NormalShell}, +- cmd: "su", +- args: []string{"-s", "/bin/bash", "foobar", "-c", "bash"}, +- os: OSLinux, +- }, +- `su -s /bin/bash foobar -c $'bash -l'`: { +- info: common.ShellScriptInfo{Shell: "bash", User: "foobar", Type: common.LoginShell}, +- cmd: "su", +- args: []string{"-s", "/bin/bash", "foobar", "-c", "bash -l"}, +- os: OSLinux, +- }, +- `su -s /bin/sh foobar -c $'sh -l'`: { +- info: common.ShellScriptInfo{Shell: "sh", User: "foobar", Type: common.LoginShell}, +- cmd: "su", +- args: []string{"-s", "/bin/sh", "foobar", "-c", "sh -l"}, +- os: OSLinux, +- }, +- `su foobar -c $'bash -l'`: { +- info: common.ShellScriptInfo{Shell: "bash", User: "foobar", Type: common.LoginShell}, +- cmd: "su", +- args: []string{"foobar", "-c", "bash -l"}, +- os: "darwin", +- }, +- } +- +- for tn, tc := range tests { +- t.Run(tn, func(t *testing.T) { +- if tc.os != "" && tc.os != runtime.GOOS { +- t.Skipf("test only runs on %s", tc.os) +- } +- +- sh := BashShell{Shell: tc.info.Shell} +- config, err := sh.GetConfiguration(tc.info) +- require.NoError(t, err) +- +- assert.Equal(t, tc.cmd, config.Command) +- assert.Equal(t, tc.args, config.Arguments) +- assert.Equal(t, tn, config.CmdLine) +- }) +- } +-}