Prepare the Makefile and scripts/ for releasing
cover Prepare the Makefile and scripts/ for releasing
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
Signature · 1 line
2.30.2
PATCH 1/3 scripts/remove_COLOPHON.sh: Allow passing directories to the script
--- scripts/remove_COLOPHON.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/remove_COLOPHON.sh +3 -3
@@ -11,6 +11,7 @@ ###################################################################### # # (C) Copyright 2008 & 2013, Michael Kerrisk +# and (C) Copyright 2022, Alejandro Colomar <[email protected]> # 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';
Signature · 1 line
2.30.2
PATCH 2/3 scripts/append_COLOPHON.sh: Add script to append the COLOPHON section
In reply to Alejandro ColomarI 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).
--- scripts/append_COLOPHON.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 scripts/append_COLOPHON.sh
scripts/append_COLOPHON.sh new file +38 -0
@@ -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 . +"
Signature · 1 line
2.30.2
PATCH 3/3 Makefile: dist: Add target to create distribution archives
In reply to Alejandro ColomarOther subtargets are also created, with the obvious results:
dist-tar, dist-gz, and dist-xz.
--- Makefile | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
Makefile +49 -0
@@ -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
Signature · 1 line
2.30.2
RFC v3 3/3 Makefile: dist: Add target to create distribution archives
Other subtargets are also created, with the obvious results:
dist-tar, dist-gz, and dist-xz.
---
v2: Fix some accidents (forgot to send this one to the list)
v3: Simplify
Makefile | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
Makefile +41 -0
@@ -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
Signature · 1 line
2.30.2
Quoted 2 lines · Alejandro Colomar
./scripts/append_COLOPHON.sh
make dist-gz
I meant s/dist-gz/dist/