diff --git a/src/mandb.c b/src/mandb.c index 86b9e97..15f28fa 100644 --- a/src/mandb.c +++ b/src/mandb.c @@ -429,23 +429,25 @@ static int mandb (const char *catpath, const char *manpath) if (!quiet) printf (_("Processing manual pages under %s...\n"), manpath); - cachedir_tag = xasprintf ("%s/CACHEDIR.TAG", catpath); - if (stat (cachedir_tag, &st) == -1 && errno == ENOENT) { - FILE *cachedir_tag_file; - - cachedir_tag_file = fopen (cachedir_tag, "w"); - if (cachedir_tag_file) { - fputs ("Signature: 8a477f597d28d172789f06886806bc55\n" - "# This file is a cache directory tag created " - "by man-db.\n" - "# For information about cache directory tags, " - "see:\n" - "#\thttp://www.brynosaurus.com/cachedir/\n", - cachedir_tag_file); - fclose (cachedir_tag_file); + if (!STREQ (catpath, manpath)) { + cachedir_tag = xasprintf ("%s/CACHEDIR.TAG", catpath); + if (stat (cachedir_tag, &st) == -1 && errno == ENOENT) { + FILE *cachedir_tag_file; + + cachedir_tag_file = fopen (cachedir_tag, "w"); + if (cachedir_tag_file) { + fputs ("Signature: 8a477f597d28d172789f06886806bc55\n" + "# This file is a cache directory tag created " + "by man-db.\n" + "# For information about cache directory tags, " + "see:\n" + "#\thttp://www.brynosaurus.com/cachedir/\n", + cachedir_tag_file); + fclose (cachedir_tag_file); + } } + free (cachedir_tag); } - free (cachedir_tag); #ifdef NDBM # ifdef BERKELEY_DB diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index aea3800..64d88fa 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -30,7 +30,7 @@ ALL_TESTS = \ lexgrog-1 \ man-1 man-2 man-3 man-4 man-5 man-6 man-7 man-8 man-9 \ manconv-1 manconv-2 manconv-3 \ - mandb-1 mandb-2 mandb-3 mandb-4 mandb-5 mandb-6 \ + mandb-1 mandb-2 mandb-3 mandb-4 mandb-5 mandb-6 mandb-7 \ whatis-1 \ zsoelim-1 if !CROSS_COMPILING diff --git a/src/tests/mandb-7 b/src/tests/mandb-7 new file mode 100755 index 0000000..7c530ca --- /dev/null +++ b/src/tests/mandb-7 @@ -0,0 +1,29 @@ +#! /bin/sh + +# Don't create CACHEDIR.TAG in manpath + +: ${srcdir=.} +. "$srcdir/testlib.sh" + +: ${MANDB=mandb} + +init +fake_config /usr/share/man +mkdir -p "$tmpdir/usr/share/man" +mkdir -p "$tmpdir/usr/dir/man" +mkdir -p "$tmpdir/var/cache/man" +echo "MANDATORY_MANPATH " $(realpath $tmpdir/usr/share/man) > "$tmpdir/manpath.config" +echo "MANDATORY_MANPATH " $(realpath $tmpdir/usr/dir/man) >> "$tmpdir/manpath.config" +echo "MANDB_MAP " $(realpath $tmpdir/usr/share/man) $(realpath $tmpdir/var/cache/man) >> "$tmpdir/manpath.config" + +write_page test 1 "$tmpdir/usr/share/man/man1/test.1" UTF-8 '' '' \ + 'test \- simple mandb test' +write_page test2 1 "$tmpdir/usr/dir/man/man1/test2.1" UTF-8 '' '' \ + 'test2 \- simple mandb test' +run $MANDB -C "$tmpdir/manpath.config" -q "$tmpdir/usr/share/man:$tmpdir/usr/dir/man" +expect_pass "CACHEDIR.TAG exists" "[ -e $tmpdir/var/cache/man/CACHEDIR.TAG ]" +expect_pass "CACHEDIR.TAG doesn't exist 01" "[ ! -e $tmpdir/usr/share/man/CACHEDIR.TAG ]" +expect_pass "CACHEDIR.TAG doesn't exist 02" "[ ! -e $tmpdir/usr/dir/man/CACHEDIR.TAG ]" + +finish +