All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/3] Prepare the Makefile and scripts/ for releasing
@ 2022-04-15 23:30 Alejandro Colomar
  2022-04-15 23:30 ` [PATCH 1/3] scripts/remove_COLOPHON.sh: Allow passing directories to the script Alejandro Colomar
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Alejandro Colomar @ 2022-04-15 23:30 UTC (permalink / raw)
  To: mtk.manpages, nab, G . Branden Robinson; +Cc: Alejandro Colomar, linux-man


Hi!

I'm preparing the Makefile and scripts to be able to release
without hidden scripts, just from the repository.  I put in the
Makefile everything that can be done incrementally (or at least
idempotently, since tar(1) doesn't really allow incrementally
creating an archive, unlike ar(1)), and in scripts what can't
(i.e., the COLOPHON generation).

I tried to follow conventions (from GNU and others) as much as
possible.

The COLOPHON format was kept as I see it in existing pages in my
system, with one difference: until now, the URI in the COLOPHON
wasn't being enclosed in <> (the script didn't use .UR/.UE).
I fixed that.

Now one can generate DISTFILES (.tar, .tar.gz, and .tar.xz files)
simply with the following commands.  The version number is taken
from git.

	./scripts/append_COLOPHON.sh
	make dist-gz

Of course, the generation of the COLOPHON is not a dependency for
the generation of the tarballs, but it's likely that both commands
will be run together.


Cheers,

Alex


Alejandro Colomar (3):
  scripts/remove_COLOPHON.sh: Allow passing directories to the script
  scripts/append_COLOPHON.sh: Add script to append the COLOPHON section
  Makefile: dist: Add target to create distribution archives

 Makefile                   | 49 ++++++++++++++++++++++++++++++++++++++
 scripts/append_COLOPHON.sh | 38 +++++++++++++++++++++++++++++
 scripts/remove_COLOPHON.sh |  6 ++---
 3 files changed, 90 insertions(+), 3 deletions(-)
 create mode 100755 scripts/append_COLOPHON.sh

-- 
2.30.2


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

* [PATCH 1/3] scripts/remove_COLOPHON.sh: Allow passing directories to the script
  2022-04-15 23:30 [RFC 0/3] Prepare the Makefile and scripts/ for releasing Alejandro Colomar
@ 2022-04-15 23:30 ` Alejandro Colomar
  2022-04-15 23:30 ` [PATCH 2/3] scripts/append_COLOPHON.sh: Add script to append the COLOPHON section Alejandro Colomar
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Alejandro Colomar @ 2022-04-15 23:30 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, G . Branden Robinson, nab

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
 scripts/remove_COLOPHON.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/remove_COLOPHON.sh b/scripts/remove_COLOPHON.sh
index 712106656..780caab98 100755
--- a/scripts/remove_COLOPHON.sh
+++ b/scripts/remove_COLOPHON.sh
@@ -11,6 +11,7 @@
 ######################################################################
 #
 # (C) Copyright 2008 & 2013, Michael Kerrisk
+# and (C) Copyright 2022, Alejandro Colomar <alx.manpages@gmail.com>
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 # as published by the Free Software Foundation; either version 2
@@ -23,6 +24,5 @@
 # (http://www.gnu.org/licenses/gpl-2.0.html).
 #
 #
-for f in "$@"; do
-    sed -i '/^\.SH COLOPHON/,$d' "$f"
-done
+find $@ -not -type d \
+|xargs sed -i '/^.SH COLOPHON/,$d';
-- 
2.30.2


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

* [PATCH 2/3] scripts/append_COLOPHON.sh: Add script to append the COLOPHON section
  2022-04-15 23:30 [RFC 0/3] Prepare the Makefile and scripts/ for releasing Alejandro Colomar
  2022-04-15 23:30 ` [PATCH 1/3] scripts/remove_COLOPHON.sh: Allow passing directories to the script Alejandro Colomar
@ 2022-04-15 23:30 ` Alejandro Colomar
  2022-04-15 23:30 ` [PATCH 3/3] Makefile: dist: Add target to create distribution archives Alejandro Colomar
  2022-04-15 23:33 ` [RFC 0/3] Prepare the Makefile and scripts/ for releasing Alejandro Colomar
  3 siblings, 0 replies; 6+ messages in thread
From: Alejandro Colomar @ 2022-04-15 23:30 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, G . Branden Robinson, nab

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


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

* [PATCH 3/3] Makefile: dist: Add target to create distribution archives
  2022-04-15 23:30 [RFC 0/3] Prepare the Makefile and scripts/ for releasing Alejandro Colomar
  2022-04-15 23:30 ` [PATCH 1/3] scripts/remove_COLOPHON.sh: Allow passing directories to the script Alejandro Colomar
  2022-04-15 23:30 ` [PATCH 2/3] scripts/append_COLOPHON.sh: Add script to append the COLOPHON section Alejandro Colomar
@ 2022-04-15 23:30 ` Alejandro Colomar
  2022-04-16 13:02   ` [RFC v3 " Alejandro Colomar
  2022-04-15 23:33 ` [RFC 0/3] Prepare the Makefile and scripts/ for releasing Alejandro Colomar
  3 siblings, 1 reply; 6+ messages in thread
From: Alejandro Colomar @ 2022-04-15 23:30 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, G . Branden Robinson, nab

Other subtargets are also created, with the obvious results:
dist-tar, dist-gz, and dist-xz.

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
 Makefile | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/Makefile b/Makefile
index 38ea89c69..d7935ccae 100644
--- a/Makefile
+++ b/Makefile
@@ -316,6 +316,55 @@ uninstall-man: $(_mandir_rmdir) $(uninstall_manX)
 	@:
 
 
