version 1.2 | | version 1.3 |
---|
| | |
open( NSI, ">".$output.".nsi" );
| | open( NSI, ">".$output.".nsi" );
|
| |
|
# Let's write the header
| | # Let's write the header
|
| | print NSI "!include \"MUI.nsh\" |
| | Name \"Crossfire Server - $mapset\" |
| |
|
print NSI ";Application title\n";
| | CRCCheck On |
print NSI "Name \"Crossfire Server - $mapset\"\n";
| | |
print NSI "\n";
| | OutFile \"$output.exe\" |
print NSI ";Do A CRC Check\n";
| | |
print NSI "CRCCheck On\n";
| | InstallDir \"\$PROGRAMFILES\\Crossfire Server\" |
print NSI "\n";
| | |
print NSI ";Output File Name\n";
| | !define MUI_ABORTWARNING |
print NSI "OutFile \"$output.exe\"\n";
| | |
print NSI "\n";
| | !insertmacro MUI_PAGE_WELCOME |
print NSI ";License Page Introduction\n";
| | !insertmacro MUI_PAGE_LICENSE \"..\\COPYING\" |
print NSI "LicenseText \"You must agree to this license before installing.\"\n";
| | !insertmacro MUI_PAGE_COMPONENTS |
print NSI "\n";
| | !insertmacro MUI_PAGE_DIRECTORY |
print NSI ";License Data\n";
| | !insertmacro MUI_PAGE_INSTFILES |
print NSI "LicenseData \"..\\COPYING\"\n";
| | !insertmacro MUI_PAGE_FINISH |
print NSI "\n";
| | |
print NSI ";The Default Installation Directory\n";
| | !insertmacro MUI_UNPAGE_WELCOME |
print NSI "InstallDir \"\$PROGRAMFILES\\Crossfire Server\"\n";
| | !insertmacro MUI_UNPAGE_COMPONENTS |
print NSI "\n";
| | !insertmacro MUI_UNPAGE_INSTFILES |
print NSI ";The text to prompt the user to enter a directory\n";
| | !insertmacro MUI_UNPAGE_FINISH |
print NSI "DirText \"Please select the folder below\"\n";
| | |
print NSI "\n";
| | !insertmacro MUI_LANGUAGE \"English\" |
print NSI "CompletedText \"Installation complete\"\n";
| | |
print NSI "\n";
| | DirText \"Please select the folder below\" |
print NSI "Section \"Install\"\n";
| | |
| | CompletedText \"Installation complete\" |
| | |
| | UninstallText \"This will uninstall Crossfire Server $mapset from your system\" |
| | |
| | SetOverwrite IfNewer |
| | |
| | "; |
| |
|
my $startdir = $ARGV[ 1 ];
| | my $startdir = $ARGV[ 1 ];
|
chdir( $startdir );
| | chdir( $startdir );
|
| | |
my $currentinstdir = "";
| | my $currentinstdir = "";
|
| |
|
my $outdir = "\$INSTDIR\\share\\maps";
| | my $outdir = "\$INSTDIR\\share\\maps";
|
| | my $data = ""; |
my $remove = "";
| | |
my $remove = "";
| | my $remove = "";
|
| | my $mode = 0; |
| |
|
print "Startdir: $startdir\n";
| | print "Startdir: $startdir\n";
|
| |
|
find( \&handleFind, $startdir );
| | find( \&handleFind, $startdir );
|
| |
|
# Some reg keys for uninstall
| | print NSI "Section \"$mapset\" maps |
print NSI " WriteRegStr HKLM \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Crossfire Server $mapset\" \"DisplayName\" \"Crossfire Server $mapset (remove only)\"\n";
| | SectionIn RO |
print NSI " WriteRegStr HKLM \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Crossfire Server $mapset\" \"UninstallString\" \"\$INSTDIR\\UninstMaps.exe\"\n";
| | $data |
print NSI " WriteUninstaller \"UninstMaps.exe\"\n";
| | WriteRegStr HKLM \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Crossfire Server $mapset\" \"DisplayName\" \"Crossfire Server $mapset (remove only)\" |
| | WriteRegStr HKLM \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Crossfire Server $mapset\" \"UninstallString\" \"\$INSTDIR\\UninstMaps.exe\" |
# Finish: the remove statements
| | WriteUninstaller \"UninstMaps.exe\" |
print NSI "SectionEnd\n";
| | SectionEnd |
print NSI "\n";
| | "; |
print NSI "UninstallText \"This will uninstall Crossfire Server $mapset from your system\"\n";
| | |
print NSI "\n";
| | print NSI " |
print NSI "Section Uninstall\n";
| | |
print NSI "$remove";
| | Section \"un.$mapset\" |
print NSI " Delete \"\$INSTDIR\\UninstMaps.exe\"\n";
| | $remove |
print NSI " DeleteRegKey HKEY_LOCAL_MACHINE \"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Crossfire Server $mapset\"\n";
| | Delete \"\$INSTDIR\\UninstMaps.exe\" |
print NSI "SectionEnd\n";
| | DeleteRegKey HKEY_LOCAL_MACHINE \"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Crossfire Server $mapset\" |
| | SectionEnd |
| | |
| | "; |
| | |
| | #Unlinked maps |
| | do_maps( "Unlinked maps", "unlinked", 1 ); |
| | |
| | # test maps |
| | do_maps( "Test maps", "test", 2 ); |
| | |
| | # Python scripts |
| | do_maps( "Python scripts", "python", 3 ); |
| | |
| | print NSI " |
| | !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN |
| | !insertmacro MUI_DESCRIPTION_TEXT \${maps} \"The main game maps. Required.\" |
| | !insertmacro MUI_DESCRIPTION_TEXT \${unlinked} \"Maps that can't be accessed from the main maps.\" |
| | !insertmacro MUI_DESCRIPTION_TEXT \${test} \"Game test maps.\" |
| | !insertmacro MUI_DESCRIPTION_TEXT \${python} \"Python scripts. Require the server to have the Python plugin installed.\" |
| | !insertmacro MUI_FUNCTION_DESCRIPTION_END |
| | "; |
| |
|
print "Terminé.\n";
| | print "Done.\n"; |
| |
|
exit;
| | exit;
|
| |
|
| | |
my $foundFile = $File::Find::name;
| | my $foundFile = $File::Find::name;
|
my $dir = $File::Find::dir;
| | my $dir = $File::Find::dir;
|
if ($dir =~ m/\/CVS$/) { return 1; }
| | if ($dir =~ m/\/CVS$/) { return 1; }
|
| | if (($mode != 1) && ($dir =~ m/$startdir\/unlinked/ )) { return 1; } |
| | if (($mode != 2) && ($dir =~ m/$startdir\/test/ )) { return 1; } |
| | if (($mode != 3) && ($dir =~ m/$startdir\/python/ )) { return 1; } |
if ($foundFile =~ m/\/CVS$/) { return 1; }
| | if ($foundFile =~ m/\/CVS$/) { return 1; }
|
| | if ($foundFile =~ m/\.pyc$/) { return 1; } |
| | |
| | # Temp |
| | # if (( $mode == 0 ) && ($dir !=~ m/\/world\// )) { return 1; } |
| |
|
if ($currentdir ne $dir)
| | if ($currentdir ne $dir)
|
{
| | {
|
| | |
| |
|
$currentinstdir = $outdir.$dir;
| | $currentinstdir = $outdir.$dir;
|
| |
|
print NSI " CreateDirectory \"$currentinstdir\"\n";
| | $data .= " CreateDirectory \"$currentinstdir\"\n"; |
print NSI " SetOutPath \"$currentinstdir\"\n";
| | $data .= " SetOutPath \"$currentinstdir\"\n"; |
| |
|
# Remove statement
| | # Remove statement
|
$remove = " RmDir \"$currentinstdir\"\n" . $remove;
| | $remove = " RmDir \"$currentinstdir\"\n" . $remove;
|
| | |
if (!(-d $foundFile))
| | if (!(-d $foundFile))
|
{
| | {
|
$foundFile =~ s/\//\\/gi;
| | $foundFile =~ s/\//\\/gi;
|
print NSI " File \"" . $foundFile . "\"\n";
| | $data .= " File \"" . $foundFile . "\"\n"; |
# Remove statement
| | # Remove statement
|
$remove = " Delete \"$currentinstdir\\$base\"\n" . $remove;
| | $remove = " Delete \"$currentinstdir\\$base\"\n" . $remove;
|
if ( $foundFile =~ /.*py$/ )
| | if ( $foundFile =~ /.*py$/ )
|
| | |
exit;
| | exit;
|
}
| | }
|
| |
|
| | sub do_maps( ) |
| | { |
| | my $name = shift( ); |
| | my $path = shift( ); |
| | my $m = shift( ); |
| | |
| | $data = ""; |
| | $remove = ""; |
| | $mode = $m; |
| | print "$name from " . $startdir . "/$path/\n"; |
| | |
| | find( \&handleFind, $startdir . "/$path/" ); |
| | |
| | print NSI "Section \"$name\" $path |
| | $data |
| | SectionEnd |
| | |
| | Section \"un.$name\" |
| | $remove |
| | SectionEnd |
| | |
| | "; |
| | |
| | } |
| | |