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