From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 4F/6EGgyt17cDAAA0tVLHw (envelope-from ) for ; Sat, 09 May 2020 22:44:56 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id aBznIHUyt15EeAAAB5/wlQ (envelope-from ) for ; Sat, 09 May 2020 22:45:09 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 475FD940B28 for ; Sat, 9 May 2020 22:45:07 +0000 (UTC) Received: from localhost ([::1]:57970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXYDS-0002CQ-Hh for larch@yhetil.org; Sat, 09 May 2020 18:45:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXYDO-0002CJ-I9 for guix-patches@gnu.org; Sat, 09 May 2020 18:45:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36994) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jXYDO-0000Kc-88 for guix-patches@gnu.org; Sat, 09 May 2020 18:45:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jXYDO-0003uT-4E for guix-patches@gnu.org; Sat, 09 May 2020 18:45:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41163] [PATCH] gnu: grub: Allow a PNG image and replace (aspect-ratio) with (resolution). Resent-From: Stefan Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 09 May 2020 22:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 41163 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 41163@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.158906426914964 (code B ref -1); Sat, 09 May 2020 22:45:01 +0000 Received: (at submit) by debbugs.gnu.org; 9 May 2020 22:44:29 +0000 Received: from localhost ([127.0.0.1]:48540 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jXYCr-0003tI-Ct for submit@debbugs.gnu.org; Sat, 09 May 2020 18:44:29 -0400 Received: from lists.gnu.org ([209.51.188.17]:35014) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jXYCp-0003tA-Gk for submit@debbugs.gnu.org; Sat, 09 May 2020 18:44:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXYCp-0002AD-92 for guix-patches@gnu.org; Sat, 09 May 2020 18:44:27 -0400 Received: from mx009.vodafonemail.xion.oxcs.net ([153.92.174.39]:5597) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXYCn-0007lv-Fc for guix-patches@gnu.org; Sat, 09 May 2020 18:44:26 -0400 Received: from vsmx002.vodafonemail.xion.oxcs.net (unknown [192.168.75.192]) by mta-6-out.mta.xion.oxcs.net (Postfix) with ESMTP id 6606F6057CE for ; Sat, 9 May 2020 22:44:19 +0000 (UTC) Received: from macbook-pro.kuh-wiese.my-router.de (unknown [90.186.146.103]) by mta-6-out.mta.xion.oxcs.net (Postfix) with ESMTPA id 283A06057D7 for ; Sat, 9 May 2020 22:44:16 +0000 (UTC) From: Stefan Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Message-Id: Date: Sun, 10 May 2020 00:44:16 +0200 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) X-Mailer: Apple Mail (2.3124) X-VADE-STATUS: LEGIT Received-SPF: pass client-ip=153.92.174.39; envelope-from=stefan-guix@vodafonemail.de; helo=mx009.vodafonemail.xion.oxcs.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/09 18:44:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x (no timestamps) [generic] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -2.3 (--) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 X-Spam-Score: 0.99 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Scan-Result: default: False [0.99 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.5397610697225]; MX_INVALID(1.00)[cached]; DWL_DNSWL_FAIL(0.00)[209.51.188.17:server fail]; R_SPF_ALLOW(-0.20)[+ip4:209.51.188.0/24:c]; MV_CASE(0.50)[]; TO_DN_NONE(0.00)[]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.09), country: US(-0.00), ip: 209.51.188.17(-0.54)]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[90.186.146.103:received]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:22989, ipnet:209.51.188.0/24, country:US]; MIME_TRACE(0.00)[0:+]; TAGGED_FROM(0.00)[larch=yhetil.org]; ARC_NA(0.00)[]; FROM_NEQ_ENVFROM(0.00)[stefan-guix@vodafonemail.de,guix-patches-bounces@gnu.org]; FROM_HAS_DN(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[vodafonemail.de]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; DNSWL_BLOCKED(0.00)[209.51.188.17:from]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.51.188.17:from]; RCVD_COUNT_SEVEN(0.00)[11]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: NqwizKTuHbF8 * gnu/bootloaders/grub.scm ()[resolution]: Replacement of = the 'aspect-ratio' field. ()[image]: Replacement of the 'images' field. (svg->png): Remove default-values for 'width' and 'height' and only do = the conversion with them, if the suffix of the file is actually ".svg". Using image formats different to SVG was not possible. For a to be chosen, the 'aspect-ratio' of it had to be 4/3, = as the resolution of any image was defaulting to 1024 x 768. There was no code yet to determine the proper boot-resolution, to make = any use of a list of images with different aspect-ratios. It seems to be a better solution to only define a single image with any = format, and use a given resolution only for the conversion from a SVG file. Moving the default values from '%background-image' and '%default-theme' = into and makes a customisation easier without = (inherit) and allows to deprecate %background-image' and '%default-theme'. --- gnu/bootloader/grub.scm | 74 +++++++++++++++++++---------------------- gnu/system.scm | 1 + 2 files changed, 36 insertions(+), 39 deletions(-) diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 67736724a7..c70c3e260d 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -40,12 +40,12 @@ #:use-module (srfi srfi-2) #:export (grub-image grub-image? - grub-image-aspect-ratio + grub-image-resolution grub-image-file =20 grub-theme grub-theme? - grub-theme-images + grub-theme-image grub-theme-color-normal grub-theme-color-highlight =20 @@ -82,34 +82,28 @@ denoting a file name." (define-record-type* grub-image make-grub-image grub-image? - (aspect-ratio grub-image-aspect-ratio ;rational number - (default 4/3)) - (file grub-image-file)) ;file-valued gexp = (SVG) + (resolution grub-image-resolution + (default '(1024 . 768))) + (file grub-image-file + (default (file-append %artwork-repository + = "/grub/GuixSD-fully-black-4-3.svg")))) =20 (define-record-type* + ;; Default theme contributed by Felipe L=C3=B3pez. grub-theme make-grub-theme grub-theme? - (images grub-theme-images - (default '())) ;list of + (image grub-theme-image + (default (grub-image))) (color-normal grub-theme-color-normal - (default '((fg . cyan) (bg . blue)))) + (default '((fg . light-gray) (bg . black)))) (color-highlight grub-theme-color-highlight - (default '((fg . white) (bg . blue)))) + (default '((fg . yellow) (bg . black)))) (gfxmode grub-gfxmode (default '("auto")))) ;list of string =20 -(define %background-image - (grub-image - (aspect-ratio 4/3) - (file (file-append %artwork-repository - "/grub/GuixSD-fully-black-4-3.svg")))) +(define %background-image (grub-image)) =20 -(define %default-theme - ;; Default theme contributed by Felipe L=C3=B3pez. - (grub-theme - (images (list %background-image)) - (color-highlight '((fg . yellow) (bg . black))) - (color-normal '((fg . light-gray) (bg . black))))) ;XXX: #x303030 +(define %default-theme (grub-theme)) =20 ^L ;;; @@ -117,32 +111,34 @@ denoting a file name." ;;; =20 (define (bootloader-theme config) - "Return user defined theme in CONFIG if defined or %default-theme + "Return user defined theme in CONFIG if defined or a default theme otherwise." - (or (bootloader-configuration-theme config) %default-theme)) + (or (bootloader-configuration-theme config) (grub-theme))) =20 (define* (svg->png svg #:key width height) - "Build a PNG of HEIGHT x WIDTH from SVG." + "Build a PNG of HEIGHT x WIDTH from SVG if its file suffix is = \".svg\". +Otherwise the picture in SVG is just copied." (computed-file "grub-image.png" (with-imported-modules '((gnu build svg)) (with-extensions (list guile-rsvg guile-cairo) - #~(begin - (use-modules (gnu build svg)) - (svg->png #+svg #$output - #:width #$width - #:height #$height)))))) - -(define* (grub-background-image config #:key (width 1024) (height 768)) - "Return the GRUB background image defined in CONFIG with a ratio of -WIDTH/HEIGHT, or #f if none was found." - (let* ((ratio (/ width height)) - (image (find (lambda (image) - (=3D (grub-image-aspect-ratio image) ratio)) - (grub-theme-images - (bootloader-theme config))))) + #~(if (string-suffix? ".svg" #+svg) + (begin + (use-modules (gnu build svg)) + (svg->png #+svg #$output + #:width #$width + #:height #$height)) + (copy-file #+svg #$output)))))) + +(define* (grub-background-image config) + "Return the GRUB background image defined in CONFIG or #f if none was = found. +If the suffix of the image file is \".svg\", then it is converted into = a PNG +file with the resolution provided in CONFIG." + (let* ((image (grub-theme-image (bootloader-theme config)))) (and image - (svg->png (grub-image-file image) - #:width width #:height height)))) + (let ((resolution (grub-image-resolution image))) + (svg->png (grub-image-file image) + #:width (car resolution) + #:height (cdr resolution)))))) =20 (define* (eye-candy config store-device store-mount-point #:key port) --=20 2.26.0