From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VuJoz-0008NW-AK for mharc-grub-devel@gnu.org; Sat, 21 Dec 2013 05:30:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VuJop-00089P-Hw for grub-devel@gnu.org; Sat, 21 Dec 2013 05:30:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VuJoh-0004s6-3N for grub-devel@gnu.org; Sat, 21 Dec 2013 05:30:03 -0500 Received: from mail-lb0-x22e.google.com ([2a00:1450:4010:c04::22e]:36284) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VuJog-0004s0-MN for grub-devel@gnu.org; Sat, 21 Dec 2013 05:29:55 -0500 Received: by mail-lb0-f174.google.com with SMTP id y6so1510716lbh.19 for ; Sat, 21 Dec 2013 02:29:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:date:in-reply-to:references:content-type :mime-version:content-transfer-encoding; bh=xiJnoRpNE1BfFBLNL4qkWZBuxvMRA2PAheRymWG5jcw=; b=aBpFNo8Z0gW6AOvIM3uNEMkAjShuNpWgFDDUr+vLr0POAWRhe2TicRV6cB9aCEFjBh SW15tA2jpFigloIhX5HPc73VFeJ2MCGuII07NtHJW9G6l42UD3bbBypmAQzTyIWu+ueE S87+xR6ii25wvLv9OfwOl5OmyoNQmjalmb6A5oj6enBdTLr4YfDbfRBGsjONFQJAcd26 qJFUr4T+E07gEi8TUXJhx0vmo7IDRRim89Rcl4UI0jQbUk/ckCCsrR4Gfa0EVfl7W/Sq jw5hYi2L8o9kwVZJoqJ0IDriiYz7Ak9Grd9m7os9O8w3xepAXGyck9JilRRGEhV9GuuI lJNw== X-Received: by 10.152.163.69 with SMTP id yg5mr939021lab.33.1387621793425; Sat, 21 Dec 2013 02:29:53 -0800 (PST) Received: from [192.168.1.44] (ppp91-76-134-134.pppoe.mtu-net.ru. [91.76.134.134]) by mx.google.com with ESMTPSA id i8sm6757923lbh.2.2013.12.21.02.29.52 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Sat, 21 Dec 2013 02:29:52 -0800 (PST) Message-ID: <1387621792.918.2.camel@opensuse.site> Subject: Re: [PATCH] add --boot-directory option to grub-mkstandalone From: Andrey Borzenkov To: grub-devel@gnu.org Date: Sat, 21 Dec 2013 14:29:52 +0400 In-Reply-To: <20131220121616.GA25815@riva.ucam.org> References: <20131213131841.GW5883@riva.ucam.org> <1386949254-7733-1-git-send-email-arvidjaar@gmail.com> <20131220121616.GA25815@riva.ucam.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::22e 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: Sat, 21 Dec 2013 10:30:12 -0000 В Пт, 20/12/2013 в 12:16 +0000, Colin Watson пишет: > On Fri, Dec 13, 2013 at 07:40:54PM +0400, Andrey Borzenkov wrote: > > > 2) make it possible for grub-mkstandalone to build images with the > > > prefix set to something other than (memdisk)/boot/grub > > > > Like below? > > Indeed, I like this general approach, and it's probably better than > fiddling around with "search". > > > I'm not keen on using --boot-directory; may be using full > > --grub-directory (without implied ../grub) will actually be more > > logical. > > I agree - I would prefer to explicitly specify the whole thing. Could > you redo the patch that way? > See below > > enum > > { > > OPTION_OUTPUT = 'o', > > - OPTION_FORMAT = 'O' > > + OPTION_FORMAT = 'O', > > + OPTION_BOOT_DIRECTORY = 0x301, > > + > > }; > > Stray newline. > Fixed > > @@ -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); > > I'd probably assign the result of that xasprintf to a variable in order > to be able to free it, for valgrind-friendliness. > Well, I could do it but as part of separate clean up patch. There are many non-freed allocations besides it. From: Andrey Borzenkov Subject: [PATCH] add --boot-directory option to grub-mkstandalone 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 | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/util/grub-mkstandalone.c b/util/grub-mkstandalone.c index 576ab40..77c1998 100644 --- a/util/grub-mkstandalone.c +++ b/util/grub-mkstandalone.c @@ -30,15 +30,19 @@ static char **files; static int nfiles; const struct grub_install_image_target_desc *format; static FILE *memdisk; +static char *grubdir; enum { OPTION_OUTPUT = 'o', - OPTION_FORMAT = 'O' + OPTION_FORMAT = 'O', + OPTION_GRUB_DIRECTORY = 0x301, }; static struct argp_option options[] = { GRUB_INSTALL_OPTIONS, + {"grub-directory", OPTION_GRUB_DIRECTORY, N_("DIR"), + 0, N_("install GRUB images under the directory DIR 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 +80,11 @@ argp_parser (int key, char *arg, struct argp_state *state) switch (key) { + case OPTION_GRUB_DIRECTORY: + free (grubdir); + grubdir = xstrdup (arg); + return 0; + case 'o': if (output_image) free (output_image); @@ -294,6 +303,9 @@ main (int argc, char *argv[]) argp_parse (&argp, argc, argv, 0, 0, 0); + if (!grubdir) + grubdir = xstrdup ("/boot/grub"); + pkglibdir = grub_util_get_pkglibdir (); if (!output_image) @@ -308,7 +320,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 (2, memdisk_dir, grubdir); grub_install_copy_files (grub_install_source_directory, boot_grub, plat); @@ -346,8 +358,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", bootdir), + output_image, memdisk_img, NULL, grub_util_get_target_name (format), 0); grub_util_unlink (memdisk_img); -- tg: (065adc3..) u/grub-directory (depends on: master)