Add a '-c' option to fc-cache to do a chroot before (re)building the

font cache. Useful for builds with $DESTDIR set, to prepare a binary
distribution.
This commit is contained in:
matthieu 2007-10-27 20:00:20 +00:00
parent a12489dbfe
commit b66e17dd2f
3 changed files with 30 additions and 7 deletions

View File

@ -1,4 +1,4 @@
...\" $Header: /home/cvs/xenocara/lib/fontconfig/fc-cache/Attic/fc-cache.1,v 1.1 2007/05/05 10:32:29 matthieu Exp $
...\" $Header: /home/cvs/xenocara/lib/fontconfig/fc-cache/Attic/fc-cache.1,v 1.2 2007/10/27 20:00:20 matthieu Exp $
...\"
...\" transcript compatibility for postscript use.
...\"
@ -56,7 +56,7 @@
fc-cache \(em build font information cache files
.SH "SYNOPSIS"
.PP
\fBfc-cache\fR [\fB-fsvV?\fP] [\fB\-\-force\fP] [\fB\-\-system-only\fP] [\fB\-\-verbose\fP] [\fB\-\-version\fP] [\fB\-\-help\fP] [\fB\fIdirs\fR\fP]
\fBfc-cache\fR [\fB-cfsvV?\fP] [\fB\-\-chroot root\fP] [\fB\-\-force\fP] [\fB\-\-system-only\fP] [\fB\-\-verbose\fP] [\fB\-\-version\fP] [\fB\-\-help\fP] [\fB\fIdirs\fR\fP]
.SH "DESCRIPTION"
.PP
\fBfc-cache\fR scans the font directories on
@ -82,6 +82,9 @@ architecture\&.
This program follows the usual GNU command line syntax,
with long options starting with two dashes (`\-\&')\&. A summary of
options is included below\&.
.IP "\fB-c root\fP \fB\-\-chroot root\fP " 10
Change root directory into root
before starting\&.
.IP "\fB-f\fP \fB\-\-force\fP " 10
Force re-generation of apparently up-to-date cache files,
overriding the timestamp checking\&.
@ -111,4 +114,4 @@ The fontconfig user\&'s guide, in HTML format:
.PP
This manual page was written by Keith Packard
keithp@keithp\&.com and Josselin Mouette joss@debian\&.org\&.
...\" created by instant / docbook-to-man, Sat 05 May 2007, 11:42
...\" created by instant / docbook-to-man, Tue 16 Oct 2007, 23:05

View File

@ -67,6 +67,7 @@
#define _GNU_SOURCE
#include <getopt.h>
const struct option longopts[] = {
{"chroot", 0, 0, 'c'},
{"force", 0, 0, 'f'},
{"really-force", 0, 0, 'r'},
{"system-only", 0, 0, 's'},
@ -386,16 +387,20 @@ main (int argc, char **argv)
FcConfig *config;
int i;
int ret;
char *destdir = NULL;
#if HAVE_GETOPT_LONG || HAVE_GETOPT
int c;
#if HAVE_GETOPT_LONG
while ((c = getopt_long (argc, argv, "frsVv?", longopts, NULL)) != -1)
while ((c = getopt_long (argc, argv, "c:frsVv?", longopts, NULL)) != -1)
#else
while ((c = getopt (argc, argv, "frsVv?")) != -1)
while ((c = getopt (argc, argv, "c:frsVv?")) != -1)
#endif
{
switch (c) {
case 'c':
destdir = optarg;
break;
case 'r':
really_force = FcTrue;
/* fall through */
@ -420,7 +425,14 @@ main (int argc, char **argv)
#else
i = 1;
#endif
if (destdir) {
if (chroot(destdir) == -1) {
fprintf(stderr, "%s: Can't chroot to %s: %s\n", argv[0], destdir,
strerror(errno));
return 1;
}
systemOnly = FcTrue;
}
if (systemOnly)
FcConfigEnableHome (FcFalse);
config = FcInitLoadConfig ();

View File

@ -63,7 +63,8 @@ manpage.1: manpage.sgml
<cmdsynopsis>
<command>&dhpackage;</command>
<arg><option>-fsvV?</option></arg>
<arg><option>-cfsvV?</option></arg>
<arg><option>--chroot <replacable>root</replacable></option></arg>
<arg><option>--force</option></arg>
<arg><option>--system-only</option></arg>
<arg><option>--verbose</option></arg>
@ -105,6 +106,13 @@ manpage.1: manpage.sgml
<variablelist>
<varlistentry>
<term><option>-c <replacable>root</replacable></option>
<option>--chroot <replacable>root</replacable></option>
</term>
<listitem>
<para>Change root directory into <replacable>root</replacable>
before starting.</para>
</listitem>
<term><option>-f</option>
<option>--force</option>
</term>