Subject: Re: perl modules patch
To: None <tech-pkg@netbsd.org>
From: Johnny C. Lam <lamj@stat.cmu.edu>
List: tech-pkg
Date: 08/24/2000 05:24:49
I've included a patch to bsd.pkg.mk which shows how the code from
textproc/eperl could be incorporated.  The textproc/eperl Makefile
would then simply need to have:

USE_PERL5=	# defined
PERL5_PACKLIST=	${PERL5_SITEARCH}/auto/Parse/ePerl/.packlist

and the PLIST would have the appropriate lines automatically appended.
For files which have multiple .packlists, you'd simply list them all
in PERL5_PACKLIST, much like LTCONFIG_OVERRIDE or MASTER_SITES.

One possible change to have the comment that the lines are
automatically generated be added by the code directly, instead of by
the package maintainer in each PLIST.

	Cheers,

     -- Johnny C. Lam <lamj@stat.cmu.edu>
        Department of Statistics, Carnegie Mellon University
        http://www.stat.cmu.edu/~lamj/

--- bsd.pkg.mk	2000/08/23 22:22:53	1.549
+++ bsd.pkg.mk	2000/08/24 09:10:56
@@ -135,6 +135,9 @@
 
 .if defined(USE_PERL5)
 DEPENDS+=		perl-*:../../lang/perl5
+PERL5_SITEARCH!=	eval `${LOCALBASE}/bin/perl -V:installsitearch`; echo $${installsitearch}
+PERL5_SITELIB!=		eval `${LOCALBASE}/bin/perl -V:installsitelib`; echo $${installsitelib}
+PERL5_ARCHLIB!=		eval `${LOCALBASE}/bin/perl -V:installarchlib`; echo $${installarchlib}
 .endif
 
 .if defined(USE_FORTRAN)
@@ -3089,6 +3092,8 @@
 #   (we don't take any notice of MANCOMPRESSED as many packages have .gz
 #   pages in PLIST even when they install manpages without compressing them)
 # - substituting by ${PLIST_SUBST}
+# - adding files and appropriate rmdir statements for perl5 modules if
+#   PERL5_PACKLIST is defined
 
 .if ${OPSYS} == "NetBSD"
 IMAKE_MAN_CMD=
@@ -3132,6 +3142,20 @@
 MANZ_EXPRESSION= 
 .endif # SunOS
 
+.if defined(PERL5_PACKLIST)
+PERL5_PACKLIST_FILES=	( ${CAT} ${PERL5_PACKLIST}; for f in ${PERL5_PACKLIST}; do echo $$f; done ) \
+		| ${SED} -e "s,/./,/,g" -e "s,${PREFIX}/,," \
+		| sort -u >> ${PLIST}
+PERL5_PACKLIST_DIRS=	( ${CAT} ${PERL5_PACKLIST}; for f in ${PERL5_PACKLIST}; do echo $$f; done ) \
+		| ${SED} -e "s,/./,/,g" -e "s,${PREFIX}/,," \
+			-e "s,^,@unexec rmdir -p %D/," \
+			-e "s,/[^/]*$$, 2>/dev/null || true," \
+		| sort -ur >> ${PLIST}
+.else
+PERL5_PACKLIST_FILES=	${TRUE}
+PERL5_PACKLIST_DIRS=	${TRUE}
+.endif
+
 plist: ${PLIST}
 ${PLIST}: ${PLIST_SRC}
 	${_PKG_SILENT}${_PKG_DEBUG}					\
@@ -3145,6 +3169,8 @@
 			${SED} 	${MANZ_EXPRESSION}			\
 				${PLIST_SUBST:S/=/}!/:S/$/!g/:S/^/ -e s!\\\${/}\
 			> ${PLIST}; 					\
+		${PERL5_PACKLIST_FILES};				\
+		${PERL5_PACKLIST_DIRS};					\
 	fi
 
 # generate ${DESCR} from ${DESCR_SRC} by: