ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/make_win32/make_maps_nsi.pl
Revision: 1.1.1.1 (vendor branch)
Committed: Fri Feb 3 07:14:17 2006 UTC (18 years, 3 months ago) by root
Content type: text/plain
Branch: UPSTREAM
CVS Tags: UPSTREAM_2006_03_15, LAST_C_VERSION, STABLE, UPSTREAM_2006_02_22, difficulty_fix_merge_060810_2300, UPSTREAM_2006_02_03
Branch point for: difficulty_fix
Changes since 1.1: +0 -0 lines
Log Message:
initial import

File Contents

# User Rev Content
1 root 1.1 # This is a Perl script used to generate Nullsoft's Installer
2     # scripts for Crossfire maps.
3     # NullSoft installer can be found at http://nsis.sourceforge.net
4     # (note: this script is probably relevant to Windows platform only)
5    
6     # Created by Nicolas 'Ryo'
7     # Released in public domain
8    
9     # Based on http://nsis.sourceforge.net/archive/nsisweb.php?page=93&instances=0,8
10    
11     # Usage: make_maps_nsi.pl <map set name> <path to search>
12     # <map set name> is for instance 'Bigworld Maps' or 'SmallWorld Maps'
13     # <path to search> is, well, the path to search for maps
14    
15     # The install script will have the following features:
16     # * its name is 'CrossfireServer<map set name without spaces>.nsi'
17     # * generated .exe name 'CrossfireServer<map set name without spaces>.exe'
18     # * all files except CVS\* are grabbed
19     # * default install path %program files%\Crossfire Server\share\maps
20     # * uninstall entry 'Crossfire Server - <map set name>' in control panel
21     # * uninstaller called 'UnistMaps.exe' in %program files%\Crossfire Server (to avoid
22     # conflits with Crossfire Server's uninstaller)
23    
24     # Notes:
25     # * the licence the .nsi will use is supposed to be ..\COPYING
26     # the idea is that the .nsi is ran from make_win32 subdirectory
27    
28     use File::Find;
29     use File::Spec;
30     use Cwd;
31    
32     use strict;
33    
34     my $Crossfire = "Crossfire Server";
35    
36     &help unless @ARGV == 2;
37    
38     my $mapset = $ARGV[ 0 ];
39    
40     my $output = $Crossfire.$mapset;
41     $output =~ s/ //g;
42    
43     print "Output: $output\n";
44    
45     open( NSI, ">".$output.".nsi" );
46    
47     # Let's write the header
48     print NSI "!include \"MUI.nsh\"
49     Name \"Crossfire Server - $mapset\"
50    
51     CRCCheck On
52    
53     OutFile \"$output.exe\"
54    
55     InstallDir \"\$PROGRAMFILES\\Crossfire Server\"
56    
57     !define MUI_ABORTWARNING
58    
59     !insertmacro MUI_PAGE_WELCOME
60     !insertmacro MUI_PAGE_LICENSE \"..\\COPYING\"
61     !insertmacro MUI_PAGE_COMPONENTS
62     !insertmacro MUI_PAGE_DIRECTORY
63     !insertmacro MUI_PAGE_INSTFILES
64     !insertmacro MUI_PAGE_FINISH
65    
66     !insertmacro MUI_UNPAGE_WELCOME
67     !insertmacro MUI_UNPAGE_COMPONENTS
68     !insertmacro MUI_UNPAGE_INSTFILES
69     !insertmacro MUI_UNPAGE_FINISH
70    
71     !insertmacro MUI_LANGUAGE \"English\"
72    
73     DirText \"Please select the folder below\"
74    
75     CompletedText \"Installation complete\"
76    
77     UninstallText \"This will uninstall Crossfire Server $mapset from your system\"
78    
79     SetOverwrite IfNewer
80    
81     ";
82    
83     my $startdir = $ARGV[ 1 ];
84     chdir( $startdir );
85     $startdir = cwd( );
86    
87     my $currentdir = "";
88     my $currentinstdir = "";
89    
90     my $outdir = "\$INSTDIR\\share\\maps";
91     my $data = "";
92     my $remove = "";
93     my $mode = 0;
94    
95     print "Startdir: $startdir\n";
96    
97     find( \&handleFind, $startdir );
98    
99     print NSI "Section \"$mapset\" maps
100     SectionIn RO
101     $data
102     WriteRegStr HKLM \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Crossfire Server $mapset\" \"DisplayName\" \"Crossfire Server $mapset (remove only)\"
103     WriteRegStr HKLM \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Crossfire Server $mapset\" \"UninstallString\" \"\$INSTDIR\\UninstMaps.exe\"
104     WriteUninstaller \"UninstMaps.exe\"
105     SectionEnd
106     ";
107    
108     print NSI "
109    
110     Section \"un.$mapset\"
111     $remove
112     Delete \"\$INSTDIR\\UninstMaps.exe\"
113     DeleteRegKey HKEY_LOCAL_MACHINE \"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Crossfire Server $mapset\"
114     SectionEnd
115    
116     ";
117    
118     #Unlinked maps
119     do_maps( "Unlinked maps", "unlinked", 1 );
120    
121     # test maps
122     do_maps( "Test maps", "test", 2 );
123    
124     # Python scripts
125     do_maps( "Python scripts", "python", 3 );
126    
127     print NSI "
128     !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
129     !insertmacro MUI_DESCRIPTION_TEXT \${maps} \"The main game maps. Required.\"
130     !insertmacro MUI_DESCRIPTION_TEXT \${unlinked} \"Maps that can't be accessed from the main maps.\"
131     !insertmacro MUI_DESCRIPTION_TEXT \${test} \"Game test maps.\"
132     !insertmacro MUI_DESCRIPTION_TEXT \${python} \"Python scripts. Require the server to have the Python plugin installed.\"
133     !insertmacro MUI_FUNCTION_DESCRIPTION_END
134     ";
135    
136     print "Done.\n";
137    
138     exit;
139    
140     sub handleFind
141     {
142     my $base = $_;
143     my $foundFile = $File::Find::name;
144     my $dir = $File::Find::dir;
145     if ($dir =~ m/\/CVS$/) { return 1; }
146     if (($mode != 1) && ($dir =~ m/$startdir\/unlinked/ )) { return 1; }
147     if (($mode != 2) && ($dir =~ m/$startdir\/test/ )) { return 1; }
148     if (($mode != 3) && ($dir =~ m/$startdir\/python/ )) { return 1; }
149     if ($foundFile =~ m/\/CVS$/) { return 1; }
150     if ($foundFile =~ m/\.pyc$/) { return 1; }
151    
152     # Temp
153     # if (( $mode == 0 ) && ($dir !=~ m/\/world\// )) { return 1; }
154    
155     if ($currentdir ne $dir)
156     {
157     $currentdir = $dir;
158    
159     $dir =~ s/$startdir//ig;
160     $dir =~ s/\//\\/ig;
161    
162     $currentinstdir = $outdir.$dir;
163    
164     $data .= " CreateDirectory \"$currentinstdir\"\n";
165     $data .= " SetOutPath \"$currentinstdir\"\n";
166    
167     # Remove statement
168     $remove = " RmDir \"$currentinstdir\"\n" . $remove;
169     }
170    
171     if (!(-d $foundFile))
172     {
173     $foundFile =~ s/\//\\/gi;
174     $data .= " File \"" . $foundFile . "\"\n";
175     # Remove statement
176     $remove = " Delete \"$currentinstdir\\$base\"\n" . $remove;
177     if ( $foundFile =~ /.*py$/ )
178     {
179     $remove = " Delete \"$currentinstdir\\" . $base . "c\"\n" . $remove;
180     }
181     }
182     }
183    
184     sub help( )
185     {
186     print "Syntax error.\n";
187     print "Read instructions at top of this script.\n";
188     exit;
189     }
190    
191     sub do_maps( )
192     {
193     my $name = shift( );
194     my $path = shift( );
195     my $m = shift( );
196    
197     $data = "";
198     $remove = "";
199     $mode = $m;
200     print "$name from " . $startdir . "/$path/\n";
201    
202     find( \&handleFind, $startdir . "/$path/" );
203    
204     print NSI "Section \"$name\" $path
205     $data
206     SectionEnd
207    
208     Section \"un.$name\"
209     $remove
210     SectionEnd
211    
212     ";
213    
214     }