Skip to content

Commit

Permalink
spread: patch local script path in client
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsgruk committed Sep 24, 2024
1 parent a83f1f0 commit 4ef5178
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
{
ght = pkgs.callPackage ./ght { };
nixfmt-plus = pkgs.callPackage ./nixfmt-plus.nix { };
spread = pkgs.callPackage ./spread.nix { };
spread = pkgs.callPackage ./spread { };
}
16 changes: 16 additions & 0 deletions pkgs/spread.nix → pkgs/spread/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,28 @@ pkgs.buildGoModule {

subPackages = [ "cmd/spread" ];

nativeBuildInputs = with pkgs; [ makeWrapper ];

patches = [ ./path.patch ];

postPatch = ''
# Replace direct calls to /bin/bash
substituteInPlace spread/lxd.go --replace-fail '"/bin/bash", ' '"/usr/bin/env", "bash", '
substituteInPlace spread/client.go --replace-fail '"/bin/bash", ' '"/usr/bin/env", "bash", '
substituteInPlace spread/project.go --replace-fail '"/bin/bash", ' '"/usr/bin/env", "bash", '
'';

postInstall = ''
wrapProgram $out/bin/spread --prefix PATH ${
lib.makeBinPath [
pkgs.bash
pkgs.coreutils
pkgs.gnutar
pkgs.gzip
]
}
'';

meta = {
mainProgram = "spread";
description = "Convenient full-system test (task) distribution";
Expand Down
13 changes: 13 additions & 0 deletions pkgs/spread/local-script-path.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/spread/client.go b/spread/client.go
index c72d48a..e927567 100644
--- a/spread/client.go
+++ b/spread/client.go
@@ -791,7 +791,7 @@ func (s *localScript) run() (stdout, stderr []byte, err error) {
buf.WriteString("NOMATCH() { { set +xu; } 2> /dev/null; local stdin=$(cat); if echo $stdin | grep -q -E \"$@\"; then echo \"NOMATCH pattern='$@' found in:\n$stdin\">&2; return 1; fi }\n")
buf.WriteString("export DEBIAN_FRONTEND=noninteractive\n")
buf.WriteString("export DEBIAN_PRIORITY=critical\n")
- buf.WriteString("export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin\n")
+ buf.WriteString(fmt.Sprintf("export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:%s\n", os.Getenv("PATH")))

for _, k := range s.env.Keys() {
v := s.env.Get(k)

0 comments on commit 4ef5178

Please sign in to comment.