unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob 65d20f04323be3b1fb6205583d957adbc0a8137d 3735 bytes (raw)
name: guix/import/libreoffice.scm 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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.

debug log:

solving 65d20f0432 ...
found 65d20f0432 in https://yhetil.org/guix-patches/20240923123731.18571-1-ngraves@ngraves.fr/ ||
	https://yhetil.org/guix-patches/20241016170744.15991-1-ngraves@ngraves.fr/ ||
	https://yhetil.org/guix-patches/20241016170612.15587-1-ngraves@ngraves.fr/ ||
	https://yhetil.org/guix-patches/20241001145505.9409-1-ngraves@ngraves.fr/ ||
	https://yhetil.org/guix-patches/20240926075102.24531-1-ngraves@ngraves.fr/ ||
	https://yhetil.org/guix-patches/20240925074053.27623-1-ngraves@ngraves.fr/

applying [1/1] https://yhetil.org/guix-patches/20240923123731.18571-1-ngraves@ngraves.fr/
diff --git a/guix/import/libreoffice.scm b/guix/import/libreoffice.scm
new file mode 100644
index 0000000000..65d20f0432

Checking patch guix/import/libreoffice.scm...
Applied patch guix/import/libreoffice.scm cleanly.

skipping https://yhetil.org/guix-patches/20241016170744.15991-1-ngraves@ngraves.fr/ for 65d20f0432
skipping https://yhetil.org/guix-patches/20241016170612.15587-1-ngraves@ngraves.fr/ for 65d20f0432
skipping https://yhetil.org/guix-patches/20241001145505.9409-1-ngraves@ngraves.fr/ for 65d20f0432
skipping https://yhetil.org/guix-patches/20240926075102.24531-1-ngraves@ngraves.fr/ for 65d20f0432
skipping https://yhetil.org/guix-patches/20240925074053.27623-1-ngraves@ngraves.fr/ for 65d20f0432
index at:
100644 65d20f04323be3b1fb6205583d957adbc0a8137d	guix/import/libreoffice.scm

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

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).