On Tuesday 28 February 2012 14:57:20 Mel Flynn wrote:
> It is only incorrect for the INSTALL_AS_USER case. In that case the
> FONTROOTDIR should be set to $PREFIX/.fontconfig and -s should be
> omitted. The not so pretty case is where she sets PREFIX to be something
> else then $HOME. Also, when -s is omitted, fc-cache will still try the
> system directories (and fail) and generate some mild noise if -v is also
> set.

bapt@ explicitly asked me to not care about INSTALL_AS_USER, so let's 
drop the discussion on this.

> You could define a variable that a maintainer can use in pkg-message.
> Might be tricky with \n. Documenting it and providing default text is
> the better solution in my opinion. Especially if you fix up existing
> ports to use the standard text, so that if a maintainer copies another
> port he's using the correct text.

Pardon, can you rephrase?

> I'm not sure 8 lines is enough to motivate a script, but it would at
> least resolve any ordering/timing issues if they exist now.

I has misunderstood this point. @ lines are not going away from plists with 
pkgng, only @(un)exec. Actually, more @ lines will appear thanks to 
extensible YAML scripts (there will be keywords for font handling too - I 
didn't include bapt@'s preview code in this patch just because it needs 
some tweaking to work as it should), so this is another non-problem. Yay, 
two solved! \o/

Now, attached you can find a patch that shows an updated procedure to 
handle fonts installation. I moved *_DEPENDS and post-install lines out of 
XORG_CAT (and post-install is now in post-makefile section, checking for 
already existing target - let maintainers define their own target, if they 
really want), as that is really X.Org specific stuff. Port variables are:
- FONTDIR (I will probably set it to ${PORTNAME} by default - can be set to a 
list of directories, bsd.xorg.mk will handle it just fine);
- FONTROOTDIR (defaults to ${PREFIX}/lib/X11/fonts, and shouldn't be 
modified);
- FONTROOTDIR_REL (relative version of the one above);
- INSTALLS_TTF (set to "yes" to call fc-cache);
- NEED_MKFONTFOO (set to "yes" to call mkfont* stuff - defaults to "yes" if 
INSTALLS_TTF is set).
What triggers the inclusion of bsd.xorg.mk and the whole procedure are 
INSTALLS_TTF or NEED_MKFONTFOO. We obviously need a better way to 
do it: bapt@ suggests INSTALLS_FONTS=(ttf|whatever). I'll implement it in 
my next patch.

On port installation, this is what happens:
===>   Updating font cache
fc-cache -s /usr/local/lib/X11/fonts/oxygen-fonts
mkfontscale /usr/local/lib/X11/fonts/oxygen-fonts
mkfontdir /usr/local/lib/X11/fonts/oxygen-fonts

And these are resulting scripts in package manifest:
scripts:
  post-install: |
    fc-cache -s /usr/local/lib/X11/fonts/oxygen-fonts 2>/dev/null || true
    mkfontscale /usr/local/lib/X11/fonts/oxygen-fonts 2>/dev/null || true
    mkfontdir /usr/local/lib/X11/fonts/oxygen-fonts 2>/dev/null || true
  post-deinstall: |
    fc-cache -s /usr/local/lib/X11/fonts/oxygen-fonts 2>/dev/null || true
    /bin/rm /usr/local/lib/X11/fonts/oxygen-fonts/fonts.scale
    /bin/rm /usr/local/lib/X11/fonts/oxygen-fonts/fonts.dir
    if [ -n "`ls -A /usr/local/lib/X11/fonts/oxygen-fonts`" ]; then 
mkfontscale /usr/local/lib/X11/fonts/oxygen-fonts 2>/dev/null || true; 
mkfontdir /usr/local/lib/X11/fonts/oxygen-fonts 2>/dev/null || true; fi

As you can see, I've not included any pkg-message handling code yet.

Now if you could please review this first change... :)

P.S.: I've also attached an example Makefile. And no, I've not tested any 
existing port, yet.
-- 
Alberto Villa, FreeBSD committer <[email protected]>
http://people.FreeBSD.org/~avilla

At the source of every error which is blamed on the computer you will find
at least two human errors, including the error of blaming it on the 
computer.
--- bsd.port.mk	2012-02-28 18:25:03.450038885 +0100
+++ /usr/ports/Mk/bsd.port.mk	2012-02-28 18:26:28.859948464 +0100
@@ -1368,7 +1368,7 @@
 .include "${PORTSDIR}/Mk/bsd.linux-apps.mk"
 .endif
 
-.if defined(USE_XORG) || defined(XORG_CAT)
+.if defined(USE_XORG) || defined(XORG_CAT) || defined(INSTALLS_TTF) || defined(NEED_MKFONTFOO)
 .include "${PORTSDIR}/Mk/bsd.xorg.mk"
 .endif
 
