Gzip the man pages

20 views
Skip to first unread message

Fergus Henderson

unread,
Oct 24, 2011, 9:41:16 PM10/24/11
to Craig Silverstein, distcc-...@googlegroups.com

Gzip the man pages before installing them.

This is required by the Debian policy manual
<http://www.debian.org/doc/debian-policy/ch-docs.html>
and is also assumed by our packaging/RedHat/rpm.spec file
which we use for building both RPM and Debian packages.

Also some whitespaces changes; only the first of the
four segments in this patch has non-whitespace changes.

Index: Makefile.in
===================================================================
--- Makefile.in (revision 746)
+++ Makefile.in (working copy)
@@ -1081,26 +1081,34 @@

install-man: $(man1_MEN)
$(mkinstalldirs) "$(DESTDIR)$(man1dir)"
- for p in $(man1_MEN); do \
- $(INSTALL_DATA) "$(srcdir)/$$p" "$(DESTDIR)$(man1dir)" || exit 1; \
+ for p in $(man1_MEN); do \
+ if $(GZIP_BIN) --help >/dev/null; then \
+ if [ -e "$(DESTDIR)$(man1dir)$$p" ]; then rm -fv "$(DESTDIR)$(man1dir)$$p"; fi; \
+ $(GZIP_BIN) < "$(srcdir)/$$p" > "$$p.gz"; \
+ $(INSTALL_DATA) "$$p.gz" "$(DESTDIR)$(man1dir)" || exit 1; \
+ else \
+ echo "Warning: no working gzip, installing man pages uncompressed" 1>&2; \
+ if [ -e "$(DESTDIR)$(man1dir)$$p.gz" ]; then rm -fv "$(DESTDIR)$(man1dir)$$p.gz"; fi; \
+ $(INSTALL_DATA) "$(srcdir)/$$p" "$(DESTDIR)$(man1dir)" || exit 1; \
+ fi; \
done

install-doc: $(pkgdoc_DOCS)
$(mkinstalldirs) "$(DESTDIR)$(docdir)"
- for p in $(pkgdoc_DOCS); do \
- $(INSTALL_DATA) "$(srcdir)/$$p" "$(DESTDIR)$(docdir)" || exit 1; \
+ for p in $(pkgdoc_DOCS); do \
+ $(INSTALL_DATA) "$(srcdir)/$$p" "$(DESTDIR)$(docdir)" || exit 1; \
done

install-example: $(example_DOCS)
$(mkinstalldirs) "$(DESTDIR)$(docdir)/example"
- for p in $(example_DOCS); do \
- $(INSTALL_DATA) "$(srcdir)/$$p" "$(DESTDIR)$(docdir)/example" || exit 1; \
+ for p in $(example_DOCS); do \
+ $(INSTALL_DATA) "$(srcdir)/$$p" "$(DESTDIR)$(docdir)/example" || exit 1; \
done

install-gnome-data: $(gnome_data)
$(mkinstalldirs) "$(DESTDIR)$(pkgdatadir)"
- for p in $(gnome_data); do \
- $(INSTALL_DATA) "$$p" "$(DESTDIR)$(pkgdatadir)" || exit 1; \
+ for p in $(gnome_data); do \
+ $(INSTALL_DATA) "$$p" "$(DESTDIR)$(pkgdatadir)" || exit 1; \
done

install-conf: $(conf_files) $(default_files)
@@ -1162,6 +1170,7 @@
for p in $(man1_MEN); do \
file="$(DESTDIR)$(man1dir)/`basename $$p`"; \
if [ -e "$$file" ]; then rm -fv "$$file"; fi \
+ if [ -e "$$file.gz" ]; then rm -fv "$$file.gz"; fi \
done
-[ "`basename $(man1dir)`" = "$(PACKAGE)" ] && rmdir "$(DESTDIR)$(man1dir)"

Property changes on: man
___________________________________________________________________
Added: svn:ignore
+ *.1.gz


patch

Craig Silverstein

unread,
Oct 24, 2011, 9:44:47 PM10/24/11
to Fergus Henderson, distcc-...@googlegroups.com
Looks good to me.

craig

Fergus Henderson

unread,
Oct 24, 2011, 11:26:57 PM10/24/11
to Craig Silverstein, distcc-...@googlegroups.com

I had to make a couple more changes to get "make distcheck" to pass.

