xorg-server: Changes to 'ubuntu'
debian/patches/190_cache-xkbcomp_output_for_fast_start_up.patch | 136 +++++-----
1 file changed, 79 insertions(+), 57 deletions(-)
New commits:
commit 7d5896b9a06ad07b05507edf77054789203a132e
Author: Robert Hooker <sarvatt@ubuntu.com>
Date: Mon May 17 20:01:24 2010 -0400
Replace 190_cache-xkbcomp_output_for_fast_start_up.patch with meego's rebased version.
diff --git a/debian/patches/190_cache-xkbcomp_output_for_fast_start_up.patch b/debian/patches/190_cache-xkbcomp_output_for_fast_start_up.patch
index 193d23c..20ba82f 100644
--- a/debian/patches/190_cache-xkbcomp_output_for_fast_start_up.patch
+++ b/debian/patches/190_cache-xkbcomp_output_for_fast_start_up.patch
@@ -1,11 +1,30 @@
-Patch from Moblin to cache xkbcomp output for faster booting
+From d2d3bcc9e23b9a4bea9f67a06cd23aa3ce7f4b59 Mon Sep 17 00:00:00 2001
+Message-Id: <d2d3bcc9e23b9a4bea9f67a06cd23aa3ce7f4b59.1268201183.git.yan.i.li@intel.com>
+From: Yan Li <yan.i.li@intel.com>
+Date: Wed, 10 Mar 2010 14:06:17 +0800
+Subject: [PATCH] XKB: cache xkbcomp output for fast start-up v6 for 1.7.99.901
-Signed-off-by: Bryce Harrington <bryce@canonical.com>
+xkbcomp outputs will be cached in files with hashed keymap as
+names. This saves boot time for around 1s on commodity netbooks.
+
+v6: rebased to v1.7.99.901
+
+v5: now using a much bigger xkbKeyMapBuf (100k) since the XKB to be
+ complied may be very large (as seen with
+ gnome-keyboard-properties), rebased to v1.6.1
+
+Signed-off-by: Yan Li <yan.i.li@intel.com>
---
+ configure.ac | 6 +-
+ xkb/README.compiled | 8 +-
+ xkb/ddxLoad.c | 187 +++++++++++++++++++++++++++++++++++++++++----------
+ 3 files changed, 159 insertions(+), 42 deletions(-)
+diff --git a/configure.ac b/configure.ac
+index de252f3..54a0327 100644
--- a/configure.ac
+++ b/configure.ac
-@@ -540,9 +540,9 @@ AC_MSG_RESULT([$FONTPATH])
+@@ -527,9 +527,9 @@ AC_MSG_RESULT([$FONTPATH])
AC_ARG_WITH(xkb-path, AS_HELP_STRING([--with-xkb-path=PATH], [Path to XKB base dir (default: ${datadir}/X11/xkb)]),
[ XKBPATH="$withval" ],
[ XKBPATH="${datadir}/X11/xkb" ])
@@ -17,7 +36,7 @@ Signed-off-by: Bryce Harrington <bryce@canonical.com>
AC_ARG_WITH(default-xkb-rules, AS_HELP_STRING([--with-default-xkb-rules=RULES],
[Keyboard ruleset (default: base/evdev)]),
[ XKB_DFLT_RULES="$withval" ],
-@@ -1168,7 +1168,7 @@ AC_DEFINE_DIR(XKB_BIN_DIRECTORY, XKB_BIN
+@@ -1148,7 +1148,7 @@ AC_DEFINE_DIR(XKB_BIN_DIRECTORY, XKB_BIN_DIRECTORY, [Path to XKB bin dir])
dnl Make sure XKM_OUTPUT_DIR is an absolute path
XKBOUTPUT_FIRSTCHAR=`echo $XKBOUTPUT | cut -b 1`
if [[ x$XKBOUTPUT_FIRSTCHAR != x/ -a x$XKBOUTPUT_FIRSTCHAR != 'x$' ]] ; then
@@ -26,9 +45,11 @@ Signed-off-by: Bryce Harrington <bryce@canonical.com>
fi
dnl XKM_OUTPUT_DIR (used in code) must end in / or file names get hosed
+diff --git a/xkb/README.compiled b/xkb/README.compiled
+index 71caa2f..a4a2ae0 100644
--- a/xkb/README.compiled
+++ b/xkb/README.compiled
-@@ -4,10 +4,10 @@ current keymap and/or any scratch keymap
+@@ -4,10 +4,10 @@ current keymap and/or any scratch keymaps used by clients. The X server
or some other tool might destroy or replace the files in this directory,
so it is not a safe place to store compiled keymaps for long periods of
time. The default keymap for any server is usually stored in:
@@ -43,18 +64,20 @@ Signed-off-by: Bryce Harrington <bryce@canonical.com>
Unless the X server is modified, sharing this directory between servers on
different hosts could cause problems.
+diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
+index 4ccddda..63b9f97 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -30,6 +30,12 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <xkb-config.h>
-+#ifdef HAVE_SHA1_IN_LIBGCRYPT /* Use libgcrypt for SHA1 */
-+# include <gcrypt.h>
++#ifdef HAVE_SHA1_IN_LIBMD /* Use libmd for SHA1 */
++# include <sha1.h>
+#else /* Use OpenSSL's libcrypto */
-+#warning "xkbcomp caching support disabled"
++# include <stddef.h> /* buggy openssl/sha.h wants size_t */
++# include <openssl/sha.h>
+#endif
-+
#include <stdio.h>
#include <ctype.h>
#include <X11/X.h>
@@ -84,44 +107,41 @@ Signed-off-by: Bryce Harrington <bryce@canonical.com>
#define PRE_ERROR_MSG "\"The XKEYBOARD keymap compiler (xkbcomp) reports:\""
#define ERROR_PREFIX "\"> \""
#define POST_ERROR_MSG1 "\"Errors from xkbcomp are not fatal to the X server\""
-@@ -174,6 +169,47 @@ OutputDirectory(
- }
+@@ -175,6 +170,45 @@ OutputDirectory(
}
-+#ifndef SHA_DIGEST_LENGTH
-+#define SHA_DIGEST_LENGTH 20
-+#endif
-+
-+static Bool
+ static Bool
+Sha1Asc(char sha1Asc[SHA_DIGEST_LENGTH*2+1], const char * input)
+{
+ int i;
+ unsigned char sha1[SHA_DIGEST_LENGTH];
+
-+#ifdef HAVE_SHA1_IN_LIBGCRYPT /* Use libgcrypt for SHA1 */
-+ static int init;
-+ gcry_md_hd_t h;
-+ gcry_error_t err;
++#ifdef HAVE_SHA1_IN_LIBMD /* Use libmd for SHA1 */
++ SHA1_CTX ctx;
+
-+ if (!init) {
-+ if (!gcry_check_version(NULL))
-+ return BadAlloc;
-+ gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
-+ gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
-+ init = 1;
-+ }
++ SHA1Init (&ctx);
++ SHA1Update (&ctx, input, strlen(input));
++ SHA1Final (sha1, &ctx);
++#else /* Use OpenSSL's libcrypto */
++ SHA_CTX ctx;
++ int success;
++
++ success = SHA1_Init (&ctx);
++ if (! success)
++ return BadAlloc;
+
-+ err = gcry_md_open(&h, GCRY_MD_SHA1, 0);
-+ if (err)
++ success = SHA1_Update (&ctx, input, strlen(input));
++ if (! success)
++ return BadAlloc;
++
++ success = SHA1_Final (sha1, &ctx);
++ if (! success)
+ return BadAlloc;
-+ gcry_md_write(h, input, strlen(input));
-+ memcpy(sha1, gcry_md_read(h, GCRY_MD_SHA1), 20);
-+ gcry_md_close(h);
+#endif
+
+ /* convert sha1 to sha1_asc */
+ for(i=0; i<SHA_DIGEST_LENGTH; ++i) {
-+ sprintf(sha1Asc+i*2, "%02X", sha1[i]);
++ sprintf(sha1Asc+i*2, "%02X", sha1[i]);
+ }
+
+ return Success;
@@ -129,10 +149,11 @@ Signed-off-by: Bryce Harrington <bryce@canonical.com>
+
+/* call xkbcomp and compile XKB keymap, return xkm file name in
+ nameRtrn */
- static Bool
++static Bool
XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
XkbComponentNamesPtr names,
-@@ -183,7 +219,11 @@ XkbDDXCompileKeymapByNames( XkbDescPtr
+ unsigned want,
+@@ -183,7 +217,11 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
int nameRtrnLen)
{
FILE * out;
@@ -145,7 +166,7 @@ Signed-off-by: Bryce Harrington <bryce@canonical.com>
const char *emptystring = "";
const char *xkbbasedirflag = emptystring;
-@@ -194,14 +234,67 @@ XkbDDXCompileKeymapByNames( XkbDescPtr
+@@ -194,15 +232,67 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
/* WIN32 has no popen. The input must be stored in a file which is
used as input for xkbcomp. xkbcomp does not read from stdin. */
char tmpname[PATH_MAX];
@@ -165,15 +186,14 @@ Signed-off-by: Bryce Harrington <bryce@canonical.com>
+ return FALSE;
+ }
+ ret = XkbWriteXKBKeymapForNames(out, names, xkb, want, need);
-+ if (fclose(out) !=0)
-+ {
++ if (fclose(out) !=0) {
+ ErrorF("[xkb] XkbWriteXKBKeymapForNames error, perhaps xkbKeyMapBuf is too small\n");
+ return FALSE;
+ }
+#ifdef DEBUG
+ if (xkbDebugFlags) {
-+ ErrorF("[xkb] XkbDDXCompileKeymapByNames compiling keymap:\n");
-+ fputs(xkbKeyMapBuf, stderr);
++ ErrorF("[xkb] XkbDDXCompileKeymapByNames compiling keymap:\n");
++ fputs(xkbKeyMapBuf, stderr);
+ }
#endif
+ if (!ret) {
@@ -185,14 +205,14 @@ Signed-off-by: Bryce Harrington <bryce@canonical.com>
+ DebugF("[xkb] computing SHA1 of keymap\n");
+ if (Success == Sha1Asc(sha1Asc, xkbKeyMapBuf)) {
+ snprintf(xkmfile, sizeof(xkmfile), "server-%s", sha1Asc);
-+ }
-+ else {
++ } else {
+ ErrorF("[xkb] Computing SHA1 of keymap failed, "
+ "using display name instead as xkm file name\n");
+ snprintf(xkmfile, sizeof(xkmfile), "server-%s", display);
+ }
OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
+
+ /* set nameRtrn, fail if it's too small */
+ if ((strlen(xkmfile)+1 > nameRtrnLen) && nameRtrn) {
+ ErrorF("[xkb] nameRtrn too small to hold xkmfile name\n");
@@ -213,10 +233,11 @@ Signed-off-by: Bryce Harrington <bryce@canonical.com>
+ /* continue to call xkbcomp to compile the keymap. to avoid race
+ condition, we compile it to a tmpfile then rename it to
+ xkmfile */
-
++
#ifdef WIN32
strcpy(tmpname, Win32TempDir());
-@@ -225,19 +318,30 @@ XkbDDXCompileKeymapByNames( XkbDescPtr
+ strcat(tmpname, "\\xkb_XXXXXX");
+@@ -225,19 +315,30 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
}
}
@@ -250,7 +271,7 @@ Signed-off-by: Bryce Harrington <bryce@canonical.com>
#ifndef WIN32
out= Popen(buf,"w");
#else
-@@ -245,31 +349,43 @@ XkbDDXCompileKeymapByNames( XkbDescPtr
+@@ -245,31 +346,41 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
#endif
if (out!=NULL) {
@@ -258,28 +279,28 @@ Signed-off-by: Bryce Harrington <bryce@canonical.com>
- if (xkbDebugFlags) {
- ErrorF("[xkb] XkbDDXCompileKeymapByNames compiling keymap:\n");
- XkbWriteXKBKeymapForNames(stderr,names,xkb,want,need);
+- }
+-#endif
+- XkbWriteXKBKeymapForNames(out,names,xkb,want,need);
+ /* write XKBKeyMapBuf to xkbcomp */
+ if (EOF==fputs(xkbKeyMapBuf, out))
+ {
+ ErrorF("[xkb] Sending keymap to xkbcomp failed\n");
+ result = FALSE;
+ goto _ret;
- }
--#endif
-- XkbWriteXKBKeymapForNames(out,names,xkb,want,need);
++ }
#ifndef WIN32
if (Pclose(out)==0)
#else
if (fclose(out)==0 && System(buf) >= 0)
#endif
{
-+ /* xkbcomp success */
++ /* xkbcomp success */
if (xkbDebugFlags)
DebugF("[xkb] xkb executes: %s\n",buf);
- if (nameRtrn) {
- strncpy(nameRtrn,keymap,nameRtrnLen);
- nameRtrn[nameRtrnLen-1]= '\0';
-+
+ /* if canonicalXkmFileName already exists now, we simply
+ overwrite it, this is OK */
+ ret = rename(tmpXkmFile, canonicalXkmFileName);
@@ -297,17 +318,16 @@ Signed-off-by: Bryce Harrington <bryce@canonical.com>
- if (buf != NULL)
- xfree (buf);
- return TRUE;
-+
-+ result = TRUE;
-+ goto _ret;
++ result = TRUE;
++ goto _ret;
}
else
- LogMessage(X_ERROR, "Error compiling keymap (%s)\n", keymap);
-+ LogMessage(X_ERROR, "Error compiling keymap (%s)\n", xkbfile);
++ LogMessage(X_ERROR, "Error compiling keymap (%s)\n", xkbfile);
#ifdef WIN32
/* remove the temporary file */
unlink(tmpname);
-@@ -284,9 +400,17 @@ XkbDDXCompileKeymapByNames( XkbDescPtr
+@@ -284,9 +395,16 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
}
if (nameRtrn)
nameRtrn[0]= '\0';
@@ -321,12 +341,11 @@ Signed-off-by: Bryce Harrington <bryce@canonical.com>
if (buf != NULL)
xfree (buf);
- return FALSE;
-+
+ return result;
}
static FILE *
-@@ -370,7 +494,6 @@ unsigned missing;
+@@ -370,7 +488,6 @@ unsigned missing;
DebugF("Loaded XKB keymap %s, defined=0x%x\n",fileName,(*xkbRtrn)->defined);
}
fclose(file);
@@ -334,3 +353,6 @@ Signed-off-by: Bryce Harrington <bryce@canonical.com>
return (need|want)&(~missing);
}
+--
+1.5.6.5
+
Reply to: