chiark / gitweb /
Build system substitutions, for absurdities
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 24 Oct 2016 00:04:22 +0000 (01:04 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 24 Oct 2016 00:43:50 +0000 (01:43 +0100)
* Introduce absurddir, which is where the absurdities will go
* Substitute the absurddir into the dgit script during make all
* Install the substituted scripts rather than the originals in make install
* Provide a default in dgit, based on $0
* Clean the substitutions up in make clean

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
.gitignore
Makefile
dgit

index 428c4cc3eaaebaefdfea678ba6c671c06825f7b9..69c2feaa3f697ec18ef72a69ca14561c845b5805 100644 (file)
@@ -7,3 +7,4 @@ debian/*.substvars
 debian/*.log
 debian/debhelper-build-stamp
 dgit-maint-merge.7
+substituted
index 291265d905db94388008f2cd41040c6f1208fa3c..b72a1e9f477f61e1c7edcda2afa4e2e9796170a5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -30,6 +30,7 @@ man1dir=$(mandir)/man1
 man7dir=$(mandir)/man7
 infraexamplesdir=$(prefix)/share/doc/dgit-infrastructure/examples
 txtdocdir=$(prefix)/share/doc/dgit
+absurddir=$(prefix)/share/dgit/absurd
 
 PROGRAMS=dgit
 MAN1PAGES=dgit.1
@@ -46,10 +47,16 @@ INFRA_PERLMODULES= \
        Debian/Dgit/Infra.pm \
        Debian/Dgit/Policy/Debian.pm
 
-all:   $(MAN7PAGES)
+all:   $(MAN7PAGES) $(addprefix substituted/,$(PROGRAMS))
 
-install:       installdirs $(MAN7PAGES)
-       $(INSTALL_PROGRAM) $(PROGRAMS) $(DESTDIR)$(bindir)
+substituted/%: %
+       mkdir -p substituted
+       perl -pe 's{\bundef\b}{'\''$(absurddir)'\''} if m/###substituted###/' \
+               <$< >$@
+
+install:       installdirs all
+       $(INSTALL_PROGRAM) $(addprefix substituted/,$(PROGRAMS)) \
+               $(DESTDIR)$(bindir)
        $(INSTALL_DATA) $(MAN1PAGES) $(DESTDIR)$(man1dir)
        $(INSTALL_DATA) $(MAN7PAGES) $(DESTDIR)$(man7dir)
        $(INSTALL_DATA) $(TXTDOCS) $(DESTDIR)$(txtdocdir)
@@ -60,7 +67,7 @@ install:      installdirs $(MAN7PAGES)
 installdirs:
        $(INSTALL_DIR) $(DESTDIR)$(bindir) \
                $(DESTDIR)$(man1dir) $(DESTDIR)$(man7dir) \
-               $(DESTDIR)$(txtdocdir) \
+               $(DESTDIR)$(txtdocdir) $(DESTDIR)$(absurddir) \
                $(addprefix $(DESTDIR)$(perldir)/, $(dir $(PERLMODULES)))
 
 install-infra: installdirs-infra
@@ -79,7 +86,7 @@ installdirs-infra:
 check installcheck:
 
 clean distclean mostlyclean maintainer-clean:
-       rm -rf tests/tmp
+       rm -rf tests/tmp substituted
        set -e; for m in $(MAN7PAGES); do \
                test -e $$m.pod && rm -f $$m; \
        done
diff --git a/dgit b/dgit
index 5fa500c65cc7ff2393d0ceb6fdce458b52446954..344d006692e40a80b40517d58e83502c16284020 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -41,6 +41,7 @@ use Carp;
 use Debian::Dgit;
 
 our $our_version = 'UNRELEASED'; ###substituted###
+our $absurdity = undef; ###substituted###
 
 our @rpushprotovsn_support = qw(4 3 2); # 4 is new tag format
 our $protovsn;
@@ -146,6 +147,11 @@ our @ourdscfield = qw(Dgit Vcs-Dgit-Master);
 our $csuite;
 our $instead_distro;
 
+if (!defined $absurdity) {
+    $absurdity = $0;
+    $absurdity =~ s{/[^/]+$}{/absurd} or die;
+}
+
 sub debiantag ($$) {
     my ($v,$distro) = @_;
     return $tagformatfn->($v, $distro);