[Midnightbsd-cvs] mports [16061] trunk/Mk: add a fake-man-compress target that pre-compresses all our man pages if they 're not already compressed.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun Mar 16 20:35:02 EDT 2014


Revision: 16061
          http://svnweb.midnightbsd.org/mports/?rev=16061
Author:   laffer1
Date:     2014-03-16 20:35:01 -0400 (Sun, 16 Mar 2014)
Log Message:
-----------
add a fake-man-compress target that pre-compresses all our man pages if they're not already compressed.

This allows us to put man pages in the plist now like FreeBSD does.

Modified Paths:
--------------
    trunk/Mk/bsd.mport.mk
    trunk/Mk/components/man.mk

Modified: trunk/Mk/bsd.mport.mk
===================================================================
--- trunk/Mk/bsd.mport.mk	2014-03-16 22:20:24 UTC (rev 16060)
+++ trunk/Mk/bsd.mport.mk	2014-03-17 00:35:01 UTC (rev 16061)
@@ -2666,7 +2666,7 @@
 _FAKE_DEP=		build
 _FAKE_SEQ=		fake-message fake-dir apply-slist pre-fake fake-pre-install \
 				generate-plist fake-pre-su-install create-users-groups do-fake fake-post-install \
-				post-fake compress-man install-rc-script install-ldconfig-file install-license install-desktop-entries \
+				post-fake fake-compress-man compress-man install-rc-script install-ldconfig-file install-license install-desktop-entries \
 				fix-fake-symlinks finish-tmpplist fix-plist-sequence
 
 .if defined(MPORT_MAINTAINER_MODE) && !defined(_MAKEPLIST)

Modified: trunk/Mk/components/man.mk
===================================================================
--- trunk/Mk/components/man.mk	2014-03-16 22:20:24 UTC (rev 16060)
+++ trunk/Mk/components/man.mk	2014-03-17 00:35:01 UTC (rev 16061)
@@ -10,6 +10,7 @@
 MANPREFIX?=	${PREFIX}
 .endif
 
+MANDIRS+=	${MANPREFIX}/man
 .for sect in 1 2 3 4 5 6 7 8 9
 MAN${sect}PREFIX?=	${MANPREFIX}
 .endfor
@@ -95,3 +96,38 @@
 .endfor
 
 .endif
+
+# Compress all manpage not already compressed which are not hardlinks
+# Find all manpages which are not compressed and are hadlinks, and only get the
+# list of inodes concerned, for each of them compress the first one found and recreate the hardlinks for the others
+# Fixes all dead symlinks left by the previous round
+.if !target(fake-compress-man)
+fake-compress-man:
+	@${ECHO_MSG} "====> Compressing man pages (fake-compress-man)"
+	@mdirs= ; \
+	for dir in ${MANDIRS:S/^/${FAKE_DESTDIR}/} ; do \
+		[ -d $$dir ] && mdirs="$$mdirs $$dir" ;\
+	done ; \
+	for dir in $$mdirs; do \
+	${FIND} $$dir -type f \! -name "*.gz" -links 1 -exec ${GZIP_CMD} {} \; ; \
+	${FIND} $$dir -type f \! -name "*.gz" \! -links 1 -exec ${STAT} -f '%i' {} \; | \
+		${SORT} -u | while read inode ; do \
+			unset ref ; \
+			for f in $$(${FIND} $$dir -type f -inum $${inode} -print); do \
+				if [ -z $$ref ]; then \
+					ref=$${f}.gz ; \
+					${GZIP_CMD} $${f} ; \
+					continue ; \
+				fi ; \
+				${RM} -f $${f} ; \
+				(cd $${f%/*}; ${LN} -f $${ref##*/} $${f##*/}.gz) ; \
+				done ; \
+			done ; \
+		${FIND} $$dir -type l \! -name "*.gz" | while read link ; do \
+				dest=$$(readlink $$link) ; \
+				rm -f $$link ; \
+				(cd $${link%/*} ; ${LN} -sf $${dest##*/}.gz $${link##*/}.gz) ;\
+		done; \
+	done
+.endif
+



More information about the Midnightbsd-cvs mailing list