GNU bug report logs - #76661
[PATCH 1/1] guix appstream: New script.

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Noé Lopez <noe@HIDDEN>; Keywords: patch; merged with #76662; dated Sat, 1 Mar 2025 16:46:01 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.
Merged 76661 76662. Request was from Noé Lopez <noe@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 76661 <at> debbugs.gnu.org:


Received: (at 76661) by debbugs.gnu.org; 1 Mar 2025 16:54:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 01 11:54:50 2025
Received: from localhost ([127.0.0.1]:42355 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1toQ6z-0003Z4-ON
	for submit <at> debbugs.gnu.org; Sat, 01 Mar 2025 11:54:50 -0500
Received: from smtp.domeneshop.no ([2a01:5b40:0:3006::1]:46616)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <noe@HIDDEN>)
 id 1toQ6w-0003Y7-2k; Sat, 01 Mar 2025 11:54:47 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=xn--no-cja.eu; s=ds202502; h=Content-Type:MIME-Version:Message-ID:Date:To:
 From:From:Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:
 Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description:
 Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
 In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=PwzRnsI7Q0MZA5UqemPiLeFUfL5U9niJAwdBA3rVHMM=; b=oQdQo2Oh7Zc1WRpXi6O427RnEq
 AdDr5r6E1kjIdsCFUMgz0UTI0uPplxO5KwU+LYAVAfPZ2uJDHNIdMx5zR2rmvJyE8ZTIjL8a+swUN
 v5aDH7Mgx2m5p1uQrpVLD/vxjEDTRjZ5nD1gl/JzBcZt13gZWf7pNDyij8stxB46Dw5HRN4UfS46D
 06VYVDiV+ckp/Upgxo2hD8q0vGTcPAbH8aglwfrl2ybTy4qb5hELHHQewOaXSxgvw8tF7qb2Z2dON
 n1pPRkHyKO6S/IV3zLo0nteA8xoIhAYUA/vAIOvK1pZVrwz3Y28v0cSxtbQ+11aLbtzdSmXgOgyVr
 iQw/wO0w==;
Received: from smtp by smtp.domeneshop.no with esmtpsa (TLS1.3) tls
 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95)
 id 1toQ6p-00802H-Vn; Sat, 01 Mar 2025 17:54:40 +0100
From: =?utf-8?Q?No=C3=A9_Lopez?= <noe@HIDDEN>
To: control <at> debbugs.gnu.org, 76661 <at> debbugs.gnu.org, 76662 <at> debbugs.gnu.org
Date: Sat, 01 Mar 2025 17:54:38 +0100
Message-ID: <87ikosk7xt.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha256; protocol="application/pgp-signature"
X-Spam-Score: 2.0 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  merge 76661 76662 thanks 
 Content analysis details:   (2.0 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 SPF_PASS               SPF: sender matches SPF record
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 1.8 MISSING_SUBJECT        Missing Subject: header
 0.2 NO_SUBJECT             Extra score for no subject
X-Debbugs-Envelope-To: 76661
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

--=-=-=
Content-Type: text/plain

merge 76661 76662
thanks

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQHGBAEBCAAwFiEEXVTPJVeyOOiNwYCiLSIyQQq3QEMFAmfDO84SHG5vZUB4bi0t
bm8tY2phLmV1AAoJEC0iMkEKt0BD2i8L/jyVEwciT1pIEsd+vBAFT3b7yqje+CU2
tvTX/BSQS2lzINbwCyVtnPTIucLfjjYFrLe3N5rNy9Nyfo52UzqNp5BZ06ZoBERP
fclbK8zO1JA8ETdqvjNylL0UwRTOmNZgnnOwkzUMNoOMTTzy2Jc/cJmsCiPxfn/G
KCDU5ODYLjkqsZJOVsushuJnanes3TcrLrO9FLlsvbuisKx9jLzh3mIr1aaVwHeE
DFmIKKNn6KcMbbU9tQcSkaxw6+rdtSLNeIN7GU+w/JOoHeBPpevRJ6jwaE2tvU4B
LJdwYTjRnrzUl2w6cOKAzQ2m9uSu2S98/rr97/p8kRq0gEkWCyGdP+CAcYNaxVW2
YUHWxbxS82e7pmzK7Stq4ikILnFWCGdIZHornhaLXXhPqeWnKeesQ8O9O1qs4ofp
xQ1a+Bq8nwCTY7qodrK1sXAUotV9UFuIBulPUbVjmV+OoJlgCmdlBDtrvEYSuBRJ
+hrtxe2/t0VTpIE0pyeGqZK1Tu6Er0tCgA==
=DGgu
-----END PGP SIGNATURE-----
--=-=-=--




Information forwarded to guix-patches@HIDDEN:
bug#76661; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 1 Mar 2025 16:45:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 01 11:45:39 2025
Received: from localhost ([127.0.0.1]:42248 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1toPy5-0002ik-Fy
	for submit <at> debbugs.gnu.org; Sat, 01 Mar 2025 11:45:39 -0500
Received: from lists.gnu.org ([2001:470:142::17]:44342)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <noe@HIDDEN>) id 1toPy2-0002hy-NK
 for submit <at> debbugs.gnu.org; Sat, 01 Mar 2025 11:45:35 -0500
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 <noe@HIDDEN>) id 1toPxx-0004xw-28
 for guix-patches@HIDDEN; Sat, 01 Mar 2025 11:45:29 -0500
