Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VjZ35-0001IO-VM for mharc-grub-devel@gnu.org; Thu, 21 Nov 2013 13:32:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjZ33-0001IB-0y for grub-devel@gnu.org; Thu, 21 Nov 2013 13:32:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VjZ31-00042e-Me for grub-devel@gnu.org; Thu, 21 Nov 2013 13:32:16 -0500 Received: from v6.chiark.greenend.org.uk ([2001:ba8:1e3::]:56096 helo=chiark.greenend.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjZ31-00042K-FN for grub-devel@gnu.org; Thu, 21 Nov 2013 13:32:15 -0500 Received: from [172.20.153.9] (helo=riva.pelham.vpn.ucam.org) by chiark.greenend.org.uk (Debian Exim 4.72 #1) with esmtps (return-path cjwatson@ubuntu.com) id 1VjZ2z-0003oQ-T4 for grub-devel@gnu.org; Thu, 21 Nov 2013 18:32:14 +0000 Received: from ns1.pelham.vpn.ucam.org ([172.20.153.2] helo=riva.ucam.org) by riva.pelham.vpn.ucam.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1VjZ2t-0000Ps-FJ for grub-devel@gnu.org; Thu, 21 Nov 2013 18:32:07 +0000 Date: Thu, 21 Nov 2013 18:32:06 +0000 From: Colin Watson To: grub-devel@gnu.org Subject: [PATCH] Add a --locale-directory option to grub-install and related tools. Message-ID: <20131121183206.GA1595@riva.ucam.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:ba8:1e3:: X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Nov 2013 18:32:18 -0000 * include/grub/util/install.h (GRUB_INSTALL_OPTIONS): Add --locale-directory option. (enum grub_install_options): Add GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY. * util/grub-install-common.c (grub_install_help_filter): Handle GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY. (grub_install_parse): Likewise. (get_localedir): New function to check for a user-provided option before trying grub_util_get_localedir. (copy_locales): Use get_localedir rather than grub_util_get_localedir. (grub_install_copy_files): Likewise. --- ChangeLog | 17 +++++++++++++++++ include/grub/util/install.h | 4 ++++ util/grub-install-common.c | 20 ++++++++++++++++++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d4b5b2..62a4d48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,22 @@ 2013-11-21 Colin Watson + Add a --locale-directory option to grub-install and related tools. + + * include/grub/util/install.h (GRUB_INSTALL_OPTIONS): Add + --locale-directory option. + (enum grub_install_options): Add + GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY. + * util/grub-install-common.c (grub_install_help_filter): Handle + GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY. + (grub_install_parse): Likewise. + (get_localedir): New function to check for a user-provided option + before trying grub_util_get_localedir. + (copy_locales): Use get_localedir rather than + grub_util_get_localedir. + (grub_install_copy_files): Likewise. + +2013-11-21 Colin Watson + * util/grub-mkrescue.c (main): If a source directory is not specified, read platform-specific files from subdirectories of pkglibdir, not pkgdatadir. diff --git a/include/grub/util/install.h b/include/grub/util/install.h index c1cd6b3..6b0bc33 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -47,6 +47,9 @@ { "override-directory", GRUB_INSTALL_OPTIONS_DIRECTORY2, \ N_("DIR"), OPTION_HIDDEN, \ N_("use images and modules under DIR [default=%s/]"), 1 }, \ + { "locale-directory", GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY, \ + N_("DIR"), 0, \ + N_("use translations under DIR [default=%s]"), 1 }, \ { "grub-mkimage", GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE, \ "FILE", OPTION_HIDDEN, 0, 1 }, \ /* TRANSLATORS: "embed" is a verb (command description). "*/ \ @@ -100,6 +103,7 @@ enum grub_install_options { GRUB_INSTALL_OPTIONS_INSTALL_LOCALES, GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS, GRUB_INSTALL_OPTIONS_DIRECTORY2, + GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY, GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE }; diff --git a/util/grub-install-common.c b/util/grub-install-common.c index 4e1d41a..c733489 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -58,6 +58,8 @@ grub_install_help_filter (int key, const char *text, case GRUB_INSTALL_OPTIONS_DIRECTORY: case GRUB_INSTALL_OPTIONS_DIRECTORY2: return xasprintf(text, grub_util_get_pkglibdir ()); + case GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY: + return xasprintf(text, grub_util_get_localedir ()); default: return (char *) text; } @@ -217,6 +219,7 @@ struct install_list install_locales = { 1, 0, 0, 0 }; struct install_list install_fonts = { 1, 0, 0, 0 }; struct install_list install_themes = { 1, 0, 0, 0 }; char *grub_install_source_directory = NULL; +char *grub_install_locale_directory = NULL; void grub_install_push_module (const char *val) @@ -313,6 +316,10 @@ grub_install_parse (int key, char *arg) free (grub_install_source_directory); grub_install_source_directory = xstrdup (arg); return 1; + case GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY: + free (grub_install_locale_directory); + grub_install_locale_directory = xstrdup (arg); + return 1; case GRUB_INSTALL_OPTIONS_INSTALL_MODULES: handle_install_list (&install_modules, arg, 0); return 1; @@ -551,12 +558,21 @@ copy_all (const char *srcd, grub_util_fd_closedir (d); } +static const char * +get_localedir (void) +{ + if (grub_install_locale_directory) + return grub_install_locale_directory; + else + return grub_util_get_localedir (); +} + static void copy_locales (const char *dstd) { grub_util_fd_dir_t d; grub_util_fd_dirent_t de; - const char *locale_dir = grub_util_get_localedir (); + const char *locale_dir = get_localedir (); d = grub_util_fd_opendir (locale_dir); if (!d) @@ -706,7 +722,7 @@ grub_install_copy_files (const char *src, } else { - const char *locale_dir = grub_util_get_localedir (); + const char *locale_dir = get_localedir (); for (i = 0; i < install_locales.n_entries; i++) { -- 1.8.4.3