diff options
| author | Anderson Torres <anderson.torres.8519@gmail.com> | 2026-01-16 14:28:10 -0300 |
|---|---|---|
| committer | Hilton Chain <hako@ultrarare.space> | 2026-07-25 20:50:48 +0800 |
| commit | 09d469f64aafbff1ce1e98e562dfcce12cc07d37 (patch) | |
| tree | c542d341be8ad15d08ae59998873989544a42659 | |
| parent | 2688596e16fd0b6b900d2e1c7167a9f78d3c4de3 (diff) | |
import: Add %google-chrome-updater.
* guix/import/google-chrome.scm: New file.
Signed-off-by: Hilton Chain <hako@ultrarare.space>
Co-authored-by: Hilton Chain <hako@ultrarare.space>
| -rw-r--r-- | guix/import/google-chrome.scm | 69 | ||||
| -rw-r--r-- | nongnu/packages/chrome.scm | 4 |
2 files changed, 71 insertions, 2 deletions
diff --git a/guix/import/google-chrome.scm b/guix/import/google-chrome.scm new file mode 100644 index 0000000..6746930 --- /dev/null +++ b/guix/import/google-chrome.scm | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | ;;; SPDX-License-Identifier: GPL-3.0-or-later | ||
| 2 | ;;; Copyright © 2026 Anderson Torres <anderson.torres.8519@gmail.com> | ||
| 3 | ;;; Copyright © 2026 Hilton Chain <hako@ultrarare.space> | ||
| 4 | ;;; | ||
| 5 | ;;; This file is not part of GNU Guix but requires this naming scheme so that | ||
| 6 | ;;; the %google-chrome-updater is properly read when used in Nonguix root: | ||
| 7 | ;;; | ||
| 8 | ;;; guix refresh -t google-chrome -L$(pwd) google-chrome-{stable,beta,unstable,canary} | ||
| 9 | |||
| 10 | (define-module (guix import google-chrome) | ||
| 11 | #:use-module (ice-9 textual-ports) | ||
| 12 | #:use-module (srfi srfi-1) | ||
| 13 | #:use-module (guix http-client) | ||
| 14 | #:use-module (guix memoization) | ||
| 15 | #:use-module (guix packages) | ||
| 16 | #:use-module (guix upstream) | ||
| 17 | #:export (%google-chrome-updater)) | ||
| 18 | |||
| 19 | (define http-fetch* | ||
| 20 | ;; Like http-fetch, but memoized and returning the body as a string. | ||
| 21 | (memoize (lambda args | ||
| 22 | (call-with-port (apply http-fetch args) get-string-all)))) | ||
| 23 | |||
| 24 | (define %google-chrome-control-file-url | ||
| 25 | "https://dl.google.com/linux/chrome/deb/dists/stable/main/binary-amd64/Packages") | ||
| 26 | |||
| 27 | (define (collect-package-and-version port) | ||
| 28 | (define (extract-package-or-version str) | ||
| 29 | ;; "Package: google-chrome-beta" => "google-chrome-beta" | ||
| 30 | (second (string-split str #\space))) | ||
| 31 | |||
| 32 | (let loop ((line (get-line port)) | ||
| 33 | (result '())) | ||
| 34 | (if (eof-object? line) | ||
| 35 | result | ||
| 36 | (let ((next-line (get-line port))) | ||
| 37 | (loop next-line | ||
| 38 | (if (string-prefix? "Package:" line) | ||
| 39 | (cons (cons (extract-package-or-version line) | ||
| 40 | (extract-package-or-version next-line)) | ||
| 41 | result) | ||
| 42 | result)))))) | ||
| 43 | |||
| 44 | (define* (latest-release package #:key (version #f) partial-version?) | ||
| 45 | "Return an <upstream-source> for the latest-release of PACKAGE." | ||
| 46 | (let* ((file (http-fetch* %google-chrome-control-file-url)) | ||
| 47 | (versions (call-with-input-string file collect-package-and-version)) | ||
| 48 | (name (package-name package)) | ||
| 49 | (version (or version (assoc-ref versions name)))) | ||
| 50 | (upstream-source | ||
| 51 | (package name) | ||
| 52 | (version version) | ||
| 53 | (urls | ||
| 54 | (list (string-append | ||
| 55 | "https://dl.google.com/linux/chrome/deb/pool/main/g/" name "/" | ||
| 56 | name "_" version "_amd64.deb")))))) | ||
| 57 | |||
| 58 | (define (google-chrome-package? package) | ||
| 59 | "Return #t if PACKAGE is Google Chrome." | ||
| 60 | (string-prefix? "google-chrome-" (package-name package))) | ||
| 61 | |||
| 62 | (define %google-chrome-updater | ||
| 63 | (upstream-updater | ||
| 64 | (name 'google-chrome) | ||
| 65 | (description "Updater for Google Chrome packages") | ||
| 66 | (pred google-chrome-package?) | ||
| 67 | (import latest-release))) | ||
| 68 | |||
| 69 | ;;; google-chrome.scm ends here. | ||
diff --git a/nongnu/packages/chrome.scm b/nongnu/packages/chrome.scm index 0074ee8..cdaec57 100644 --- a/nongnu/packages/chrome.scm +++ b/nongnu/packages/chrome.scm | |||
| @@ -136,6 +136,8 @@ | |||
| 136 | (home-page "https://www.google.com/chrome/") | 136 | (home-page "https://www.google.com/chrome/") |
| 137 | (license (nonfree "https://www.google.com/intl/en/chrome/terms/"))))) | 137 | (license (nonfree "https://www.google.com/intl/en/chrome/terms/"))))) |
| 138 | 138 | ||
| 139 | ;; See also (guix import google-chrome) for the `guix refresh' updater. | ||
| 140 | ;; | ||
| 139 | ;; Available versions can be here: https://chromereleases.googleblog.com | 141 | ;; Available versions can be here: https://chromereleases.googleblog.com |
| 140 | ;; The following has a nicer representation: https://deb.pkgs.org/apps/google-amd64/ | 142 | ;; The following has a nicer representation: https://deb.pkgs.org/apps/google-amd64/ |
| 141 | ;; | 143 | ;; |
| @@ -152,8 +154,6 @@ | |||
| 152 | ;; Yet another (From AUR scripts): | 154 | ;; Yet another (From AUR scripts): |
| 153 | ;; https://dl.google.com/linux/chrome/deb/dists/stable/main/binary-amd64/Packages | 155 | ;; https://dl.google.com/linux/chrome/deb/dists/stable/main/binary-amd64/Packages |
| 154 | ;; This link provides a Debian-like control file containing most recent versions. | 156 | ;; This link provides a Debian-like control file containing most recent versions. |
| 155 | ;; | ||
| 156 | ;; TODO: write a nice importer for this in Scheme. | ||
| 157 | 157 | ||
| 158 | (define-public google-chrome-stable | 158 | (define-public google-chrome-stable |
| 159 | (package | 159 | (package |
