bazel: fix nix-hacks.patch with the latest version of Bazel (#63052)
* bazel: add a failing test for nix-hacks * fix the patch
This commit is contained in:
parent
910b179506
commit
bad7bc44db
|
@ -31,6 +31,7 @@ let
|
|||
|
||||
testBazel = bazelTest {
|
||||
name = "bazel-test-bash-tools";
|
||||
bazelPkg = bazel;
|
||||
inherit workspaceDir;
|
||||
|
||||
bazelScript = ''
|
||||
|
|
|
@ -122,7 +122,7 @@ stdenv.mkDerivation rec {
|
|||
|
||||
# bazel wants to extract itself into $install_dir/install every time it runs,
|
||||
# so let’s do that only once.
|
||||
extracted =
|
||||
extracted = bazelPkg:
|
||||
let install_dir =
|
||||
# `install_base` field printed by `bazel info`, minus the hash.
|
||||
# yes, this path is kinda magic. Sorry.
|
||||
|
@ -130,7 +130,7 @@ stdenv.mkDerivation rec {
|
|||
in runLocal "bazel-extracted-homedir" { passthru.install_dir = install_dir; } ''
|
||||
export HOME=$(mktemp -d)
|
||||
touch WORKSPACE # yeah, everything sucks
|
||||
install_base="$(${bazel}/bin/bazel info | grep install_base)"
|
||||
install_base="$(${bazelPkg}/bin/bazel info | grep install_base)"
|
||||
# assert it’s actually below install_dir
|
||||
[[ "$install_base" =~ ${install_dir} ]] \
|
||||
|| (echo "oh no! $install_base but we are \
|
||||
|
@ -138,21 +138,23 @@ stdenv.mkDerivation rec {
|
|||
cp -R ${install_dir} $out
|
||||
'';
|
||||
|
||||
bazelTest = { name, bazelScript, workspaceDir }:
|
||||
runLocal name {} (
|
||||
bazelTest = { name, bazelScript, workspaceDir, bazelPkg }:
|
||||
let
|
||||
be = extracted bazelPkg;
|
||||
in runLocal name {} (
|
||||
# skip extraction caching on Darwin, because nobody knows how Darwin works
|
||||
(lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
|
||||
# set up home with pre-unpacked bazel
|
||||
export HOME=$(mktemp -d)
|
||||
mkdir -p ${extracted.install_dir}
|
||||
cp -R ${extracted}/install ${extracted.install_dir}
|
||||
mkdir -p ${be.install_dir}
|
||||
cp -R ${be}/install ${be.install_dir}
|
||||
|
||||
# https://stackoverflow.com/questions/47775668/bazel-how-to-skip-corrupt-installation-on-centos6
|
||||
# Bazel checks whether the mtime of the install dir files
|
||||
# is >9 years in the future, otherwise it extracts itself again.
|
||||
# see PosixFileMTime::IsUntampered in src/main/cpp/util
|
||||
# What the hell bazel.
|
||||
${lr}/bin/lr -0 -U ${extracted.install_dir} | ${xe}/bin/xe -N0 -0 touch --date="9 years 6 months" {}
|
||||
${lr}/bin/lr -0 -U ${be.install_dir} | ${xe}/bin/xe -N0 -0 touch --date="9 years 6 months" {}
|
||||
'')
|
||||
+
|
||||
''
|
||||
|
@ -165,9 +167,13 @@ stdenv.mkDerivation rec {
|
|||
touch $out
|
||||
'');
|
||||
|
||||
bazelWithNixHacks = bazel.override { enableNixHacks = true; };
|
||||
in {
|
||||
pythonBinPath = callPackage ./python-bin-path-test.nix{ inherit runLocal bazelTest; };
|
||||
bashTools = callPackage ./bash-tools-test.nix { inherit runLocal bazelTest; };
|
||||
pythonBinPathWithoutNixHacks = callPackage ./python-bin-path-test.nix{ inherit runLocal bazelTest; };
|
||||
bashToolsWithoutNixHacks = callPackage ./bash-tools-test.nix { inherit runLocal bazelTest; };
|
||||
|
||||
pythonBinPathWithNixHacks = callPackage ./python-bin-path-test.nix{ inherit runLocal bazelTest; bazel = bazelWithNixHacks; };
|
||||
bashToolsWithNixHacks = callPackage ./bash-tools-test.nix { inherit runLocal bazelTest; bazel = bazelWithNixHacks; };
|
||||
};
|
||||
|
||||
name = "bazel-${version}";
|
||||
|
|
|
@ -1,33 +1,35 @@
|
|||
diff -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
|
||||
--- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java 1980-01-01 00:00:00.000000000 -0500
|
||||
+++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java 2018-01-18 08:17:22.420459162 -0500
|
||||
@@ -287,21 +287,8 @@
|
||||
markerData.put(key, value);
|
||||
}
|
||||
}
|
||||
- boolean result = false;
|
||||
- if (markerRuleKey.equals(ruleKey)) {
|
||||
- result = handler.verifyMarkerData(rule, markerData, env);
|
||||
- if (env.valuesMissing()) {
|
||||
--- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java 2019-06-12 20:39:37.420705161 -0700
|
||||
+++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java 2019-06-12 20:44:18.894429744 -0700
|
||||
@@ -428,24 +428,7 @@
|
||||
try {
|
||||
content = FileSystemUtils.readContent(markerPath, StandardCharsets.UTF_8);
|
||||
String markerRuleKey = readMarkerFile(content, markerData);
|
||||
- boolean verified = false;
|
||||
- if (Preconditions.checkNotNull(ruleKey).equals(markerRuleKey)
|
||||
- && Objects.equals(
|
||||
- markerData.get(MANAGED_DIRECTORIES_MARKER),
|
||||
- this.markerData.get(MANAGED_DIRECTORIES_MARKER))) {
|
||||
- verified = handler.verifyMarkerData(rule, markerData, env);
|
||||
- if (env.valuesMissing()) {
|
||||
- return null;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- if (verified) {
|
||||
return new Fingerprint().addString(content).digestAndReset();
|
||||
- } else {
|
||||
- // So that we are in a consistent state if something happens while fetching the repository
|
||||
- markerPath.delete();
|
||||
- return null;
|
||||
- }
|
||||
- }
|
||||
|
||||
- if (result) {
|
||||
- return new Fingerprint().addString(content).digestAndReset();
|
||||
- } else {
|
||||
- // So that we are in a consistent state if something happens while fetching the repository
|
||||
- markerPath.delete();
|
||||
- return null;
|
||||
- }
|
||||
+ return new Fingerprint().addString(content).digestAndReset();
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RepositoryFunctionException(e, Transience.TRANSIENT);
|
||||
} catch (IOException e) {
|
||||
throw new RepositoryFunctionException(e, Transience.TRANSIENT);
|
||||
}
|
||||
diff -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
|
||||
--- a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java 1980-01-01 00:00:00.000000000 -0500
|
||||
+++ b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java 2018-01-18 08:17:53.274877980 -0500
|
||||
@@ -129,7 +129,6 @@
|
||||
--- a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java 2019-06-12 20:39:37.538708196 -0700
|
||||
+++ b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java 2019-06-12 20:44:18.863429602 -0700
|
||||
@@ -146,7 +146,6 @@
|
||||
ProcessBuilder builder = new ProcessBuilder();
|
||||
builder.command(params.getArgv());
|
||||
if (params.getEnv() != null) {
|
||||
|
|
|
@ -41,6 +41,7 @@ let
|
|||
testBazel = bazelTest {
|
||||
name = "bazel-test-builtin-rules";
|
||||
inherit workspaceDir;
|
||||
bazelPkg = bazel;
|
||||
bazelScript = ''
|
||||
${bazel}/bin/bazel \
|
||||
run \
|
||||
|
|
Loading…
Reference in New Issue