tools: atomic creation of include files
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 16 May 2017 19:32:49 +0000 (21:32 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 29 May 2017 17:29:33 +0000 (19:29 +0200)
Replace shell redirect by equivalent `sponge` script from moreutils,
which keeps the original contents during creation avoiding downtime
during possibly slow remake.

Makefile

index 8e644e89b8a6ecd2e25a7109c7c1c115f17d915e..43323a15d08e1e59557e5607682e117bf4a54cc1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,37 +5,37 @@ download: data/DerivedAge.txt data/rfc1345.txt data/xorg-compose data/countryInf
 .PHONY: download
 
 sitemap.xml: tools/mksitemap
 .PHONY: download
 
 sitemap.xml: tools/mksitemap
-       $< >$@
+       $< | sponge $@
 
 data/DerivedAge.txt:
        tools/wget-ifmodified http://www.unicode.org/Public/UNIDATA/$(@F) $@
 
 data/unicode-age.inc.pl: tools/mkcharver data/DerivedAge.txt
 
 data/DerivedAge.txt:
        tools/wget-ifmodified http://www.unicode.org/Public/UNIDATA/$(@F) $@
 
 data/unicode-age.inc.pl: tools/mkcharver data/DerivedAge.txt
-       $< $(word 2,$^) >$@
+       $< $(word 2,$^) | sponge $@
 
 data/rfc1345.txt:
        tools/wget-ifmodified http://www.ietf.org/rfc/$(@F) $@
 
 data/digraphs-rfc.inc.pl: tools/mkdigraphs-rfc data/rfc1345.txt
 
 data/rfc1345.txt:
        tools/wget-ifmodified http://www.ietf.org/rfc/$(@F) $@
 
 data/digraphs-rfc.inc.pl: tools/mkdigraphs-rfc data/rfc1345.txt
-       $< $(word 2,$^) >$@
+       $< $(word 2,$^) | sponge $@
 
 data/digraphs-shiar.inc.pl: tools/mkdigraphs-shiar shiar.inc.txt
 
 data/digraphs-shiar.inc.pl: tools/mkdigraphs-shiar shiar.inc.txt
-       $< $(word 2,$^) >$@
+       $< $(word 2,$^) | sponge $@
 
 data/xorg-compose:
        tools/wget-ifmodified http://cgit.freedesktop.org/xorg/lib/libX11/plain/nls/en_US.UTF-8/Compose.pre $@
 
 data/digraphs-xorg.inc.pl: tools/mkdigraphs-xorg data/xorg-compose
 
 data/xorg-compose:
        tools/wget-ifmodified http://cgit.freedesktop.org/xorg/lib/libX11/plain/nls/en_US.UTF-8/Compose.pre $@
 
 data/digraphs-xorg.inc.pl: tools/mkdigraphs-xorg data/xorg-compose
-       $< $(word 2,$^) >$@
+       $< $(word 2,$^) | sponge $@
 
 data/digraphs-vim.inc.pl: tools/mkdigraphs-vim
 
 data/digraphs-vim.inc.pl: tools/mkdigraphs-vim
-       $< >$@
+       $< | sponge $@
 
 data/digraphs.inc.pl: tools/mkdigraphlist data/digraphs-rfc.inc.pl data/digraphs-vim.inc.pl data/digraphs-shiar.inc.pl data/unicode-char.inc.pl
 
 data/digraphs.inc.pl: tools/mkdigraphlist data/digraphs-rfc.inc.pl data/digraphs-vim.inc.pl data/digraphs-shiar.inc.pl data/unicode-char.inc.pl
-       $< >$@
+       $< | sponge $@
 
 data/unicode-char.inc.pl: tools/mkcharinfo data/digraphs-rfc.inc.pl data/digraphs-shiar.inc.pl data/unicode-age.inc.pl unicode-table.inc.pl
 
 data/unicode-char.inc.pl: tools/mkcharinfo data/digraphs-rfc.inc.pl data/digraphs-shiar.inc.pl data/unicode-age.inc.pl unicode-table.inc.pl
-       $< >$@
+       $< | sponge $@
 
 data/font/%.inc.pl: tools/mkttfinfo data/font/%.ttf
        $< $(word 2,$^) $@ || true
 
 data/font/%.inc.pl: tools/mkttfinfo data/font/%.ttf
        $< $(word 2,$^) $@ || true
@@ -46,7 +46,7 @@ data/xcolors:
        @[ -e $@ ] || git clone https://github.com/tlatsas/xcolors $@
 
 data/termcol-xcolor.inc.pl: tools/mktermcol-xcolor data/xcolors/themes
        @[ -e $@ ] || git clone https://github.com/tlatsas/xcolors $@
 
 data/termcol-xcolor.inc.pl: tools/mktermcol-xcolor data/xcolors/themes
-       $< $(word 2,$^)/* >$@
+       $< $(word 2,$^)/* | sponge $@
 
 .SECONDARY:
 data/font/%.ttf:
 
 .SECONDARY:
 data/font/%.ttf:
@@ -82,13 +82,13 @@ data/font/all-other: data/font/unifont.inc.pl data/font/code2000.inc.pl data/fon
 #      $< --headless unifont_upper.ttf >>$@
 
 data/unicode-cover.inc.pl: tools/mkfontinfo data/font $(patsubst data/font/%.ttf,data/font/%.inc.pl,$(wildcard data/font/*.ttf))
 #      $< --headless unifont_upper.ttf >>$@
 
 data/unicode-cover.inc.pl: tools/mkfontinfo data/font $(patsubst data/font/%.ttf,data/font/%.inc.pl,$(wildcard data/font/*.ttf))
-       $< >$@
+       $< | sponge $@
 
 data/countryInfo.txt:
        tools/wget-ifmodified http://download.geonames.org/export/dump/$(@F) $@
 
 data/countries.inc.pl: tools/mkcountries-geonames data/countryInfo.txt
 
 data/countryInfo.txt:
        tools/wget-ifmodified http://download.geonames.org/export/dump/$(@F) $@
 
 data/countries.inc.pl: tools/mkcountries-geonames data/countryInfo.txt
-       $< $(word 2,$^) >$@
+       $< $(word 2,$^) | sponge $@
 
 data/browser: data/browser/support.inc.pl data/browser/usage-wm.inc.pl
 
 
 data/browser: data/browser/support.inc.pl data/browser/usage-wm.inc.pl
 
@@ -98,13 +98,13 @@ data/browser/caniuse:
        @[ -e $@ ] || git clone https://github.com/Fyrd/caniuse.git $@
 
 data/browser/support.inc.pl: tools/mkcaniuse data/browser/caniuse/data.json
        @[ -e $@ ] || git clone https://github.com/Fyrd/caniuse.git $@
 
 data/browser/support.inc.pl: tools/mkcaniuse data/browser/caniuse/data.json
-       $< $(word 2,$^) >$@
+       $< $(word 2,$^) | sponge $@
 
 data/browser/usage-wm.tsv:
        tools/wget-ifmodified https://analytics.wikimedia.org/datasets/periodic/reports/metrics/browser/all_sites_by_browser_family_and_major_percent.tsv $@
 
 data/browser/usage-wm.inc.pl: tools/mkusage-wikimedia data/browser/usage-wm.tsv
 
 data/browser/usage-wm.tsv:
        tools/wget-ifmodified https://analytics.wikimedia.org/datasets/periodic/reports/metrics/browser/all_sites_by_browser_family_and_major_percent.tsv $@
 
 data/browser/usage-wm.inc.pl: tools/mkusage-wikimedia data/browser/usage-wm.tsv
-       $< $(word 2,$^) >$@
+       $< $(word 2,$^) | sponge $@
 
 clean:
        -rm data/digraphs.inc.pl
 
 clean:
        -rm data/digraphs.inc.pl
@@ -118,5 +118,5 @@ clean:
 .SECONDEXPANSION:
 
 data/writing-latn.inc.pl: $$(@F)
 .SECONDEXPANSION:
 
 data/writing-latn.inc.pl: $$(@F)
-       perl -MData::Dumper -wE 'my @t = do "$<" or die $$@; print Data::Dumper->new([\@t])->Terse(1)->Quotekeys(0)->Indent(1)->Dump' >$@
+       perl -MData::Dumper -wE 'my @t = do "$<" or die $$@; print Data::Dumper->new([\@t])->Terse(1)->Quotekeys(0)->Indent(1)->Dump' | sponge $@