[PATCH 2/3] scripts/append_COLOPHON.sh: Add script to append the COLOPHON section

Alejandro Colomar
2022-04-15T23:31:05Z

I first implemented it using cat <<-, but sed(1) is around 5 times
faster, so even if it's a bit more complex and slightly less
readable, let's use sed(1).

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
scripts/append_COLOPHON.sh | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100755 scripts/append_COLOPHON.sh

diff --git a/scripts/append_COLOPHON.sh b/scripts/append_COLOPHON.sh
new file mode 100755
index 000000000..f277b997f
--- /dev/null
+++ b/scripts/append_COLOPHON.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# append_COLOPHON.sh
+#
+# Append the COLOPHON section to the man pages. This script should be
+# run before running `make dist`.
+#
+########################################################################
+# SPDX-License-Identifier: GPL-2.0-only
+########################################################################
+#
+# (C) Copyright 2022, Alejandro Colomar
+# These functions are free software; you can redistribute them and/or
+# modify them under the terms of the GNU General Public License
+# as published by the Free Software Foundation; version 2.
+#
+# These functions are distributed in the hope that they will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details
+# (http://www.gnu.org/licenses/gpl-2.0.html).
+#
+########################################################################
+find man?/ -not -type d \
+|xargs sed -i "\$a \\
+.SH COLOPHON\\
+This page is part of release\\
+$(git describe | sed 's/^man-pages-//')\\
+of the Linux\\
+.I man-pages\\
+project.\\
+A description of the project,\\
+information about reporting bugs,\\
+and the latest version of this page,\\
+can be found at\\
+.UR https://www.kernel.org/doc/man-pages/\\
+.UE .
+"
--
2.30.2