unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] build: do not repeatedly build some docs
@ 2021-11-09  0:20 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2021-11-09  0:20 UTC (permalink / raw)
  To: meta

Text versions of manpages do not need to be generated for normal
installations, they're only used for generating HTML and our
amazing, award-winning homepage.

We'll also rely on touch(1) instead of Perl utime to benefit
users w/o git-set-file-times in txt2pre.  Perl numeric values
cannot represent nanosecond resolution accurately even with
Time::HiRes; which causes nanosecond-aware make(1)
implementations to repeatedly rebuild.
---
 Documentation/common.perl | 14 +++++++++-----
 Documentation/txt2pre     |  6 ------
 Makefile.PL               | 11 ++++++-----
 3 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/Documentation/common.perl b/Documentation/common.perl
index 5fdbe8da..3a6617c4 100755
--- a/Documentation/common.perl
+++ b/Documentation/common.perl
@@ -34,11 +34,15 @@ L<http://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/meta/>
 			^AUTO-GENERATED-SEARCH-TERMS-END\n
 			!search_terms()!emsx;
 	$s =~ s/[ \t]+$//sgm;
-	next if $s eq $orig;
-	seek($fh, 0, SEEK_SET) or die "seek: $!";
-	truncate($fh, 0) or die "truncate: $!";
-	print $fh $s or die "print: $!";
-	close $fh or die "close: $!";
+	if ($s eq $orig) {
+		my $t = time;
+		utime($t, $t, $fh);
+	} else {
+		seek($fh, 0, SEEK_SET) or die "seek: $!";
+		truncate($fh, 0) or die "truncate: $!";
+		print $fh $s or die "print: $!";
+		close $fh or die "close: $!";
+	}
 }
 
 sub search_terms {
diff --git a/Documentation/txt2pre b/Documentation/txt2pre
index 04bc3b0e..3ecd9100 100755
--- a/Documentation/txt2pre
+++ b/Documentation/txt2pre
@@ -177,9 +177,3 @@ print '<html><head>',
   "<title>$title</title>",
   "</head><body><pre>",  $str , '</pre></body></html>';
 STDOUT->flush;
-
-# keep mtime on website consistent so clients can cache
-if (-f STDIN && -f STDOUT) {
-	my @st = stat(STDIN);
-	utime($st[8], $st[9], \*STDOUT);
-}
diff --git a/Makefile.PL b/Makefile.PL
index c0aef488..cde6194b 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -23,7 +23,7 @@ push @dtxt, @{$v->{txt}};
 for my $txt (@dtxt) {
 	my $html = $txt;
 	$html =~ s/\.txt\z/.html/ or $html .= '.html';
-	$t->{"$html : $txt"} = [ "\$(txt2pre) <$txt" ];
+	$t->{"$html : $txt"} = [ "\$(txt2pre) <$txt", "touch -r $txt \$@" ];
 }
 $v->{t_slash_star_dot_t} = [ grep(m!\At/.*\.t\z!, @manifest) ];
 my @scripts = qw(scripts/ssoma-replay); # legacy
@@ -74,9 +74,10 @@ for my $i (@sections) {
 		my $txt = "Documentation/$m.txt";
 		$t->{"$m.$i : $pod"} = [ "\$(podman) -s$i $pod \$@" ];
 		$t->{"$txt : $m.$i"} = [ "\$(man2text) ./$m.$i >\$\@+",
-					"touch -r $pod \$\@+",
+					"touch -r $pod \$\@+ ./$m.$i",
 					"mv \$\@+ \$@" ];
-		$t->{"Documentation/$m.html : $txt"} = [ "\$(txt2pre) <$txt" ];
+		$t->{"Documentation/$m.html : $txt"} = [ "\$(txt2pre) <$txt",
+							"touch -r $txt \$@" ];
 		$t->{".$m.cols : $m.$i"} = [
 			"\@echo CHECK80 $m.$i;".
 			"COLUMNS=80 \$(MAN) ./$m.$i | \$(check_man)",
@@ -91,13 +92,13 @@ for my $i (@sections) {
 	push @{$v->{manuals}}, @$manuals;
 	push @{$v->{mantxt}}, map { "Documentation/$_.txt" } @$ary;
 }
-push @dtxt, @{$v->{mantxt}};
+push @dtxt;
 $v->{docs} = [ @dtxt, 'NEWS' ];
 $v->{docs_html} = [ map {;
 		my $x = $_;
 		$x =~ s/\.txt\z//;
 		"$x.html"
-	} @{$v->{docs}} ];
+	} (@{$v->{docs}}, @{$v->{mantxt}}) ];
 $v->{gz_docs} = [ map { "$_.gz" } (@{$v->{docs}},@{$v->{docs_html}}) ];
 $v->{rsync_docs} = [ @{$v->{gz_docs}}, @{$v->{docs}},
 	@{$v->{docs_html}}, qw(NEWS.atom NEWS.atom.gz)];

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-09  0:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-09  0:20 [PATCH] build: do not repeatedly build some docs Eric Wong

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).