Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cask: Fix shebang of cask executable #123134

Merged
merged 1 commit into from Jul 22, 2021

Conversation

seppeljordan
Copy link
Contributor

@seppeljordan seppeljordan commented May 15, 2021

Hi, the cask executable was broken. To fix the issue the shebang was set correctly.

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@seppeljordan
Copy link
Contributor Author

Result of nixpkgs-review pr 123134 run on x86_64-linux 1

1 package built:
  • cask

@r-rmcgibbo
Copy link

Result of nixpkgs-review pr 123134 at f259c5f3 run on x86_64-linux 1

1 package built successfully:
  • cask
3 suggestions:
  • warning: unused-argument

    Unused argument: fetchurl.
    Near pkgs/development/tools/cask/default.nix:1:16:

      |
    1 | { lib, stdenv, fetchurl, python3, emacs }:
      |                ^
    
  • warning: missing-phase-hooks

    buildPhase should probably contain runHook preBuild and runHook postBuild.

    Near pkgs/development/tools/cask/default.nix:20:3:

       |
    20 |   buildPhase = ''
       |   ^
    
  • warning: missing-phase-hooks

    installPhase should probably contain runHook preInstall and runHook postInstall.

    Near pkgs/development/tools/cask/default.nix:25:3:

       |
    25 |   installPhase = ''
       |   ^
    

@SuperSandro2000
Copy link
Member

patchShebang replaced the shebang with the buildPlatform instead of the targetPlatform which means the script breaks when cross compiling.

@seppeljordan
Copy link
Contributor Author

What can I do about that?

@@ -19,6 +19,7 @@ stdenv.mkDerivation rec {

buildPhase = ''
emacs --batch -L . -f batch-byte-compile cask.el cask-cli.el
patchShebangs bin/cask
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
patchShebangs bin/cask
patchShebangs --host bin/cask

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suggested solution does not produce the expected result. As soon as I add the --host argument to the patchShebangs command the resulting executable is not correctly patched anymore.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔

https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/setup-hooks/patch-shebangs.sh#L21

You may need to add the package to buildInput that are added to the shebang.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SuperSandro2000 Thanks for the hint. Adding bash to the build inputs totally solved the problem. Instead of calling patchShebangs manually I added pre and post phase hooks to buildPhase and installPhase. This seems to be the preferred way of doing this kind of stuff in nixpkgs.

@seppeljordan seppeljordan force-pushed the fix-cask branch 2 times, most recently from c9f4bbf to 294aec7 Compare July 10, 2021 12:40
@seppeljordan
Copy link
Contributor Author

Suggestion of @SuperSandro2000 incorporated

@seppeljordan seppeljordan marked this pull request as draft July 10, 2021 13:03
Add the pre and post phase hooks was done to fix the broken shebangs
of the cask executable.
@seppeljordan seppeljordan marked this pull request as ready for review July 14, 2021 15:04
@seppeljordan
Copy link
Contributor Author

Result of nixpkgs-review pr 123134 run on x86_64-linux 1

1 package built:
  • cask

@SuperSandro2000 SuperSandro2000 merged commit 265bc05 into NixOS:master Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants