summaryrefslogtreecommitdiff
blob: f3786055c35bcc917e57fc0030871c2faeb65a41 (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
bug #473484
Index: work/extra/locale/locale-gen
===================================================================
--- work.orig/extra/locale/locale-gen
+++ work/extra/locale/locale-gen
@@ -8,7 +8,13 @@ unset POSIXLY_CORRECT IFS
 umask 0022
 
 argv0=${0##*/}
-source /etc/init.d/functions.sh || {
+
+EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
+if [[ ${EPREFIX} == "@"GENTOO_PORTAGE_EPREFIX"@" ]] ; then
+	EPREFIX=""
+fi
+
+source "${EPREFIX}"/etc/init.d/functions.sh || {
 	echo "${argv0}: Could not source /etc/init.d/functions.sh!" 1>&2
 	exit 1
 }
@@ -97,13 +103,14 @@ if [[ -n ${DESTDIR} ]] && [[ ${ROOT} !=
 	eerror "DESTDIR and ROOT are mutually exclusive options"
 	exit 1
 fi
-if [[ ${ROOT} != "/" ]] ; then
-	einfo "Using locale.gen from ROOT ${ROOT}etc/"
+: ${EROOT:="${ROOT%/}${EPREFIX}/"}
+if [[ ${EROOT} != "/" ]] ; then
+	einfo "Using locale.gen from ROOT ${EROOT}etc/"
 fi
 if [[ -n ${DESTDIR} ]] ; then
 	einfo "Building locales in DESTDIR '${DESTDIR}'"
 else
-	DESTDIR=${ROOT}
+	DESTDIR=${EROOT}
 fi
 
 # XXX: should fix this ...
@@ -112,7 +119,7 @@ if [[ ${ROOT} != "/" ]] ; then
 	exit 0
 fi
 
-: ${CONFIG:=${ROOT}etc/locale.gen}
+: ${CONFIG:=${EROOT}etc/locale.gen}
 LOCALES=${DESTDIR}usr/share/i18n/locales
 CHARMAPS=${DESTDIR}usr/share/i18n/charmaps
 SUPPORTED=${DESTDIR}usr/share/i18n/SUPPORTED
@@ -150,7 +157,10 @@ fi
 
 # Extract the location of the locale dir on the fly as `localedef --help` has:
 #                        locale path    : /usr/lib64/locale:/usr/share/i18n
-LOCALEDIR=${DESTDIR}$(LC_ALL="C" "${DESTDIR}"usr/bin/localedef --help | sed -n -e '/locale path/{s|.* : ||;s|:.*||;p}')
+# For long paths, the line may get wrapped into two, in which case space (' ') is replaced
+# by newline (\n).
+LOCALEDIR=$(LC_ALL="C" "${DESTDIR}"usr/bin/localedef --help | sed -n -r '/locale path/{N;s|.*:[ \n](.*):/.*|\1|;p}')
+LOCALEDIR="${DESTDIR}${LOCALEDIR#${EPREFIX}}"
 if [[ $? -ne 0 ]] || [[ -z ${LOCALEDIR} ]] || [[ ${LOCALEDIR} != ${DESTDIR}/usr/lib*/locale ]] ; then
 	eerror "Unable to parse the output of your localedef utility." 1>&2
 	eerror "File a bug about this issue and include the output of 'localedef --help'." 1>&2
@@ -160,7 +170,7 @@ fi
 
 
 if [[ ${QUIET} -eq 0 ]] && [[ -z ${JUST_LIST} ]] && \
-   [[ -e ${ROOT}etc/locales.build ]]
+   [[ -e ${EROOT}etc/locales.build ]]
 then
 	ewarn "You should upgrade your /etc/locales.build to /etc/locale.gen"
 	ewarn "and then remove /etc/locales.build when you're done.\n"
@@ -280,7 +290,7 @@ generate_locale() {
 				-i "${input}" \
 				-f "${charmap}" \
 				-A "${ALIAS}" \
-				--prefix "${DESTDIR}" \
+				--prefix "${DESTDIR%${EPREFIX}/}/" \
 				"${locale}" 2>&1
 			ret=$?
 			[[ -n ${output} ]] && eend ${ret}