Last active
February 23, 2024 19:19
-
-
Save Guts/6303dc5eb941eb24be3e27609cd46985 to your computer and use it in GitHub Desktop.
Use OSGeo4W installer command-line abilities to provide a real-life example like downloading and installing QGIS LTR full meta-package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
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
?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 asqgis-ltr
. It's also possible to add it as "User URL" in the "Choose a download Site" page when using the installer interactively.