From unknown Tue Jun 24 05:09:03 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#75501 <75501@debbugs.gnu.org> To: bug#75501 <75501@debbugs.gnu.org> Subject: Status: [PATCH] gnu: mandoc: Support zstd-compressed man pages. Reply-To: bug#75501 <75501@debbugs.gnu.org> Date: Tue, 24 Jun 2025 12:09:03 +0000 retitle 75501 [PATCH] gnu: mandoc: Support zstd-compressed man pages. reassign 75501 guix-patches submitter 75501 soeren@soeren-tempel.net severity 75501 normal tag 75501 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 11 14:10:35 2025 Received: (at submit) by debbugs.gnu.org; 11 Jan 2025 19:10:35 +0000 Received: from localhost ([127.0.0.1]:44935 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tWgsU-0006vo-Ne for submit@debbugs.gnu.org; Sat, 11 Jan 2025 14:10:35 -0500 Received: from lists.gnu.org ([2001:470:142::17]:43214) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tWgsS-0006vN-3R for submit@debbugs.gnu.org; Sat, 11 Jan 2025 14:10:32 -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 1tWgsK-0004ji-EH for guix-patches@gnu.org; Sat, 11 Jan 2025 14:10:24 -0500 Received: from magnesium.8pit.net ([45.76.88.171]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tWgsH-000144-Gr; Sat, 11 Jan 2025 14:10:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=opensmtpd; bh=gCVpSxgw PbxjqKboSWaAGuUh1QA+16x7ay2Qf/7JnQo=; h=date:subject:to:from; d=soeren-tempel.net; b=lbXl0gGB2TKDoi1YU/935mqVrDTOkpBuC0zjWRNHJFln+Kf EDf1Y5Any0jzUzT0FAO8ZaWJLmzi4iemwcOd7Xhn48j9up0J9rKshwxZ4XlFLUtvVDhTme CtlhtqkXqi27g3bTH0qf07rGT5Aup7z3vsLmM7D7MkVrqwJhvGN4ow= Received: from localhost ( [2a02:560:4d3d:df00:dc2b:c47d:2594:21b8]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id 3e834283 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Sat, 11 Jan 2025 20:10:15 +0100 (CET) From: soeren@soeren-tempel.net To: guix-patches@gnu.org Subject: [PATCH] gnu: mandoc: Support zstd-compressed man pages. Date: Sat, 11 Jan 2025 20:07:52 +0100 Message-ID: <20250111190753.32110-2-soeren@soeren-tempel.net> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 X-Debbugs-Cc: maxim.cournoyer@gmail.com, me@tobias.gr, ludo@gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=45.76.88.171; envelope-from=soeren@soeren-tempel.net; helo=magnesium.8pit.net 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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) 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. * gnu/packages/man.scm (mandoc): Support zstd compression. * gnu/local.mk: Add new patch. * gnu/packages/patches/mandoc-support-zstd-compression.patch: New file. --- Without this patch, mandoc is essentially defunct on Guix. You cannot view any Guix man pages with mandoc presently because of this issue. gnu/local.mk | 1 + gnu/packages/man.scm | 47 +++++++++------ .../mandoc-support-zstd-compression.patch | 58 +++++++++++++++++++ 3 files changed, 89 insertions(+), 17 deletions(-) create mode 100644 gnu/packages/patches/mandoc-support-zstd-compression.patch diff --git a/gnu/local.mk b/gnu/local.mk index f118fe4442..c8bfe47509 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1799,6 +1799,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 3148fcc8a1..c62568e515 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,42 @@ (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")))))))) + #:make-flags + (list "VPATH=./zstd-src/zlibWrapper" + (string-join + (list "CFLAGS=-DZWRAP_USE_ZSTD=1" + (string-append "-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 0000000000..b8cbeb6782 --- /dev/null +++ b/gnu/packages/patches/mandoc-support-zstd-compression.patch @@ -0,0 +1,58 @@ +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. + +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 From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 15 00:10:10 2025 Received: (at 75501) by debbugs.gnu.org; 15 Jan 2025 05:10:10 +0000 Received: from localhost ([127.0.0.1]:56581 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tXvfO-0007NQ-5E for submit@debbugs.gnu.org; Wed, 15 Jan 2025 00:10:10 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:56511) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tXvfJ-0007Mk-FI for 75501@debbugs.gnu.org; Wed, 15 Jan 2025 00:10:08 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-2163b0c09afso115562635ad.0 for <75501@debbugs.gnu.org>; Tue, 14 Jan 2025 21:10:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736917799; x=1737522599; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=52+EbrdH4ZhO8q9Gj3t4KHeGbKPQAIY64DTkWEWVh3g=; b=VwQo1oDzOers7icQPQoR07nbjEC+2oRAINHYCBNXhg5yH4nfI33CuygyGX6IQSY2sF eDmlHfF7wUa3EnJjdTY/v414EbdgWe/9fRvz7YOqUnh/RlgOSb29OR8t6ubaVbAj5bWa uvJuUH2lgAOYDN4neViydBXxLQGgzutyx/cf9LX1WxXItOflojK0hsaLENTRu/soD4Pi AZu+i+6Z5VHa/bD4ICruie9glr+Oz69qVw02MD/jrJjJYy9EtiFU2K9ePDYaU6SDWT7r sggVZOhx/+Ub8ilG/2WtMdZXlM8DpjpOZ0Z4ZbPQ/9Hh3oNvrQac0p32sNHh1HzAPKC7 rZwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736917799; x=1737522599; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=52+EbrdH4ZhO8q9Gj3t4KHeGbKPQAIY64DTkWEWVh3g=; b=gdjkV8w06rzaADbKMDR1Sx1cQp5oO5QXXdVeG6YNjyA4ROT2c0lNayTQJEyolDzMvb QhniTPY1hhqZZKY/GBEs3il7QFgBWCssNSBKQswC1UbyE0OZ65AeqWb+qJDLERXsmRl7 L+aDZwzI/ieO6Pn2IJrdCctJc3zSGY7p+W9tpvP7AKkrqhxTwHhhSQ3eJf0iqXmwMq+Y VJuXHZG3NH5Mj5Y2GGYPb6xE7eqck8/nOyj8+5U13TOhSjYlS9XDtiQKM0U5ViB8RBs3 9K1TDbim9/sQrNgrjvjPVyx7aPdR9xdriufs90I7f9rDMp6Vx6p6iRoKz3KCzAYID3el kEJg== X-Gm-Message-State: AOJu0YxCsPk/k4Myx+MzSnXJ58NgLiRAW0bNiqw4BfhKiyson1YW2m+A uKwMEApjYRplX68c6Nb3y+xR5t7yqUdhA3bDZrq5kbVQF/uFnCzq X-Gm-Gg: ASbGncsIPqla6u/MD50Hca0+UsyNwYaDtSRT3plt2fVG7zYKTptt9Ctc+32wD7FjGbs p0YeQG0ZUYWNA5ANSOJ1M+r91915/H/BIgwSh0IOUwxy2pdRyv/9zOqoH+DaptsLug1nOkDiCp+ qJJyeX5fE6JkGm5XSGUwVnvNCAwHDZbVlWpPAexGLWcLhNQ/hUVwjQrUXit5fK27O0zIq5FJDg7 q3qf7vIea/BH6Y3jd8Mlh5Af3DTsQbeaVjv9KGdVNjol0WHH7e8fA== X-Google-Smtp-Source: AGHT+IEUxcKJvmdQxuCsEwohr3l0K1g2EZHJ3dH6OVQpK0YiSXhPmfSAgsPIYNKBD3qsKoFNDYUZ3Q== X-Received: by 2002:a17:90b:538e:b0:2ee:3cc1:793a with SMTP id 98e67ed59e1d1-2f548f580femr39526346a91.29.1736917799012; Tue, 14 Jan 2025 21:09:59 -0800 (PST) Received: from terra ([2405:6586:be0:0:c8ff:1707:9b9:af89]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f72c20f503sm432956a91.38.2025.01.14.21.09.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 21:09:58 -0800 (PST) From: Maxim Cournoyer To: soeren@soeren-tempel.net Subject: Re: [bug#75501] [PATCH] gnu: mandoc: Support zstd-compressed man pages. In-Reply-To: <20250111190753.32110-2-soeren@soeren-tempel.net> (soeren@soeren-tempel.net's message of "Sat, 11 Jan 2025 20:07:52 +0100") References: <20250111190753.32110-2-soeren@soeren-tempel.net> Date: Wed, 15 Jan 2025 14:09:47 +0900 Message-ID: <87zfjsd5no.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 75501 Cc: me@tobias.gr, ludo@gnu.org, 75501@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello! soeren@soeren-tempel.net writes: > From: S=C3=B6ren 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. Oh! I have never used mandoc, only man-db. > * gnu/packages/man.scm (mandoc): Support zstd compression. > * gnu/local.mk: Add new patch. > * gnu/packages/patches/mandoc-support-zstd-compression.patch: New > file. [...] > (arguments > `(#:test-target "regress" > - #:phases (modify-phases %standard-phases > - (add-before 'configure 'set-prefix > - (lambda* (#:key outputs #:allow-other-keys) > - (substitute* "configure" > - (("^CC=3D.*") > - (string-append "CC=3D" ,(cc-for-target) "\n")) > - (("^DEFCFLAGS=3D\\\\\"") > - "DEFCFLAGS=3D\"-O2 ") > - (("^UTF8_LOCALE=3D.*") ;used for tests > - "UTF8_LOCALE=3Den_US.UTF-8\n") > - (("^MANPATH_(BASE|DEFAULT)=3D.*" _ which) > - (string-append "MANPATH_" which "=3D" > - "/run/current-system/profile/sha= re/man\n")) > - (("^PREFIX=3D.*") > - (string-append "PREFIX=3D" (assoc-ref outputs "= out") > - "\n")))))))) > + #:make-flags > + (list "VPATH=3D./zstd-src/zlibWrapper" > + (string-join > + (list "CFLAGS=3D-DZWRAP_USE_ZSTD=3D1" > + (string-append "-I./zstd-src/zlibWrapper")) > + " ")) > + #:phases ,#~(modify-phases %standard-phases > + (add-after 'unpack 'unpack-zstd > + (lambda _ > + (mkdir "zstd-src") > + (invoke "tar" "--strip-components=3D1" "-C" "zs= td-src" > + "-xf" #$(package-source zstd)))) > + (add-before 'configure 'set-prefix > + (lambda* (#:key outputs #:allow-other-keys) > + (substitute* "configure" > + (("^CC=3D.*") > + (string-append "CC=3D" #$(cc-for-target) "\n= ")) > + (("^DEFCFLAGS=3D\\\\\"") > + "DEFCFLAGS=3D\"-O2 ") > + (("^UTF8_LOCALE=3D.*") ;used for tests > + "UTF8_LOCALE=3Den_US.UTF-8\n") > + (("^MANPATH_(BASE|DEFAULT)=3D.*" _ which) > + (string-append "MANPATH_" which "=3D" > + "/run/current-system/profile/= share/man\n")) > + (("^PREFIX=3D.*") > + (string-append "PREFIX=3D" (assoc-ref output= s "out") > + "\n")))))))) While moving things around, I'd use a plain list for the arguments, and format the phases under the #:phases argument (newline), to satisfy our max 80 columns of width convention. > (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 0000000000..b8cbeb6782 > --- /dev/null > +++ b/gnu/packages/patches/mandoc-support-zstd-compression.patch > @@ -0,0 +1,58 @@ > +mandoc upstream does not support zstd compression. However, Guix uses zs= td > +compression for its man pages, therefore=E2=80=94without support for thi= s compression > +method=E2=80=94mandoc would be quite useless. Hence, this patchset uses = zlibWrapper > +from the zstd project to add zstd compression support to mandoc. Interesting solution! The issue should be ideally be brought upstream though, and referenced here. With the leading implementation man-db having gained zstd support, others should follow suite. They may be interested in using your solution, or otherwise adding "native" support for it. Could you please create such an issue with them, cross-reference it in your patch, and send a v2? --=20 Thanks, Maxim From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 16 15:44:34 2025 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 To: 75501@debbugs.gnu.org Subject: [PATCH v2] gnu: mandoc: Support zstd-compressed man pages. Date: Thu, 16 Jan 2025 21:44:08 +0100 Message-ID: X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 75501 Cc: ludo@gnu.org, me@tobias.gr, maxim.cournoyer@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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 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 base-commit: da69a9e15115d6acc7e4a95cc6295f97c97f827e From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 16 15:53:39 2025 Received: (at 75501) by debbugs.gnu.org; 16 Jan 2025 20:53:39 +0000 Received: from localhost ([127.0.0.1]:34855 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tYWry-0003sE-N0 for submit@debbugs.gnu.org; Thu, 16 Jan 2025 15:53:39 -0500 Received: from magnesium.8pit.net ([45.76.88.171]:44545) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tYWrv-0003ry-UQ for 75501@debbugs.gnu.org; Thu, 16 Jan 2025 15:53:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=opensmtpd; bh=J1h3XOxv NmpNLNJlVS2NpMfyY06xxiRAdmjemoI3lSQ=; h=in-reply-to:references:from: subject:cc:to:date; d=soeren-tempel.net; b=Om2a+jSB71ApunQ52zecLTDj2US C8xnJ7vPI10Y8Jg4ajpLPSZA9qJd3T15zisJiBBDz1UgwxWc7yY/uS9PoGsoBRGDcYZnIz VaaXUQjtA8/idsgalocwbQCqmwjKZwm0UHjS30cV71YsFcvFlQ2FV7obziBOj9YcZtr4DC 8YMw= Received: from localhost ( [2a02:560:4d3d:df00:25e2:1fce:629a:54c5]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id 2f5dd629 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Thu, 16 Jan 2025 21:53:33 +0100 (CET) Date: Thu, 16 Jan 2025 21:53:32 +0100 To: Maxim Cournoyer Subject: Re: [bug#75501] [PATCH] gnu: mandoc: Support zstd-compressed man pages. From: =?UTF-8?Q?S=C3=B6ren?= Tempel References: <20250111190753.32110-2-soeren@soeren-tempel.net> <87zfjsd5no.fsf@gmail.com> In-Reply-To: <87zfjsd5no.fsf@gmail.com> Message-Id: <3GW4TH6POR7DJ.393NEMAQAI01C@8pit.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 75501 Cc: me@tobias.gr, ludo@gnu.org, 75501@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello Maxim, thank you for having a look at the patch and your fast feedback! Maxim Cournoyer wrote: > While moving things around, I'd use a plain list for the arguments, and > format the phases under the #:phases argument (newline), to satisfy our > max 80 columns of width convention. Changed accordingly in the v2 that I just send. > Interesting solution! The issue should be ideally be brought upstream > though, and referenced here. With the leading implementation man-db > having gained zstd support, others should follow suite. They may be > interested in using your solution, or otherwise adding "native" support > for it. >=20 > Could you please create such an issue with them, cross-reference it in > your patch, and send a v2? Having worked with upstream mandoc before, I doubt that they would be interested in implementing additional compression schemes. mandoc is an OpenBSD project, and OpenBSD doesn't compress its man pages. Usually, its hard to convince them to add features that do not benefit OpenBSD. Specifically, regarding compression there is a prior thread on adding bzip2 where the mandoc maintainer states =E2=80=9Ccompressing manual pages makes absolutely no sense to me [=E2=80=A6]=E2=80=9D: https://inbox.vuxu.org/mandoc-discuss/20201129201424.GI58187@athene.usta.d= e/ The Guix patch is very small so that I don't see any issue with maintaining it downstream for the foreseeable future. Nonetheless, I added a link to the aforementioned thread to the patch description. If it is a requirement, I can create another =E2=80=9Ccompression support= =E2=80=9D thread on their ML but I would prefer to use my time elsewhere. Greetings S=C3=B6ren From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 19 02:12:17 2025 Received: (at 75501) by debbugs.gnu.org; 19 Jan 2025 07:12:17 +0000 Received: from localhost ([127.0.0.1]:44645 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tZPTl-0004Vw-3h for submit@debbugs.gnu.org; Sun, 19 Jan 2025 02:12:17 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:57695) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tZPTi-0004Vb-2P for 75501@debbugs.gnu.org; Sun, 19 Jan 2025 02:12:15 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-21628b3fe7dso61725275ad.3 for <75501@debbugs.gnu.org>; Sat, 18 Jan 2025 23:12:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737270728; x=1737875528; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZRKtNwyyDsvvotneGaSHCbWMhlzpNVB0WKlw6Q6qRzo=; b=Fx+ZqQPYGF2E/KavXyhEIMWOsCDadzu6amsrhSuY8A9rRccacJd7qsv4GPLM0mFqaF z+8Vz5azIxU23DPoEqAh9Bs/jNSWX5Ng8vUoj/2+NmD+wqFfjtp0yU3EYV6v2iN4ghl9 kug/OHpKbRaFHZ9DqJ9fjXwjQbDK/TdnyEjFH9MSmVBixOa9GzNgsPLbuNKCmFdWepH/ shmrWep1r9DNrk3elMq9p+2P5G6l6F6Qa0IuX8vI147xSJ/nqoFunvxaP/Ap00ENXPSg Bt4941zTxKb1N+6M/hY2j9pFe82Q/gzvDO5mT2zbCa/cQaq/sqr+xHg04gdXnLWqj2Lt BqWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737270728; x=1737875528; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ZRKtNwyyDsvvotneGaSHCbWMhlzpNVB0WKlw6Q6qRzo=; b=QYwiVk3nbLBRGc94ZScGDaXueCA9MKFuIRjsl91Vtpzzn3kqlp5QvV11jjq77jOhAW eox2vwqTNb8Q3D4wE+UwytCJX2GrUxNMoxqgAnM7frK2aS4rDOpWwU5G9uW4BM+b8V5j pLT766vHFPZgEKOtEytXDmIAjzcrhxizg63KFgpST7aUbsa7rYLC59D/yatI7TBDDcAS EX+02fyrKlBsIAkn57XADVottAvbIl64VcH5Xt0nlx0rCL7cxnh76H+119ssLGLOIsHo 6st0pQXLJluBVBHsCXoB5lajKW/hRW4gXLzCeD1PH1DMQmJz/qgFZaoU7YIdh4JcDFoT BM0A== X-Gm-Message-State: AOJu0YxQNkIupn0E3aD/uFudFSsueiUvEvM8KQ0Aw2Ty1L5FN2ZGWNfz Fc2PLT4bkKKkI9AGZLpyig3Gq/D8oO+kNS70GhP5eqr0v/Qfya2M X-Gm-Gg: ASbGnctBVTqYxclj3kmRlI6NflLkL23IVWPcPPS1ZbEIbCFB68Xrs53Msq6RUxjJbwP +SovVkg2tULQ2zwQ/NzahsYoH2WTzJ+d/vd9N/EsOKLth46eX1f73ovZS9VNxlXww08Jp1amxPZ G603EOaFm4Ege/7aTfvoMGxmG05DzVUcxMOgBclWpz1OnbVFKZolGcCfYi8hXFGCdSy3YzbppUf thwkqvjydPscL7cxqswFVPVQVotyIzrawgpvSJFuMfkO+QoS/GTdHxqWShIjAsg4s4= X-Google-Smtp-Source: AGHT+IEU3mlmQ2J/dusjSOPlg3VxPc4VHL03GeSMlv4Fkxyxs5fI7o4r5/Q1TkKI7bDIzM1mmtTdjw== X-Received: by 2002:a17:903:1246:b0:216:2abc:194f with SMTP id d9443c01a7336-21c355c6546mr130256875ad.40.1737270726934; Sat, 18 Jan 2025 23:12:06 -0800 (PST) Received: from terra ([2405:6586:be0:0:c8ff:1707:9b9:af89]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21c2d3ac3e2sm39822455ad.139.2025.01.18.23.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Jan 2025 23:12:04 -0800 (PST) From: Maxim Cournoyer To: =?utf-8?Q?S=C3=B6ren?= Tempel Subject: Re: [bug#75501] [PATCH] gnu: mandoc: Support zstd-compressed man pages. In-Reply-To: <3GW4TH6POR7DJ.393NEMAQAI01C@8pit.net> (=?utf-8?Q?=22S=C3=B6r?= =?utf-8?Q?en?= Tempel"'s message of "Thu, 16 Jan 2025 21:53:32 +0100") References: <20250111190753.32110-2-soeren@soeren-tempel.net> <87zfjsd5no.fsf@gmail.com> <3GW4TH6POR7DJ.393NEMAQAI01C@8pit.net> Date: Sun, 19 Jan 2025 16:11:54 +0900 Message-ID: <877c6r9t1h.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 75501 Cc: me@tobias.gr, ludo@gnu.org, 75501@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi S=C3=B6ren, S=C3=B6ren Tempel writes: > Hello Maxim, > > thank you for having a look at the patch and your fast feedback! > > Maxim Cournoyer wrote: >> While moving things around, I'd use a plain list for the arguments, and >> format the phases under the #:phases argument (newline), to satisfy our >> max 80 columns of width convention. > > Changed accordingly in the v2 that I just send. > >> Interesting solution! The issue should be ideally be brought upstream >> though, and referenced here. With the leading implementation man-db >> having gained zstd support, others should follow suite. They may be >> interested in using your solution, or otherwise adding "native" support >> for it. >>=20 >> Could you please create such an issue with them, cross-reference it in >> your patch, and send a v2? > > Having worked with upstream mandoc before, I doubt that they would be > interested in implementing additional compression schemes. mandoc is an > OpenBSD project, and OpenBSD doesn't compress its man pages. Usually, > its hard to convince them to add features that do not benefit OpenBSD. I see. I think just at least a mention of that issue and a pointer to the solution devised for Guix would be useful to share with upstream, in case it'd motivate them to address it themselves. You could argue why mandoc is such a great piece of software that you want to use it over man-db on other systems than OpenBSD, they may soften a bit on their position, ha! > Specifically, regarding compression there is a prior thread on adding > bzip2 where the mandoc maintainer states =E2=80=9Ccompressing manual pages > makes absolutely no sense to me [=E2=80=A6]=E2=80=9D: > > https://inbox.vuxu.org/mandoc-discuss/20201129201424.GI58187@athene.usta= .de/ Interesting position, but a bit extreme. It's true that a few megabytes saved are not the end of the world, especially if users are using full disk compression such as Btrfs + Zstd, but it's still a plus in my book. I had done some limited number crunching in [0], which found zstd mildy better at compressing man pages than zstd (about 10% size reduction), and 1.5x faster at decompressing. [0] https://issues.guix.gnu.org/68242#16 > If it is a requirement, I can create another =E2=80=9Ccompression support= =E2=80=9D > thread on their ML but I would prefer to use my time elsewhere. I'd encourage you to do so, whatever the outcome. --=20 Thanks, Maxim From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 28 10:56:45 2025 Received: (at 75501) by debbugs.gnu.org; 28 Jan 2025 15:56:45 +0000 Received: from localhost ([127.0.0.1]:38134 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tcnxF-0005Lw-4h for submit@debbugs.gnu.org; Tue, 28 Jan 2025 10:56:45 -0500 Received: from magnesium.8pit.net ([2001:19f0:6c01:4ae:5400:ff:fe66:af9d]:28600) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tcnxB-0005Ld-W0; Tue, 28 Jan 2025 10:56:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=opensmtpd; bh=gmBs9b7Y Zqj1jTPNn6Leixw/oTyRUuMTOF1N9uM9kag=; h=date:subject:cc:to:from; d=soeren-tempel.net; b=YMiBxDId420F0EOVUxN1ZqJOnzg4cisHBf3zmMYVofXTb4O zRtPBBG8TwCbvfH6BL+MYXHQaTuNg4PHMN5GIUyv3Mw0yaIDJ8YVOF55yWwKzdBYsCAPxD mv58mfrNJVrORb0TN7VKF4jH5fTkQcimi2rEoSJlXqZfGWsHsZUGOo= Received: from localhost ( [2a02:560:4d3d:df00:c88a:55fa:1d58:8939]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id b884d0f7 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Tue, 28 Jan 2025 16:56:37 +0100 (CET) From: soeren@soeren-tempel.net To: 75501@debbugs.gnu.org Subject: [PATCH v3] gnu: mandoc: Support zstd-compressed man pages. Date: Tue, 28 Jan 2025 16:55:48 +0100 Message-ID: X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 75501 Cc: maxim.cournoyer@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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. --- Change since v2: Update reference to the upstream ML in the patch 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 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..1c0ded56e4d --- /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/Z5i0H+XrKVrZqAXB@asta-kit.de/T/#t + +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 base-commit: da69a9e15115d6acc7e4a95cc6295f97c97f827e From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 28 10:58:15 2025 Received: (at 75501) by debbugs.gnu.org; 28 Jan 2025 15:58:15 +0000 Received: from localhost ([127.0.0.1]:38150 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tcnyg-0005PK-QC for submit@debbugs.gnu.org; Tue, 28 Jan 2025 10:58:15 -0500 Received: from magnesium.8pit.net ([45.76.88.171]:34776) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tcnye-0005PA-RY for 75501@debbugs.gnu.org; Tue, 28 Jan 2025 10:58:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=opensmtpd; bh=5s43kOTy qWtal5cJCkAIUY7jXY4EhquuePqt3c6fqto=; h=in-reply-to:references:from: subject:cc:to:date; d=soeren-tempel.net; b=JKfjpQNFasN2/mqT4dmZ214Xlhi 58pb7Ni88PqxIyeAQl2vYrpgKLdlkKZM0M7ivTMAGHpJdrhWjaO0fZlIUWvIm+LjYccrpV ROZEZRLF+I7imxW2MCUSILfAkluXtmT/E6mQWY1TKGwRCx+GMAiadaU8SIpBqk6+aOurbV qlso= Received: from localhost ( [2a02:560:4d3d:df00:c88a:55fa:1d58:8939]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id 78193ded (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Tue, 28 Jan 2025 16:58:11 +0100 (CET) Date: Tue, 28 Jan 2025 16:58:11 +0100 To: Maxim Cournoyer Subject: Re: [bug#75501] [PATCH] gnu: mandoc: Support zstd-compressed man pages. From: =?UTF-8?Q?S=C3=B6ren?= Tempel References: <20250111190753.32110-2-soeren@soeren-tempel.net> <87zfjsd5no.fsf@gmail.com> <3GW4TH6POR7DJ.393NEMAQAI01C@8pit.net> <877c6r9t1h.fsf@gmail.com> In-Reply-To: <877c6r9t1h.fsf@gmail.com> Message-Id: <3L85LLP66SB0W.3KHGVB0OS294N@8pit.net> User-Agent: NeoMutt/20230322 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 75501 Cc: me@tobias.gr, ludo@gnu.org, 75501@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Maxim Cournoyer wrote: > Hi S=C3=B6ren, Hello Maxim, > I see. I think just at least a mention of that issue and a pointer to > the solution devised for Guix would be useful to share with upstream, in > case it'd motivate them to address it themselves. As requested, I did just that. There is a new thread on the mandoc mailing list which discusses zstd compression support: https://inbox.vuxu.org/mandoc-discuss/Z5i0H+XrKVrZqAXB@asta-kit.de/T/#t Feel free to add to it. I also send a v3 which updates the patch comment accordingly to point to this thread. Is there anything else that needs to be addressed? Greetings S=C3=B6ren From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 29 08:19:08 2025 Received: (at 75501-done) by debbugs.gnu.org; 29 Jan 2025 13:19:08 +0000 Received: from localhost ([127.0.0.1]:40301 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1td7yG-0001zs-1o for submit@debbugs.gnu.org; Wed, 29 Jan 2025 08:19:08 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:43179) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1td7yD-0001yw-4a for 75501-done@debbugs.gnu.org; Wed, 29 Jan 2025 08:19:06 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-2162c0f6a39so12919235ad.0 for <75501-done@debbugs.gnu.org>; Wed, 29 Jan 2025 05:19:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738156739; x=1738761539; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Y9G87AhFu8TCHGGDcbNjseekGiUS4O2QLU0lfCdJRs4=; b=ThzIFOCdYl3HprRW8/v9LFppt1pnMWDdejDMhIkI9sNrEGzUOwQdZGZV9EImSCIrss zXnvXAjYJN9iZp25ZC5AUqxMRgyTu47C03/+WN1DszbRTl/FNItyve57azhuUFqRMJ+n YjkT0wup9p4li2bHLPrqQHAo7sO/BVG42pGHWP5oHqgllMorR87D7Re/2CrMrs3/SQ8w 8FNIOGp0SokSnt7gOOL/qehKJs2Acw0sHxjA5AGD24M6i7fyYi7Htu9X7EouKkpAcrAb 3gBhrNFWlTBLPLeyT9bSXbhD5KnfMpdECENq0Qv+WprWVysHT9tlmr/64AV5gvdMeQzT Ao1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738156739; x=1738761539; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Y9G87AhFu8TCHGGDcbNjseekGiUS4O2QLU0lfCdJRs4=; b=XHOZWVdEKRa3NI7haQoOgFqsJLjbq8NnIcoVbMrMXtexUdNJm4VoReofuGF+M22MyC GjeJzBr/9kHPXAP76d6cResiC+ntLbj1a0+tZnztW1sQvGfWhfpqW1WHSeEnTBouRt5f z71TbYHQGS1fgk2k5LUNmDz6cspRNuva5/YwlbD6JwxbGzZ76Pq6p3zThOdVONdP9vDo xaBcvJhjUYd6FnJrCpRuo0WNilhHJ+eh2ns8L+hh1Yrj8kTl+WrvVGcPMbPVprXDquHH Mj2lRAHKyLehei5Fasn+Q3YuxPPDJkdjnxd1/U215os5pExZZduby17wdMFfu3iEw4uv fGlQ== X-Gm-Message-State: AOJu0Yw4NJwDXvT/8qBt0tncY0eRlO0b+rG/F+SBLbSZFX2BODTTxH/D VuARZ42WreqRpe/A4Wi6SrQi5cHwvKfzAvkeL0SOSaMJXxYMksOs X-Gm-Gg: ASbGncslRcYDnKiuF1vY9CkBQrU+INR6TO44mMoreCfWjEfZeGIYf/tgCg8I0IWU6Rw jMvx11Yp2Ozv/uQGSM33aPiJZ+iwt0vVAJ6p14ocYeg6NFem9JbXsIh7o6VbViY1QkPCzXILmwc Nwuw4vLhPtBF6DHuSBIVdqeGwmnHOwTD2es8RMk5aIFmHpmKbcb7g8arDErQujT1MjYF8+r5Bi2 qCvwrRK3Z9+dOtPegAh3yZ57k7d1LZddl3HNo4sQkqOBJ4ri0BY5a2UGjjcsrCh+uK7Gz/yPW9z 0DcvS6LK+ogC X-Google-Smtp-Source: AGHT+IGkcQ1/X4S/gNiDNWD/mW8fCBJcUFEPG35RJs5Cib6r7LFoJ2SiCDvt2w90q2ljZQyDkakk3g== X-Received: by 2002:a17:902:ea04:b0:21d:90d0:6c10 with SMTP id d9443c01a7336-21dd7806edbmr54725605ad.23.1738156738981; Wed, 29 Jan 2025 05:18:58 -0800 (PST) Received: from terra ([2405:6586:be0:0:c8ff:1707:9b9:af89]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21da424f344sm98906055ad.232.2025.01.29.05.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jan 2025 05:18:58 -0800 (PST) From: Maxim Cournoyer To: =?utf-8?Q?S=C3=B6ren?= Tempel Subject: Re: [bug#75501] [PATCH] gnu: mandoc: Support zstd-compressed man pages. In-Reply-To: <3L85LLP66SB0W.3KHGVB0OS294N@8pit.net> (=?utf-8?Q?=22S=C3=B6r?= =?utf-8?Q?en?= Tempel"'s message of "Tue, 28 Jan 2025 16:58:11 +0100") References: <20250111190753.32110-2-soeren@soeren-tempel.net> <87zfjsd5no.fsf@gmail.com> <3GW4TH6POR7DJ.393NEMAQAI01C@8pit.net> <877c6r9t1h.fsf@gmail.com> <3L85LLP66SB0W.3KHGVB0OS294N@8pit.net> Date: Wed, 29 Jan 2025 22:18:46 +0900 Message-ID: <87plk5pxl5.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 75501-done Cc: ludo@gnu.org, me@tobias.gr, 75501-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Pushed, thank you! -- Maxim From unknown Tue Jun 24 05:09:03 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 27 Feb 2025 12:24:09 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator