From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:5f26::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id gNxWEAnilmVtkgAAkFu2QA (envelope-from ) for ; Thu, 04 Jan 2024 17:51:21 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id uM3rCwnilmWzBQAAqHPOHw (envelope-from ) for ; Thu, 04 Jan 2024 17:51:21 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=kQpjiRTn; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1704387080; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=U1VUaYj9q2fqTmycjhUiIHy5KObjtlKMu8Eo6Cz5gUc=; b=GZ7AV+AiLr8b5qJnRSSIEcDLXBvryj3czv4jo49KhRT5VT8gIb3HAD4a8VFzCmNUBUhY1D 0giUkj5ygz0uxtuUevmaGxJVOohn9TVHYmiUBsTYOVQrNEqlCMLlL8Uc6zqy5TeE1/nVcX nx3Hg0pmYIJg4bze11mV+YzwkA6Mbnm7Toqv4nR7sYc9OL6pTnE4ifBvCYmj9I+1lD9Mvl 3C+Tm2x1YKaQ9DTPl6Ntb0o0oHMMl41nC8Fv5ujWSY0orfF0Dyp+iSxv387x9tAQXjnTcJ cTI4TbsWsYf+DTCBw/pAcFeYDKfejWWODQI6o059tbfS44ncpF/d3yIWrGP23w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=kQpjiRTn; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1704387080; a=rsa-sha256; cv=none; b=u126W3f+NIQjOt7JcrXven5jVRdJJFIA7F+xARENByWxH8MdXZayr8G+yTHvv/cIjCqkzo R7gKFly9vS47B8CmDQAOvfOIY5NMCprkmBvz3Sn5kyX5TZUrYvL5Iw/h4gv/b+lwgH/Lx5 aduumukcu+X2zPsaE1NDpsPyaYzctia//ZnMsG9FNs6PL1NSrKkeylNUlITbay9a6H5zUt LJ5bs/RwnmqO5OrmPkOZ+tgVgdLTF04q5s2BCM+TEsS/cGpxYqB/Ss1LiLhSjRuvUl7HH0 e/HOWvAbK+2xWxU0dIPw/HbK7pYwurMZOvya9cg6L8CVyzcqo3AxTIk2cqSqsw== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B53AA51716 for ; Thu, 4 Jan 2024 17:51:20 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rLQvy-0003WN-W1; Thu, 04 Jan 2024 11:51:07 -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 ) id 1rLQvx-0003Ue-7n for guix-patches@gnu.org; Thu, 04 Jan 2024 11:51:05 -0500 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 1rLQvv-0001Tf-FV; Thu, 04 Jan 2024 11:51:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rLQvw-0005Wt-BZ; Thu, 04 Jan 2024 11:51:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68242] [PATCH 5/5] man-db: Add support for zstd compressed man pages. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Thu, 04 Jan 2024 16:51:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68242 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68242@debbugs.gnu.org Cc: Maxim Cournoyer , Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 68242-submit@debbugs.gnu.org id=B68242.170438700921154 (code B ref 68242); Thu, 04 Jan 2024 16:51:04 +0000 Received: (at 68242) by debbugs.gnu.org; 4 Jan 2024 16:50:09 +0000 Received: from localhost ([127.0.0.1]:55556 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLQv2-0005V4-Rg for submit@debbugs.gnu.org; Thu, 04 Jan 2024 11:50:09 -0500 Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]:61552) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLQv0-0005To-5S for 68242@debbugs.gnu.org; Thu, 04 Jan 2024 11:50:07 -0500 Received: by mail-qt1-x82c.google.com with SMTP id d75a77b69052e-4280e3ab14fso4219031cf.2 for <68242@debbugs.gnu.org>; Thu, 04 Jan 2024 08:50:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704386996; x=1704991796; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U1VUaYj9q2fqTmycjhUiIHy5KObjtlKMu8Eo6Cz5gUc=; b=kQpjiRTnPEMMP3HLCbu/ZqmTQUHa3TjNzNwNLrp21/S9CyFKrh2Cra48lrzmeH39rz k/oouXMO9HlNPKpoCVwhxHWOo4r8GlurTI2RZKC/ZH4C7bnLpe+Hjawo/b5XqLBn3aV0 Mn3sx1/5uQ7bWfllzoSUAAZ+Wogl+8HB6OzFo+g8qIazxu/ke/Z7thUyqy5LixVC8Afa 4/F0FuLTAAOywZSeVsvAlrXThB1wibuUoUh1/SFy2K4h5Itk1DNp9w1pOKM0O7KbMgnE n/Ix3J3IZMtafSQR20f55Pk59jWtahtyuAT6a3nJfZJJrOcI1OpCi+Ox8p+INLkqfmGI OZ4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704386996; x=1704991796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U1VUaYj9q2fqTmycjhUiIHy5KObjtlKMu8Eo6Cz5gUc=; b=mWOqMntJw/KD87lNwM3nAmladlcy3tt1eT0VTXCTthdQ9B0LiKV3peQ3h2vzdIepJa LSeQyEVbBg0q+Nonol4IAjOGDgXaplQ1ta2r7gpj7eViSY8YEssyBuRKEKLUnTVkgW+o 4XFMaHloeAInULFuMMPergjX5hHGvlvX0CqCab0SvbbQe7ZGYswecnoyIjxSMl6U2L0H Bk1Iz+SdRbK8IWPiuNXtSVQIKCo/9MQ2knL4urMjs7T/uCumfqfYfxPrw2Vte3I/r54S RbOjNEV9cHuuIzE6HAi5exbJ/dJ2ZsIzOzEyEcO1aQ1fI9CYzF2tLWpZsiSIJqAPc5f7 TS8w== X-Gm-Message-State: AOJu0YyonF9InIXhn+cxTj+aSADqoTif3wUEBVU5horpgKHVm8G+YRU6 UbAqmLPVXaFliNRZp0Jvsk64ys4vMQIqDw== X-Google-Smtp-Source: AGHT+IF93doo9qXtuKzVZPx1eBU1ULGpuSqMPliUYCZG3gPA/Dex6NQ9C/hQHzmfqVzG6EdITS1UPA== X-Received: by 2002:a05:6214:262f:b0:680:d30a:d599 with SMTP id gv15-20020a056214262f00b00680d30ad599mr955397qvb.69.1704386996381; Thu, 04 Jan 2024 08:49:56 -0800 (PST) Received: from localhost.localdomain (dsl-10-135-125.b2b2c.ca. [72.10.135.125]) by smtp.gmail.com with ESMTPSA id o2-20020a0cecc2000000b0067aab230ed9sm11854706qvq.21.2024.01.04.08.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 08:49:56 -0800 (PST) From: Maxim Cournoyer Date: Thu, 4 Jan 2024 11:48:21 -0500 Message-ID: <44d6f0f8471ad290a78c102228352481a131f60f.1704386901.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: -3.67 X-Spam-Score: -3.67 X-Migadu-Queue-Id: B53AA51716 X-TUID: yrrjgez1/58W * guix/man-db.scm (): Adjust comment. (abbreviate-file-name): Adjust regexp. (gz-compressed?, zstd-compressed?): New predicates. (entry->string): Use them. (man-page->entry): Adjust doc. Use input port reader appropriate to the compression type, if any. (man-files): Adjust regexp. (mandb-entries): Adjust link resolving predicate. * guix/profiles.scm (manual-database): Add guile-zlib extension. Change-Id: I6336e46e2d324c520a7d15d6cafd12bbf43c5b09 --- guix/man-db.scm | 45 +++++++++++++++++++++++++++++++++++---------- guix/profiles.scm | 8 ++++++-- 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/guix/man-db.scm b/guix/man-db.scm index 7d9707a592..12887ce400 100644 --- a/guix/man-db.scm +++ b/guix/man-db.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017, 2018 Ludovic Courtès +;;; Copyright © 2022, 2024 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -18,6 +19,7 @@ (define-module (guix man-db) #:use-module (zlib) + #:use-module (zstd) #:use-module ((guix build utils) #:select (find-files)) #:use-module (gdbm) ;gdbm-ffi #:use-module (srfi srfi-9) @@ -48,7 +50,7 @@ (define-module (guix man-db) (define-record-type (mandb-entry file-name name section synopsis kind) mandb-entry? - (file-name mandb-entry-file-name) ;e.g., "../abiword.1.gz" + (file-name mandb-entry-file-name) ;e.g., "../abiword.1.zst" (name mandb-entry-name) ;e.g., "ABIWORD" (section mandb-entry-section) ;number (synopsis mandb-entry-synopsis) ;string @@ -63,7 +65,7 @@ (define (mandb-entrystring entry) "Return the wire format for ENTRY as a string." (match entry @@ -92,7 +102,11 @@ (define (entry->string entry) "\t-\t-\t" - (if (string-suffix? ".gz" file) "gz" "") + (cond + ((gzip-compressed? file) "gz") + ((zstd-compressed? file) "zst") + (else "")) + "\t" synopsis "\x00")))) @@ -148,7 +162,8 @@ (define (read-synopsis port) (loop (cons line lines)))))) (define* (man-page->entry file #:optional (resolve identity)) - "Parse FILE, a gzipped man page, and return a for it." + "Parse FILE, a gzip or zstd compressed man page, and return a +for it." (define (string->number* str) (if (and (string-prefix? "\"" str) (> (string-length str) 1) @@ -156,8 +171,13 @@ (define* (man-page->entry file #:optional (resolve identity)) (string->number (string-drop (string-drop-right str 1) 1)) (string->number str))) - ;; Note: This works for both gzipped and uncompressed files. - (call-with-gzip-input-port (open-file file "r0") + (define call-with-input-port* + (cond + ((gzip-compressed? file) call-with-gzip-input-port) + ((zstd-compressed? file) call-with-zstd-input-port) + (else call-with-port))) + + (call-with-input-port* (open-file file "r0") (lambda (port) (let loop ((name #f) (section #f) @@ -191,14 +211,19 @@ (define* (man-page->entry file #:optional (resolve identity)) (define (man-files directory) "Return the list of man pages found under DIRECTORY, recursively." ;; Filter the list to ensure that broken symlinks are excluded. - (filter file-exists? (find-files directory "\\.[0-9][a-z]?(\\.gz)?$"))) + (filter file-exists? + (find-files directory "\\.[0-9][a-z]?(\\.(gz|zst))?$"))) (define (mandb-entries directory) "Return mandb entries for the man pages found under DIRECTORY, recursively." (map (lambda (file) (man-page->entry file (lambda (link) - (let ((file (string-append directory "/" link - ".gz"))) - (and (file-exists? file) file))))) + (let ((file-gz (string-append directory "/" link + ".gz")) + (file-zst (string-append directory "/" link + ".zst"))) + (and (or (file-exists? file-gz) + (file-exists? file-zst) file) + file))))) (man-files directory))) diff --git a/guix/profiles.scm b/guix/profiles.scm index da7790d819..7fa5dab62a 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -7,7 +7,7 @@ ;;; Copyright © 2016, 2017, 2018, 2019, 2021, 2022 Ricardo Wurmus ;;; Copyright © 2016 Chris Marusich ;;; Copyright © 2017 Huang Ying -;;; Copyright © 2017, 2021 Maxim Cournoyer +;;; Copyright © 2017, 2021, 2024 Maxim Cournoyer ;;; Copyright © 2019 Kyle Meyer ;;; Copyright © 2019 Mathieu Othacehe ;;; Copyright © 2020 Danny Milosavljevic @@ -1701,6 +1701,9 @@ (define* (manual-database manifest #:optional system) (define guile-zlib (module-ref (resolve-interface '(gnu packages guile)) 'guile-zlib)) + (define guile-zstd + (module-ref (resolve-interface '(gnu packages guile)) 'guile-zstd)) + (define modules (delete '(guix config) (source-module-closure `((guix build utils) @@ -1709,7 +1712,8 @@ (define* (manual-database manifest #:optional system) (define build (with-imported-modules modules (with-extensions (list gdbm-ffi ;for (guix man-db) - guile-zlib) + guile-zlib + guile-zstd) #~(begin (use-modules (guix man-db) (guix build utils) -- 2.41.0