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

rpm: Add Darwin support #35142

Merged
merged 3 commits into from Feb 21, 2018
Merged

rpm: Add Darwin support #35142

merged 3 commits into from Feb 21, 2018

Conversation

Kaali
Copy link

@Kaali Kaali commented Feb 18, 2018

Motivation for this change

RPM didn't work on macOS, now it does.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • 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 nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Could not run nox-phase because .nox/nixpkgs/pkgs/applications/virtualization/qemu/statfs-flags.patch was missing. Shouldn't break Linux packages as the derivation is the same on Linux.

I'm new to Nix so the "ln -s" solution in this PR might not be the best solution. It was used in other derivations so I picked it. The problem was that rpm tools pointed to @execution_path/libnss3.dylib, but I could not fix that with install_name_tool because nss itself had more of those paths.

@vcunat
Copy link
Member

vcunat commented Feb 18, 2018

BTW, the missing files for qemu were added in e3f947a.

@vcunat vcunat added the 6.topic: darwin Running or building packages on Darwin label Feb 18, 2018
@GrahamcOfBorg GrahamcOfBorg removed the 6.topic: darwin Running or building packages on Darwin label Feb 18, 2018
@abbradar
Copy link
Member

@grahamc ^ Possible @GrahamcOfBorg's bug -- how does it determine when the change is Darwin-specific?

@abbradar abbradar added the 6.topic: darwin Running or building packages on Darwin label Feb 18, 2018
@LnL7
Copy link
Member

LnL7 commented Feb 18, 2018

Yeah, I have a pr open for that.

@grahamc
Copy link
Member

grahamc commented Feb 18, 2018

The darwin tag is added if these paths are touched: https://github.com/NixOS/ofborg/blob/released/config.public.json#L46-L48 which is obviously not sufficient. We may want to remove the darwin tagger for now, before making a smarter tagger for it.

@Kaali
Copy link
Author

Kaali commented Feb 19, 2018

I don't understand the error in the checker. Can someone help with that?

