]> git.proxmox.com Git - rustc.git/commitdiff
update mdbook & linkchecker patches
authorXimin Luo <infinity0@debian.org>
Fri, 16 Apr 2021 04:54:28 +0000 (05:54 +0100)
committerXimin Luo <infinity0@debian.org>
Fri, 16 Apr 2021 04:54:28 +0000 (05:54 +0100)
debian/patches/d-0000-ignore-removed-submodules.patch
debian/patches/d-0003-mdbook-strip-embedded-libs.patch
debian/patches/d-cargo-doc-paths.patch [new file with mode: 0644]
debian/patches/series
debian/rust-doc.links [deleted file]

index 4d8d842c3d6eb71e8b3d9f7f43dc8d8996a1afa8..ffabf7fda22dc4dc42d3a917605da6c4f51e0849 100644 (file)
@@ -128,19 +128,6 @@ Index: rustc.git/src/bootstrap/doc.rs
      EditionGuide, "src/doc/edition-guide", "edition-guide";
      EmbeddedBook, "src/doc/embedded-book", "embedded-book";
      Nomicon, "src/doc/nomicon", "nomicon";
-Index: rustc.git/src/doc/index.md
-===================================================================
---- rustc.git.orig/src/doc/index.md
-+++ rustc.git/src/doc/index.md
-@@ -87,7 +87,7 @@ accomplishing various tasks.
- ## The Cargo Book
--[The Cargo Book](cargo/index.html) is a guide to Cargo, Rust's build tool and dependency manager.
-+[The Cargo Book](../../cargo-doc/doc/index.html) is a guide to Cargo, Rust's build tool and dependency manager.
- ## The Rustdoc Book
 Index: rustc.git/src/bootstrap/test.rs
 ===================================================================
 --- rustc.git.orig/src/bootstrap/test.rs
index 820a75626293a989edbeb4a1a500ad08e2673dcc..c50e113cfa980e3e9b4bd3e52aa63f47231a6ff9 100644 (file)
@@ -9,27 +9,27 @@ Comment:
  Make sure the paths here match the ones in debian/rust-doc.links
 ---
 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