@@ -1997,7 +1997,7 @@
 .include "${PORTSDIR}/Mk/bsd.local.mk"
 .endif
 
-.if defined(USE_XORG) || defined(XORG_CAT)
+.if defined(USE_XORG) || defined(XORG_CAT) || defined(INSTALLS_TTF) || defined(NEED_MKFONTFOO)
 .include "${PORTSDIR}/Mk/bsd.xorg.mk"
 .endif
 
--- bsd.xorg.mk	2012-02-28 18:01:57.489933059 +0100
+++ /usr/ports/Mk/bsd.xorg.mk	2012-02-28 19:59:11.391468933 +0100
@@ -61,8 +61,8 @@
 
 . if ${XORG_CAT} == "font"
 FONTDIR?=	${PORTNAME:C/.*-//g:S/type/Type/:S/ttf/TTF/:S/speedo/Speedo/}
-CONFIGURE_ARGS+=	--with-fontrootdir=${PREFIX}/lib/X11/fonts
-CONFIGURE_ENV+=	FONTROOTDIR=${PREFIX}/lib/X11/fonts
+CONFIGURE_ARGS+=	--with-fontrootdir=${FONTROOTDIR}
+CONFIGURE_ENV+=	FONTROOTDIR=${FONTROOTDIR}
 NEED_MKFONTFOO=	yes
 
 .  if ${PORTNAME:M*type1*}x != x
@@ -81,40 +81,9 @@
 .  if ${PORTNAME:M*font-util*}x != x
 USE_GNOME+=	gnomehack
 NEED_MKFONTFOO=	no
-.  elif ${INSTALLS_TTF} == "yes"
-USE_GNOME+=	pkgconfig
-BUILD_DEPENDS+=	${LOCALBASE}/libdata/pkgconfig/fontconfig.pc:${PORTSDIR}/x11-fonts/fontconfig
-RUN_DEPENDS+=	${LOCALBASE}/libdata/pkgconfig/fontconfig.pc:${PORTSDIR}/x11-fonts/fontconfig
-.  else
+.  elif ${INSTALLS_TTF} != "yes"
 BUILD_DEPENDS+=	${LOCALBASE}/bin/bdftopcf:${PORTSDIR}/x11-fonts/bdftopcf
 .  endif
-
-.  if ${NEED_MKFONTFOO} == "yes"
-BUILD_DEPENDS+=	${LOCALBASE}/bin/mkfontdir:${PORTSDIR}/x11-fonts/mkfontdir \
-				${LOCALBASE}/bin/mkfontscale:${PORTSDIR}/x11-fonts/mkfontscale
-RUN_DEPENDS+=	${LOCALBASE}/bin/mkfontdir:${PORTSDIR}/x11-fonts/mkfontdir \
-				${LOCALBASE}/bin/mkfontscale:${PORTSDIR}/x11-fonts/mkfontscale
-.  endif
-
-post-install:
-.  if ${INSTALLS_TTF} == "yes"
-.   for _fontdir in ${FONTDIR}
-	@${ECHO_CMD} "@exec fc-cache -s %D/lib/X11/fonts/${_fontdir} 2>/dev/null || true" >> ${TMPPLIST}
-	@${ECHO_CMD} "@unexec fc-cache -s %D/lib/X11/fonts/${_fontdir} 2>/dev/null || true" >> ${TMPPLIST}
-	@${ECHO_CMD} "@unexec rmdir %D/lib/X11/fonts/${_fontdir} 2>/dev/null || true" >> ${TMPPLIST}
-.   endfor
-.  endif
-.  for _fontdir in ${FONTDIR}
-.   if ${NEED_MKFONTFOO} == "yes"
-	@${ECHO_CMD} "@exec mkfontscale %D/lib/X11/fonts/${_fontdir} 2>/dev/null || true" >> ${TMPPLIST}
-	@${ECHO_CMD} "@unexec mkfontscale %D/lib/X11/fonts/${_fontdir} 2>/dev/null || true" >> ${TMPPLIST}
-	@${ECHO_CMD} "@unexec if [ -e %D/lib/X11/fonts/${_fontdir}/fonts.scale -a \"\`stat -f '%%z' %D/lib/X11/fonts/${_fontdir}/fonts.scale 2>/dev/null\`\" = '2' ]; then rm %D/lib/X11/fonts/${_fontdir}/fonts.scale; fi" >> ${TMPPLIST}
-	@${ECHO_CMD} "@exec mkfontdir %D/lib/X11/fonts/${_fontdir} 2>/dev/null || true" >> ${TMPPLIST}
-	@${ECHO_CMD} "@unexec mkfontdir %D/lib/X11/fonts/${_fontdir} 2>/dev/null || true" >> ${TMPPLIST}
-	@${ECHO_CMD} "@unexec if [ -e %D/lib/X11/fonts/${_fontdir}/fonts.dir -a \"\`stat -f '%%z' %D/lib/X11/fonts/${_fontdir}/fonts.dir 2>/dev/null\`\" = '2' ]; then rm %D/lib/X11/fonts/${_fontdir}/fonts.dir; fi" >> ${TMPPLIST}
-.   endif
-	@${ECHO_CMD} "@unexec rmdir %D/lib/X11/fonts/${_fontdir} 2>/dev/null || true" >> ${TMPPLIST}
-.  endfor
 . endif
 
 . if ${XORG_CAT} == "lib"
@@ -139,6 +108,25 @@
 
 .endif
 
+.if defined(XORG_CAT) && ${XORG_CAT} == "font" || defined(INSTALLS_TTF) && ${INSTALLS_TTF} == "yes" || defined(NEED_MKFONTFOO) && ${NEED_MKFONTFOO} == "yes"
+FONTROOTDIR?=	${PREFIX}/lib/X11/fonts
+FONTROOTDIR_REL?=	${FONTROOTDIR:S,^${PREFIX}/,,}
+NEED_MKFONTFOO?=	yes
+.endif
+
+.if defined(INSTALLS_TTF) && ${INSTALLS_TTF} == "yes"
+USE_GNOME+=	pkgconfig
+BUILD_DEPENDS+=	${LOCALBASE}/bin/fc-cache:${PORTSDIR}/x11-fonts/fontconfig
+RUN_DEPENDS+=	${LOCALBASE}/bin/fc-cache:${PORTSDIR}/x11-fonts/fontconfig
+.endif
+
+.if defined(NEED_MKFONTFOO) && ${NEED_MKFONTFOO} == "yes"
+BUILD_DEPENDS+=	${LOCALBASE}/bin/mkfontdir:${PORTSDIR}/x11-fonts/mkfontdir \
+				${LOCALBASE}/bin/mkfontscale:${PORTSDIR}/x11-fonts/mkfontscale
+RUN_DEPENDS+=	${LOCALBASE}/bin/mkfontdir:${PORTSDIR}/x11-fonts/mkfontdir \
+				${LOCALBASE}/bin/mkfontscale:${PORTSDIR}/x11-fonts/mkfontscale
+.endif
+
 .endif
 
 .if defined(_POSTMKINCLUDED) && !defined(Xorg_Post_Include)
@@ -260,4 +248,25 @@
 		done
 .endif
 
+.if (defined(INSTALLS_TTF) && ${INSTALLS_TTF} == "yes" || defined(NEED_MKFONTFOO) && ${NEED_MKFONTFOO} == "yes") && !target(post-install)
+post-install:
+. for _fontdir in ${FONTDIR}
+	@${ECHO_MSG} "===>   Updating font cache"
+.  if defined(INSTALLS_TTF) && ${INSTALLS_TTF} == "yes"
+	fc-cache -s ${FONTROOTDIR}/${_fontdir}
+	@${ECHO_CMD} "@exec fc-cache -s ${FONTROOTDIR}/${_fontdir} 2>/dev/null || ${TRUE}" >> ${TMPPLIST}
+	@${ECHO_CMD} "@unexec fc-cache -s ${FONTROOTDIR}/${_fontdir} 2>/dev/null || ${TRUE}" >> ${TMPPLIST}
+.  endif
+.  if defined(NEED_MKFONTFOO) && ${NEED_MKFONTFOO} == "yes"
+.   for t in scale dir
+	mkfont${t} ${FONTROOTDIR}/${_fontdir}
+	@${ECHO_CMD} "@exec mkfont${t} ${FONTROOTDIR}/${_fontdir} 2>/dev/null || ${TRUE}" >> ${TMPPLIST}
+	@${ECHO_CMD} "@unexec ${RM} ${FONTROOTDIR}/${_fontdir}/fonts.${t}" >> ${TMPPLIST}
+.   endfor
+	@${ECHO_CMD} "@unexec if [ -n \"\`ls -A ${FONTROOTDIR}/${FONTDIR}\`\" ]; then mkfontscale ${FONTROOTDIR}/${_fontdir} 2>/dev/null || ${TRUE}; mkfontdir ${FONTROOTDIR}/${_fontdir} 2>/dev/null || ${TRUE}; fi" >> ${TMPPLIST}
+.  endif
+	@${ECHO_CMD} "@unexec ${RMDIR} ${FONTROOTDIR}/${_fontdir} 2>/dev/null || ${TRUE}" >> ${TMPPLIST}
+. endfor
+.endif
+
 .endif

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to