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

Fix dylib references of bundled programs on macOS #2135

Merged
merged 3 commits into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nix/linux-release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let
in pkgs.stdenv.mkDerivation {
inherit name;
buildInputs = with pkgs.buildPackages; [ gnutar gzip binutils ];
checkInputs = [ pkgs.buildPackages.ruby ];
checkInputs = with pkgs.buildPackages; [ ruby gnugrep glibc.bin ];
doCheck = true;
phases = [ "buildPhase" "checkPhase" ];
tarname = "${name}-linux64.tar.gz";
Expand Down
16 changes: 14 additions & 2 deletions nix/macos-release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,27 @@ let

in pkgs.stdenv.mkDerivation {
inherit name;
buildInputs = with pkgs.buildPackages; [ gnutar gzip binutils ];
checkInputs = [ pkgs.buildPackages.ruby ];
buildInputs = with pkgs.buildPackages; [
gnutar
gzip
binutils
commonLib.haskell-nix-extra-packages.haskellBuildUtils.package
nix
];
checkInputs = with pkgs.buildPackages; [
ruby
gnugrep
gnused
darwin.cctools
];
doCheck = true;
phases = [ "buildPhase" "checkPhase" ];
tarname = "${name}-macos64.tar.gz";
buildPhase = ''
mkdir $name
cp -nR ${concatMapStringsSep " " (exe: "${exe}/bin/*") exes} $name
chmod -R 755 $name
( cd $name; rewrite-libs . `ls -1 | grep -Fv .dylib` )

mkdir -p $out/nix-support
tar -czf $out/$tarname $name
Expand Down
8 changes: 3 additions & 5 deletions release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,18 @@ let
# Release distribution jobs - these all have a Hydra download link.

# Which exes should be put in the release archive.
releaseContents = rec {
releaseContents = {
jormungandr = [
"cardano-wallet-jormungandr"
"jormungandr"
"jormungandr-cli"
];
cardanoNodeCommon = [
shelley = [
"cardano-wallet"
"bech32"
"cardano-address"
"cardano-cli"
"cardano-node"
"cardano-tx"
];
shelley = [ "cardano-wallet" ] ++ cardanoNodeCommon;
};

# function to take a list of jobs by name from a jobset.
Expand Down
23 changes: 19 additions & 4 deletions scripts/check-bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
############################################################################
# Checks that every executable required in the release package is
# present and works.
# On Linux it checks if executables are statically linked.
# On macOS it checks that there are no /nix/store dylibs.
############################################################################

require 'open3'

tests = {
"cardano-wallet-jormungandr" => [ "jormungandr", "jcli" ],
"cardano-wallet-jormungandr" => [ ],
"cardano-wallet" => [ "cardano-node", "cardano-cli", "bech32", "cardano-tx", "cardano-address" ]
}

Expand All @@ -33,15 +35,28 @@ def report(cmd, status)
end

cmd = "#{wallet} version"
ver, status = Open3.capture2("#{runner} #{cmd}")
report(cmd, status.to_i)
begin
ver, status = Open3.capture2("#{runner} #{cmd}")
report(cmd, status.to_i)
rescue Errno::ENOENT
report(cmd, 1)
end

tests[wallet].each do |cmd|
tests[wallet].unshift(wallet).each do |cmd|
Copy link
Contributor

Choose a reason for hiding this comment

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

:)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My first ruby program 🙂

begin
stdout_str, status = Open3.capture2("#{runner} #{cmd} --help")
report(cmd, status.to_i)
rescue Errno::ENOENT
report(cmd, 1)
next
end

if /darwin/ =~ RUBY_PLATFORM then
system("! otool -L `type -p #{cmd}` | sed 1d | grep nix");
report("#{cmd} is free of /nix/store", $?.exitstatus)
elsif /linux/ =~ RUBY_PLATFORM then
system("! ldd `type -p #{cmd}` > /dev/null");
report("#{cmd} is static linked", $?.exitstatus)
end
end

Expand Down