Subject: have bsd.pkg.mk automatically switch man/ to ${PKGMANDIR}
To: None <tech-pkg@netbsd.org>
From: Jeremy C. Reed <reed@reedmedia.net>
List: tech-pkg
Date: 05/04/2004 16:34:58
I have my own setting called PKGMANDIR which I set to share/man. I also
use --mandir=${PREFIX}/${PKGMANDIR} for my GNU_CONFIGURE packages.

So I had to modify over 100 PLISTs for this.

Since bsd.pkg.mk already has lots of code for automatically rewriting
shared libraries (like _AIXLIB_AWK) and man filenames (like
_PLIST_AWK_STRIP_MANZ), then it seems like I could just modify the PLIST
as needed for the my man directory too.

Also some infrequent PLISTs have something like:

@dirrm man/it_IT.88591/man1
@dirrm man/ru/man1
@dirrm man/ja_JP.eucJP/man1

And mail/qmail/PLIST may have problems too, but that looks fine because
that replace is done earlier in the awk script.

So I am testing:

## plist awk pattern-action statement to convert ^man/ to ${PKGMANDIR}/
_PLIST_AWK_PKGMANDIR=                                                     \
/^([^\/]*\/)*man\/([^\/]*\/)?(man[1-9ln]\/.*[1-9ln]|cat[1-9ln]\/.*0)$$/ { \
        sub("^man/", "${PKGMANDIR}/");                                    \
}                                                                         \
/^@dirrm man\// {                                                         \
        sub(" man/", " ${PKGMANDIR}/");                                   \
}


_PLIST_AWK_SCRIPT+=     ${_PLIST_AWK_PKGMANDIR}

I see the pattern above (based on other examples) starts line with:
^([^\/]*\/)*man\/

So maybe I could get that possible [^\/]*\/)* put in place first. I don't
know if awk sub or gsub can do this, so I may need to use match and
sprintf.

Any comments on converting PLISTs on the fly like this? It seems easier
that patching thousands of PLIST files.

Does anyone object to having a custom PKGMANDIR which can default like
"PKGMANDIR?= man" so behaviour is same for now?

 Jeremy C. Reed

 	  	 	 BSD News, BSD tutorials, BSD links
	  	 	 http://www.bsdnewsletter.com/