Received: from smtp.domeneshop.no ([2a01:5b40:0:3006::1])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <noe@HIDDEN>) id 1toPxu-0002rS-41
 for guix-patches@HIDDEN; Sat, 01 Mar 2025 11:45:28 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=xn--no-cja.eu; s=ds202502; h=Content-Transfer-Encoding:Content-Type:
 MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:From:
 Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:
 Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:
 Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:
 References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:
 List-Owner:List-Archive; bh=KTqGt7+mCpc345eelPYZXMvx+DlxfiH6gSE/lpastnc=; b=E
 QcbWY5yxRyjKzHs7ohQPAvSQUTDCGtcjfEkK39xfX3DbF0mhG2JDTF/LilqAnlDGm1cRVIVudTgle
 PUCYPr9E0UlNwL/AOZyv6A5kKqaGNdA7HBgn6MQBcjjkSolVSsPbqHruLwEt71FxkpF8fh5FJ8a04
 1ICA7McWuyw9GMEANKaSawH0QHJySy/W/dvISb+wMZnfV2j6Oo1NRDHXIGMYSmJnYa9bORDR0/abX
 n3eWi6y2TzfgNS2g4w3lFL4HI9J2ml1wCOu+RHmRAhCnb56rp17XaQZ7hzQ485OWlYsth3bMPr8At
 QbyUUguKc7vdWEgumoBhRqkttqnWtSf6Q==;
Received: from smtp by smtp.domeneshop.no with esmtpsa (TLS1.3) tls
 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95)
 id 1toPxs-007xzn-LZ; Sat, 01 Mar 2025 17:45:24 +0100
From: =?UTF-8?q?No=C3=A9=20Lopez?= <noe@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH 1/1] guix appstream: New script.
Date: Sat,  1 Mar 2025 17:44:46 +0100
Message-ID: <7eaad478e8a4a5468ad9268a656e3fd480a5be83.1740845771.git.noelopez@HIDDEN>
In-Reply-To: <cover.1740845771.git.noelopez@HIDDEN>
References: <cover.1740845771.git.noelopez@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=2a01:5b40:0:3006::1;
 envelope-from=noe@HIDDEN; helo=smtp.domeneshop.no
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
Cc: =?UTF-8?q?No=C3=A9=20Lopez?= <noe@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

From: Noé Lopez <noelopez@HIDDEN>

* Makefile.am (MODULES): Add (guix scripts appstream).
* guix/import/utils.scm (license->spdx-string): New function.
* guix/scripts/appstream.scm: New script.

Change-Id: Ie6246b0d46d2796664944657349edd3de3f6596c
---
 Makefile.am                |   1 +
 guix/import/utils.scm      |  14 +++++
 guix/scripts/appstream.scm | 125 +++++++++++++++++++++++++++++++++++++
 3 files changed, 140 insertions(+)
 create mode 100644 guix/scripts/appstream.scm

diff --git a/Makefile.am b/Makefile.am
index f759803b8b..95529ca88d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -319,6 +319,7 @@ MODULES =					\
   guix/import/texlive.scm   			\
   guix/import/utils.scm				\
   guix/scripts.scm				\
+  guix/scripts/appstream.scm			\
   guix/scripts/download.scm			\
   guix/scripts/perform-download.scm		\
   guix/scripts/build.scm			\
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 6f5efa790e..5d63415435 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -72,6 +72,7 @@ (define-module (guix import utils)
             package->definition
 
             spdx-string->license
+            license->spdx-string
             license->symbol
 
             snake-case
@@ -308,6 +309,19 @@ (define (spdx-string->license str)
           ;; GNU licenses (see above).  Here, we handle other uses of +.
           (spdx-string->license (string-drop-right str 1))))))
 
