git.iko.soy/typeable/nixpkgs
on master help sign in
bazel: fix nix-hacks.patch with the latest version of Bazel (#63052)

* bazel: add a failing test for nix-hacks * fix the patch

commitbad7bc44db55912ca27a62362ed71f4dd6721f9c authorWael Nasreddine <wael.nasreddine@gmail.com> dateThu 13 Jun 2019, 07:12 (7 years ago) parent910b179
4 files changed+45−35
pkgs/development/tools/build-managers/bazel/bash-tools-test.nix+1 pkgs/development/tools/build-managers/bazel/default.nix+15−9 pkgs/development/tools/build-managers/bazel/nix-hacks.patch+28−26 pkgs/development/tools/build-managers/bazel/python-bin-path-test.nix+1
pkgs/development/tools/build-managers/bazel/bash-tools-test.nix+1
@@ -31,6 +31,7 @@ let
3131
3232 testBazel = bazelTest {
3333 name = "bazel-test-bash-tools";
34+ bazelPkg = bazel;
3435 inherit workspaceDir;
3536
3637 bazelScript = ''
pkgs/development/tools/build-managers/bazel/default.nix+15−9
@@ -122,7 +122,7 @@ stdenv.mkDerivation rec {
122122
123123 # bazel wants to extract itself into $install_dir/install every time it runs,
124124 # so let’s do that only once.
125− extracted =
125+ extracted = bazelPkg:
126126 let install_dir =
127127 # `install_base` field printed by `bazel info`, minus the hash.
128128 # yes, this path is kinda magic. Sorry.
@@ -130,7 +130,7 @@ stdenv.mkDerivation rec {
130130 in runLocal "bazel-extracted-homedir" { passthru.install_dir = install_dir; } ''
131131 export HOME=$(mktemp -d)
132132 touch WORKSPACE # yeah, everything sucks
133− install_base="$(${bazel}/bin/bazel info | grep install_base)"
133+ install_base="$(${bazelPkg}/bin/bazel info | grep install_base)"
134134 # assert it’s actually below install_dir
135135 [[ "$install_base" =~ ${install_dir} ]] \
136136 || (echo "oh no! $install_base but we are \
@@ -138,21 +138,23 @@ stdenv.mkDerivation rec {
138138 cp -R ${install_dir} $out
139139 '';
140140
141− bazelTest = { name, bazelScript, workspaceDir }:
142− runLocal name {} (
141+ bazelTest = { name, bazelScript, workspaceDir, bazelPkg }:
142+ let
143+ be = extracted bazelPkg;
144+ in runLocal name {} (
143145 # skip extraction caching on Darwin, because nobody knows how Darwin works
144146 (lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
145147 # set up home with pre-unpacked bazel
146148 export HOME=$(mktemp -d)
147− mkdir -p ${extracted.install_dir}
148− cp -R ${extracted}/install ${extracted.install_dir}
149+ mkdir -p ${be.install_dir}
150+ cp -R ${be}/install ${be.install_dir}
149151
150152 # https://stackoverflow.com/questions/47775668/bazel-how-to-skip-corrupt-installation-on-centos6
151153 # Bazel checks whether the mtime of the install dir files
152154 # is >9 years in the future, otherwise it extracts itself again.
153155 # see PosixFileMTime::IsUntampered in src/main/cpp/util
154156 # What the hell bazel.
155− ${lr}/bin/lr -0 -U ${extracted.install_dir} | ${xe}/bin/xe -N0 -0 touch --date="9 years 6 months" {}
157+ ${lr}/bin/lr -0 -U ${be.install_dir} | ${xe}/bin/xe -N0 -0 touch --date="9 years 6 months" {}
156158 '')
157159 +
158160 ''
@@ -165,9 +167,13 @@ stdenv.mkDerivation rec {
165167 touch $out
166168 '');
167169
170+ bazelWithNixHacks = bazel.override { enableNixHacks = true; };
168171 in {
169− pythonBinPath = callPackage ./python-bin-path-test.nix{ inherit runLocal bazelTest; };
170− bashTools = callPackage ./bash-tools-test.nix { inherit runLocal bazelTest; };
172+ pythonBinPathWithoutNixHacks = callPackage ./python-bin-path-test.nix{ inherit runLocal bazelTest; };
173+ bashToolsWithoutNixHacks = callPackage ./bash-tools-test.nix { inherit runLocal bazelTest; };
174+
175+ pythonBinPathWithNixHacks = callPackage ./python-bin-path-test.nix{ inherit runLocal bazelTest; bazel = bazelWithNixHacks; };
176+ bashToolsWithNixHacks = callPackage ./bash-tools-test.nix { inherit runLocal bazelTest; bazel = bazelWithNixHacks; };
171177 };
172178
173179 name = "bazel-${version}";
pkgs/development/tools/build-managers/bazel/nix-hacks.patch+28−26
@@ -1,33 +1,35 @@
11diff -Naur a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java
2−--- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java 1980-01-01 00:00:00.000000000 -0500
3−+++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java 2018-01-18 08:17:22.420459162 -0500
4−@@ -287,21 +287,8 @@
5− markerData.put(key, value);
6− }
7− }
8−- boolean result = false;
9−- if (markerRuleKey.equals(ruleKey)) {
10−- result = handler.verifyMarkerData(rule, markerData, env);
11−- if (env.valuesMissing()) {
2+--- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java 2019-06-12 20:39:37.420705161 -0700
3++++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java 2019-06-12 20:44:18.894429744 -0700
4+@@ -428,24 +428,7 @@
5+ try {
6+ content = FileSystemUtils.readContent(markerPath, StandardCharsets.UTF_8);
7+ String markerRuleKey = readMarkerFile(content, markerData);
8+- boolean verified = false;
9+- if (Preconditions.checkNotNull(ruleKey).equals(markerRuleKey)
10+- && Objects.equals(
11+- markerData.get(MANAGED_DIRECTORIES_MARKER),
12+- this.markerData.get(MANAGED_DIRECTORIES_MARKER))) {
13+- verified = handler.verifyMarkerData(rule, markerData, env);
14+- if (env.valuesMissing()) {
15+- return null;
16+- }
17+- }
18+-
19+- if (verified) {
20+ return new Fingerprint().addString(content).digestAndReset();
21+- } else {
22+- // So that we are in a consistent state if something happens while fetching the repository
23+- markerPath.delete();
1224- return null;
1325- }
14−- }
15−
16−- if (result) {
17−- return new Fingerprint().addString(content).digestAndReset();
18−- } else {
19−- // So that we are in a consistent state if something happens while fetching the repository
20−- markerPath.delete();
21−- return null;
22−- }
23−+ return new Fingerprint().addString(content).digestAndReset();
24−
25− } catch (IOException e) {
26− throw new RepositoryFunctionException(e, Transience.TRANSIENT);
26+ } catch (IOException e) {
27+ throw new RepositoryFunctionException(e, Transience.TRANSIENT);
28+ }
2729diff -Naur a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
28−--- a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java 1980-01-01 00:00:00.000000000 -0500
29−+++ b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java 2018-01-18 08:17:53.274877980 -0500
30−@@ -129,7 +129,6 @@
30+--- a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java 2019-06-12 20:39:37.538708196 -0700
31++++ b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java 2019-06-12 20:44:18.863429602 -0700
32+@@ -146,7 +146,6 @@
3133 ProcessBuilder builder = new ProcessBuilder();
3234 builder.command(params.getArgv());
3335 if (params.getEnv() != null) {
pkgs/development/tools/build-managers/bazel/python-bin-path-test.nix+1
@@ -41,6 +41,7 @@ let
4141 testBazel = bazelTest {
4242 name = "bazel-test-builtin-rules";
4343 inherit workspaceDir;
44+ bazelPkg = bazel;
4445 bazelScript = ''
4546 ${bazel}/bin/bazel \
4647 run \