summaryrefslogtreecommitdiff
path: root/fc-cache
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2013-02-06 19:35:30 +0900
committerAkira TAGOH <akira@tagoh.org>2013-03-05 18:38:50 +0900
commite96d7760886a3781a46b3271c76af99e15cb0146 (patch)
tree6af044654838607bc3fa221aa6ee6b68f381db14 /fc-cache
parent569657a24ca11aedfd3b588984344d7ab97fe09f (diff)
downloadfontconfig-e96d7760886a3781a46b3271c76af99e15cb0146.tar.gz
Bug 59456 - Adding a --sysroot like option to fc-cache
Add an ability to set the system root to generate the caches. In order to do this, new APIs, FcConfigGetSysRoot() and FcConfigSetSysRoot() is available.
Diffstat (limited to 'fc-cache')
-rw-r--r--fc-cache/fc-cache.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c
index 2206096..aeb0af2 100644
--- a/fc-cache/fc-cache.c
+++ b/fc-cache/fc-cache.c
@@ -67,6 +67,7 @@
const struct option longopts[] = {
{"force", 0, 0, 'f'},
{"really-force", 0, 0, 'r'},
+ {"sysroot", 0, 0, 'y'},
{"system-only", 0, 0, 's'},
{"version", 0, 0, 'V'},
{"verbose", 0, 0, 'v'},
@@ -85,26 +86,28 @@ usage (char *program, int error)
{
FILE *file = error ? stderr : stdout;
#if HAVE_GETOPT_LONG
- fprintf (file, "usage: %s [-frsvVh] [--force|--really-force] [--system-only] [--verbose] [--version] [--help] [dirs]\n",
+ fprintf (file, "usage: %s [-frsvVh] [-y SYSROOT] [--force|--really-force] [--sysroot=SYSROOT] [--system-only] [--verbose] [--version] [--help] [dirs]\n",
program);
#else
- fprintf (file, "usage: %s [-frsvVh] [dirs]\n",
+ fprintf (file, "usage: %s [-frsvVh] [-y SYSROOT] [dirs]\n",
program);
#endif
fprintf (file, "Build font information caches in [dirs]\n"
"(all directories in font configuration by default).\n");
fprintf (file, "\n");
#if HAVE_GETOPT_LONG
- fprintf (file, " -f, --force scan directories with apparently valid caches\n");
- fprintf (file, " -r, --really-force erase all existing caches, then rescan\n");
- fprintf (file, " -s, --system-only scan system-wide directories only\n");
- fprintf (file, " -v, --verbose display status information while busy\n");
- fprintf (file, " -V, --version display font config version and exit\n");
- fprintf (file, " -h, --help display this help and exit\n");
+ fprintf (file, " -f, --force scan directories with apparently valid caches\n");
+ fprintf (file, " -r, --really-force erase all existing caches, then rescan\n");
+ fprintf (file, " -s, --system-only scan system-wide directories only\n");
+ fprintf (file, " -y, --sysroot=SYSROOT prepend SYSROOT to all paths for scanning\n");
+ fprintf (file, " -v, --verbose display status information while busy\n");
+ fprintf (file, " -V, --version display font config version and exit\n");
+ fprintf (file, " -h, --help display this help and exit\n");
#else
fprintf (file, " -f (force) scan directories with apparently valid caches\n");
fprintf (file, " -r, (really force) erase all existing caches, then rescan\n");
fprintf (file, " -s (system) scan system-wide directories only\n");
+ fprintf (file, " -y SYSROOT (sysroot) prepend SYSROOT to all paths for scanning\n");
fprintf (file, " -v (verbose) display status information while busy\n");
fprintf (file, " -V (version) display font config version and exit\n");
fprintf (file, " -h (help) display this help and exit\n");
@@ -270,6 +273,7 @@ main (int argc, char **argv)
FcBool really_force = FcFalse;
FcBool systemOnly = FcFalse;
FcConfig *config;
+ FcChar8 *sysroot = NULL;
int i;
int changed;
int ret;
@@ -277,9 +281,9 @@ main (int argc, char **argv)
int c;
#if HAVE_GETOPT_LONG
- while ((c = getopt_long (argc, argv, "frsVvh", longopts, NULL)) != -1)
+ while ((c = getopt_long (argc, argv, "frsy:Vvh", longopts, NULL)) != -1)
#else
- while ((c = getopt (argc, argv, "frsVvh")) != -1)
+ while ((c = getopt (argc, argv, "frsy:Vvh")) != -1)
#endif
{
switch (c) {
@@ -292,6 +296,9 @@ main (int argc, char **argv)
case 's':
systemOnly = FcTrue;
break;
+ case 'y':
+ sysroot = FcStrCopy ((const FcChar8 *)optarg);
+ break;
case 'V':
fprintf (stderr, "fontconfig version %d.%d.%d\n",
FC_MAJOR, FC_MINOR, FC_REVISION);
@@ -312,7 +319,16 @@ main (int argc, char **argv)
if (systemOnly)
FcConfigEnableHome (FcFalse);
- config = FcInitLoadConfig ();
+ if (sysroot)
+ {
+ FcConfigSetSysRoot (NULL, sysroot);
+ FcStrFree (sysroot);
+ config = FcConfigGetCurrent();
+ }
+ else
+ {
+ config = FcInitLoadConfig ();
+ }
if (!config)
{
fprintf (stderr, "%s: Can't init font config library\n", argv[0]);