+(define (license->spdx-string license)
+  "Convert LICENSE to an SPDX license identifier. Return #f if LICENSE does not match
+any known SPDX license identifiers."
+  (let ((license (license->symbol license)))
+    (let loop ((licenses %spdx-license-identifiers))
+      (cond
+       ((null? licenses)
+        #f)
+       ((eq? license (cdr (car licenses)))
+        (car (car licenses)))
+       (else
+        (loop (cdr licenses)))))))
+
 (define (license->symbol license)
   "Convert LICENSE object to a prefixed symbol representing the variable the
 object is bound to in the (guix licenses) module, such as 'license:gpl3+, or
diff --git a/guix/scripts/appstream.scm b/guix/scripts/appstream.scm
new file mode 100644
index 0000000000..6ba60d811b
--- /dev/null
+++ b/guix/scripts/appstream.scm
@@ -0,0 +1,125 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2025 Noé Lopez <noelopez@HIDDEN>
+;;;
+;;; 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 scripts appstream)
+  #:use-module ((gnu packages package-management) #:select (current-guix))
+  #:use-module ((guix config) #:select (%system))
+  #:use-module ((guix import utils) #:select (license->spdx-string))
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (gnu packages)
+  #:use-module (guix gexp)
+  #:use-module (guix modules)
+  #:use-module (guix monads)
+  #:use-module (guix packages)
+  #:use-module (guix progress)
+  #:use-module (guix store)
+  #:use-module (guix scripts)
+  #:use-module (guix ui)
+  #:use-module (ice-9 match)
+  #:use-module (sxml simple)
+  #:use-module (srfi srfi-37)
+  #:export (guix-appstream))
+
+(define %repo-id (string-append "guix-" (package-version (current-guix))))
+
+(define (appstream-catalog reporter)
+  (sxml->xml (packages->catalog reporter)))
+
+(define (packages->catalog reporter)
+  (let ((components
+         (fold-packages
+          (lambda (package result)
+            (reporter)
+            (cons (package->component package) result))
+          '())))
+    `(components (@ (version "0.14")
+                    (origin ,%repo-id))
+                 ,components)))
+
+(define (package->component package)
+  `(component (@ (type "desktop-application"))   ;apps don’t appear in gnome software if we don’t set this…
+    ;; FIXME: version?
+    (id ,(string-append (package-name package))) ;ideally should be rDNS
+    (name ,(package-name package))
+    (pkgname ,(package-name package))
+    (project_license ,(licenses->project-license (package-license package)))
+    (summary ,(package-synopsis-string package))
+    ;;FIXME: handle markup https://www.freedesktop.org/software/appstream/docs/chap-CatalogData.html#tag-ct-description
+    (description ,(package-description-string package))
+    (url (@ (type "homepage"))
+            ,(package-home-page package))))
+
+(define (licenses->project-license licenses)
+  (cond
+   ((list? licenses)
+    (string-join (map license->project-license licenses) " AND ")) ;could be OR, but we don’t know
+   (else
+    (license->project-license licenses))))
+
+(define (license->project-license license)
+  (cond
+   ((eq? license #f)
+    "LicenseRef-proprietary")           ;shouldn’t happen, of course
+   (else
+    (or (license->spdx-string license)
+        (license-ref-for-uri (license:license-uri license))))))
+
+(define (license-ref-for-uri uri)
+  (if uri
+    (string-append "LicenseRef=" uri)
+    "LicenseRef"))
+
+(define package-count (length (all-packages)))
+(define progress-bar (progress-reporter/bar package-count (G_ "Processing packages")))
+
+
+(define (show-help)
+  (display (G_ "Usage: guix appstream [OPTION]...
+Generate an appstream catalog of all available packages."))
+  (newline)
+  (display (G_ "
+  -h, --help             display this help and exit"))
+  (display (G_ "
+  -V, --version          display version information and exit"))
+  (newline)
+  (show-bug-report-information))
+
+(define %options
+  ;; Specification of the command-line options.
+  (list (option '(#\h "help") #f #f
+                (lambda args
+                  (leave-on-EPIPE (show-help))
+                  (exit 0)))
+        (option '(#\V "version") #f #f
+                (lambda args
+                  (show-version-and-exit "guix appstream")))))
+
+(define-command (guix-appstream . args)
+  (synopsis "generate an appstream catalog")
+
+  (define opts
+    (parse-command-line args %options '(())
+                        #:build-options? #f))
+  (define output-file (string-append %repo-id ".xml"))
+
+  (call-with-progress-reporter progress-bar
+    (lambda (reporter)
+      (with-output-to-file output-file
+        (lambda ()
+          (appstream-catalog reporter)))))
+  (simple-format #t (G_ "Created ~a with ~a packages~%") output-file package-count))
-- 
2.48.1





Acknowledgement sent to Noé Lopez <noe@HIDDEN>:
New bug report received and forwarded. Copy sent to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN. Full text available.
Report forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#76661; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 1 Mar 2025 17:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.