0014-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. From 8ebf6708ba54147b44f5638b93f123fd55d4c37e Mon Sep 17 00:00:00 2001
  2. From: Khem Raj <raj.khem@gmail.com>
  3. Date: Fri, 3 Aug 2018 09:42:06 -0700
  4. Subject: [PATCH] localedef --add-to-archive uses a hard-coded locale path
  5. it doesn't exist in normal use, and there's no way to pass an
  6. alternative filename.
  7. Add a fallback of $LOCALEARCHIVE from the environment, and allow
  8. creation of new locale archives that are not the system archive.
  9. Upstream-Status: Inappropriate (OE-specific)
  10. Signed-off-by: Ross Burton <ross.burton@intel.com>
  11. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  12. ---
  13. locale/programs/locarchive.c | 35 +++++++++++++++++++++++++----------
  14. 1 file changed, 25 insertions(+), 10 deletions(-)
  15. diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c
  16. index eeb2fa6ffe..15274b0191 100644
  17. --- a/locale/programs/locarchive.c
  18. +++ b/locale/programs/locarchive.c
  19. @@ -339,12 +339,24 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head)
  20. struct namehashent *oldnamehashtab;
  21. struct locarhandle new_ah;
  22. size_t prefix_len = output_prefix ? strlen (output_prefix) : 0;
  23. - char archivefname[prefix_len + sizeof (ARCHIVE_NAME)];
  24. - char fname[prefix_len + sizeof (ARCHIVE_NAME) + sizeof (".XXXXXX") - 1];
  25. + char *archivefname;
  26. + char *fname;
  27. + char *envarchive = getenv("LOCALEARCHIVE");
  28. - if (output_prefix)
  29. - memcpy (archivefname, output_prefix, prefix_len);
  30. - strcpy (archivefname + prefix_len, ARCHIVE_NAME);
  31. + if (envarchive != NULL)
  32. + {
  33. + archivefname = xmalloc(strlen(envarchive) + 1);
  34. + fname = xmalloc(strlen(envarchive) + sizeof (".XXXXXX"));
  35. + strcpy (archivefname, envarchive);
  36. + }
  37. + else
  38. + {
  39. + archivefname = xmalloc(prefix_len + sizeof (ARCHIVE_NAME));
  40. + fname = xmalloc(prefix_len + sizeof (ARCHIVE_NAME) + sizeof (".XXXXXX") - 1);
  41. + if (output_prefix)
  42. + memcpy (archivefname, output_prefix, prefix_len);
  43. + strcpy (archivefname + prefix_len, ARCHIVE_NAME);
  44. + }
  45. strcpy (stpcpy (fname, archivefname), ".XXXXXX");
  46. /* Not all of the old file has to be mapped. Change this now this
  47. @@ -568,10 +580,13 @@ open_archive (struct locarhandle *ah, bool readonly)
  48. /* If ah has a non-NULL fname open that otherwise open the default. */
  49. if (archivefname == NULL)
  50. {
  51. - archivefname = default_fname;
  52. - if (output_prefix)
  53. - memcpy (default_fname, output_prefix, prefix_len);
  54. - strcpy (default_fname + prefix_len, ARCHIVE_NAME);
  55. + archivefname = getenv("LOCALEARCHIVE");
  56. + if (archivefname == NULL) {
  57. + archivefname = default_fname;
  58. + if (output_prefix)
  59. + memcpy (default_fname, output_prefix, prefix_len);
  60. + strcpy (default_fname + prefix_len, ARCHIVE_NAME);
  61. + }
  62. }
  63. while (1)
  64. @@ -584,7 +599,7 @@ open_archive (struct locarhandle *ah, bool readonly)
  65. the default locale archive we ignore the failure and
  66. list an empty archive, otherwise we print an error
  67. and exit. */
  68. - if (errno == ENOENT && archivefname == default_fname)
  69. + if (errno == ENOENT)
  70. {
  71. if (readonly)
  72. {