From patchwork Wed Oct 16 17:06:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 68984 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 52A9027BBEA; Wed, 16 Oct 2024 18:07:26 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A454227BBE2 for ; Wed, 16 Oct 2024 18:07:25 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t17U9-0004ZM-MH; Wed, 16 Oct 2024 13:06:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t17Ty-0004Xp-0V for guix-patches@gnu.org; Wed, 16 Oct 2024 13:06:46 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t17Tv-0003RT-H1 for guix-patches@gnu.org; Wed, 16 Oct 2024 13:06:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:In-Reply-To:References:Subject; bh=85SIt1M0T4d53TWhbDlFi9IV8dqtJ0/FttAj7MqHNTQ=; b=QKdapIb2vlYg2wfcTxogGZ7RQBIqvpEFibg4nw4VTpnmo2Ot1FttDggPwaxvnbCIXPuUHGauD+pToVnoHdi1sQ5PW6u3GTqPA7i6nKN/cQ+CwxUuVUMxm9FITwVliP5h24mWTj4QERFrnlLwVdnPwN2Sj3Dr1GAjUyaV1e2dYsXhQtWwa2STYSSj/ohGDrCaQGw2jVEKdnRYauaC+hgSPxfppmUWhk0zRv0i9W+yJ5p8w2TbDlPbo4kQY7ARFOT6laDy7F+3Wj+35j/TS18mB3FA4C5YQRaAQaO5DVykA2yMXglke+V3Asald+hPoDanyBgzTVQ37AYCxu3ZWcNolg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t17UF-0002vK-7w for guix-patches@gnu.org; Wed, 16 Oct 2024 13:07:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#68315] [PATCH v4 1/5] import: Add %libreoffice-updater. References: <20240108080048.25026-1-ngraves@ngraves.fr> In-Reply-To: <20240108080048.25026-1-ngraves@ngraves.fr> Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 16 Oct 2024 17:07:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68315 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68315@debbugs.gnu.org Cc: Nicolas Graves Received: via spool by 68315-submit@debbugs.gnu.org id=B68315.172909840911187 (code B ref 68315); Wed, 16 Oct 2024 17:07:03 +0000 Received: (at 68315) by debbugs.gnu.org; 16 Oct 2024 17:06:49 +0000 Received: from localhost ([127.0.0.1]:60287 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t17U0-0002uK-N1 for submit@debbugs.gnu.org; Wed, 16 Oct 2024 13:06:49 -0400 Received: from 10.mo581.mail-out.ovh.net ([178.33.250.56]:43001) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t17Tr-0002tN-V8 for 68315@debbugs.gnu.org; Wed, 16 Oct 2024 13:06:43 -0400 Received: from director10.ghost.mail-out.ovh.net (unknown [10.109.140.35]) by mo581.mail-out.ovh.net (Postfix) with ESMTP id 4XTHRs5kRMz1G4t for <68315@debbugs.gnu.org>; Wed, 16 Oct 2024 17:06:17 +0000 (UTC) Received: from ghost-submission-55b549bf7b-w8jh6 (unknown [10.108.54.8]) by director10.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 377221FE3B; Wed, 16 Oct 2024 17:06:17 +0000 (UTC) Received: from ngraves.fr ([37.59.142.95]) by ghost-submission-55b549bf7b-w8jh6 with ESMTPSA id JqN1M4jyD2fUdQEASk84Lw (envelope-from ); Wed, 16 Oct 2024 17:06:17 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-95G001e74be23e-bcd4-4a42-9ff7-99182d1e9df4, BC581D0AC8476CF08C37484D3F5A4D28D157660B) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 90.110.172.34 Date: Wed, 16 Oct 2024 19:06:01 +0200 Message-ID: <20241016170612.15587-1-ngraves@ngraves.fr> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Ovh-Tracer-Id: 17476499830224708322 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeeftddrvdegledguddtlecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecunecujfgurhephffvvefufffkofggtgfgsehtkeertdertdejnecuhfhrohhmpefpihgtohhlrghsucfirhgrvhgvshcuoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqnecuggftrfgrthhtvghrnhepueeljedvgefgkeethedtfedtudffhfdvtdduudethfefhfekgfefteefhfehkefhnecuffhomhgrihhnpehgnhhurdhorhhgpdguohgtuhhmvghnthhfohhunhgurghtihhonhdrohhrghenucfkphepuddvjedrtddrtddruddpledtrdduuddtrddujedvrdefgedpfeejrdehledrudegvddrleehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpehnghhrrghvvghssehnghhrrghvvghsrdhfrhdpnhgspghrtghpthhtohepuddprhgtphhtthhopeeikeefudehseguvggssghughhsrdhgnhhurdhorhhgpdfovfetjfhoshhtpehmohehkedupdhmohguvgepshhmthhpohhuth DKIM-Signature: a=rsa-sha256; bh=85SIt1M0T4d53TWhbDlFi9IV8dqtJ0/FttAj7MqHNTQ=; c=relaxed/relaxed; d=ngraves.fr; h=From; s=ovhmo4487190-selector1; t=1729098378; v=1; b=XHotQJbZ/nztG/+3nfYDM0/a0Nl3lmkmC2K0YsVLktH/CuViqMVmh83id7VA0lLf7c2Jrwp8 dVQFr2gco36gZybwi3z3pASW0AE2LrfK7TT5VIH48KDOF8mXJ5ZVOuniF5nbp2vKMEWdMj27RuN 0MWp5socbrTrm/jMlatWY29VG3CWQoQjN2oaoLXCcb/HTFkJORUFJF7raHGatLH/XHnXNPv5mYM +Em60bMIWY/ol9gQKai8iDsY15sSQ0EbpM/Z3h2RUuY9OApNGOHguCmPA44qt/ojZLU/cUJAURq 9cMlNGkvd+uNEyAmgPnoaJaFXn3QvIayBnvM/rpkNSXjQ== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches X-Patchwork-Original-From: Nicolas Graves via Guix-patches via From: Nicolas Graves Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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 +;;; +;;; 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 . + +(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, tags don't have closing . + ;; This trick preprocesses html to extract all tags in + ;; a wrapper, which sxml-match can handle well. + (xml (xml->sxml + (string-append + "<" + (string-join + (filter (cute string-prefix? "a " <>) + (string-split content #\<)) + "<") + ">") + #: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 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.