From 2b356039b21c0b32e3f5d631bec37368f9534c41 Mon Sep 17 00:00:00 2001 From: Matthew Dawson Date: Sun, 2 Oct 2016 15:42:31 -0400 Subject: [PATCH 1/2] Add a --docdir option, defaulting to /share/doc/rust Now any files installed into /share/doc/.*/ will be installed in the path specified by --docdir. This is based on the work by orbea in #49. --- install-template.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/install-template.sh b/install-template.sh index 692a394..868265b 100644 --- a/install-template.sh +++ b/install-template.sh @@ -624,6 +624,12 @@ install_components() { _file_install_path="$CFG_MANDIR/$_f" fi + if echo "$_file" | grep "^share/doc/" > /dev/null + then + local _f="$(echo "$_file" | sed 's/^share\/doc\/[^/]*\///')" + _file_install_path="$CFG_DOCDIR/$_f" + fi + # Make sure there's a directory for it make_dir_recursive "$(dirname "$_file_install_path")" critical_need_ok "directory creation failed" @@ -834,6 +840,7 @@ valopt components "" "comma-separated list of components to install" flag list-components "list available components" valopt libdir "$CFG_DESTDIR_PREFIX/lib" "install libraries" valopt mandir "$CFG_DESTDIR_PREFIX/share/man" "install man pages in PATH" +valopt docdir "$CFG_DESTDIR_PREFIX/share/doc/rust" "install documentation in PATH" opt ldconfig 1 "run ldconfig after installation (Linux only)" opt verify 1 "obsolete" flag verbose "run with verbose output" From b3c7e67fe8ec1fabb1b25e8a089571641b89758b Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 5 Oct 2016 00:10:25 +0000 Subject: [PATCH 2/2] Update --docdir handling and add tests --- install-template.sh | 27 +++++++--- test.sh | 50 +++++++++++++++++++ test/image-docdir1/share/doc/rust/README | 1 + .../image-docdir1/share/doc/rust/rustdocs.txt | 1 + test/image-docdir2/share/doc/cargo/README | 1 + .../share/doc/cargo/cargodocs.txt | 1 + 6 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 test/image-docdir1/share/doc/rust/README create mode 100644 test/image-docdir1/share/doc/rust/rustdocs.txt create mode 100644 test/image-docdir2/share/doc/cargo/README create mode 100644 test/image-docdir2/share/doc/cargo/cargodocs.txt diff --git a/install-template.sh b/install-template.sh index 868265b..dcc1ee0 100644 --- a/install-template.sh +++ b/install-template.sh @@ -624,11 +624,24 @@ install_components() { _file_install_path="$CFG_MANDIR/$_f" fi - if echo "$_file" | grep "^share/doc/" > /dev/null - then - local _f="$(echo "$_file" | sed 's/^share\/doc\/[^/]*\///')" - _file_install_path="$CFG_DOCDIR/$_f" - fi + # HACK: Try to support overriding --docdir. Paths with the form + # "share/doc/$product/" can be redirected to a single --docdir + # path. If the following detects that --docdir has been specified + # then it will replace everything preceeding the "$product" path + # component. The problem here is that the combined rust installer + # contains two "products": rust and cargo; so the contents of those + # directories will both be dumped into the same directory; and the + # contents of those directories are _not_ disjoint. Since this feature + # is almost entirely to support 'make install' anyway I don't expect + # this problem to be a big deal in practice. + if [ "$CFG_DOCDIR" != "" ] + then + if echo "$_file" | grep "^share/doc/" > /dev/null + then + local _f="$(echo "$_file" | sed 's/^share\/doc\/[^/]*\///')" + _file_install_path="$CFG_DOCDIR/$_f" + fi + fi # Make sure there's a directory for it make_dir_recursive "$(dirname "$_file_install_path")" @@ -840,7 +853,9 @@ valopt components "" "comma-separated list of components to install" flag list-components "list available components" valopt libdir "$CFG_DESTDIR_PREFIX/lib" "install libraries" valopt mandir "$CFG_DESTDIR_PREFIX/share/man" "install man pages in PATH" -valopt docdir "$CFG_DESTDIR_PREFIX/share/doc/rust" "install documentation in PATH" +# NB See the docdir handling in install_components for an explanation of this +# weird string +valopt docdir "\" "install documentation in PATH" opt ldconfig 1 "run ldconfig after installation (Linux only)" opt verify 1 "obsolete" flag verbose "run with verbose output" diff --git a/test.sh b/test.sh index bebb69d..d47f50f 100755 --- a/test.sh +++ b/test.sh @@ -1370,6 +1370,56 @@ CDPATH_does_not_destroy_things() { } runtest CDPATH_does_not_destroy_things +docdir_default() { + try sh "$S/gen-installer.sh" \ + --image-dir="$TEST_DIR/image-docdir1" \ + --work-dir="$WORK_DIR" \ + --output-dir="$OUT_DIR" + try "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR" + try test -e "$PREFIX_DIR/share/doc/rust/README" + try test -e "$PREFIX_DIR/share/doc/rust/rustdocs.txt" +} +runtest docdir_default + +docdir() { + try sh "$S/gen-installer.sh" \ + --image-dir="$TEST_DIR/image-docdir1" \ + --work-dir="$WORK_DIR" \ + --output-dir="$OUT_DIR" + try mkdir "$WORK_DIR/docdir" + try "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR" --docdir="$WORK_DIR/docdir" + try test -e "$WORK_DIR/docdir/README" + try test -e "$WORK_DIR/docdir/rustdocs.txt" +} +runtest docdir + +docdir_combined() { + try sh "$S/gen-installer.sh" \ + --image-dir="$TEST_DIR/image-docdir1" \ + --work-dir="$WORK_DIR" \ + --output-dir="$OUT_DIR" \ + --package-name="rustc" \ + --component-name="rustc" + try sh "$S/gen-installer.sh" \ + --image-dir="$TEST_DIR/image-docdir2" \ + --work-dir="$WORK_DIR" \ + --output-dir="$OUT_DIR" \ + --package-name="cargo" \ + --component-name="cargo" + try sh "$S/combine-installers.sh" \ + --work-dir="$WORK_DIR" \ + --output-dir="$OUT_DIR" \ + --package-name=rust \ + --input-tarballs="$OUT_DIR/rustc.tar.gz,$OUT_DIR/cargo.tar.gz" + try mkdir "$WORK_DIR/docdir" + try "$WORK_DIR/rust/install.sh" --prefix="$PREFIX_DIR" --docdir="$WORK_DIR/docdir" + try test -e "$WORK_DIR/docdir/README" + try test -e "$WORK_DIR/docdir/rustdocs.txt" + try test -e "$WORK_DIR/docdir/README" + try test -e "$WORK_DIR/docdir/cargodocs.txt" +} +runtest docdir_combined + echo echo "TOTAL SUCCESS!" echo diff --git a/test/image-docdir1/share/doc/rust/README b/test/image-docdir1/share/doc/rust/README new file mode 100644 index 0000000..871732e --- /dev/null +++ b/test/image-docdir1/share/doc/rust/README @@ -0,0 +1 @@ +rust diff --git a/test/image-docdir1/share/doc/rust/rustdocs.txt b/test/image-docdir1/share/doc/rust/rustdocs.txt new file mode 100644 index 0000000..871732e --- /dev/null +++ b/test/image-docdir1/share/doc/rust/rustdocs.txt @@ -0,0 +1 @@ +rust diff --git a/test/image-docdir2/share/doc/cargo/README b/test/image-docdir2/share/doc/cargo/README new file mode 100644 index 0000000..033a48c --- /dev/null +++ b/test/image-docdir2/share/doc/cargo/README @@ -0,0 +1 @@ +cargo diff --git a/test/image-docdir2/share/doc/cargo/cargodocs.txt b/test/image-docdir2/share/doc/cargo/cargodocs.txt new file mode 100644 index 0000000..033a48c --- /dev/null +++ b/test/image-docdir2/share/doc/cargo/cargodocs.txt @@ -0,0 +1 @@ +cargo