public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* [PATCH cygport] dodoc: Skip a file if a compressed version already exists
@ 2024-03-01 13:13 Christian Franke
  2024-03-10 15:29 ` Jon Turney
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Franke @ 2024-03-01 13:13 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: text/plain, Size: 420 bytes --]

It IMO makes sense to compress large and rarely viewed doc files like 
change logs. This seems to be common practice on Debian etc.

With current cygport, the following results in ChangeLog and 
ChangeLog.gz in the docdir:

src_install()
{
   ...
   dodoc ChangeLog
   gzip -9 -n "${D}/usr/share/doc/${PN}/ChangeLog"
}

The attached patch fixes this and also adds some missing documentation.

-- 
Regards,
Christian


[-- Attachment #2: 0001-dodoc-Skip-a-file-if-a-compressed-version-already-ex.patch --]
[-- Type: text/plain, Size: 1561 bytes --]

From 1934651b93cda92207429ac91b964cff220c76d5 Mon Sep 17 00:00:00 2001
From: Christian Franke <christian.franke@t-online.de>
Date: Fri, 1 Mar 2024 13:56:45 +0100
Subject: [PATCH] dodoc: Skip a file if a compressed version already exists

This prevents that __prepdoc() also adds the uncompressed version
of a default doc file if src_install() installed the compressed
version.  Also add missing documentation about the handling of
FILE.md, FILE.rst and FILE.txt.
---
 lib/src_install.cygpart | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/src_install.cygpart b/lib/src_install.cygpart
index 481457dc..7aca673c 100644
--- a/lib/src_install.cygpart
+++ b/lib/src_install.cygpart
@@ -162,9 +162,12 @@ docinto() {
 #  DESCRIPTION
 #  Installs the given files or directories into $D/usr/share/doc/PN/, or a
 #  subdirectory thereof specified by the previous call to docinto.
+#  If a FILE does not exist, FILE.md, FILE.rst and FILE.txt are also
+#  considered.  A FILE is skipped if the destination file or a compressed
+#  version (.bz2, .gz, .xz, .zstd) of it already exists.
 #****
 dodoc() {
-	local docdir d f i x
+	local docdir d e f i x
 
 	case "${_docinto_dir}" in
 		'')	docdir=/usr/share/doc/${PN} ;;
@@ -191,6 +194,10 @@ dodoc() {
 			do
 				if [ -s "${i}${x}" -a ! -f "${D}${docdir}/${i}${x}" ]
 				then
+					for e in bz2 gz xz zst
+					do
+						! [ -f "${D}${docdir}/${i}${x}.${e}" ] || continue 2
+					done
 					__doinstall 0644 "${i}${x}" ${docdir} || error "dodoc ${i} failed"
 					break
 				fi
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH cygport] dodoc: Skip a file if a compressed version already exists
  2024-03-01 13:13 [PATCH cygport] dodoc: Skip a file if a compressed version already exists Christian Franke
@ 2024-03-10 15:29 ` Jon Turney
  2024-03-10 15:44   ` Christian Franke
  0 siblings, 1 reply; 4+ messages in thread
From: Jon Turney @ 2024-03-10 15:29 UTC (permalink / raw)
  To: Christian Franke; +Cc: cygwin-apps

On 01/03/2024 13:13, Christian Franke via Cygwin-apps wrote:
> It IMO makes sense to compress large and rarely viewed doc files like 
> change logs. This seems to be common practice on Debian etc.
> 
> With current cygport, the following results in ChangeLog and 
> ChangeLog.gz in the docdir:
> 
> src_install()
> {
>    ...
>    dodoc ChangeLog
>    gzip -9 -n "${D}/usr/share/doc/${PN}/ChangeLog"
> }

Uh, I don't quite see how this patch will change the behavior of this 
fragment.

Even more confusing, why isn't this already doing what you want? Unless 
you specify -k/--keep to gzip, the input file is removed, right?

> The attached patch fixes this and also adds some missing documentation.

I applied the documentation change as that is obviously needed.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH cygport] dodoc: Skip a file if a compressed version already exists
  2024-03-10 15:29 ` Jon Turney
@ 2024-03-10 15:44   ` Christian Franke
  2024-04-29 19:31     ` Jon Turney
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Franke @ 2024-03-10 15:44 UTC (permalink / raw)
  To: cygwin-apps

Jon Turney wrote:
> On 01/03/2024 13:13, Christian Franke via Cygwin-apps wrote:
>> It IMO makes sense to compress large and rarely viewed doc files like 
>> change logs. This seems to be common practice on Debian etc.
>>
>> With current cygport, the following results in ChangeLog and 
>> ChangeLog.gz in the docdir:
>>
>> src_install()
>> {
>>    ...
>>    dodoc ChangeLog
>>    gzip -9 -n "${D}/usr/share/doc/${PN}/ChangeLog"
>> }
>
> Uh, I don't quite see how this patch will change the behavior of this 
> fragment.
>

Yes, it actually doesn't change the behavior of this fragment itself.


> Even more confusing, why isn't this already doing what you want? 
> Unless you specify -k/--keep to gzip, the input file is removed, right?

Yes - but after this src_install() the file will be re-added by 
__predoc() unless _CYGPORT_RESTRICT_postinst_doc_ is set. The patch 
avoids this because __predoc() also uses dodoc().


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH cygport] dodoc: Skip a file if a compressed version already exists
  2024-03-10 15:44   ` Christian Franke
@ 2024-04-29 19:31     ` Jon Turney
  0 siblings, 0 replies; 4+ messages in thread
From: Jon Turney @ 2024-04-29 19:31 UTC (permalink / raw)
  To: Christian Franke; +Cc: cygwin-apps

On 10/03/2024 15:44, Christian Franke via Cygwin-apps wrote:
> Jon Turney wrote:
>> On 01/03/2024 13:13, Christian Franke via Cygwin-apps wrote:
>>> It IMO makes sense to compress large and rarely viewed doc files like 
>>> change logs. This seems to be common practice on Debian etc.
>>>
>>> With current cygport, the following results in ChangeLog and 
>>> ChangeLog.gz in the docdir:
>>>
>>> src_install()
>>> {
>>>    ...
>>>    dodoc ChangeLog
>>>    gzip -9 -n "${D}/usr/share/doc/${PN}/ChangeLog"
>>> }
>>
>> Uh, I don't quite see how this patch will change the behavior of this 
>> fragment.
>>
> 
> Yes, it actually doesn't change the behavior of this fragment itself.
> 
> 
>> Even more confusing, why isn't this already doing what you want? 
>> Unless you specify -k/--keep to gzip, the input file is removed, right?
> 
> Yes - but after this src_install() the file will be re-added by 
> __predoc() unless _CYGPORT_RESTRICT_postinst_doc_ is set. The patch 
> avoids this because __predoc() also uses dodoc().

Ah, I get it.

Applied with a bit of rewording of the commit commentary for dullards 
like myself.

Thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-29 19:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-01 13:13 [PATCH cygport] dodoc: Skip a file if a compressed version already exists Christian Franke
2024-03-10 15:29 ` Jon Turney
2024-03-10 15:44   ` Christian Franke
2024-04-29 19:31     ` Jon Turney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).