@@ -18,7 +18,8 @@ stdenv.mkDerivation rec {
buildInputs = [ cpio zlib bzip2 file libarchive nspr nss db xz python lua ];

# rpm/rpmlib.h includes popt.h, and then the pkg-config file mentions these as linkage requirements
propagatedBuildInputs = [ popt elfutils nss db bzip2 libarchive libbfd ];
propagatedBuildInputs = [ popt nss db bzip2 libarchive libbfd ]
++ stdenv.lib.optionals stdenv.isLinux elfutils;
Copy link
Member

Choose a reason for hiding this comment

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

The checker marks line 21. optionals takes a list as the second parameter, so either use a singleton list or optional instead.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks

@@ -52,13 +53,20 @@ stdenv.mkDerivation rec {
# symlinks produced by build are incorrect
ln -sf $out/bin/{rpm,rpmquery}
ln -sf $out/bin/{rpm,rpmverify}
'' + stdenv.lib.optionalString stdenv.isDarwin ''
cd $out/bin
ln -s "${nss}/lib/libnss3.dylib"
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer to fix the install_name of these libraries, everything that depends on them is going to have this problem otherwise.

Copy link
Author

Choose a reason for hiding this comment

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

That sounds right. I wasn't sure if there is a reason for them to have this problem. New to Nix so didn't want to assume. Should they be their own issues / PR's?

Copy link
Member

Choose a reason for hiding this comment

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

You can add it to this pr if you want, just try to keep the changes in a separate commit per package.

@Mic92
Copy link
Member

Mic92 commented Feb 20, 2018

@GrahamcOfBorg build rpm

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Partial log (click to expand)

strip is /nix/store/adidfx4pa7vmvby0gjqqmiwg2x49yr27-binutils-2.28.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/mn4nppi2d2kkgkgnphaqw2ca6rmdvmh5-rpm-4.14.0-dev/lib 
patching script interpreter paths in /nix/store/mn4nppi2d2kkgkgnphaqw2ca6rmdvmh5-rpm-4.14.0-dev
checking for references to /tmp/nix-build-rpm-4.14.0.drv-0 in /nix/store/mn4nppi2d2kkgkgnphaqw2ca6rmdvmh5-rpm-4.14.0-dev...
shrinking RPATHs of ELF executables and libraries in /nix/store/ga7i62yjlkr79mbgj7cn4r5x5qv72rdm-rpm-4.14.0-man
gzipping man pages under /nix/store/ga7i62yjlkr79mbgj7cn4r5x5qv72rdm-rpm-4.14.0-man/share/man/
strip is /nix/store/adidfx4pa7vmvby0gjqqmiwg2x49yr27-binutils-2.28.1/bin/strip
patching script interpreter paths in /nix/store/ga7i62yjlkr79mbgj7cn4r5x5qv72rdm-rpm-4.14.0-man
checking for references to /tmp/nix-build-rpm-4.14.0.drv-0 in /nix/store/ga7i62yjlkr79mbgj7cn4r5x5qv72rdm-rpm-4.14.0-man...
/nix/store/8w249j7s55dk7h8armzhy70rxfchdgw4-rpm-4.14.0

@GrahamcOfBorg
Copy link

Success on x86_64-darwin (full log)

Partial log (click to expand)

/nix/store/9wx7k5s365ja4w6z1j17y0p45zqd2239-rpm-4.14.0/lib/rpm/rpmdb_loadcvt: interpreter directive changed from "/bin/bash" to "/nix/store/19cc89zq5n68ibr53izy4zgcr5qg2rza-bash-4.4-p12/bin/bash"
/nix/store/9wx7k5s365ja4w6z1j17y0p45zqd2239-rpm-4.14.0/lib/rpm/script.req: interpreter directive changed from "/bin/sh" to "/nix/store/19cc89zq5n68ibr53izy4zgcr5qg2rza-bash-4.4-p12/bin/sh"
/nix/store/9wx7k5s365ja4w6z1j17y0p45zqd2239-rpm-4.14.0/lib/rpm/tgpg: interpreter directive changed from "/bin/sh" to "/nix/store/19cc89zq5n68ibr53izy4zgcr5qg2rza-bash-4.4-p12/bin/sh"
strip is /nix/store/v8ifq0hapblpr2z0hx4wvwg02w4aczqy-cctools-binutils-darwin/bin/strip
stripping (with command strip and flags -S) in /nix/store/q4bxa7wfaf45vcpbf2x0zab7ya8dw9nr-rpm-4.14.0-dev/lib
patching script interpreter paths in /nix/store/q4bxa7wfaf45vcpbf2x0zab7ya8dw9nr-rpm-4.14.0-dev
gzipping man pages under /nix/store/9jafiyszhjjagg7lx0j199qgg9xa353w-rpm-4.14.0-man/share/man/
strip is /nix/store/v8ifq0hapblpr2z0hx4wvwg02w4aczqy-cctools-binutils-darwin/bin/strip
patching script interpreter paths in /nix/store/9jafiyszhjjagg7lx0j199qgg9xa353w-rpm-4.14.0-man
/nix/store/9wx7k5s365ja4w6z1j17y0p45zqd2239-rpm-4.14.0

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Partial log (click to expand)

strip is /nix/store/skd6ix5ipkyhxzq7naylj4digawakl4j-binutils-2.28.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/7i4j0jljxbnwl3bckh3m7vaw0w70j00z-rpm-4.14.0-dev/lib
patching script interpreter paths in /nix/store/7i4j0jljxbnwl3bckh3m7vaw0w70j00z-rpm-4.14.0-dev
checking for references to /build in /nix/store/7i4j0jljxbnwl3bckh3m7vaw0w70j00z-rpm-4.14.0-dev...
shrinking RPATHs of ELF executables and libraries in /nix/store/ygzzsqjlhisjj1grmqmsrdkzznp4f5s3-rpm-4.14.0-man
gzipping man pages under /nix/store/ygzzsqjlhisjj1grmqmsrdkzznp4f5s3-rpm-4.14.0-man/share/man/
strip is /nix/store/skd6ix5ipkyhxzq7naylj4digawakl4j-binutils-2.28.1/bin/strip
patching script interpreter paths in /nix/store/ygzzsqjlhisjj1grmqmsrdkzznp4f5s3-rpm-4.14.0-man
checking for references to /build in /nix/store/ygzzsqjlhisjj1grmqmsrdkzznp4f5s3-rpm-4.14.0-man...
/nix/store/6pc27mkrqiby02nhc3pm04clrdc04dhz-rpm-4.14.0

@@ -33,6 +33,10 @@ in stdenv.mkDerivation rec {

patchFlags = "-p0";

postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
substituteInPlace nss/coreconf/Darwin.mk --replace '@executable_path/$(notdir $@)' "$out/lib/\$(notdir \$@)"
Copy link
Member

Choose a reason for hiding this comment

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

does this work correctly if you need to fixup the install_name afterwards anyway?

Copy link
Author

Choose a reason for hiding this comment

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

Yes. It fixes a part of the paths. I couldn’t fix them all in the build. So I ended up hacking the rest with install_name_tool.

Copy link
Member

@LnL7 LnL7 Feb 20, 2018

Choose a reason for hiding this comment

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

ah, in that case take a look at fixDarwinDylibNames, that should handle the fixup for you. (the second part)

Copy link
Author

Choose a reason for hiding this comment

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

Thanks. Didn't notice that when grepping around.

@Mic92
Copy link
Member

Mic92 commented Feb 21, 2018

@GrahamcOfBorg build rpm

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Partial log (click to expand)

strip is /nix/store/adidfx4pa7vmvby0gjqqmiwg2x49yr27-binutils-2.28.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/mn4nppi2d2kkgkgnphaqw2ca6rmdvmh5-rpm-4.14.0-dev/lib
patching script interpreter paths in /nix/store/mn4nppi2d2kkgkgnphaqw2ca6rmdvmh5-rpm-4.14.0-dev
checking for references to /build in /nix/store/mn4nppi2d2kkgkgnphaqw2ca6rmdvmh5-rpm-4.14.0-dev...
shrinking RPATHs of ELF executables and libraries in /nix/store/ga7i62yjlkr79mbgj7cn4r5x5qv72rdm-rpm-4.14.0-man
gzipping man pages under /nix/store/ga7i62yjlkr79mbgj7cn4r5x5qv72rdm-rpm-4.14.0-man/share/man/
strip is /nix/store/adidfx4pa7vmvby0gjqqmiwg2x49yr27-binutils-2.28.1/bin/strip
patching script interpreter paths in /nix/store/ga7i62yjlkr79mbgj7cn4r5x5qv72rdm-rpm-4.14.0-man
checking for references to /build in /nix/store/ga7i62yjlkr79mbgj7cn4r5x5qv72rdm-rpm-4.14.0-man...
/nix/store/8w249j7s55dk7h8armzhy70rxfchdgw4-rpm-4.14.0

@GrahamcOfBorg
Copy link

Success on x86_64-darwin (full log)

Partial log (click to expand)

/nix/store/kl1m27g6q9lfndh7rkwx1aiq3pbschgl-rpm-4.14.0/lib/rpm/rpmdb_loadcvt: interpreter directive changed from "/bin/bash" to "/nix/store/19cc89zq5n68ibr53izy4zgcr5qg2rza-bash-4.4-p12/bin/bash"
/nix/store/kl1m27g6q9lfndh7rkwx1aiq3pbschgl-rpm-4.14.0/lib/rpm/script.req: interpreter directive changed from "/bin/sh" to "/nix/store/19cc89zq5n68ibr53izy4zgcr5qg2rza-bash-4.4-p12/bin/sh"
/nix/store/kl1m27g6q9lfndh7rkwx1aiq3pbschgl-rpm-4.14.0/lib/rpm/tgpg: interpreter directive changed from "/bin/sh" to "/nix/store/19cc89zq5n68ibr53izy4zgcr5qg2rza-bash-4.4-p12/bin/sh"
strip is /nix/store/v8ifq0hapblpr2z0hx4wvwg02w4aczqy-cctools-binutils-darwin/bin/strip
stripping (with command strip and flags -S) in /nix/store/76hzi26hj6la28j317qj1n4d9wiwf3ar-rpm-4.14.0-dev/lib
patching script interpreter paths in /nix/store/76hzi26hj6la28j317qj1n4d9wiwf3ar-rpm-4.14.0-dev
gzipping man pages under /nix/store/37x4i6iddzw6kr40gmvacs96ml9i9x1w-rpm-4.14.0-man/share/man/
strip is /nix/store/v8ifq0hapblpr2z0hx4wvwg02w4aczqy-cctools-binutils-darwin/bin/strip
patching script interpreter paths in /nix/store/37x4i6iddzw6kr40gmvacs96ml9i9x1w-rpm-4.14.0-man
/nix/store/kl1m27g6q9lfndh7rkwx1aiq3pbschgl-rpm-4.14.0

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Partial log (click to expand)

strip is /nix/store/skd6ix5ipkyhxzq7naylj4digawakl4j-binutils-2.28.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/7i4j0jljxbnwl3bckh3m7vaw0w70j00z-rpm-4.14.0-dev/lib
patching script interpreter paths in /nix/store/7i4j0jljxbnwl3bckh3m7vaw0w70j00z-rpm-4.14.0-dev
checking for references to /build in /nix/store/7i4j0jljxbnwl3bckh3m7vaw0w70j00z-rpm-4.14.0-dev...
shrinking RPATHs of ELF executables and libraries in /nix/store/ygzzsqjlhisjj1grmqmsrdkzznp4f5s3-rpm-4.14.0-man
gzipping man pages under /nix/store/ygzzsqjlhisjj1grmqmsrdkzznp4f5s3-rpm-4.14.0-man/share/man/
strip is /nix/store/skd6ix5ipkyhxzq7naylj4digawakl4j-binutils-2.28.1/bin/strip
patching script interpreter paths in /nix/store/ygzzsqjlhisjj1grmqmsrdkzznp4f5s3-rpm-4.14.0-man
checking for references to /build in /nix/store/ygzzsqjlhisjj1grmqmsrdkzznp4f5s3-rpm-4.14.0-man...
/nix/store/6pc27mkrqiby02nhc3pm04clrdc04dhz-rpm-4.14.0

@Mic92 Mic92 merged commit b6cad72 into NixOS:master Feb 21, 2018
@LnL7
Copy link
Member

LnL7 commented Feb 21, 2018

Thanks!

@Kaali
Copy link
Author

Kaali commented Feb 21, 2018

I’m really new at Nix. Just trying it out. You were one of the most helpful and active reviewers I’ve seen. Thanks for all the help with this PR.

@vcunat
Copy link
Member

vcunat commented Feb 21, 2018

Welcome! Darwin really lacks contributors, compared to x86_64-linux.

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

8 participants