build: reinstate distribution of man pages

man pages change little between systems,
so falling back to distributed pages make sense
when cross compiling or lacking perl.

* man/local.mk: Add all man pages to EXTRA_DIST
so that they're distributed in the generated tarball.
Use the dummy-man page generator if cross compiling.
Set TZ to avoid a distcheck failure where man pages
used a diffent month than those rebuilt (with a .timestamp).
* man/dummy-man: Only fall back to generating a stub
if copying an existing man page fails.
* man/help2man: Sync portable TZ=UTC0 specification
from upstream help2man.
* NEWS: Mention the build-related change.
Fixes https://bugs.gnu.org/28574
This commit is contained in:
Pádraig Brady 2017-09-30 17:08:02 -07:00
parent 6774b991db
commit 856b828320
4 changed files with 29 additions and 17 deletions

5
NEWS
View File

@ -11,6 +11,11 @@ GNU coreutils NEWS -*- outline -*-
to attempt to hide the original length of the file name. to attempt to hide the original length of the file name.
[bug introduced in coreutils-8.28] [bug introduced in coreutils-8.28]
** Build-related
Default man pages are now distributed which are used if perl is
not available on the build system, or when cross compiling.
* Noteworthy changes in release 8.28 (2017-09-01) [stable] * Noteworthy changes in release 8.28 (2017-09-01) [stable]

View File

@ -1,8 +1,7 @@
#!/bin/sh #!/bin/sh
# Poor man's placeholder for help2man invocation on systems lacking perl; # Poor man's placeholder for help2man invocation on systems lacking perl,
# it generates a dummy man page stating that a proper one could not be # or when cross compiling.
# generated, and redirecting the user back to either the info # It just copies the distributed man pages.
# documentation or the '--help' output.
set -e; set -u set -e; set -u
@ -24,12 +23,12 @@ while test $# -gt 0; do
# Help2man options we recognize and handle. # Help2man options we recognize and handle.
--output=*) output=`expr x"$1" : x'--output=\(.*\)'`;; --output=*) output=`expr x"$1" : x'--output=\(.*\)'`;;
--output) shift; output=$1;; --output) shift; output=$1;;
--include=*) include=`expr x"$1" : x'--include=\(.*\)'`;;
--include) shift; include=$1;;
--source=*) source=`expr x"$1" : x'--source=\(.*\)'`;; --source=*) source=`expr x"$1" : x'--source=\(.*\)'`;;
--source) shift; source=$1;; --source) shift; source=$1;;
# Recognize (as no-op) other help2man options that might be used # Recognize (as no-op) other help2man options that might be used
# in the makefile. # in the makefile.
--include=*);;
--include) shift;;
--info-page=*);; --info-page=*);;
-*) fatal_ "invalid or unrecognized help2man option '$1'";; -*) fatal_ "invalid or unrecognized help2man option '$1'";;
--) shift; break;; --) shift; break;;
@ -41,10 +40,13 @@ done
test $# -gt 0 || fatal_ "missing argument" test $# -gt 0 || fatal_ "missing argument"
test $# -le 1 || fatal_ "too many non-option arguments" test $# -le 1 || fatal_ "too many non-option arguments"
dist_man=$(printf '%s\n' "$include" | sed 's/\.x$/.1/')
test -f "$dist_man" && cp "$dist_man" "$output" && exit || :
baseout=`basename_ "$output"` baseout=`basename_ "$output"`
sed 's/^/WARNING: /' >&2 <<END sed 's/^/WARNING: /' >&2 <<END
Cannot create proper '$baseout' man page, since perl is missing or Did not generate or find default '$baseout' man page.
inadequate on this system. Creating a stub man page instead. Creating a stub man page instead.
END END
progname=`basename_ "$1"` progname=`basename_ "$1"`
@ -55,9 +57,8 @@ cat >"$output" <<END
.SH NAME .SH NAME
$progname $bs- a $source program $progname $bs- a $source program
.SH DESCRIPTION .SH DESCRIPTION
.B OOOPS! .B OOPS!
Due to the lack of perl on the build system, we were We were unable to create a proper manual page for
unable to create a proper manual page for
.B $progname. .B $progname.
For concise option descriptions, run For concise option descriptions, run
.IP .IP

View File

