-
-
Save Guts/6303dc5eb941eb24be3e27609cd46985 to your computer and use it in GitHub Desktop.
#Requires -RunAsAdministrator | |
<# | |
.Synopsis | |
Download the OSGeo4W installer then download and install QGIS LTR (through the 'full' meta-package). | |
.DESCRIPTION | |
This script will: | |
1. change the current directory to the user downloads folder | |
2. download the OSGeo4W installer | |
3. launch it passing command-line parameters to DOWNLOAD packages required to QGIS LTR FULL | |
4. launch it passing command-line parameters to INSTALL QGIS LTR | |
Documentation reference: https://trac.osgeo.org/osgeo4w/wiki/CommandLine | |
#> | |
# Save current working directory | |
$starter_path = Get-Location | |
# Move into the user download directory | |
Set-Location -Path "$env:USERPROFILE/Downloads" | |
# Download installer if not exists | |
if (-Not (Test-Path "osgeo4w_v2-setup.exe" -PathType leaf )) { | |
Write-Host "= Start downloading the OSGeo4W installer" -ForegroundColor Yellow | |
Invoke-WebRequest -Uri "https://download.osgeo.org/osgeo4w/v2/osgeo4w-setup.exe" -OutFile "osgeo4w_v2-setup.exe" | |
Write-Host "== Installer downloaded into $env:USERPROFILE/Downloads" -ForegroundColor Yellow | |
} | |
else | |
{ Write-Host "= OSGeo4W installer already exists. Let's use it!" -ForegroundColor Blue } | |
# Download and install (same command to upgrade with clean up) | |
Write-Host "=== Start installing / upgrading QGIS LTR..." -ForegroundColor Yellow | |
& .\osgeo4w_v2-setup.exe ` | |
--advanced ` | |
--arch x86_64 ` | |
--autoaccept ` | |
--delete-orphans ` | |
--local-package-dir "$env:APPDATA/OSGeo4W_v2-Packages" ` | |
--menu-name "QGIS LTR" ` | |
--no-desktop ` | |
--packages qgis-ltr-full ` | |
--quiet-mode ` | |
--root "$env:ProgramFiles/OSGeo4W_v2" ` | |
--site "http://www.norbit.de/osgeo4w/v2" ` | |
--site "http://download.osgeo.org/osgeo4w/v2" ` | |
--site "http://ftp.osuosl.org/pub/osgeo/download/osgeo4w/v2" ` | |
--upgrade-also ` | |
| out-null | |
# Return to the initial directory | |
Set-Location -Path $starter_path | |
Write-Host "==== Work is done!" -ForegroundColor Green |
A heads up: --root "$env:ProgramFiles/OSGeo4W_v2" moves the root to /Program Files/OSGeo4W_v2. Won't this interfere with your settings.json?
@MarByteBeep There is no settings.json
here so I don't get your point... Sorry! But it's just a sample, don't hesitate in adapting it to your need or preferences.
See also https://trac.osgeo.org/osgeo4w/ticket/804#comment:4
Thank @jef-n, can you specify to which comment are you referring? or is the whole gist?
The link points at comment 4: the batch file version.
is there a switch to download a specific version of qgis?
No. But you can older versions from snapshots of the repo. Lookup from when a specific version is and pick a snapshot shortly after. Eg. in http://download.osgeo.org/osgeo4w/v2/x86_64/release/qgis/qgis-ltr/ has qgis-ltr-3.22.9-1.tar.bz2 from 2022-Jul-15 14:49, so if you pick a snapshot from http://download.osgeo.org/osgeo4w/v2/snapshots/ from shortly after by specifying (only) --site http://download.osgeo.org/osgeo4w/v2/snapshots/20220715-190611/
you get 3.22.9 as qgis-ltr
. It's also possible to add it as "User URL" in the "Choose a download Site" page when using the installer interactively.
Thanks for the information @jef-n. But when I try to install the old version you mentioned, it always shows me version 3.28.15-1, I can click to change the version, but it should be a silent installation.
Thanks for the information @jef-n. But when I try to install the old version you mentioned, it always shows me version 3.28.15-1, I can click to change the version, but it should be a silent installation.
Then why didn't you specify --quiet-mode
?
A heads up:
--root "$env:ProgramFiles/OSGeo4W_v2"
moves the root to/Program Files/OSGeo4W_v2
. Won't this interfere with yoursettings.json
?