+########################################################################
+# dist
+#
+# Do NOT use `make -j` with dist targets:
+# <https://www.gnu.org/software/make/manual/html_node/Archive-Pitfalls.html#Archive-Pitfalls>.
+
+PKGNAME     := man-pages
+DISTVERSION := $(shell git describe | sed 's/^man-pages-//')
+DISTNAME    := $(PKGNAME)-$(DISTVERSION)
+DISTSRC     := $(sort $(shell git ls-files $(srcdir)))
+DISTFILE    := $(builddir)/$(DISTNAME).tar
+compression := gz xz
+dist        := $(sort $(foreach x,$(compression),dist-$(x)))
+
+
+$(DISTFILE): $(DISTSRC) | $$(@D)/.
+	$(info TAR	$@)
+	tar cf $@ -T /dev/null
+
+$(DISTFILE)($(DISTSRC)): $% $(DISTFILE) | $$(@D)/.
+	$(info TAR	$@($%))
+	tar rf $@ $%
+
+$(DISTFILE).gz: $(DISTFILE)($(DISTSRC)) | $$(@D)/.
+	$(info GZIP	$@)
+	gzip -kn $<
+
+$(DISTFILE).xz: $(DISTFILE)($(DISTSRC)) | $$(@D)/.
+	$(info XZ	$@)
+	xz -k $<
+
+
+.PHONY: dist-tar
+dist-tar: $(DISTFILE)($(DISTSRC)) | builddirs-dist
+	@:
+
+.PHONY: $(dist)
+$(dist): dist-%: $(DISTFILE).% | builddirs-dist
+	@:
+
+.PHONY: builddirs-dist
+builddirs-dist: $(builddir)/.
+	@:
+
+.PHONY: dist
+dist: $(dist)
+	@:
+
+
 ########################################################################
 # src
 
-- 
2.30.2


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

* Re: [RFC 0/3] Prepare the Makefile and scripts/ for releasing
  2022-04-15 23:30 [RFC 0/3] Prepare the Makefile and scripts/ for releasing Alejandro Colomar
                   ` (2 preceding siblings ...)
  2022-04-15 23:30 ` [PATCH 3/3] Makefile: dist: Add target to create distribution archives Alejandro Colomar
@ 2022-04-15 23:33 ` Alejandro Colomar
  3 siblings, 0 replies; 6+ messages in thread
From: Alejandro Colomar @ 2022-04-15 23:33 UTC (permalink / raw)
  To: mtk.manpages, nab, G . Branden Robinson; +Cc: linux-man



On 4/16/22 01:30, Alejandro Colomar wrote:
> 	./scripts/append_COLOPHON.sh
> 	make dist-gz

I meant s/dist-gz/dist/

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

* [RFC v3 3/3] Makefile: dist: Add target to create distribution archives
  2022-04-15 23:30 ` [PATCH 3/3] Makefile: dist: Add target to create distribution archives Alejandro Colomar
@ 2022-04-16 13:02   ` Alejandro Colomar
  0 siblings, 0 replies; 6+ messages in thread
From: Alejandro Colomar @ 2022-04-16 13:02 UTC (permalink / raw)
  To: mtk.manpages, linux-man, Branden Robinson, наб
  Cc: Alejandro Colomar

Other subtargets are also created, with the obvious results:
dist-tar, dist-gz, and dist-xz.

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---

v2: Fix some accidents (forgot to send this one to the list)
v3: Simplify


 Makefile | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/Makefile b/Makefile
index 38ea89c69..889e356b3 100644
--- a/Makefile
+++ b/Makefile
@@ -316,6 +316,47 @@ uninstall-man: $(_mandir_rmdir) $(uninstall_manX)
 	@:
 
 
+########################################################################
+# dist
+
+DISTNAME    := $(shell git describe 2>/dev/null)
+DISTFILE    := $(builddir)/$(DISTNAME).tar
+compression := gz xz
+dist        := $(foreach x,$(compression),dist-$(x))
+
+
+$(DISTFILE): $(shell git ls-files) | $$(@D)/.
+	$(info TAR	$@)
+	tar cf $@ -T /dev/null
+	git ls-files \
+	| xargs tar rf $@
+
+$(DISTFILE).gz: %.gz: % | $$(@D)/.
+	$(info GZIP	$@)
+	gzip -knf $<
+
+$(DISTFILE).xz: %.xz: % | $$(@D)/.
+	$(info XZ	$@)
+	xz -kf $<
+
+
+.PHONY: dist-tar
+dist-tar: $(DISTFILE) | builddirs-dist
+	@:
+
+.PHONY: $(dist)
+$(dist): dist-%: $(DISTFILE).% | builddirs-dist
+	@:
+
+.PHONY: builddirs-dist
+builddirs-dist: $(builddir)/.
+	@:
+
+.PHONY: dist
+dist: $(dist)
+	@:
+
+
 ########################################################################
 # src
 
-- 
2.30.2


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

end of thread, other threads:[~2022-04-16 13:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-15 23:30 [RFC 0/3] Prepare the Makefile and scripts/ for releasing Alejandro Colomar
2022-04-15 23:30 ` [PATCH 1/3] scripts/remove_COLOPHON.sh: Allow passing directories to the script Alejandro Colomar
2022-04-15 23:30 ` [PATCH 2/3] scripts/append_COLOPHON.sh: Add script to append the COLOPHON section Alejandro Colomar
2022-04-15 23:30 ` [PATCH 3/3] Makefile: dist: Add target to create distribution archives Alejandro Colomar
2022-04-16 13:02   ` [RFC v3 " Alejandro Colomar
2022-04-15 23:33 ` [RFC 0/3] Prepare the Makefile and scripts/ for releasing Alejandro Colomar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.