chiark / gitweb /
preview png, actually make it a png
[pandemic-rising-tide.git] / maybe-rerun-optim
1 #!/bin/bash
2 #
3 # maybe-rerun-optim - helper for build system for board layouts
4 #
5 # Copyright (C) 2019 Ian Jackson
6 #
7 # This program is dual licensed, GPv3+ or CC-BY-SA 4.0+.
8 # Only to the Pandemic Rising Tide folks, it is permissively licensed.
9 #
10 #   This program is free software.
11 #
12 #   You can redistribute it and/or modify it under the terms of the
13 #   GNU General Public License as published by the Free Software
14 #   Foundation, either version 3 of the License, or (at your option)
15 #   any later version; or (at your option), under the terms of the
16 #   Creative Commons Attribution-ShareAlike International License,
17 #   version 4.0 of that License, or (at your option), any later
18 #   version.
19 #
20 #   This program is distributed in the hope that it will be useful,
21 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
22 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23 #   General Public License Creative Commons Attribution-ShareAlike
24 #   License or the for more details.
25 #
26 #   You should have received a copy of these licenses along with this
27 #   program.  If not, see <https://www.gnu.org/licenses/> and
28 #   <https://creativecommons.org/licenses/>.
29 #
30 # Pandemic and Pandemic Rising Tide are (I think) trademarks of Z-Man
31 # games and I use them without permission.
32
33 # For the avoidance of doubt, I do not consider this program to be a
34 # derivative work of the game Pandemic Rising Tide.  However, it is
35 # not very useful without a pair of game description files and the
36 # only nontrivial game description files I know of are indeed such
37 # derivatives.
38
39
40 set -e
41 set -o posix
42 set -o pipefail
43
44 input=$1        ; shift
45 planar_graph=$1 ; shift
46 dest=$1         ; shift
47 sums=$1         ; shift
48
49 inst () { mv -vf $dest.tmp $dest; }
50
51 if test -f $dest.reuse; then
52         cp -v $dest.reuse $dest.tmp
53         inst
54         exit 0
55 fi
56
57 sha256sum "$input" "$planar_graph" >$sums.tmp
58 for arg in "$@"; do printf >>$sums.tmp "%s\n" "$arg"; done
59
60 if cmp $sums.tmp $sums; then
61         exit 0
62 fi
63
64 "$planar_graph" <$input "$@"
65
66 inst
67 mv -f $sums.tmp $sums