Skip to content
Permalink
Browse files

osgeo4w:

* only use GRASS major version in executable names
* autodetect GRASS folder

(cherry picked from commit 3a4a3af)
  • Loading branch information
jef-n committed Nov 10, 2018
1 parent ef10781 commit bd5c44d49dfa13870156e3dcb220db480a7b5536
@@ -250,9 +250,11 @@ if errorlevel 1 (echo creation of registry template & goto error)

set batches=
for %%g IN (%GRASS_VERSIONS%) do (
sed -e 's/@package@/%PACKAGENAME%/g' -e 's/@version@/%VERSION%/g' -e 's/@grassversion@/%%g/g' qgis-grass.bat.tmpl >%OSGEO4W_ROOT%\bin\%PACKAGENAME%-g%%g.bat.tmpl
for /F "delims=." %%i in ("%%g") do set v=%%i

sed -e 's/@package@/%PACKAGENAME%/g' -e 's/@version@/%VERSION%/g' -e 's/@grassversion@/%%g/g' qgis-grass.bat.tmpl >%OSGEO4W_ROOT%\bin\%PACKAGENAME%-g!v!.bat.tmpl
if errorlevel 1 (echo creation of desktop template failed & goto error)
set batches=!batches! bin/%PACKAGENAME%-g%%g.bat.tmpl
set batches=!batches! bin/%PACKAGENAME%-g!v!.bat.tmpl
)

sed -e 's/@package@/%PACKAGENAME%/g' -e 's/@version@/%VERSION%/g' python.bat.tmpl >%OSGEO4W_ROOT%\bin\python-%PACKAGENAME%.bat.tmpl
@@ -1,3 +1,5 @@
setlocal enabledelayedexpansion

textreplace -std -t bin\@package@-designer.bat
textreplace -std -t bin\python-@package@.bat

@@ -7,13 +9,15 @@ if not %OSGEO4W_MENU_LINKS%==0 mkdir "%OSGEO4W_STARTMENU%"
if not %OSGEO4W_DESKTOP_LINKS%==0 mkdir "%OSGEO4W_DESKTOP%"

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
call "%OSGEO4W_ROOT%\bin\@package@-g%%g.bat" --postinstall
for /F "delims=." %%i in ("%%g") do set v=%%i

copy "%OSGEO4W_ROOT%\bin\@package@-bin.exe" "%OSGEO4W_ROOT%\bin\@package@-bin-g!v!.exe"
copy "%OSGEO4W_ROOT%\bin\@package@-bin.vars" "%OSGEO4W_ROOT%\bin\@package@-bin-g!v!.vars"
textreplace -std -map @grassmajor@ !v! -t bin\@package@-g!v!.bat
call "%OSGEO4W_ROOT%\bin\@package@-g!v!.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)"
if not %OSGEO4W_MENU_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\@package@-bin-g!v!.exe" "%OSGEO4W_STARTMENU%" "QGIS Desktop @version@ with GRASS %%g (Nightly)"
if not %OSGEO4W_DESKTOP_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\@package@-bin-g!v!.exe" "%OSGEO4W_DESKTOP%" "QGIS Desktop @version@ with GRASS %%g (Nightly)"
)

if not %OSGEO4W_MENU_LINKS%==0 nircmd shortcut "%OSGEO4W_ROOT%\bin\nircmd.exe" "%OSGEO4W_STARTMENU%" "Qt Designer with QGIS @version@ custom widgets (Nightly)" "exec hide """%OSGEO4W_ROOT%\bin\@package@-designer.bat"" "%OSGEO4W_ROOT%\apps\@package@\icons\QGIS.ico"
@@ -35,3 +39,5 @@ set QGIS_PREFIX_PATH=%OSGEO4W_ROOT:\=/%/apps/@package@

del /s /q "%OSGEO4W_ROOT%\apps\@package@\*.pyc"
exit /b 0

endlocal
@@ -1,12 +1,16 @@
setlocal enabledelayedexpansion

