diff --git a/install-template.sh b/install-template.sh index 692a394..dcc1ee0 100644 --- a/install-template.sh +++ b/install-template.sh @@ -624,6 +624,25 @@ install_components() { _file_install_path="$CFG_MANDIR/$_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")" critical_need_ok "directory creation failed" @@ -834,6 +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" +# 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