From patchwork Thu Jan 16 20:44:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?S=C3=B6ren_Tempel?= X-Patchwork-Id: 37091 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 7A9A427BBEA; Thu, 16 Jan 2025 20:45:21 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 6BB0927BBE2 for ; Thu, 16 Jan 2025 20:45:20 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tYWjh-0007g4-8D; Thu, 16 Jan 2025 15:45:05 -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 1tYWje-0007ea-Qm for guix-patches@gnu.org; Thu, 16 Jan 2025 15:45:02 -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 1tYWje-0004TM-E5 for guix-patches@gnu.org; Thu, 16 Jan 2025 15:45:02 -0500 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=MIPS8aZIY5+I/Vjccl7nazEEqDXMBVEWWJACSxTXxfA=; b=SmnNFsUP1CPSfVBlhdRpHkHsfpc9sxtl5suVe3gjG0XOYdHTS4Adag1MpaCWHq+UG8O+hixXxWtkn2iFX/+HkzZ1sz+wlLEZax32KcCbGpowrgWIbcecvj7jKUWdYc8kNMh74b9Zy/lrtTqdEXJPmQdMAKSWZJTa3wpl60PRBbiZ3bundkBqA5q+mc1Jf7tVE9M7HMNthq3pDVE9Pn+AzOoTAhGXrUhJ0WE02a3+rqJAlG/PWQ0lW83qNbUQ5pU+XAYdsYWueGywSHdKvPwCtFObOufA4wgfmb8Axn+xpTycaPGGiiS7uncKnxMIiy/ohclCLyiJ7qYa9s2auVoF0g==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tYWje-0003Rt-91 for guix-patches@gnu.org; Thu, 16 Jan 2025 15:45:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75501] [PATCH v2] gnu: mandoc: Support zstd-compressed man pages. References: <20250111190753.32110-2-soeren@soeren-tempel.net> In-Reply-To: <20250111190753.32110-2-soeren@soeren-tempel.net> Resent-From: soeren@soeren-tempel.net Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 16 Jan 2025 20:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75501 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75501@debbugs.gnu.org Cc: ludo@gnu.org, me@tobias.gr, maxim.cournoyer@gmail.com Received: via spool by 75501-submit@debbugs.gnu.org id=B75501.173706027413199 (code B ref 75501); Thu, 16 Jan 2025 20:45:02 +0000 Received: (at 75501) by debbugs.gnu.org; 16 Jan 2025 20:44:34 +0000 Received: from localhost ([127.0.0.1]:34822 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tYWjB-0003Qp-N2 for submit@debbugs.gnu.org; Thu, 16 Jan 2025 15:44:34 -0500 Received: from magnesium.8pit.net ([45.76.88.171]:18698) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tYWj7-0003Qc-Or; Thu, 16 Jan 2025 15:44:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=opensmtpd; bh=MIPS8aZI Y5+I/Vjccl7nazEEqDXMBVEWWJACSxTXxfA=; h=date:subject:cc:to:from; d=soeren-tempel.net; b=Vr/SheVa3eYIq2VWH0MsWNvpMq47w77+qhx1gN0dnpPIMQP 2PzQbtV/uQllgAr7/YGJFPrkP7ahZcQeXWhY8mNl0LBVwgVoSzMO99l1cqgsi+Z7aySivX QMwunYWneUi3i0R9zESCtJkzZJSWiRxLU/72KtPIROayXVqINRFGzc= Received: from localhost ( [2a02:560:4d3d:df00:25e2:1fce:629a:54c5]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id f4862ba5 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Thu, 16 Jan 2025 21:44:26 +0100 (CET) From: soeren@soeren-tempel.net Date: Thu, 16 Jan 2025 21:44:08 +0100 Message-ID: X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches From: Sören Tempel Since #68242 Guix uses zstd compression for man pages. Unfortunately, upstream mandoc only supports gzip compressed man pages. Luckily, zstd provides a wrapper library which easily allows adapting software using zlib to zstd compression. This patch uses this wrapper library in conjunction with mandoc to add support for zstd compression to it, thereby allowing Guix man pages to be viewed with mandoc again. Without this patch, mandoc is essentially defunct on Guix. * gnu/packages/man.scm (mandoc): Support zstd compression. * gnu/local.mk: Add new patch. * gnu/packages/patches/mandoc-support-zstd-compression.patch: New file. --- gnu/local.mk | 1 + gnu/packages/man.scm | 54 ++++++++++------ .../mandoc-support-zstd-compression.patch | 63 +++++++++++++++++++ 3 files changed, 100 insertions(+), 18 deletions(-) create mode 100644 gnu/packages/patches/mandoc-support-zstd-compression.patch base-commit: da69a9e15115d6acc7e4a95cc6295f97c97f827e diff --git a/gnu/local.mk b/gnu/local.mk index 5fb354caae9..fef9a560284 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1807,6 +1807,7 @@ dist_patch_DATA = \ %D%/packages/patches/lxc-no-static-bin.patch \ %D%/packages/patches/mactelnet-remove-init.patch \ %D%/packages/patches/mailutils-variable-lookup.patch \ + %D%/packages/patches/mandoc-support-zstd-compression.patch \ %D%/packages/patches/make-impure-dirs.patch \ %D%/packages/patches/mariadb-rocksdb-atomic-linking.patch \ %D%/packages/patches/mathjax-disable-webpack.patch \ diff --git a/gnu/packages/man.scm b/gnu/packages/man.scm index 3148fcc8a16..1ff1fac991f 100644 --- a/gnu/packages/man.scm +++ b/gnu/packages/man.scm @@ -37,6 +37,7 @@ (define-module (gnu packages man) #:use-module (guix build-system gnu) #:use-module (guix build-system ruby) #:use-module (guix utils) + #:use-module (gnu packages) #:use-module (gnu packages base) #:use-module (gnu packages compression) #:use-module (gnu packages dbm) @@ -273,30 +274,47 @@ (define-public mandoc (method url-fetch) (uri (string-append "https://mandoc.bsd.lv/snapshots/mandoc-" version ".tar.gz")) + (patches (search-patches "mandoc-support-zstd-compression.patch")) (sha256 (base32 "174x2x9ws47b14lm339j6rzm7mxy1j3qhh484khscw0yy1qdbw4b")))) (build-system gnu-build-system) (arguments - `(#:test-target "regress" - #:phases (modify-phases %standard-phases - (add-before 'configure 'set-prefix - (lambda* (#:key outputs #:allow-other-keys) - (substitute* "configure" - (("^CC=.*") - (string-append "CC=" ,(cc-for-target) "\n")) - (("^DEFCFLAGS=\\\\\"") - "DEFCFLAGS=\"-O2 ") - (("^UTF8_LOCALE=.*") ;used for tests - "UTF8_LOCALE=en_US.UTF-8\n") - (("^MANPATH_(BASE|DEFAULT)=.*" _ which) - (string-append "MANPATH_" which "=" - "/run/current-system/profile/share/man\n")) - (("^PREFIX=.*") - (string-append "PREFIX=" (assoc-ref outputs "out") - "\n")))))))) + (list + #:test-target "regress" + #:make-flags + #~(list "VPATH=./zstd-src/zlibWrapper" + (string-join + (list "CFLAGS=-DZWRAP_USE_ZSTD=1" + "-I./zstd-src/zlibWrapper") + " ")) + #:phases + #~(modify-phases %standard-phases + (add-after 'unpack 'unpack-zstd + (lambda _ + (mkdir "zstd-src") + (invoke "tar" "--strip-components=1" "-C" + "zstd-src" "-xf" #$(package-source zstd)))) + (add-before 'configure 'set-prefix + (lambda* (#:key outputs #:allow-other-keys) + (substitute* + "configure" + (("^CC=.*") + (string-append "CC=" #$(cc-for-target) "\n")) + (("^DEFCFLAGS=\\\\\"") + "DEFCFLAGS=\"-O2 ") + (("^UTF8_LOCALE=.*") ;used for tests + "UTF8_LOCALE=en_US.UTF-8\n") + (("^MANPATH_(BASE|DEFAULT)=.*" _ which) + (string-append + "MANPATH_" which "=" + "/run/current-system/profile/share/man\n")) + (("^PREFIX=.*") + (string-append "PREFIX=" + (assoc-ref outputs "out") + "\n")))))))) (native-inputs (list (libc-utf8-locales-for-target) perl)) ;used to run tests - (inputs (list zlib)) + (inputs (list zlib (list zstd "lib"))) (native-search-paths (list (search-path-specification (variable "MANPATH") diff --git a/gnu/packages/patches/mandoc-support-zstd-compression.patch b/gnu/packages/patches/mandoc-support-zstd-compression.patch new file mode 100644 index 00000000000..3577ff0891b --- /dev/null +++ b/gnu/packages/patches/mandoc-support-zstd-compression.patch @@ -0,0 +1,63 @@ +mandoc upstream does not support zstd compression. However, Guix uses zstd +compression for its man pages, therefore—without support for this compression +method—mandoc would be quite useless. Hence, this patchset uses zlibWrapper +from the zstd project to add zstd compression support to mandoc. + +Note that upstream is presently not interested in adding support for additional +compression scheme, fourtunately, the patch is minimal and easy to maintain, see: + + https://inbox.vuxu.org/mandoc-discuss/20201129201424.GI58187@athene.usta.de/ + +diff -upr mandoc-1.14.6.orig/Makefile mandoc-1.14.6/Makefile +--- mandoc-1.14.6.orig/Makefile 2025-01-11 16:20:31.511129163 +0100 ++++ mandoc-1.14.6/Makefile 2025-01-11 19:16:35.924788821 +0100 +@@ -251,7 +251,12 @@ LIBMANDOC_OBJS = $(LIBMAN_OBJS) \ + msec.o \ + preconv.o \ + read.o \ +- tag.o ++ tag.o \ ++ zstd_zlibwrapper.o \ ++ gzclose.o \ ++ gzlib.o \ ++ gzread.o \ ++ gzwrite.o + + ALL_COBJS = compat_err.o \ + compat_fts.o \ +Only in mandoc-1.14.6: Makefile.orig +diff -upr mandoc-1.14.6.orig/configure mandoc-1.14.6/configure +--- mandoc-1.14.6.orig/configure 2025-01-11 16:20:31.511129163 +0100 ++++ mandoc-1.14.6/configure 2025-01-11 19:16:35.924788821 +0100 +@@ -430,7 +430,7 @@ fi + [ "${FATAL}" -eq 0 ] || exit 1 + + # --- LDADD --- +-LDADD="${LDADD} ${LD_NANOSLEEP} ${LD_RECVMSG} ${LD_OHASH} -lz" ++LDADD="${LDADD} ${LD_NANOSLEEP} ${LD_RECVMSG} ${LD_OHASH} -lz -lzstd" + echo "selected LDADD=\"${LDADD}\"" 1>&2 + echo "selected LDADD=\"${LDADD}\"" 1>&3 + echo 1>&3 +Only in mandoc-1.14.6: configure.orig +diff -upr mandoc-1.14.6.orig/read.c mandoc-1.14.6/read.c +--- mandoc-1.14.6.orig/read.c 2025-01-11 16:35:03.825441715 +0100 ++++ mandoc-1.14.6/read.c 2025-01-11 19:16:35.924788821 +0100 +@@ -37,7 +37,7 @@ + #include + #include + #include +-#include ++#include + + #include "mandoc_aux.h" + #include "mandoc.h" +@@ -627,7 +627,7 @@ mparse_open(struct mparse *curp, const char *file) + int fd, save_errno; + + cp = strrchr(file, '.'); +- curp->gzip = (cp != NULL && ! strcmp(cp + 1, "gz")); ++ curp->gzip = (cp != NULL && (! strcmp(cp + 1, "gz") || ! strcmp(cp + 1, "zst"))); + + /* First try to use the filename as it is. */ + +Only in mandoc-1.14.6: read.c.orig