summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/glibc/glibc/0014-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch
blob: 3e7d5b74c1b203c81280dce3e27709f7c71aaf57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
From 653b0631f80f17abe01957c06ef8a8d5d189b789 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 3 Aug 2018 09:42:06 -0700
Subject: [PATCH] localedef --add-to-archive uses a hard-coded locale path

it doesn't exist in normal use, and there's no way to pass an
alternative filename.

Add a fallback of $LOCALEARCHIVE from the environment, and allow
creation of new locale archives that are not the system archive.

Upstream-Status: Inappropriate (OE-specific)

Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 locale/programs/locarchive.c | 35 +++++++++++++++++++++++++----------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c
index 71fd9f34fa..cd3eb90ad5 100644
--- a/locale/programs/locarchive.c
+++ b/locale/programs/locarchive.c
@@ -339,12 +339,24 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head)
   struct namehashent *oldnamehashtab;
   struct locarhandle new_ah;
   size_t prefix_len = output_prefix ? strlen (output_prefix) : 0;
-  char archivefname[prefix_len + sizeof (ARCHIVE_NAME)];
-  char fname[prefix_len + sizeof (ARCHIVE_NAME) + sizeof (".XXXXXX") - 1];
+  char *archivefname;
+  char *fname;
+  char *envarchive = getenv("LOCALEARCHIVE");
 
-  if (output_prefix)
-    memcpy (archivefname, output_prefix, prefix_len);
-  strcpy (archivefname + prefix_len, ARCHIVE_NAME);
+  if (envarchive != NULL)
+    {
+      archivefname = xmalloc(strlen(envarchive) + 1);
+      fname = xmalloc(strlen(envarchive) + sizeof (".XXXXXX"));
+      strcpy (archivefname, envarchive);
+    }
+  else
+    {
+      archivefname = xmalloc(prefix_len + sizeof (ARCHIVE_NAME));
+      fname = xmalloc(prefix_len + sizeof (ARCHIVE_NAME) + sizeof (".XXXXXX") - 1);
+      if (output_prefix)
+        memcpy (archivefname, output_prefix, prefix_len);
+      strcpy (archivefname + prefix_len, ARCHIVE_NAME);
+    }
   strcpy (stpcpy (fname, archivefname), ".XXXXXX");
 
   /* Not all of the old file has to be mapped.  Change this now this
@@ -568,10 +580,13 @@ open_archive (struct locarhandle *ah, bool readonly)
   /* If ah has a non-NULL fname open that otherwise open the default.  */
   if (archivefname == NULL)
     {
-      archivefname = default_fname;
-      if (output_prefix)
-        memcpy (default_fname, output_prefix, prefix_len);
-      strcpy (default_fname + prefix_len, ARCHIVE_NAME);
+      archivefname = getenv("LOCALEARCHIVE");
+      if (archivefname == NULL) {
+              archivefname = default_fname;
+              if (output_prefix)
+                memcpy (default_fname, output_prefix, prefix_len);
+              strcpy (default_fname + prefix_len, ARCHIVE_NAME);
+      }
     }
 
   while (1)
@@ -584,7 +599,7 @@ open_archive (struct locarhandle *ah, bool readonly)
 	     the default locale archive we ignore the failure and
 	     list an empty archive, otherwise we print an error
 	     and exit.  */
-	  if (errno == ENOENT && archivefname == default_fname)
+	  if (errno == ENOENT)
 	    {
 	      if (readonly)
 		{