for %%g in (@grassversions@) do (
for /F "delims=." %%i in ("%%g") do set v=%%i

del "%OSGEO4W_STARTMENU%\QGIS Desktop @version@ with GRASS %%g (Nightly).lnk"
del "%OSGEO4W_STARTMENU%\QGIS Browser @version@ with GRASS %%g (Nightly).lnk"
del "%OSGEO4W_DESKTOP%\QGIS Desktop @version@ with GRASS %%g (Nightly).lnk"
del "%OSGEO4W_DESKTOP%\QGIS Browser @version@ with GRASS %%g (Nightly).lnk"
del "%OSGEO4W_ROOT%\bin\@package@-g%%g.bat"
del "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.exe"
del "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.env"
del "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.vars"
del "%OSGEO4W_ROOT%\bin\@package@-g!v!.bat"
del "%OSGEO4W_ROOT%\bin\@package@-bin-g!v!.exe"
del "%OSGEO4W_ROOT%\bin\@package@-bin-g!v!.env"
del "%OSGEO4W_ROOT%\bin\@package@-bin-g!v!.vars"
)

del "%OSGEO4W_STARTMENU%\Qt Designer with QGIS @version@ custom widgets (Nightly).lnk"
@@ -20,3 +24,5 @@ del "%OSGEO4W_ROOT%\bin\python-@package@.bat"
del "%OSGEO4W_ROOT%\apps\@package@\python\qgis\qgisconfig.py"
del "%OSGEO4W_ROOT%\apps\@package@\bin\qgis.reg"
del /s /q "%OSGEO4W_ROOT%\apps\@package@\*.pyc"

endlocal
@@ -11,4 +11,4 @@ rem Set VSI cache to be used as buffer, see #6448
set VSI_CACHE=TRUE
set VSI_CACHE_SIZE=1000000
set QT_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\@package@\qtplugins;%OSGEO4W_ROOT%\apps\qt5\plugins
start "QGIS" /B "%OSGEO4W_ROOT%\bin\@package@-bin-g@grassversion@.exe" %*
start "QGIS" /B "%OSGEO4W_ROOT%\bin\@package@-bin-g@grassmajor@.exe" %*
@@ -52,7 +52,7 @@ def load(self):
ProcessingConfig.settingIcons[self.name()] = self.icon()
ProcessingConfig.addSetting(Setting(self.name(), 'ACTIVATE_GRASS7',
self.tr('Activate'), True))
if isWindows() or isMac():
if isMac():
ProcessingConfig.addSetting(Setting(
self.name(),
Grass7Utils.GRASS_FOLDER, self.tr('GRASS7 folder'),
@@ -84,7 +84,7 @@ def load(self):

def unload(self):
ProcessingConfig.removeSetting('ACTIVATE_GRASS7')
if isWindows() or isMac():
if isMac():
ProcessingConfig.removeSetting(Grass7Utils.GRASS_FOLDER)
ProcessingConfig.removeSetting(Grass7Utils.GRASS_LOG_COMMANDS)
ProcessingConfig.removeSetting(Grass7Utils.GRASS_LOG_CONSOLE)
@@ -193,8 +193,11 @@ def grassPath():
if not isWindows() and not isMac():
return ''

folder = ProcessingConfig.getSetting(Grass7Utils.GRASS_FOLDER) or ''
if not os.path.exists(folder):
if isMac():
folder = ProcessingConfig.getSetting(Grass7Utils.GRASS_FOLDER) or ''
if not os.path.exists(folder):
folder = None
else:
folder = None

if folder is None:
@@ -206,10 +209,9 @@ def grassPath():
testfolder = str(QgsApplication.prefixPath())
testfolder = os.path.join(testfolder, 'grass')
if os.path.isdir(testfolder):
for subfolder in os.listdir(testfolder):
if subfolder.startswith('grass-7'):
folder = os.path.join(testfolder, subfolder)
break
grassfolders = sorted([f for f in os.listdir(testfolder) if f.startswith("grass-7.") and os.path.isdir(os.path.join(testfolder, f))], reverse=True, key=lambda x: [int(v) for v in x[len("grass-"):].split('.')])
if grassfolders:
folder = os.path.join(testfolder, grassfolders[0])
elif isMac():
# For MacOSX, we scan some well-known directories
# Start with QGIS bundle

0 comments on commit bd5c44d

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