-Index: rustc.git/src/tools/linkchecker/main.rs
-===================================================================
---- rustc.git.orig/src/tools/linkchecker/main.rs
-+++ rustc.git/src/tools/linkchecker/main.rs
-@@ -172,6 +172,11 @@ fn check(cache: &mut Cache, root: &Path,
-         {
-             return;
-         }
-+        // Ignore parent URLs, so that the package installation process can
-+        // provide a symbolic link later
-+        if url.starts_with("../") {
-+            return;
-+        }
-         let (url, fragment) = match url.split_once('#') {
-             None => (url, None),
-             Some((url, fragment)) => (url, Some(fragment)),
-Index: rustc.git/vendor/mdbook/src/theme/index.hbs
-===================================================================
---- rustc.git.orig/vendor/mdbook/src/theme/index.hbs
-+++ rustc.git/vendor/mdbook/src/theme/index.hbs
-@@ -32,13 +32,10 @@
+--- a/src/tools/linkchecker/main.rs
++++ b/src/tools/linkchecker/main.rs
+@@ -321,6 +321,15 @@
+                     println!("`#{}` pointing to `{}`", fragment, pretty_path.display());
+                 };
+             }
++        } else if fs::symlink_metadata(&path).is_ok() {
++            let target = fs::read_link(&path).unwrap();
++            if target.starts_with("/usr/share") {
++                // broken symlink to /usr/share, ok for our Debian build
++                return;
++            }
++            *errors = true;
++            print!("{}:{}: broken link - ", path.display(), i + 1);
++            println!("{}", path.display());
+         } else {
+             let pretty_path = path.strip_prefix(root).unwrap_or(&path);
+             if !is_exception(file, pretty_path.to_str().unwrap()) {
+--- a/vendor/mdbook/src/theme/index.hbs
++++ b/vendor/mdbook/src/theme/index.hbs
+@@ -34,10 +34,7 @@
          {{/if}}
  
          <!-- Fonts -->
@@ -37,24 +37,20 @@ Index: rustc.git/vendor/mdbook/src/theme/index.hbs
 -        {{#if copy_fonts}}
 -        <link rel="stylesheet" href="{{ path_to_root }}fonts/fonts.css">
 -        {{/if}}
-+        <link rel="stylesheet" href="{{ path_to_root }}../font-awesome.min.css">
++        <link rel="stylesheet" href="{{ path_to_root }}css/font-awesome.min.css">
  
          <!-- Highlight.js Stylesheets -->
--        <link rel="stylesheet" href="{{ path_to_root }}highlight.css">
-+        <link rel="stylesheet" href="{{ path_to_root }}../highlight.css">
-         <link rel="stylesheet" href="{{ path_to_root }}tomorrow-night.css">
-         <link rel="stylesheet" href="{{ path_to_root }}ayu-highlight.css">
-@@ -49,7 +46,7 @@
+         <link rel="stylesheet" href="{{ path_to_root }}highlight.css">
+@@ -51,7 +48,7 @@
  
          {{#if mathjax_support}}
          <!-- MathJax -->
 -        <script async type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
-+        <script async type="text/javascript" src="../mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
++        <script async type="text/javascript" src="MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
          {{/if}}
      </head>
      <body>
-@@ -59,46 +56,6 @@
+@@ -61,46 +58,6 @@
              var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "{{ preferred_dark_theme }}" : "{{ default_theme }}";
          </script>
  
@@ -101,7 +97,7 @@ Index: rustc.git/vendor/mdbook/src/theme/index.hbs
          <nav id="sidebar" class="sidebar" aria-label="Table of contents">
              <div class="sidebar-scrollbox">
                  {{#toc}}{{/toc}}
-@@ -226,53 +183,7 @@
+@@ -230,52 +187,6 @@
          </script>
          {{/if}}
  
@@ -151,16 +147,12 @@ Index: rustc.git/vendor/mdbook/src/theme/index.hbs
 -        {{/if}}
 -
 -        <script src="{{ path_to_root }}clipboard.min.js" type="text/javascript" charset="utf-8"></script>
--        <script src="{{ path_to_root }}highlight.js" type="text/javascript" charset="utf-8"></script>
-+        <script src="{{ path_to_root }}../highlight.js" type="text/javascript" charset="utf-8"></script>
+         <script src="{{ path_to_root }}highlight.js" type="text/javascript" charset="utf-8"></script>
          <script src="{{ path_to_root }}book.js" type="text/javascript" charset="utf-8"></script>
  
-         <!-- Custom JS scripts -->
-Index: rustc.git/vendor/mdbook/src/book/init.rs
-===================================================================
---- rustc.git.orig/vendor/mdbook/src/book/init.rs
-+++ rustc.git/vendor/mdbook/src/book/init.rs
-@@ -151,12 +151,6 @@ impl BookBuilder {
+--- a/vendor/mdbook/src/book/init.rs
++++ b/vendor/mdbook/src/book/init.rs
+@@ -151,12 +151,6 @@
          let mut js = File::create(themedir.join("book.js"))?;
          js.write_all(theme::JS)?;
  
@@ -173,11 +165,9 @@ Index: rustc.git/vendor/mdbook/src/book/init.rs
          Ok(())
      }
  
-Index: rustc.git/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs
-===================================================================
---- rustc.git.orig/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs
-+++ rustc.git/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs
-@@ -3,7 +3,7 @@ use crate::config::{Config, HtmlConfig,
+--- a/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs
++++ b/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs
+@@ -3,7 +3,7 @@
  use crate::errors::*;
  use crate::renderer::html_handlebars::helpers;
  use crate::renderer::{RenderContext, Renderer};
@@ -186,7 +176,15 @@ Index: rustc.git/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs
  use crate::utils;
  
  use std::borrow::Cow;
-@@ -198,80 +198,8 @@ impl HtmlHandlebars {
+@@ -11,6 +11,7 @@
+ use std::collections::HashMap;
+ use std::fs::{self, File};
+ use std::path::{Path, PathBuf};
++use std::os::unix::fs::symlink;
+ use crate::utils::fs::get_404_output_file;
+ use handlebars::Handlebars;
+@@ -204,80 +205,13 @@
          if let Some(contents) = &theme.favicon_svg {
              write_file(destination, "favicon.svg", &contents)?;
          }
@@ -264,14 +262,17 @@ Index: rustc.git/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs
 -                playground_editor::THEME_TOMORROW_NIGHT_JS,
 -            )?;
 -        }
++        symlink("/usr/share/fonts-font-awesome/css/font-awesome.min.css", destination.join("css/font-awesome.min.css"))?;
++        symlink("/usr/share/fonts-font-awesome/fonts", destination.join("fonts"))?;
++        symlink("/usr/share/javascript/highlight.js/styles/atelier-dune-light.css", destination.join("highlight.css"))?;
++        symlink("/usr/share/javascript/highlight.js/highlight.js", destination.join("highlight.js"))?;
++        symlink("/usr/share/javascript/mathjax/MathJax.js", destination.join("MathJax.js"))?;
  
          Ok(())
      }
-Index: rustc.git/vendor/mdbook/src/renderer/html_handlebars/search.rs
-===================================================================
---- rustc.git.orig/vendor/mdbook/src/renderer/html_handlebars/search.rs
-+++ rustc.git/vendor/mdbook/src/renderer/html_handlebars/search.rs
-@@ -34,8 +34,6 @@ pub fn create_files(search_config: &Sear
+--- a/vendor/mdbook/src/renderer/html_handlebars/search.rs
++++ b/vendor/mdbook/src/renderer/html_handlebars/search.rs
+@@ -34,8 +34,6 @@
              format!("Object.assign(window.search, {});", index).as_bytes(),
          )?;
          utils::fs::write_file(destination, "searcher.js", searcher::JS)?;
@@ -280,10 +281,8 @@ Index: rustc.git/vendor/mdbook/src/renderer/html_handlebars/search.rs
          debug!("Copying search files ✓");
      }
  
-Index: rustc.git/vendor/mdbook/src/theme/mod.rs
-===================================================================
---- rustc.git.orig/vendor/mdbook/src/theme/mod.rs
-+++ rustc.git/vendor/mdbook/src/theme/mod.rs
+--- a/vendor/mdbook/src/theme/mod.rs
++++ b/vendor/mdbook/src/theme/mod.rs
 @@ -1,9 +1,5 @@
  #![allow(missing_docs)]
  
@@ -294,7 +293,7 @@ Index: rustc.git/vendor/mdbook/src/theme/mod.rs
  #[cfg(feature = "search")]
  pub mod searcher;
  
-@@ -24,19 +20,8 @@ pub static VARIABLES_CSS: &[u8] = includ
+@@ -24,19 +20,8 @@
  pub static FAVICON_PNG: &[u8] = include_bytes!("favicon.png");
  pub static FAVICON_SVG: &[u8] = include_bytes!("favicon.svg");
  pub static JS: &[u8] = include_bytes!("book.js");
@@ -314,7 +313,7 @@ Index: rustc.git/vendor/mdbook/src/theme/mod.rs
  
  /// The `Theme` struct should be used instead of the static variables because
  /// the `new()` method will look if the user has a theme directory in their
-@@ -57,11 +42,8 @@ pub struct Theme {
+@@ -57,11 +42,8 @@
      pub favicon_png: Option<Vec<u8>>,
      pub favicon_svg: Option<Vec<u8>>,
      pub js: Vec<u8>,
@@ -326,7 +325,7 @@ Index: rustc.git/vendor/mdbook/src/theme/mod.rs
  }
  
  impl Theme {
-@@ -91,9 +73,6 @@ impl Theme {
+@@ -91,9 +73,6 @@
                      theme_dir.join("css/variables.css"),
                      &mut theme.variables_css,
                  ),
@@ -336,7 +335,7 @@ Index: rustc.git/vendor/mdbook/src/theme/mod.rs
                  (
                      theme_dir.join("tomorrow-night.css"),
                      &mut theme.tomorrow_night_css,
-@@ -156,11 +135,8 @@ impl Default for Theme {
+@@ -156,11 +135,8 @@
              favicon_png: Some(FAVICON_PNG.to_owned()),
              favicon_svg: Some(FAVICON_SVG.to_owned()),
              js: JS.to_owned(),
@@ -348,7 +347,7 @@ Index: rustc.git/vendor/mdbook/src/theme/mod.rs
          }
      }
  }
-@@ -243,11 +219,8 @@ mod tests {
+@@ -243,11 +219,8 @@
              favicon_png: Some(Vec::new()),
              favicon_svg: Some(Vec::new()),
              js: Vec::new(),
@@ -360,10 +359,8 @@ Index: rustc.git/vendor/mdbook/src/theme/mod.rs
          };
  
          assert_eq!(got, empty);
-Index: rustc.git/vendor/mdbook/src/theme/searcher/mod.rs
-===================================================================
---- rustc.git.orig/vendor/mdbook/src/theme/searcher/mod.rs
-+++ rustc.git/vendor/mdbook/src/theme/searcher/mod.rs
+--- a/vendor/mdbook/src/theme/searcher/mod.rs
++++ b/vendor/mdbook/src/theme/searcher/mod.rs
 @@ -2,5 +2,3 @@
  //! the "search" cargo feature is disabled.
  
diff --git a/debian/patches/d-cargo-doc-paths.patch b/debian/patches/d-cargo-doc-paths.patch
new file mode 100644 (file)
index 0000000..43317dd
--- /dev/null
@@ -0,0 +1,118 @@
+Description: Fix links to cargo-doc
+ We package cargo docs in a slightly different location; also tweak linkchecker
+ to not fail these links.
+
+--- a/src/tools/linkchecker/main.rs
++++ b/src/tools/linkchecker/main.rs
+@@ -19,6 +19,7 @@
+ use std::collections::hash_map::Entry;
+ use std::collections::{HashMap, HashSet};
+ use std::env;
++use std::ffi::OsStr;
+ use std::fs;
+ use std::path::{Component, Path, PathBuf};
+ use std::rc::Rc;
+@@ -331,7 +332,15 @@
+             print!("{}:{}: broken link - ", path.display(), i + 1);
+             println!("{}", path.display());
+         } else {
+-            let pretty_path = path.strip_prefix(root).unwrap_or(&path);
++            let pretty_path = match path.strip_prefix(root) {
++                Ok(suf) => suf,
++                Err(_) => if path.components().any(|x| x == Component::Normal(OsStr::new("cargo-doc"))) {
++                    // link to cargo-doc, ok for our Debian build
++                    return;
++                } else {
++                    &path
++                }
++            };
+             if !is_exception(file, pretty_path.to_str().unwrap()) {
+                 *errors = true;
+                 print!("{}:{}: broken link - ", pretty_file.display(), i + 1);
+--- a/src/doc/index.md
++++ b/src/doc/index.md
+@@ -87,7 +87,7 @@
+ ## The Cargo Book
+-[The Cargo Book](cargo/index.html) is a guide to Cargo, Rust's build tool and dependency manager.
++[The Cargo Book](../../cargo-doc/doc/index.html) is a guide to Cargo, Rust's build tool and dependency manager.
+ ## The Rustdoc Book
+--- a/src/doc/reference/src/conditional-compilation.md
++++ b/src/doc/reference/src/conditional-compilation.md
+@@ -332,6 +332,6 @@
+ [`target_feature` attribute]: attributes/codegen.md#the-target_feature-attribute
+ [attribute]: attributes.md
+ [attributes]: attributes.md
+-[cargo-feature]: ../cargo/reference/features.html
++[cargo-feature]: ../../cargo-doc/doc/reference/features.html
+ [crate type]: linkage.md
+ [static C runtime]: linkage.md#static-and-dynamic-c-runtimes
+--- a/src/doc/reference/src/introduction.md
++++ b/src/doc/reference/src/introduction.md
+@@ -133,8 +133,8 @@
+ [the Rust Reference repository]: https://github.com/rust-lang/reference/
+ [Unstable Book]: https://doc.rust-lang.org/nightly/unstable-book/
+ [_Expression_]: expressions.md
+-[cargo book]: ../cargo/index.html
+-[cargo reference]: ../cargo/reference/index.html
++[cargo book]: ../../cargo-doc/doc/index.html
++[cargo reference]: ../../cargo-doc/doc/reference/index.html
+ [expressions chapter]: expressions.html
+ [file an issue]: https://github.com/rust-lang/reference/issues
+ [lifetime of temporaries]: expressions.html#temporaries
+--- a/src/doc/reference/src/linkage.md
++++ b/src/doc/reference/src/linkage.md
+@@ -200,7 +200,7 @@
+ }
+ ```
+-[cargo]: ../cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts
++[cargo]: ../../cargo-doc/doc/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts
+ To use this feature locally, you typically will use the `RUSTFLAGS` environment
+ variable to specify flags to the compiler through Cargo. For example to compile
+--- a/src/doc/reference/src/procedural-macros.md
++++ b/src/doc/reference/src/procedural-macros.md
+@@ -272,7 +272,7 @@
+ ```
+ [Attribute macros]: #attribute-macros
+-[Cargo's build scripts]: ../cargo/reference/build-scripts.html
++[Cargo's build scripts]: ../../cargo-doc/doc/reference/build-scripts.html
+ [Derive macros]: #derive-macros
+ [Function-like macros]: #function-like-procedural-macros
+ [`TokenStream`]: ../proc_macro/struct.TokenStream.html
+--- a/src/doc/rustc/src/tests/index.md
++++ b/src/doc/rustc/src/tests/index.md
+@@ -266,7 +266,7 @@
+ [`--test` option]: ../command-line-arguments.md#option-test
+ [`-Z panic-abort-tests`]: https://github.com/rust-lang/rust/issues/67650
+ [`available_concurrency`]: ../../std/thread/fn.available_concurrency.html
+-[`cargo test`]: ../../cargo/commands/cargo-test.html
++[`cargo test`]: ../../../cargo-doc/doc/commands/cargo-test.html
+ [`libtest`]: ../../test/index.html
+ [`main` function]: ../../reference/crates-and-source-files.html#main-functions
+ [`Result`]: ../../std/result/index.html
+@@ -275,7 +275,7 @@
+ [attribute-should_panic]: ../../reference/attributes/testing.html#the-should_panic-attribute
+ [attribute-test]: ../../reference/attributes/testing.html#the-test-attribute
+ [bench-docs]: ../../unstable-book/library-features/test.html
+-[Cargo]: ../../cargo/index.html
++[Cargo]: ../../../cargo-doc/doc/index.html
+ [crate type]: ../../reference/linkage.html
+ [custom_test_frameworks documentation]: ../../unstable-book/language-features/custom-test-frameworks.html
+ [nightly channel]: ../../book/appendix-07-nightly-rust.html
+--- a/src/doc/rustc/src/what-is-rustc.md
++++ b/src/doc/rustc/src/what-is-rustc.md
+@@ -5,7 +5,7 @@
+ produce binary code, either as a library or executable.
+ Most Rust programmers don't invoke `rustc` directly, but instead do it through
+-[Cargo](../cargo/index.html). It's all in service of `rustc` though! If you
++[Cargo](../../cargo-doc/doc/index.html). It's all in service of `rustc` though! If you
+ want to see how Cargo calls `rustc`, you can
+ ```bash
index 891210d88cec8d0d42afb66f592edaeee6501fe6..1ccb6388a4e95a83a0e08e3d4f7964358be2cec5 100644 (file)
@@ -23,6 +23,7 @@ d-0002-pkg-config-no-special-snowflake.patch
 d-0003-mdbook-strip-embedded-libs.patch
 # Other patches needed by the full Debian build
 #d-use-system-compiler-rt.patch
+d-cargo-doc-paths.patch
 d-0004-cc-psm-rebuild-wasm32.patch
 d-custom-debuginfo-path.patch
 d-disable-cargo-vendor.patch
diff --git a/debian/rust-doc.links b/debian/rust-doc.links
deleted file mode 100644 (file)
index 499b8b6..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-# This should eventually become part of a dh_rustdoc program.
-# Something that does e.g.
-# find $(DESTDIR) -name jquery.js -execdir ln -sf -T \
-#        /usr/share/doc/rust-doc/html/jquery.js '{}' \;
-usr/share/javascript/jquery/jquery.min.js                             usr/share/doc/rust-doc/html/jquery.min.js
-usr/share/javascript/mathjax                                          usr/share/doc/rust-doc/html/mathjax
-usr/share/javascript/highlight.js/styles/atelier-dune-light.css       usr/share/doc/rust-doc/html/highlight.css
-usr/share/javascript/highlight.js/highlight.js                        usr/share/doc/rust-doc/html/highlight.js
-usr/share/fonts-font-awesome/css/font-awesome.min.css                 usr/share/doc/rust-doc/html/font-awesome.min.css
-usr/share/fonts-font-awesome/fonts                                    usr/share/doc/rust-doc/fonts