From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VrUrf-000138-Ds for mharc-grub-devel@gnu.org; Fri, 13 Dec 2013 10:41:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrUrU-00011m-Az for grub-devel@gnu.org; Fri, 13 Dec 2013 10:41:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VrUrL-0003lv-Tm for grub-devel@gnu.org; Fri, 13 Dec 2013 10:41:08 -0500 Received: from mail-la0-x22a.google.com ([2a00:1450:4010:c03::22a]:48326) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrUrL-0003lR-Ml for grub-devel@gnu.org; Fri, 13 Dec 2013 10:40:59 -0500 Received: by mail-la0-f42.google.com with SMTP id ec20so1510935lab.1 for ; Fri, 13 Dec 2013 07:40:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=SvlpheDyzgFRt3wmHWsGt88EJnXKbqiOHdZBKdrUZ9w=; b=s+QobqQziEMrc9gYag2m6oOs02L5pdQjxiAnYwPMjHr0VQVafwxrrx/541SZQESc2c fNUFCr81c1m+GhiSMwn2e113SJ1I2v+BuiwVCpDuI9qNeXLOqyEVg8dZC6qf8nzIc9Da udjGHaZkkIVLHQt0906nGkTJNXIxGm4wxyeOnrcPl62U6am/tgxpEborGIn+IjwXX8SC jWNYnuRuVTb7OzHlZw4TS7xElp/3/UyweUPVkVq8R/pALihs9LW+CTr1/NUoclNsXUgi BjvfyROi5uxbKA6KC0d4bG0b+rK03hI22S8SZ2RCljOFfZbyt9Vhv+vphPPkVMFVd0iN YvZA== X-Received: by 10.152.22.228 with SMTP id h4mr366319laf.71.1386949258450; Fri, 13 Dec 2013 07:40:58 -0800 (PST) Received: from localhost.localdomain (ppp91-76-134-134.pppoe.mtu-net.ru. [91.76.134.134]) by mx.google.com with ESMTPSA id ld10sm5270480lab.8.2013.12.13.07.40.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Dec 2013 07:40:57 -0800 (PST) From: Andrey Borzenkov To: grub-devel@gnu.org Subject: [PATCH] add --boot-directory option to grub-mkstandalone Date: Fri, 13 Dec 2013 19:40:54 +0400 Message-Id: <1386949254-7733-1-git-send-email-arvidjaar@gmail.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <20131213131841.GW5883@riva.ucam.org> References: <20131213131841.GW5883@riva.ucam.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22a 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: Fri, 13 Dec 2013 15:41:16 -0000 > 2) make it possible for grub-mkstandalone to build images with the > prefix set to something other than (memdisk)/boot/grub Like below? I'm not keen on using --boot-directory; may be using full --grub-directory (without implied ../grub) will actually be more logical. --- This allows changing of hardcoded /boot/grub path on memory disk so it does not conflict with on-disk /boot directories. Suggested by Colin Watson --- util/grub-mkstandalone.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/util/grub-mkstandalone.c b/util/grub-mkstandalone.c index 6ee5e58..3cb5d7c 100644 --- a/util/grub-mkstandalone.c +++ b/util/grub-mkstandalone.c @@ -30,15 +30,20 @@ static char **files; static int nfiles; const struct grub_install_image_target_desc *format; static FILE *memdisk; +static char *bootdir; enum { OPTION_OUTPUT = 'o', - OPTION_FORMAT = 'O' + OPTION_FORMAT = 'O', + OPTION_BOOT_DIRECTORY = 0x301, + }; static struct argp_option options[] = { GRUB_INSTALL_OPTIONS, + {"boot-directory", OPTION_BOOT_DIRECTORY, N_("DIR"), + 0, N_("install GRUB images under the directory DIR/grub instead of the /boot/grub directory"), 2}, {"output", 'o', N_("FILE"), 0, N_("save output in FILE [required]"), 2}, {"format", 'O', N_("FILE"), 0, 0, 2}, @@ -76,6 +81,11 @@ argp_parser (int key, char *arg, struct argp_state *state) switch (key) { + case OPTION_BOOT_DIRECTORY: + free (bootdir); + bootdir = xstrdup (arg); + return 0; + case 'o': if (output_image) free (output_image); @@ -294,6 +304,9 @@ main (int argc, char *argv[]) argp_parse (&argp, argc, argv, 0, 0, 0); + if (!bootdir) + bootdir = xstrdup ("/boot"); + pkglibdir = grub_util_get_pkglibdir (); if (!output_image) @@ -308,7 +321,7 @@ main (int argc, char *argv[]) enum grub_install_plat plat = grub_install_get_target (grub_install_source_directory); char *memdisk_dir = grub_util_make_temporary_dir (); - char *boot_grub = grub_util_path_concat (3, memdisk_dir, "boot", "grub"); + char *boot_grub = grub_util_path_concat (3, memdisk_dir, bootdir, "grub"); grub_install_copy_files (grub_install_source_directory, boot_grub, plat); @@ -346,8 +359,8 @@ main (int argc, char *argv[]) grub_install_push_module ("tar"); grub_install_make_image_wrap (grub_install_source_directory, - "(memdisk)/boot/grub", output_image, - memdisk_img, NULL, + xasprintf ("(memdisk)%s/%s", bootdir, "grub"), + output_image, memdisk_img, NULL, grub_util_get_target_name (format), 0); grub_util_unlink (memdisk_img); -- tg: (0df77d7..) u/grub-directory (depends on: master)