@ -256,7 +256,7 @@ my $epoch_secs = time;
if (exists $ENV{SOURCE_DATE_EPOCH} and $ENV{SOURCE_DATE_EPOCH} =~ /^(\d+)$/) if (exists $ENV{SOURCE_DATE_EPOCH} and $ENV{SOURCE_DATE_EPOCH} =~ /^(\d+)$/)
{ {
$epoch_secs = $1; $epoch_secs = $1;
$ENV{TZ} = 'UTC'; $ENV{TZ} = 'UTC0';
} }
# Translators: the following message is a strftime(3) format string, which in # Translators: the following message is a strftime(3) format string, which in

View File

@ -18,22 +18,27 @@
EXTRA_DIST += man/help2man man/dummy-man EXTRA_DIST += man/help2man man/dummy-man
## Use the distributed man pages if cross compiling or lack perl
if CROSS_COMPILING
run_help2man = $(SHELL) $(srcdir)/man/dummy-man
else
## Graceful degradation for systems lacking perl. ## Graceful degradation for systems lacking perl.
if HAVE_PERL if HAVE_PERL
run_help2man = $(PERL) -- $(srcdir)/man/help2man run_help2man = $(PERL) -- $(srcdir)/man/help2man
else else
run_help2man = $(SHELL) $(srcdir)/man/dummy-man run_help2man = $(SHELL) $(srcdir)/man/dummy-man
endif endif
endif
man1_MANS = @man1_MANS@ man1_MANS = @man1_MANS@
EXTRA_DIST += $(man1_MANS:.1=.x) EXTRA_DIST += $(man1_MANS) $(man1_MANS:.1=.x)
EXTRA_MANS = @EXTRA_MANS@ EXTRA_MANS = @EXTRA_MANS@
EXTRA_DIST += $(EXTRA_MANS:.1=.x) EXTRA_DIST += $(EXTRA_MANS) $(EXTRA_MANS:.1=.x)
ALL_MANS = $(man1_MANS) $(EXTRA_MANS) ALL_MANS = $(man1_MANS) $(EXTRA_MANS)
CLEANFILES += $(ALL_MANS) MAINTAINERCLEANFILES += $(ALL_MANS)
# This is a kludge to remove generated 'man/*.1' from a non-srcdir build. # This is a kludge to remove generated 'man/*.1' from a non-srcdir build.
# Without this, "make distcheck" might fail. # Without this, "make distcheck" might fail.
@ -179,13 +184,14 @@ endif
## Note the use of $$t/$*, rather than just '$*' as in other packages. ## Note the use of $$t/$*, rather than just '$*' as in other packages.
## That is necessary to avoid failures for programs that are also shell ## That is necessary to avoid failures for programs that are also shell
## built-in functions like echo, false, printf, pwd. ## built-in functions like echo, false, printf, pwd.
rm -f $@ $@-t \ rm -f $@-t \
&& t=$*.td \ && t=$*.td \
&& rm -rf $$t \ && rm -rf $$t \
&& $(MKDIR_P) $$t \ && $(MKDIR_P) $$t \
&& (cd $$t && $(LN_S) '$(abs_top_builddir)/src/'$$prog$(EXEEXT) \ && (cd $$t && $(LN_S) '$(abs_top_builddir)/src/'$$prog$(EXEEXT) \
$$argv$(EXEEXT)) \ $$argv$(EXEEXT)) \
&& : $${SOURCE_DATE_EPOCH=`cat $(srcdir)/.timestamp 2>/dev/null || :`} \ && : $${SOURCE_DATE_EPOCH=`cat $(srcdir)/.timestamp 2>/dev/null || :`} \
&& : $${TZ=UTC0} && export TZ \
&& export SOURCE_DATE_EPOCH && $(run_help2man) \ && export SOURCE_DATE_EPOCH && $(run_help2man) \
--source='$(PACKAGE_STRING)' \ --source='$(PACKAGE_STRING)' \
--include=$(srcdir)/man/$$name.x \ --include=$(srcdir)/man/$$name.x \
@ -198,4 +204,4 @@ endif
$$t/$$name.1 > $@-t \ $$t/$$name.1 > $@-t \
&& rm -rf $$t \ && rm -rf $$t \
&& chmod a-w $@-t \ && chmod a-w $@-t \
&& mv $@-t $@ && rm -f $@ && mv $@-t $@