unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Nicolas Graves via Guix-patches via <guix-patches@gnu.org>
To: 73439@debbugs.gnu.org
Cc: Nicolas Graves <ngraves@ngraves.fr>
Subject: [bug#73439] [PATCH 01/10] import: Add %libreoffice-updater.
Date: Mon, 23 Sep 2024 14:37:15 +0200	[thread overview]
Message-ID: <20240923123731.18571-1-ngraves@ngraves.fr> (raw)
In-Reply-To: <20240923122128.14126-1-ngraves@ngraves.fr>

Change-Id: I481b1175db531c4fea4a57838fe190f679cd1a85
---
 Makefile.am                 |  1 +
 guix/import/libreoffice.scm | 98 +++++++++++++++++++++++++++++++++++++
 2 files changed, 99 insertions(+)
 create mode 100644 guix/import/libreoffice.scm

diff --git a/Makefile.am b/Makefile.am
index e9801283f8..e4e4fb5a19 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -306,6 +306,7 @@ MODULES =					\
   guix/import/json.scm				\
   guix/import/kde.scm				\
   guix/import/launchpad.scm   			\
+  guix/import/libreoffice.scm 			\
   guix/import/minetest.scm   			\
   guix/import/npm-binary.scm			\
   guix/import/opam.scm				\
diff --git a/guix/import/libreoffice.scm b/guix/import/libreoffice.scm
new file mode 100644
index 0000000000..65d20f0432
--- /dev/null
+++ b/guix/import/libreoffice.scm
@@ -0,0 +1,98 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2024 Nicolas Graves <ngraves@ngraves.fr>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix import libreoffice)
+  #:use-module (web client)
+  #:use-module (sxml match)
+  #:use-module (sxml simple)
+  #:use-module (guix i18n)
+  #:use-module (guix diagnostics)
+  #:use-module (guix packages)
+  #:use-module (guix upstream)
+  #:use-module (guix utils)
+  #:use-module (ice-9 textual-ports)
+  #:use-module (srfi srfi-26)
+  #:use-module (srfi srfi-71)
+  #:export (%libreoffice-updater))
+
+(define archive-prefix
+  "https://downloadarchive.documentfoundation.org/libreoffice/old/")
+(define libreoffice-latest-url (string-append archive-prefix "latest/src/"))
+
+(define (libreoffice-latest-version)
+  (let* ((response port (http-get libreoffice-latest-url
+                                  #:streaming? #t))
+         (content (get-string-all port))
+         ;; xml->sxml is not flexible enough for html.
+         ;; For instance, <img> tags don't have closing </img>.
+         ;; This trick preprocesses html to extract all <a> tags in
+         ;; a <body> wrapper, which sxml-match can handle well.
+         (xml (xml->sxml
+               (string-append
+                "<body><"
+                (string-join
+                 (filter (cute string-prefix? "a " <>)
+                         (string-split content #\<))
+                 "</a><")
+                "></a></body>")
+               #:trim-whitespace? #t)))
+    (sxml-match
+     xml
+     ((*TOP*
+       (body
+        (a (@ (href "?C=N;O=D")) "Name")
+        (a (@ (href "?C=M;O=A")) "Last modified")
+        (a (@ (href "?C=S;O=A")) "Size")
+        (a (@ (href "/libreoffice/old/latest/")) "Parent Directory")
+        (a (@ (href ,link)) ,name)
+        . ,rest))
+      (if (and (string-prefix? "libreoffice-" name)
+               (string-suffix? ".tar.xz" name))
+          (string-drop
+           (string-drop-right name (string-length ".tar.xz"))
+           (string-length "libreoffice-"))
+          (raise
+           (formatted-message (G_ "Could not extract version from '~a'")
+                              name)))))))
+
+(define* (latest-release package #:key (version #f))
+  "Return an <upstream-source> for the latest-release of PACKAGE."
+  (let* ((name (package-name package))
+         (version (or version (libreoffice-latest-version))))
+    (upstream-source
+     (package name)
+     (version version)
+     (urls (list
+            (string-append
+             archive-prefix version "/src/libreoffice-" version ".tar.xz")
+            (string-append
+             "https://download.documentfoundation.org/libreoffice/src/"
+             (version-prefix version 3) "/libreoffice-" version ".tar.xz"))))))
+
+(define (libreoffice-package? package)
+  "Return true if PACKAGE is LibreOffice."
+  (string=? (package-name package) "libreoffice"))
+
+(define %libreoffice-updater
+  (upstream-updater
+   (name 'libreoffice)
+   (description "Updater for Libreoffice package")
+   (pred libreoffice-package?)
+   (import latest-release)))
+
+;; libreoffice.scm ends here.
-- 
2.46.0





  reply	other threads:[~2024-09-23 12:38 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-23 12:15 [bug#73439] [PATCH 00/10] Update libreoffice to its latest version Nicolas Graves via Guix-patches via
2024-09-23 12:37 ` Nicolas Graves via Guix-patches via [this message]
2024-09-23 12:37   ` [bug#73439] [PATCH 02/10] gnu: libreoffice: Update to 24.2.0.3 Nicolas Graves via Guix-patches via
2024-09-23 12:37   ` [bug#73439] [PATCH 03/10] gnu: libreoffice: Update to 24.2.1.2 Nicolas Graves via Guix-patches via
2024-09-23 12:37   ` [bug#73439] [PATCH 04/10] gnu: libreoffice: Update to 24.2.2.2 Nicolas Graves via Guix-patches via
2024-09-23 12:37   ` [bug#73439] [PATCH 05/10] gnu: libreoffice: Update to 24.2.3.2 Nicolas Graves via Guix-patches via
2024-09-23 12:37   ` [bug#73439] [PATCH 06/10] gnu: libreoffice: Update to 24.2.4.2 Nicolas Graves via Guix-patches via
2024-09-23 12:37   ` [bug#73439] [PATCH 07/10] gnu: libreoffice: Update to 24.2.5.2 Nicolas Graves via Guix-patches via
2024-09-23 12:37   ` [bug#73439] [PATCH 08/10] gnu: libreoffice: Update to 24.2.6.2 Nicolas Graves via Guix-patches via
2024-09-23 12:37   ` [bug#73439] [PATCH 09/10] gnu: libreoffice: Update to 24.8.1.2 Nicolas Graves via Guix-patches via
2024-09-23 12:37   ` [bug#73439] [PATCH 10/10] gnu: hunspell-dictionaries: " Nicolas Graves via Guix-patches via
2024-09-23 18:35 ` [bug#73439] [PATCH 00/10] Update libreoffice to its latest version Liliana Marie Prikler
2024-09-24 14:29   ` Nicolas Graves via Guix-patches via
2024-09-24 17:03     ` Liliana Marie Prikler
2024-09-25  7:52       ` Nicolas Graves via Guix-patches via
2024-09-25 15:43         ` Liliana Marie Prikler
2024-10-14 13:31         ` Simon Josefsson via Guix-patches via
2024-10-16 15:26           ` Nicolas Graves via Guix-patches via
2024-09-25  7:40 ` [bug#73439] [PATCH v2 1/5] import: Add %libreoffice-updater Nicolas Graves via Guix-patches via
2024-09-25  7:40   ` [bug#73439] [PATCH v2 2/5] gnu: libreoffice: Update to 24.2.0.3 Nicolas Graves via Guix-patches via
2024-09-25  7:40   ` [bug#73439] [PATCH v2 3/5] gnu: libreoffice: Update to 24.8.1.2 Nicolas Graves via Guix-patches via
2024-09-25  7:40   ` [bug#73439] [PATCH v2 4/5] gnu: hunspell-dictionaries: " Nicolas Graves via Guix-patches via
2024-09-25  7:40   ` [bug#73439] [PATCH v2 5/5] gnu: Add libreoffice-lts Nicolas Graves via Guix-patches via
2024-09-26  7:50 ` [bug#73439] [PATCH v3 1/4] import: Add %libreoffice-updater Nicolas Graves via Guix-patches via
2024-09-26  7:50   ` [bug#73439] [PATCH v3 2/4] gnu: libreoffice: Update to 24.2.0.3 Nicolas Graves via Guix-patches via
2024-09-26  7:50   ` [bug#73439] [PATCH v3 3/4] gnu: libreoffice: Update to 24.2.6.2 Nicolas Graves via Guix-patches via
2024-09-26  7:50   ` [bug#73439] [PATCH v3 4/4] gnu: hunspell-dictionary: " Nicolas Graves via Guix-patches via
2024-10-01 14:54 ` [bug#73439] [PATCH v4 1/4] import: Add %libreoffice-updater Nicolas Graves via Guix-patches via
2024-10-01 14:54   ` [bug#73439] [PATCH v4 2/4] gnu: libreoffice: Update to 24.2.0.3 Nicolas Graves via Guix-patches via
2024-10-01 14:54   ` [bug#73439] [PATCH v4 3/4] gnu: libreoffice: Update to 24.2.6.2 Nicolas Graves via Guix-patches via
2024-10-01 14:54   ` [bug#73439] [PATCH v4 4/4] gnu: hunspell-dictionary: " Nicolas Graves via Guix-patches via
2024-10-16 17:07 ` [bug#73439] [PATCH v5 1/5] import: Add %libreoffice-updater Nicolas Graves via Guix-patches via
2024-10-16 17:07   ` [bug#73439] [PATCH v5 2/5] gnu: libreoffice: Update to 24.2.0.3 Nicolas Graves via Guix-patches via
2024-10-16 17:07   ` [bug#73439] [PATCH v5 3/5] gnu: libreoffice: Update to 24.2.6.2 Nicolas Graves via Guix-patches via
2024-10-16 17:07   ` [bug#73439] [PATCH v5 4/5] gnu: libreoffice: Update to 24.8.2.1 Nicolas Graves via Guix-patches via
2024-11-15 16:48     ` Ludovic Courtès
2024-11-16  0:04       ` Nicolas Graves via Guix-patches via
2024-10-16 17:07   ` [bug#73439] [PATCH v5 5/5] gnu: hunspell-dictionary: " Nicolas Graves via Guix-patches via
2024-11-15 16:49     ` Ludovic Courtès
2024-10-18 12:31   ` [bug#73439] [PATCH v5 1/5] import: Add %libreoffice-updater Ludovic Courtès
2024-10-18 14:29     ` Nicolas Graves via Guix-patches via
2024-10-21 15:40       ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240923123731.18571-1-ngraves@ngraves.fr \
    --to=guix-patches@gnu.org \
    --cc=73439@debbugs.gnu.org \
    --cc=ngraves@ngraves.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).