Skip to content
Permalink
Browse files

osgeo4w: fix postinstall scripts (fixes #17993)

  • Loading branch information
jef-n committed Jan 31, 2018
1 parent 70fc32b commit 2a52a629647c5f65d954bf8724efd8a131684a56
@@ -6,7 +6,7 @@ REM get short path without blanks
for %%i in ("%OSGEO4W_ROOT%") do set O4W_ROOT=%%~fsi
if "%OSGEO4W_DESKTOP%"=="" set OSGEO4W_DESKTOP=~$folder.common_desktop$

"%OSGEO4W_ROOT%\bin\@package@.bat" --exit
call "%OSGEO4W_ROOT%\bin\@package@.bat" --postinstall

if not %OSGEO4W_MENU_LINKS%==0 mkdir "%OSGEO4W_STARTMENU%"
if not %OSGEO4W_DESKTOP_LINKS%==0 mkdir "%OSGEO4W_DESKTOP%"
@@ -10,7 +10,7 @@ for %%g in (@grassversions@) do (
copy "%OSGEO4W_ROOT%\bin\@package@-bin.exe" "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.exe"
copy "%OSGEO4W_ROOT%\bin\@package@-bin.vars" "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.vars"
textreplace -std -t bin\@package@-g%%g.bat
"%OSGEO4W_ROOT%\bin\@package@-g%%g.bat" --exit
call "%OSGEO4W_ROOT%\bin\@package@-g%%g.bat" --postinstall

if not %OSGEO4W_MENU_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.exe" "%OSGEO4W_STARTMENU%" "QGIS Desktop @version@ with GRASS %%g (Nightly)"
if not %OSGEO4W_DESKTOP_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.exe" "%OSGEO4W_DESKTOP%" "QGIS Desktop @version@ with GRASS %%g (Nightly)"
@@ -4,7 +4,7 @@ if "%OSGEO4W_DESKTOP%"=="" set OSGEO4W_DESKTOP=~$folder.common_desktop$

copy bin\@package@-bin.exe bin\@package@-bin-grass@grassmajor@.exe
copy bin\@package@-bin.vars bin\@package@-bin-grass@grassmajor@.vars
"%OSGEO4W_ROOT%\bin\@package@-grass@grassmajor@.bat" --exit
call "%OSGEO4W_ROOT%\bin\@package@-grass@grassmajor@.bat" --postinstall

if not %OSGEO4W_MENU_LINKS%==0 mkdir "%OSGEO4W_STARTMENU%"
if not %OSGEO4W_DESKTOP_LINKS%==0 mkdir "%OSGEO4W_DESKTOP%"
@@ -42,7 +42,7 @@ int CALLBACK WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
{
std::string basename( moduleExeBaseName() );

if ( getenv( "OSGEO4W_ROOT" ) )
if ( getenv( "OSGEO4W_ROOT" ) && __argc == 2 && strcmp( __argv[1], "--postinstall" ) == 0 )
{
std::string envfile( basename + ".env" );

@@ -90,41 +90,36 @@ int CALLBACK WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
}
}

if ( __argc == 2 && strcmp( __argv[1], "--exit" ) == 0 )
{
return EXIT_SUCCESS;
}
return EXIT_SUCCESS;
}
else

try
{
try
{
std::ifstream file;
file.open( basename + ".env" );
std::ifstream file;
file.open( basename + ".env" );

std::string var;
while ( std::getline( file, var ) )
std::string var;
while ( std::getline( file, var ) )
{
if ( _putenv( var.c_str() ) < 0 )
{
if ( _putenv( var.c_str() ) < 0 )
{
std::string message = "Could not set environment variable:" + var;
showError( message, "Error loading QGIS" );
return EXIT_FAILURE;
}
std::string message = "Could not set environment variable:" + var;
showError( message, "Error loading QGIS" );
return EXIT_FAILURE;
}
}
catch ( std::ifstream::failure e )
{
std::string message = "Could not read environment file " + basename + ".env" + " [" + e.what() + "]";
showError( message, "Error loading QGIS" );
return EXIT_FAILURE;
}
}
catch ( std::ifstream::failure e )
{
std::string message = "Could not read environment file " + basename + ".env" + " [" + e.what() + "]";
showError( message, "Error loading QGIS" );
return EXIT_FAILURE;
}

#ifdef _MSC_VER
HINSTANCE hGetProcIDDLL = LoadLibrary( "qgis_app.dll" );
#else
// MinGW
// MinGW
HINSTANCE hGetProcIDDLL = LoadLibrary( "libqgis_app.dll" );
#endif

0 comments on commit 2a52a62

Please sign in to comment.
You can’t perform that action at this time.