Skip to content

Commit bd5c44d

Browse files
committedNov 10, 2018
osgeo4w:
* only use GRASS major version in executable names * autodetect GRASS folder (cherry picked from commit 3a4a3af)
1 parent ef10781 commit bd5c44d

File tree

6 files changed

+37
-21
lines changed

6 files changed

+37
-21
lines changed
 

‎ms-windows/osgeo4w/package-nightly.cmd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,11 @@ if errorlevel 1 (echo creation of registry template & goto error)
250250

251251
set batches=
252252
for %%g IN (%GRASS_VERSIONS%) do (
253-
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
253+
for /F "delims=." %%i in ("%%g") do set v=%%i
254+
255+
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
254256
if errorlevel 1 (echo creation of desktop template failed & goto error)
255-
set batches=!batches! bin/%PACKAGENAME%-g%%g.bat.tmpl
257+
set batches=!batches! bin/%PACKAGENAME%-g!v!.bat.tmpl
256258
)
257259

258260
sed -e 's/@package@/%PACKAGENAME%/g' -e 's/@version@/%VERSION%/g' python.bat.tmpl >%OSGEO4W_ROOT%\bin\python-%PACKAGENAME%.bat.tmpl

‎ms-windows/osgeo4w/postinstall-dev.bat

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
setlocal enabledelayedexpansion
2+
13
textreplace -std -t bin\@package@-designer.bat
24
textreplace -std -t bin\python-@package@.bat
35

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

911
for %%g in (@grassversions@) do (
10-
copy "%OSGEO4W_ROOT%\bin\@package@-bin.exe" "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.exe"
11-
copy "%OSGEO4W_ROOT%\bin\@package@-bin.vars" "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.vars"
12-
textreplace -std -t bin\@package@-g%%g.bat
13-
call "%OSGEO4W_ROOT%\bin\@package@-g%%g.bat" --postinstall
12+
for /F "delims=." %%i in ("%%g") do set v=%%i
13+
14+
copy "%OSGEO4W_ROOT%\bin\@package@-bin.exe" "%OSGEO4W_ROOT%\bin\@package@-bin-g!v!.exe"
15+
copy "%OSGEO4W_ROOT%\bin\@package@-bin.vars" "%OSGEO4W_ROOT%\bin\@package@-bin-g!v!.vars"
16+
textreplace -std -map @grassmajor@ !v! -t bin\@package@-g!v!.bat
17+
call "%OSGEO4W_ROOT%\bin\@package@-g!v!.bat" --postinstall
1418

15-
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)"
16-
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)"
19+
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)"
20+
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)"
1721
)
1822

1923
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@
3539

3640
del /s /q "%OSGEO4W_ROOT%\apps\@package@\*.pyc"
3741
exit /b 0
42+
43+
endlocal

‎ms-windows/osgeo4w/preremove-dev.bat

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
setlocal enabledelayedexpansion
2+
13
for %%g in (@grassversions@) do (
4+
for /F "delims=." %%i in ("%%g") do set v=%%i
5+
26
del "%OSGEO4W_STARTMENU%\QGIS Desktop @version@ with GRASS %%g (Nightly).lnk"
37
del "%OSGEO4W_STARTMENU%\QGIS Browser @version@ with GRASS %%g (Nightly).lnk"
48
del "%OSGEO4W_DESKTOP%\QGIS Desktop @version@ with GRASS %%g (Nightly).lnk"
59
del "%OSGEO4W_DESKTOP%\QGIS Browser @version@ with GRASS %%g (Nightly).lnk"
6-
del "%OSGEO4W_ROOT%\bin\@package@-g%%g.bat"
7-
del "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.exe"
8-
del "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.env"
9-
del "%OSGEO4W_ROOT%\bin\@package@-bin-g%%g.vars"
10+
del "%OSGEO4W_ROOT%\bin\@package@-g!v!.bat"
11+
del "%OSGEO4W_ROOT%\bin\@package@-bin-g!v!.exe"
12+
del "%OSGEO4W_ROOT%\bin\@package@-bin-g!v!.env"
13+
del "%OSGEO4W_ROOT%\bin\@package@-bin-g!v!.vars"
1014
)
1115

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

‎ms-windows/osgeo4w/qgis-grass.bat.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ rem Set VSI cache to be used as buffer, see #6448
1111
set VSI_CACHE=TRUE
1212
set VSI_CACHE_SIZE=1000000
1313
set QT_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\@package@\qtplugins;%OSGEO4W_ROOT%\apps\qt5\plugins
14-
start "QGIS" /B "%OSGEO4W_ROOT%\bin\@package@-bin-g@grassversion@.exe" %*
14+
start "QGIS" /B "%OSGEO4W_ROOT%\bin\@package@-bin-g@grassmajor@.exe" %*

‎python/plugins/processing/algs/grass7/Grass7AlgorithmProvider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def load(self):
5252
ProcessingConfig.settingIcons[self.name()] = self.icon()
5353
ProcessingConfig.addSetting(Setting(self.name(), 'ACTIVATE_GRASS7',
5454
self.tr('Activate'), True))
55-
if isWindows() or isMac():
55+
if isMac():
5656
ProcessingConfig.addSetting(Setting(
5757
self.name(),
5858
Grass7Utils.GRASS_FOLDER, self.tr('GRASS7 folder'),
@@ -84,7 +84,7 @@ def load(self):
8484

8585
def unload(self):
8686
ProcessingConfig.removeSetting('ACTIVATE_GRASS7')
87-
if isWindows() or isMac():
87+
if isMac():
8888
ProcessingConfig.removeSetting(Grass7Utils.GRASS_FOLDER)
8989
ProcessingConfig.removeSetting(Grass7Utils.GRASS_LOG_COMMANDS)
9090
ProcessingConfig.removeSetting(Grass7Utils.GRASS_LOG_CONSOLE)

‎python/plugins/processing/algs/grass7/Grass7Utils.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,11 @@ def grassPath():
193193
if not isWindows() and not isMac():
194194
return ''
195195

196-
folder = ProcessingConfig.getSetting(Grass7Utils.GRASS_FOLDER) or ''
197-
if not os.path.exists(folder):
196+
if isMac():
197+
folder = ProcessingConfig.getSetting(Grass7Utils.GRASS_FOLDER) or ''
198+
if not os.path.exists(folder):
199+
folder = None
200+
else:
198201
folder = None
199202

200203
if folder is None:
@@ -206,10 +209,9 @@ def grassPath():
206209
testfolder = str(QgsApplication.prefixPath())
207210
testfolder = os.path.join(testfolder, 'grass')
208211
if os.path.isdir(testfolder):
209-
for subfolder in os.listdir(testfolder):
210-
if subfolder.startswith('grass-7'):
211-
folder = os.path.join(testfolder, subfolder)
212-
break
212+
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('.')])
213+
if grassfolders:
214+
folder = os.path.join(testfolder, grassfolders[0])
213215
elif isMac():
214216
# For MacOSX, we scan some well-known directories
215217
# Start with QGIS bundle

0 commit comments

Comments
 (0)
Please sign in to comment.