chiark / gitweb /
Tents: mark squares as non-tents with {Shift,Control}-cursor keys.
[sgt-puzzles.git] / winiss.pl
1 #!/usr/bin/perl
2
3 # Perl script to generate an Inno Setup installer script for
4 # Puzzles. This has to be scripted so that it can read gamedesc.txt
5 # and automatically adjust to the current available set of puzzles.
6
7 # Usage:
8 #
9 #   $ ./winiss.pl 20140922.sdfsdf gamedesc.txt > puzzles.iss
10 #
11 # where the first argument is the version number which will be encoded
12 # in the installer's version indicators. The first component of that
13 # version number will be expected to be a YYYYMMDD-format date.
14
15 use warnings;
16 use Time::Local;
17
18 $ver = shift @ARGV;
19
20 # Parse the date out of $ver, and convert it into an integer number of
21 # days since an arbitrary epoch. This number is used for the Windows
22 # version resource (which wants a monotonic 16-bit integer). The epoch
23 # is chosen so that the first build using this date-based mechanism
24 # has a higher number than the last build in which that number was
25 # derived from a Subversion revision.
26 die "bad date format" if $ver !~ /^(\d{4})(\d{2})(\d{2})/;
27 $date = timegm(0,0,0,$3,$2-1,$1);
28 $integer_date = int($date / 86400) - 6000;
29
30 $desc = shift @ARGV;
31 open DESC, "<", $desc;
32 while (<DESC>) {
33     chomp;
34     @_ = split /:/;
35     push @exes, $_[1];
36     $names{$_[1]} = $_[2];
37 }
38 close DESC;
39
40 print '; -*- no -*-'."\n";
41 print ';'."\n";
42 print '; -- Inno Setup installer script for Puzzles.'."\n";
43 print ''."\n";
44 print '[Setup]'."\n";
45 print 'AppName=Simon Tatham\'s Portable Puzzle Collection'."\n";
46 print 'AppVerName=Puzzles version '.$ver."\n";
47 print 'VersionInfoTextVersion=Version '.$ver."\n";
48 print 'AppVersion=r'.$ver."\n";
49 print 'VersionInfoVersion=0.0.'.$integer_date.'.0'."\n";
50 print 'AppPublisher=Simon Tatham'."\n";
51 print 'AppPublisherURL=http://www.chiark.greenend.org.uk/~sgtatham/puzzles/'."\n";
52 print 'DefaultDirName={pf}\Simon Tatham\'s Portable Puzzle Collection'."\n";
53 print 'DefaultGroupName=Simon Tatham\'s Puzzles'."\n";
54 # print 'SetupIconFile=fixmethinkoneup.ico'."\n";
55 # print 'UninstallDisplayIcon={app}\fixmethinkoneup.exe'."\n";
56 print 'ChangesAssociations=no'."\n";
57 print 'Compression=zip/9'."\n";
58 print 'AllowNoIcons=yes'."\n";
59 print ''."\n";
60 print '[Files]'."\n";
61 for $exe (@exes) {
62     print 'Source: "'.$exe.'"; DestDir: "{app}"; Flags: promptifolder replacesameversion uninsrestartdelete'."\n";
63 }
64 print 'Source: "website.url"; DestDir: "{app}"; Flags: uninsrestartdelete'."\n";
65 print 'Source: "puzzles.chm"; DestDir: "{app}"; Flags: uninsrestartdelete'."\n";
66 print 'Source: "puzzles.hlp"; DestDir: "{app}"; Flags: uninsrestartdelete'."\n";
67 print 'Source: "puzzles.cnt"; DestDir: "{app}"; Flags: uninsrestartdelete'."\n";
68 print 'Source: "LICENCE"; DestDir: "{app}"; Flags: uninsrestartdelete'."\n";
69 print ''."\n";
70 print '[Icons]'."\n";
71 for $exe (@exes) {
72     print 'Name: "{group}\\'.$names{$exe}.'"; Filename: "{app}\\'.$exe.'"'."\n";
73 }
74 print '; We have to fall back from the .chm to the older .hlp file on some Windows'."\n";
75 print '; versions.'."\n";
76 print 'Name: "{group}\Puzzles Manual"; Filename: "{app}\puzzles.chm"; MinVersion: 4.1,5.0'."\n";
77 print 'Name: "{group}\Puzzles Manual"; Filename: "{app}\puzzles.hlp"; OnlyBelowVersion: 4.1,5.0'."\n";
78 print 'Name: "{group}\Puzzles Web Site"; Filename: "{app}\website.url"'."\n";