[43022] trunk/dports/x11/xinit
jeremyhu at macports.org
jeremyhu at macports.org
Wed Dec 3 11:30:33 PST 2008
Revision: 43022
http://trac.macports.org/changeset/43022
Author: jeremyhu at macports.org
Date: 2008-12-03 11:30:33 -0800 (Wed, 03 Dec 2008)
Log Message:
-----------
xinit: Added font_cache script to generate fontconfig cache and fontdir caches when X11 starts
Modified Paths:
--------------
trunk/dports/x11/xinit/Portfile
trunk/dports/x11/xinit/files/tiger_support.patch
Added Paths:
-----------
trunk/dports/x11/xinit/files/font_cache.sh
Modified: trunk/dports/x11/xinit/Portfile
===================================================================
--- trunk/dports/x11/xinit/Portfile 2008-12-03 19:01:28 UTC (rev 43021)
+++ trunk/dports/x11/xinit/Portfile 2008-12-03 19:30:33 UTC (rev 43022)
@@ -4,6 +4,7 @@
name xinit
version 1.1.0
+revision 1
categories x11
platforms darwin
maintainers jeremyhu
@@ -44,4 +45,7 @@
xinstall -d ${destroot}${prefix}/lib/X11/xinit/xinitrc.d
eval xinstall -m 755 [glob ${filespath}/xinitrc.d/*.sh] ${destroot}${prefix}/lib/X11/xinit/xinitrc.d
+
+ xinstall -m 755 ${filespath}/font_cache.sh ${destroot}${prefix}/bin/font_cache
+ reinplace "s|^X11DIR=.*$|X11DIR=${prefix}|" ${destroot}${prefix}/bin/font_cache
}
Added: trunk/dports/x11/xinit/files/font_cache.sh
===================================================================
--- trunk/dports/x11/xinit/files/font_cache.sh (rev 0)
+++ trunk/dports/x11/xinit/files/font_cache.sh 2008-12-03 19:30:33 UTC (rev 43022)
@@ -0,0 +1,224 @@
+#!/bin/bash
+# Copyright (c) 2008 Apple Inc.
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
+# HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name(s) of the above
+# copyright holders shall not be used in advertising or otherwise to
+# promote the sale, use or other dealings in this Software without
+# prior written authorization.
+
+X11DIR=/usr/X11
+X11FONTDIR=${X11DIR}/lib/X11/fonts
+
+# Are we caching system fonts or user fonts?
+system=0
+
+# Are we including OSX font dirs ({/,~/,/System/}Library/Fonts)
+osxfonts=1
+
+# Do we want to force a recache?
+force=0
+
+# How noisy are we?
+verbose=0
+
+# Check if the data in the given directory is newer than its cache
+check_dirty() {
+ local dir=$1
+ local fontfiles=""
+ local retval=1
+
+ # If the dir does not exist, we just exit
+ if [[ ! -d "${dir}" ]]; then
+ return 1
+ fi
+
+ # Create a list of all files in the dir
+ # Filter out config / cache files. Ugly... counting down the day until
+ # xfs finally goes away
+ fontfiles="$(find ${dir}/ -maxdepth 1 -type f | awk '$0 !~ /fonts\..*$|^.*\.dir$/ {print}')"
+
+ # Fonts were deleted (or never there). Kill off the caches
+ if [[ -z "${fontfiles}" ]] ; then
+ local f
+ for f in "${dir}"/fonts.* "${dir}"/encodings.dir; do
+ if [[ -f ${f} ]] ; then
+ rm -f "${f}"
+ fi
+ done
+ return 1
+ fi
+
+ # Force a recache
+ if [[ ${force} == 1 ]] ; then
+ retval=0
+ fi
+
+ # If we don't have our caches, we are dirty
+ if [[ ! -f "${dir}/fonts.list" || ! -f "${dir}/fonts.dir" || ! -f "${dir}/encodings.dir" ]]; then
+ retval=0
+ fi
+
+ # Check that no files were added or removed....
+ if [[ "${retval}" -ne 0 && "$(cat ${dir}/fonts.list)" != "${fontfiles}" ]] ; then
+ retval=0
+ fi
+
+ # Check that no files were updated....
+ if [[ "${retval}" -ne 0 ]] ; then
+ local changed="$(find ${dir}/ -type f -cnewer ${dir}/fonts.dir | awk '$0 !~ /fonts\..*$|^.*\.dir$/ {print}')"
+
+ if [[ -n "${changed}" ]] ; then
+ retval=0
+ fi
+ fi
+
+ # Recreate fonts.list since something changed
+ if [[ "${retval}" == 0 ]] ; then
+ echo "${fontfiles}" > "${dir}"/fonts.list
+ fi
+
+ return ${retval}
+}
+
+get_fontdirs() {
+ local d
+ if [[ $system == 1 ]] ; then
+ if [[ $osxfonts == 1 ]] ; then
+ find {/System/,/}Library/Fonts -type d
+ fi
+
+ for d in "${X11FONTDIR}"/* ; do
+ case ${d#${X11FONTDIR}/} in
+ conf*|encodings*) ;;
+ *) find "$d" -type d ;;
+ esac
+ done
+ else
+ if [[ $osxfonts == 1 && -d "${HOME}/Library/Fonts" ]] ; then
+ find "${HOME}/Library/Fonts" -type d
+ fi
+
+ if [[ -d "${HOME}/.fonts" ]] ; then
+ find "${HOME}/.fonts" -type d
+ fi
+ fi
+}
+
+setup_fontdirs() {
+ local x=""
+ local fontdirs=""
+ local changed="no"
+
+ umask 022
+
+ if [[ $system == 1 ]] ; then
+ echo "font_cache: Scanning system font directories to generate X11 font caches"
+ else
+ echo "font_cache: Scanning user font directories to generate X11 font caches"
+ fi
+
+ # Generate the encodings.dir ...
+ if [[ $system == 1 ]] ; then
+ ${X11DIR}/bin/mkfontdir -n \
+ -e ${X11FONTDIR}/encodings \
+ -e ${X11FONTDIR}/encodings/large \
+ -- ${X11FONTDIR}/encodings
+ fi
+
+ OIFS=$IFS
+ IFS='
+'
+ for x in $(get_fontdirs) ; do
+ if [[ -d "${x}" ]] && check_dirty "${x}" ; then
+ if [[ -z "${fontdirs}" ]] ; then
+ fontdirs="${x}"
+ else
+ fontdirs="${fontdirs}${IFS}${x}"
+ fi
+ fi
+ done
+
+ if [[ -n "${fontdirs}" ]] ; then
+ echo "font_cache: Making fonts.dir for updated directories."
+ for x in ${fontdirs} ; do
+ if [[ $verbose == 1 ]] ; then
+ echo "font_cache: ${x}"
+ fi
+
+ # First, generate fonts.scale for scaleable fonts that might be there
+ ${X11DIR}/bin/mkfontscale \
+ -a ${X11FONTDIR}/encodings/encodings.dir \
+ -- ${x}
+
+ # Next, generate fonts.dir
+ if [[ $verbose == 1 ]] ; then
+ ${X11DIR}/bin/mkfontdir \
+ -e ${X11FONTDIR}/encodings \
+ -e ${X11FONTDIR}/encodings/large \
+ -- ${x}
+ else
+ ${X11DIR}/bin/mkfontdir \
+ -e ${X11FONTDIR}/encodings \
+ -e ${X11FONTDIR}/encodings/large \
+ -- ${x} > /dev/null
+ fi
+ done
+ fi
+ IFS=$OIFS
+
+ # Finally, update fontconfig's cache
+ echo "font_cache: Updating FC cache"
+ if [[ $system == 1 ]] ; then
+ HOME="$(echo ~root)" ${X11DIR}/bin/fc-cache \
+ $([[ $force == 1 ]] && echo "-f -r") \
+ $([[ $verbose == 1 ]] && echo "-v")
+ else
+ ${X11DIR}/bin/fc-cache \
+ $([[ $force == 1 ]] && echo "-f -r") \
+ $([[ $verbose == 1 ]] && echo "-v")
+ fi
+ echo "font_cache: Done"
+}
+
+do_usage() {
+ echo "font_cache [options]"
+ echo " -f, --force : Force cache recreation"
+ echo " -n, --no-osxfonts : Just cache X11 font directories"
+ echo " (-n just pertains to XFont cache, not fontconfig)"
+ echo " -s, --system : Cache system font dirs instead of user dirs"
+ echo " -v, --verbose : Verbose Output"
+}
+
+while [[ $# -gt 0 ]] ; do
+ case $1 in
+ -s|--system) system=1 ;;
+ -f|--force) force=1 ;;
+ -v|--verbose) verbose=1 ;;
+ -n|--no-osxfonts) osxfonts=0 ;;
+ --help) do_usage ; exit 0 ;;
+ *) do_usage ; exit 1 ;;
+ esac
+ shift
+done
+
+setup_fontdirs
Property changes on: trunk/dports/x11/xinit/files/font_cache.sh
___________________________________________________________________
Added: svn:executable
+ *
Modified: trunk/dports/x11/xinit/files/tiger_support.patch
===================================================================
--- trunk/dports/x11/xinit/files/tiger_support.patch 2008-12-03 19:01:28 UTC (rev 43021)
+++ trunk/dports/x11/xinit/files/tiger_support.patch 2008-12-03 19:30:33 UTC (rev 43022)
@@ -1,4 +1,4 @@
-diff --git a/Makefile.am b/Makefile.am
+diff --git Makefile.am Makefile.am
index 78ae154..0d831f3 100644
--- Makefile.am
+++ Makefile.am
@@ -12,7 +12,7 @@
xinitrc_DATA = xinitrc
CLEANFILES = xinitrc startx $(appman_DATA) $(launchagents_DATA)
-diff --git a/configure.ac b/configure.ac
+diff --git configure.ac configure.ac
index 2d09cad..86bd1f2 100644
--- configure.ac
+++ configure.ac
@@ -50,7 +50,7 @@
# Checks for pkg-config packages
PKG_CHECK_MODULES(XINIT, x11)
-diff --git a/org.x.startx.plist.cpp b/org.x.startx.plist.cpp
+diff --git org.x.startx.plist.cpp org.x.startx.plist.cpp
index 42c9f70..4bcedcf 100644
--- org.x.startx.plist.cpp
+++ org.x.startx.plist.cpp
@@ -62,7 +62,23 @@
+ <true/>
</dict>
</plist>
-diff --git a/privileged_startx/Makefile.am b/privileged_startx/Makefile.am
+diff --git privileged_startx/20-font_cache.cpp privileged_startx/20-font_cache.cpp
+index c13384b..6d43e10 100755
+--- privileged_startx/20-font_cache.cpp
++++ privileged_startx/20-font_cache.cpp
+@@ -27,9 +27,9 @@ XCOMM promote the sale, use or other dealings in this Software without
+ XCOMM prior written authorization.
+
+ if [ -x BINDIR/font_cache ] ; then
+- BINDIR/font_cache &
++ BINDIR/font_cache -s &
+ elif [ -x BINDIR/font_cache.sh ] ; then
+ BINDIR/font_cache.sh -s &
+-elif [ -x /usr/X11/bin/fc-cache ] ; then
++elif [ -x BINDIR/fc-cache ] ; then
+ BINDIR/fc-cache &
+ fi
+diff --git privileged_startx/Makefile.am privileged_startx/Makefile.am
index 6a143ca..2d68544 100644
--- privileged_startx/Makefile.am
+++ privileged_startx/Makefile.am
@@ -88,7 +104,7 @@
- mig -sheader privileged_startxServer.h privileged_startx.defs
+$(BUILT_SOURCES): $(srcdir)/privileged_startx.defs
+ mig -sheader privileged_startxServer.h $(srcdir)/privileged_startx.defs
-diff --git a/privileged_startx/client.c b/privileged_startx/client.c
+diff --git privileged_startx/client.c privileged_startx/client.c
index 2a24a70..a33dd02 100644
--- privileged_startx/client.c
+++ privileged_startx/client.c
@@ -113,7 +129,7 @@
exit(EXIT_FAILURE);
}
-diff --git a/privileged_startx/org.x.privileged_startx.plist.cpp b/privileged_startx/org.x.privileged_startx.plist.cpp
+diff --git privileged_startx/org.x.privileged_startx.plist.cpp privileged_startx/org.x.privileged_startx.plist.cpp
index e878dc3..7400cc4 100644
--- privileged_startx/org.x.privileged_startx.plist.cpp
+++ privileged_startx/org.x.privileged_startx.plist.cpp
@@ -149,7 +165,7 @@
+#endif
</dict>
</plist>
-diff --git a/privileged_startx/server.c b/privileged_startx/server.c
+diff --git privileged_startx/server.c privileged_startx/server.c
index 7afd424..6dd4f2b 100644
--- privileged_startx/server.c
+++ privileged_startx/server.c
@@ -318,7 +334,7 @@
return NULL;
}
+#endif
-diff --git a/startx.cpp b/startx.cpp
+diff --git startx.cpp startx.cpp
index 8ffdc70..fb23f18 100644
--- startx.cpp
+++ startx.cpp
@@ -485,7 +501,7 @@
fi
fi
-diff --git a/xinit.c b/xinit.c
+diff --git xinit.c xinit.c
index 523cfd5..d25de9d 100644
--- xinit.c
+++ xinit.c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20081203/40397b64/attachment.html>
More information about the macports-changes
mailing list