Skip to content

Commit a337a30

Browse files
committed
More make man recipe cleanup, enable reproducible man builds
* Enable reproducible man builds with `asciidoctor -a reproducible` * Make it work when cowsay.1 is absent by skipping the normalized-diff check. * Use a common build/ dir for temp dirs in `make man` and other targets. * Factor out tmpdir deletion.
1 parent 29ae85c commit a337a30

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# cowsay-specific stuff to exclude
44

5-
# (nothing here currently)
5+
build/
66

77
# Local artifacts and output files and the like
88

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Cowsay Changelog
88
- Use core Homebrew `cowsay` formula in macOS install instructions, since they picked up cowsay-org recently!
99
- Fix tabs in moofasa.cow to spaces.
1010
- Fix "Sywalker" typo in luke-koala.cow.
11+
- Enable reproducible man page builds.
1112

1213
## 3.8.4 (2024-11-30)
1314

Makefile

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ all:
5050

5151
.PHONY: clean
5252
clean:
53-
@echo "Nothing to do - 'make clean' is a no-op."
53+
rm -rf build
5454

5555
# The 'man' target creates cowsay.1, cowthink.1, and other man pages.
5656
#
5757
# The 'man' target is intended for use at authoring time, not at build time, so it is not
5858
# part of the normal build sequence, and its outputs are checked into the source repo.
5959
#
60-
# This is partially to simplify the build process, and partially to preserve the internal
61-
# "update" timestamp inside the man pages. We also do this at authoring time instead of
62-
# install time to avoid introducing a dependency on Asciidoctor for users.
60+
# This is to simplify the build process. We also do this at authoring time instead of
61+
# install time to avoid introducing a dependency on Asciidoctor for end users, who may
62+
# want to run directly from the repo without a build step.
6363

6464
.PHONY: man
6565
man: man/man1/cowsay.1
@@ -75,23 +75,23 @@ man: man/man1/cowsay.1
7575
# than just irrelevant metadata.
7676
man/man1/cowsay.1: man-src/man1/cowsay.1.adoc man-src/normalize-manpage.sed
7777
@set -e; \
78-
tmpdir="tmp$$$$"; \
79-
if $(ASCIIDOCTOR) -b manpage -D "$$tmpdir/man/man1" man-src/man1/cowsay.1.adoc; then \
80-
sed -f man-src/normalize-manpage.sed man/man1/cowsay.1 > "$$tmpdir/man/man1/normalized-old-cowsay.1"; \
81-
sed -f man-src/normalize-manpage.sed "$$tmpdir/man/man1/cowsay.1" > "$$tmpdir/man/man1/normalized-new-cowsay.1"; \
82-
if ! test -e "man/man1/cowsay.1" || ! cmp "$$tmpdir/man/man1/normalized-old-cowsay.1" "$$tmpdir/man/man1/normalized-new-cowsay.1" > /dev/null; then \
83-
echo "Updating man/man1/cowsay.1"; \
84-
mv -f "$$tmpdir/man/man1/cowsay.1" man/man1/cowsay.1; \
85-
rm -f "$$tmpdir/man/man1/normalized-old-cowsay.1"; \
86-
rm -f "$$tmpdir/man/man1/normalized-new-cowsay.1"; \
87-
rm -f "$$tmpdir/man/man1/cowthink.1"; \
88-
rmdir "$$tmpdir/man/man1"; \
89-
rmdir "$$tmpdir/man"; \
90-
rmdir "$$tmpdir"; \
78+
if ! test -d build; then mkdir build; fi; \
79+
tmpdir="build/tmp$$$$"; \
80+
if $(ASCIIDOCTOR) -a reproducible -b manpage -D "$$tmpdir/man/man1" man-src/man1/cowsay.1.adoc; then \
81+
if test -f man/man1/cowsay.1; then \
82+
sed -f man-src/normalize-manpage.sed man/man1/cowsay.1 > "$$tmpdir/man/man1/normalized-old-cowsay.1"; \
83+
sed -f man-src/normalize-manpage.sed "$$tmpdir/man/man1/cowsay.1" > "$$tmpdir/man/man1/normalized-new-cowsay.1"; \
84+
if ! test -e "man/man1/cowsay.1" || ! cmp "$$tmpdir/man/man1/normalized-old-cowsay.1" "$$tmpdir/man/man1/normalized-new-cowsay.1" > /dev/null; then \
85+
echo "Updating man/man1/cowsay.1"; \
86+
mv -f "$$tmpdir/man/man1/cowsay.1" man/man1/cowsay.1; \
87+
else \
88+
echo "man/man1/cowsay.1 is up to date"; \
89+
fi; \
9190
else \
92-
echo "man/man1/cowsay.1 is up to date"; \
93-
rm -rf "$$tmpdir"; \
91+
echo "Regenerating man/man1/cowsay.1"; \
92+
mv -f "$$tmpdir/man/man1/cowsay.1" man/man1/cowsay.1; \
9493
fi; \
94+
rm -rf "$$tmpdir"; \
9595
else \
9696
echo "Error updating man/man1/cowsay.1"; \
9797
exit 1; \

man/man1/cowsay.1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
.\" Title: cowsay
33
.\" Author: [see the "AUTHOR(S)" section]
44
.\" Generator: Asciidoctor 2.0.23
5-
.\" Date: 2024-11-30
65
.\" Manual: Cowsay Manual
76
.\" Source: Cowsay
87
.\" Language: English
98
.\"
10-
.TH "COWSAY" "1" "2024-11-30" "Cowsay" "Cowsay Manual"
9+
.TH "COWSAY" "1" "" "Cowsay" "Cowsay Manual"
1110
.ie \n(.g .ds Aq \(aq
1211
.el .ds Aq '
1312
.ss \n[.ss] 0

0 commit comments

Comments
 (0)