nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 61 lines 2.1 kB view raw
1{ 2 lib, 3 stdenv, 4 go, 5 buildGoModule, 6 # A package that relies on CGO 7 skopeo, 8 testers, 9 runCommand, 10 bintools, 11 # A package with CGO_ENABLED=0 12 athens, 13}: 14let 15 skopeo' = skopeo.override { buildGoModule = buildGoModule; }; 16 athens' = athens.override { buildGoModule = buildGoModule; }; 17 expectedCgoEnabledType = "DYN"; 18 expectedCgoDisabledType = "EXE"; 19in 20{ 21 skopeo = testers.testVersion { package = skopeo'; }; 22 version = testers.testVersion { 23 package = go; 24 command = "go version"; 25 version = "go${go.version}"; 26 }; 27 athens = testers.testVersion { package = athens'; }; 28} 29# bin type tests assume ELF file + linux-specific exe types 30// lib.optionalAttrs stdenv.hostPlatform.isLinux { 31 skopeo-bin-type = runCommand "skopeo-bin-type" { meta.broken = stdenv.hostPlatform.isStatic; } '' 32 bin="${lib.getExe' skopeo' ".skopeo-wrapped"}" 33 if ! ${lib.getExe' bintools "readelf"} -p .comment $bin | grep -Fq "GCC: (GNU)"; then 34 echo "${lib.getExe skopeo} should have been externally linked, but no GNU .comment section found" 35 exit 1 36 fi 37 if ${lib.getExe' bintools "readelf"} -h $bin | grep -q "Type:.*${expectedCgoEnabledType}"; then 38 touch $out 39 else 40 echo "ERROR: $bin is NOT ${expectedCgoEnabledType}" 41 exit 1 42 fi 43 ''; 44 athens-bin-type = runCommand "athens-bin-type" { meta.broken = stdenv.hostPlatform.isStatic; } '' 45 bin="${lib.getExe athens'}" 46 ${lib.optionalString (stdenv.buildPlatform == stdenv.targetPlatform) '' 47 # For CGO_ENABLED=0 the internal linker should be used, except 48 # for cross where we rely on external linking by default 49 if ${lib.getExe' bintools "readelf"} -p .comment ${lib.getExe athens'} | grep -Fq "GCC: (GNU)"; then 50 echo "${lib.getExe athens'} has a GCC .comment, but it should have used the internal go linker" 51 exit 1 52 fi 53 ''} 54 if ${lib.getExe' bintools "readelf"} -h "$bin" | grep -q "Type:.*${expectedCgoDisabledType}"; then 55 touch $out 56 else 57 echo "ERROR: $bin is NOT ${expectedCgoDisabledType}" 58 exit 1 59 fi 60 ''; 61}