Index: Makefile.in
===================================================================
--- Makefile.in (revision 747)
+++ Makefile.in (working copy)
@@ -914,7 +914,7 @@
rm -f src/*.[od] popt/*.[od]
rm -f test/*.pyc
rm -f $(check_PROGRAMS) $(bin_PROGRAMS)
- rm -f $(man_HTML)
+ rm -f man/*.1.gz $(man_HTML)
rm -f distccmon-gnome
rm -rf _testtmp # produced by test/testdistcc.py and daemon-installcheck
rm -rf +distcheck
@@ -1083,6 +1083,7 @@
$(mkinstalldirs) "$(DESTDIR)$(man1dir)"


for p in $(man1_MEN); do \

if $(GZIP_BIN) --help >/dev/null; then \

+ mkdir -p "`dirname $$p`"; \


if [ -e "$(DESTDIR)$(man1dir)$$p" ]; then rm -fv "$(DESTDIR)$(man1dir)$$p"; fi; \

$(GZIP_BIN) < "$(srcdir)/$$p" > "$$p.gz"; \

patch

Craig Silverstein

unread,
Oct 25, 2011, 1:55:57 PM10/25/11
to Fergus Henderson, distcc-...@googlegroups.com
} + rm -f man/*.1.gz $(man_HTML)

Is there any way to do this 'right'? I'd prefer
rm -f `echo $(man_HTML) | sed 's/\>/.gz/g'` $(man_HTML)
(I don't know if all seds accept \>, though mine does...)

Or maybe 'rf -f man/*'. But having variables for one type of man page
and a glob for the other doesn't make much sense. to me.

craig

Fergus Henderson

unread,
Oct 25, 2011, 9:23:50 PM10/25/11
to Craig Silverstein, distcc-...@googlegroups.com
On Wed, Oct 26, 2011 at 4:55 AM, Craig Silverstein <csil...@google.com> wrote:
} + rm -f man/*.1.gz $(man_HTML)

Is there any way to do this 'right'?  I'd prefer
  rm -f `echo $(man_HTML) | sed 's/\>/.gz/g'` $(man_HTML)
(I don't know if all seds accept \>, though mine does...)

I could easily add a variable for the gzipped man pages.
But it would come at the expense of some code duplication...
we can't use $(MEN:%=%.gz) because we don't want to rely on GNU Make extensions,
and we can't use the sed command that you suggest because it relies on a non-Posix sed feature
(it fails if you use sed --posix, so it probably fails with other non-GNU seds too).
So the only way I can see would be to manually define a new variable.
 
Or maybe 'rf -f man/*'.

That wouldn't work because it would delete the source files (*.1), and because it could delete other files in the user's checked-out directory that the user didn't want to delete, e.g. patch files, backups of source files, etc.

 But having variables for one type of man page
and a glob for the other doesn't make much sense. to me.

The reason that using "rm -f man/*.1.gz" is safe is that the *compressed* man pages are never going to be the checked-in source format.
"rm -rf man/*.html" would be a lot more risky, because there could in future be hand-written HTML files in there (e.g. index.html -- though currently that lives in doc/web/man/ rather than in man/).

Personally I think the current version of the patch is better than the minor code duplication required for manually defining another make variable for the *.1.gz files.  But having explained my reasons, I will defer to your judgement... what do you think?

--
Fergus Henderson <fer...@google.com>

"Defend the user, exclude no one, and create magic." -- Eric Schmidt.


Craig Silverstein

unread,
Oct 25, 2011, 9:41:44 PM10/25/11
to distcc-...@googlegroups.com
} and we can't use the sed command that you suggest because it relies
} on a non-Posix sed feature

I suspected as much. We could use another one, such as:
sed 's/\( \|$\)/.gz /g'

} The reason that using "rm -f man/*.1.gz" is safe is that the
} *compressed* man pages are never going to be the checked-in source
} format.

However, there could still be files in there that the user didn't want
to delete.

I don't like having *.1.gz plus $(MAN_gz). I think we should either
have variables for both, or the 'correct' list for both. My
preference is the sed.

craig

Craig Silverstein

unread,
Oct 25, 2011, 9:46:14 PM10/25/11
to distcc-...@googlegroups.com, distcc-...@googlegroups.com
} sed 's/\( \|$\)/.gz /g'

This doesn't seem to be POSIX either. OK:
sed -e 's/ /.gz /g' -e 's/$/.gz/'

craig

Fergus Henderson

unread,
Oct 25, 2011, 10:23:32 PM10/25/11
to distcc-...@googlegroups.com
OK, SGTM.  Here's a revised patch.  Tested with "make distcheck".

Index: Makefile.in
===================================================================
--- Makefile.in (revision 747)
+++ Makefile.in (working copy)
@@ -914,6 +914,7 @@
  rm -f src/*.[od] popt/*.[od]
  rm -f test/*.pyc
  rm -f $(check_PROGRAMS) $(bin_PROGRAMS)
+ rm -f `echo $(man1_MEN) | sed -e 's/ /.gz /g' -e 's/$$/.gz/'`
  rm -f $(man_HTML)
  rm -f distccmon-gnome
  rm -rf _testtmp  # produced by test/testdistcc.py and daemon-installcheck
@@ -1083,6 +1084,7 @@
  $(mkinstalldirs) "$(DESTDIR)$(man1dir)"
  for p in $(man1_MEN); do \
   if $(GZIP_BIN) --help >/dev/null; then \
+    mkdir -p "`dirname $$p`"; \
     if [ -e "$(DESTDIR)$(man1dir)$$p" ]; then rm -fv "$(DESTDIR)$(man1dir)$$p"; fi; \
     $(GZIP_BIN) < "$(srcdir)/$$p" > "$$p.gz"; \
     $(INSTALL_DATA) "$$p.gz" "$(DESTDIR)$(man1dir)" || exit 1; \

Craig Silverstein

unread,
Oct 25, 2011, 10:45:56 PM10/25/11
to distcc-...@googlegroups.com
Looks good to me.

Out of curiousity, how is man_HTML generated?

craig

Fergus Henderson

unread,
Oct 25, 2011, 10:53:31 PM10/25/11
to distcc-...@googlegroups.com
On Wed, Oct 26, 2011 at 1:45 PM, Craig Silverstein <csil...@google.com> wrote:
Looks good to me.

Committed revision 748.
 
Out of curiousity, how is man_HTML generated?

It is defined manually: 

man1_MEN = man/distcc.1 man/distccd.1 man/distccmon-text.1 \
           man/pump.1 man/include_server.1
man_HTML = man/distcc_1.html man/distccd_1.html man/distccmon_text_1.html \
           man/pump_1.html man/include_server_1.html

We can't easily used "sed" there since $(man_HTML) is used in the dependencies of a rule:

man-html: $(man_HTML)
Reply all
Reply to author
Forward
0 new messages