From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59459) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fH9BN-00085t-50 for guix-patches@gnu.org; Fri, 11 May 2018 10:38:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fH9BK-0005LB-Gn for guix-patches@gnu.org; Fri, 11 May 2018 10:38:05 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:50662) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fH9BK-0005L5-DV for guix-patches@gnu.org; Fri, 11 May 2018 10:38:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fH9BK-0006wf-6H for guix-patches@gnu.org; Fri, 11 May 2018 10:38:02 -0400 Subject: [bug#31416] [PATCH 2/4] bootloader: install-u-boot: Automatically select the correct installer. Resent-Message-ID: From: Danny Milosavljevic Date: Fri, 11 May 2018 16:36:50 +0200 Message-Id: <20180511143652.26935-2-dannym@scratchpost.org> In-Reply-To: <20180511143652.26935-1-dannym@scratchpost.org> References: <20180511143515.23435-1-dannym@scratchpost.org> <20180511143652.26935-1-dannym@scratchpost.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 31416@debbugs.gnu.org * gnu/bootloader/u-boot.scm (install-u-boot): Automatically select the correct installer. --- gnu/bootloader/u-boot.scm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm index bc8f98f32..e0941c961 100644 --- a/gnu/bootloader/u-boot.scm +++ b/gnu/bootloader/u-boot.scm @@ -41,7 +41,24 @@ (define install-u-boot #~(lambda (bootloader device mount-point) (if bootloader - (error "Failed to install U-Boot")))) + (let* ((config-file-name (string-append bootloader "/libexec/.config")) + (soc (call-with-input-file config-file-name + (let loop ((line (read-line port))) + (if (not (eof-object? line)) + (let ((match + (string-match + "^CONFIG_SYS_SOC=\"([^\"]*)\"" + line))) + (if match + (match:substring match 1) + (loop (read-line port)))) + #f))))) + (match soc + ("am33xx" (install-beaglebone-black-u-boot bootloader device mount-point)) + ("mx6" (install-imx-u-boot bootloader device mount-point)) + ("sunxi" (install-allwinner-u-boot bootloader device mount-point)) + (_ (error "Failed to install U-Boot (no installation method found)" + soc))))))) (define install-beaglebone-black-u-boot ;; http://wiki.beyondlogic.org/index.php?title=BeagleBoneBlack_Upgrading_uBoot