-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
xar: 1.6.1 -> 498 #329721
Merged
Merged
xar: 1.6.1 -> 498 #329721
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
{ | ||
lib, | ||
stdenv, | ||
fetchFromGitHub, | ||
applyPatches, | ||
autoreconfHook, | ||
nix-update-script, | ||
|
||
# Required dependencies. | ||
openssl, | ||
zlib, | ||
libxml2, | ||
|
||
# Optional dependencies. | ||
e2fsprogs, | ||
bzip2, | ||
xz, # lzma | ||
|
||
# Platform-specific dependencies. | ||
acl, | ||
musl-fts, | ||
|
||
# for tests | ||
testers, | ||
python3, | ||
libxslt, # xsltproc | ||
runCommand, | ||
runCommandCC, | ||
makeWrapper, | ||
xar, | ||
}: | ||
stdenv.mkDerivation (finalAttrs: { | ||
pname = "xar"; | ||
version = "498"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "apple-oss-distributions"; | ||
repo = "xar"; | ||
rev = "xar-${finalAttrs.version}"; | ||
hash = "sha256-RyWeR/ZnDBHIZhwzVxETdrTTPQA2VgsLZegRkxX1240="; | ||
}; | ||
|
||
# Update patch set with | ||
# git clone https://github.com/apple-oss-distributions/xar | ||
# cd xar | ||
# git switch -c nixpkgs | ||
# git am ../pkgs/by-name/xa/xar/patches/* | ||
# # … | ||
# rm -r ../pkgs/by-name/xa/xar/patches | ||
# git format-patch --zero-commit --output-directory ../pkgs/by-name/xa/xar/patches main | ||
patches = lib.filesystem.listFilesRecursive ./patches; | ||
|
||
# We do not use or modify files outside of the xar subdirectory. | ||
patchFlags = [ "-p2" ]; | ||
sourceRoot = "source/xar"; | ||
|
||
outputs = [ | ||
"out" | ||
"lib" | ||
"dev" | ||
]; | ||
|
||
strictDeps = true; | ||
|
||
nativeBuildInputs = [ autoreconfHook ]; | ||
|
||
# For some reason libxml2 package headers are in subdirectory and thus aren’t | ||
# picked up by stdenv’s C compiler wrapper (see ccWrapper_addCVars). This | ||
# doesn’t really belong here and either should be part of libxml2 package or | ||
# libxml2 in Nixpkgs can just fix their header paths. | ||
env.NIX_CFLAGS_COMPILE = "-isystem ${libxml2.dev}/include/libxml2"; | ||
|
||
buildInputs = | ||
[ | ||
# NB we use OpenSSL instead of CommonCrypto on Darwin. | ||
openssl | ||
zlib | ||
libxml2 | ||
bzip2 | ||
xz | ||
e2fsprogs | ||
] | ||
++ lib.optional stdenv.hostPlatform.isLinux acl ++ lib.optional stdenv.hostPlatform.isMusl musl-fts; | ||
|
||
passthru = | ||
let | ||
patchedSource = applyPatches { inherit (finalAttrs) src patches; }; | ||
pythonForTests = python3.withPackages (p: [ p.xattr ]); | ||
in | ||
{ | ||
# Tests xar outside of the Nix sandbox (extended attributes are not supported | ||
# in Nix sandbox, e.g. filtered with seccomp on Linux). | ||
# | ||
# Run with | ||
# $ nix run --file . xar.impureTests.integrationTest | ||
# Ensure that all tests are PASSED and none are FAILED or SKIPPED. | ||
impureTests.integrationTest = | ||
runCommand "xar-impure-tests-integration-test" | ||
{ | ||
src = patchedSource; | ||
xar = finalAttrs.finalPackage; | ||
xsltproc = lib.getBin libxslt; | ||
pythonInterpreter = pythonForTests.interpreter; | ||
nativeBuildInputs = [ makeWrapper ]; | ||
} | ||
'' | ||
makeWrapper "$pythonInterpreter" "$out/bin/$name" \ | ||
--prefix PATH : "$xar/bin" \ | ||
--suffix PATH : "$xsltproc/bin" \ | ||
--add-flags -- \ | ||
--add-flags "$src/xar/test/run-all.py" | ||
''; | ||
|
||
tests = lib.optionalAttrs (stdenv.buildPlatform.canExecute stdenv.hostPlatform) { | ||
version = testers.testVersion { | ||
package = finalAttrs.finalPackage; | ||
version = "1.8dev"; | ||
}; | ||
|
||
integrationTest = | ||
runCommand "xar-tests-integration-test" | ||
{ | ||
src = patchedSource; | ||
strictDeps = true; | ||
pythonExecutable = pythonForTests.executable; | ||
nativeBuildInputs = [ | ||
finalAttrs.finalPackage | ||
pythonForTests | ||
libxslt | ||
]; | ||
} | ||
'' | ||
"$pythonExecutable" "$src"/xar/test/run-all.py | ||
touch "$out" | ||
''; | ||
|
||
smokeTest = | ||
runCommandCC "xar-tests-smoke-test" | ||
{ | ||
src = patchedSource; | ||
strictDeps = true; | ||
nativeBuildInputs = [ finalAttrs.finalPackage ]; | ||
buildInputs = [ | ||
finalAttrs.finalPackage | ||
openssl | ||
]; | ||
} | ||
'' | ||
cp "$src"/xar/test/{buffer.c,validate.c} . | ||
"$CC" -lxar -o buffer buffer.c | ||
"$CC" -lxar -lcrypto -o validate validate.c | ||
./buffer validate.c | ||
xar -x -f test.xar | ||
diff validate.c mydir/secondfile | ||
./validate test.xar | ||
touch "$out" | ||
''; | ||
}; | ||
|
||
updateScript = nix-update-script { | ||
extraArgs = [ | ||
"--version-regex" | ||
"xar-(.*)" | ||
]; | ||
}; | ||
}; | ||
|
||
meta = { | ||
homepage = "https://github.com/apple-oss-distributions/xar"; | ||
description = "An easily extensible archive format"; | ||
license = lib.licenses.bsd3; | ||
maintainers = | ||
lib.teams.darwin.members | ||
++ lib.attrValues { inherit (lib.maintainers) copumpkin tie; }; | ||
platforms = lib.platforms.unix; | ||
mainProgram = "xar"; | ||
}; | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s common for C headers to be namespaced like this and it’s unfortunately common for random projects to be inconsistent about how they use them. I’m not sure there’s anything to really do here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I believe that in this case it’s actually an issue with Nixpkgs package because it’s namespaced twice, i.e.
include/libxml2/libxml/xmlwriter.h
instead ofinclude/libxml/xmlwriter.h
…The libxml’s project documentation uses
#include <libxml/xmlwriter.h>
in examples as well and that just doesn’t work with C compiler wrapper and hooks in Nixpkgs because of this unnecessary namespacing (stdenv only adds top-levelinclude
directory for each package to the C header search path).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh, yeah, that does indeed sound messed up and we should fix it. Sorry for assuming something more normal was going on here.
I guess this happens to work because most things use
pkg-config
to find the headers?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, though some other packages set
NIX_CFLAGS_COMPILE
as well. E.g.nixpkgs/pkgs/servers/sql/postgresql/generic.nix
Lines 90 to 92 in 2e11a22
Uh, yes, libxml2 also has its own
xml2-config
program that is similar to pkgconf/pkg-config and usually does not work when cross-compiling…I’m not really sure if there is some knob in libxml2 build system to put the headers in
$dev/include
instead of$dev/include/libxml2
, but at the very least it should be possible to just move the headers post install and add a symlink for compatibility.