diff --git a/cmd/maintained-apps/validate/app_commander.go b/cmd/maintained-apps/validate/app_commander.go index 7fdd5606edf..fab0afc4db5 100644 --- a/cmd/maintained-apps/validate/app_commander.go +++ b/cmd/maintained-apps/validate/app_commander.go @@ -19,6 +19,7 @@ type AppCommander struct { Name string Slug string UniqueIdentifier string + ExistsQuery string Version string AppPath string UninstallScript string @@ -94,7 +95,7 @@ func (ac *AppCommander) uninstallApp(ctx context.Context) bool { } ac.appLogger.DebugContext(ctx, fmt.Sprintf("Output: %s", output)) - existance, err := appExists(ctx, ac.appLogger, ac.Name, ac.UniqueIdentifier, ac.Version, ac.AppPath) + existance, err := appExists(ctx, ac.appLogger, ac.Name, ac.UniqueIdentifier, ac.Version, ac.AppPath, ac.ExistsQuery) if err != nil { ac.appLogger.ErrorContext(ctx, fmt.Sprintf("Error checking if app exists after uninstall: %v", err)) return false diff --git a/cmd/maintained-apps/validate/darwin.go b/cmd/maintained-apps/validate/darwin.go index 6a1d002af05..8517038c6e5 100644 --- a/cmd/maintained-apps/validate/darwin.go +++ b/cmd/maintained-apps/validate/darwin.go @@ -176,7 +176,7 @@ func checkVersionMatch(expectedVersion, foundVersion, foundBundledVersion string return false } -func appExists(ctx context.Context, logger *slog.Logger, appName, uniqueAppIdentifier, appVersion, appPath string) (bool, error) { +func appExists(ctx context.Context, logger *slog.Logger, appName, uniqueAppIdentifier, appVersion, appPath, _ string) (bool, error) { execTimeout, cancel := context.WithTimeout(ctx, 30*time.Second) defer cancel() diff --git a/cmd/maintained-apps/validate/main.go b/cmd/maintained-apps/validate/main.go index 3f1124e1bd6..d5acf8bfef7 100644 --- a/cmd/maintained-apps/validate/main.go +++ b/cmd/maintained-apps/validate/main.go @@ -149,6 +149,7 @@ func run(cfg *Config) error { ac.Name = app.Name ac.Slug = app.Slug ac.UniqueIdentifier = app.UniqueIdentifier + ac.ExistsQuery = maintainedApp.AutomaticInstallQuery // default version to maintained app version ac.Version = maintainedApp.Version ac.InstallScript = maintainedApp.InstallScript @@ -240,7 +241,7 @@ func run(cfg *Config) error { warnApp() } - existance, err := appExists(ctx, appLogger, ac.Name, ac.UniqueIdentifier, ac.Version, ac.AppPath) + existance, err := appExists(ctx, appLogger, ac.Name, ac.UniqueIdentifier, ac.Version, ac.AppPath, ac.ExistsQuery) if err != nil { appLogger.ErrorContext(ctx, fmt.Sprintf("Error checking if app exists: %v", err)) appWithError = append(appWithError, ac.Name) @@ -493,3 +494,15 @@ func validateSqlInput(input string) error { return nil } + +var programsExistsQueryRegex = regexp.MustCompile(`(?is)^\s*SELECT\s+1\s+FROM\s+programs\s+WHERE\s+(.+?);?\s*$`) + +// programsExistsWhereClause returns the WHERE clause of an exists query shaped +// "SELECT 1 FROM programs WHERE ...", or "" for any other shape. +func programsExistsWhereClause(existsQuery string) string { + m := programsExistsQueryRegex.FindStringSubmatch(existsQuery) + if m == nil { + return "" + } + return m[1] +} diff --git a/cmd/maintained-apps/validate/main_test.go b/cmd/maintained-apps/validate/main_test.go index 312814731f7..bd800808a64 100644 --- a/cmd/maintained-apps/validate/main_test.go +++ b/cmd/maintained-apps/validate/main_test.go @@ -126,3 +126,31 @@ func TestValidateSqlInput(t *testing.T) { }) } } + +func TestProgramsExistsWhereClause(t *testing.T) { + testCases := []struct { + query string + want string + }{ + {"", ""}, + { + "SELECT 1 FROM programs WHERE name LIKE 'QGIS %' AND publisher = 'QGIS.org' AND version LIKE '3.44.%';", + "name LIKE 'QGIS %' AND publisher = 'QGIS.org' AND version LIKE '3.44.%'", + }, + { + "select 1 from programs where name = 'Foo'", + "name = 'Foo'", + }, + { + "SELECT 1 FROM apps WHERE bundle_identifier = 'com.example.foo';", + "", + }, + { + "SELECT 1 WHERE EXISTS (SELECT 1 FROM programs WHERE name = 'Foo') OR NOT EXISTS (SELECT 1 FROM system_info WHERE cpu_type LIKE 'ARM%');", + "", + }, + } + for _, tc := range testCases { + require.Equal(t, tc.want, programsExistsWhereClause(tc.query), tc.query) + } +} diff --git a/cmd/maintained-apps/validate/windows.go b/cmd/maintained-apps/validate/windows.go index 0bc45cde68f..d2e5c639d7f 100644 --- a/cmd/maintained-apps/validate/windows.go +++ b/cmd/maintained-apps/validate/windows.go @@ -39,7 +39,7 @@ func normalizeVersion(version string) string { return strings.Join(parts, ".") } -func appExists(ctx context.Context, logger *slog.Logger, appName, uniqueIdentifier, appVersion, appPath string) (bool, error) { +func appExists(ctx context.Context, logger *slog.Logger, appName, uniqueIdentifier, appVersion, appPath, existsQuery string) (bool, error) { execTimeout, cancel := context.WithTimeout(ctx, 30*time.Second) defer cancel() @@ -70,6 +70,13 @@ func appExists(ctx context.Context, logger *slog.Logger, appName, uniqueIdentifi if appPath != "" { query += fmt.Sprintf(" OR install_location LIKE '%%%s%%'", appPath) } + // Some DisplayNames contain neither the catalog name nor the + // unique_identifier (e.g. QGIS LTR installs as "QGIS 3.44.14 'Solothurn'"), + // so also match the manifest's exists query, which is how Fleet detects the + // app. It comes from the manifest, so it isn't run through validateSqlInput. + if clause := programsExistsWhereClause(existsQuery); clause != "" { + query += ` OR (` + clause + `)` + } cmd := exec.CommandContext(execTimeout, "osqueryi", "--json", query) output, err := cmd.CombinedOutput() if err != nil { diff --git a/ee/maintained-apps/README.md b/ee/maintained-apps/README.md index 38db09254f4..507671610b1 100644 --- a/ee/maintained-apps/README.md +++ b/ee/maintained-apps/README.md @@ -124,6 +124,7 @@ go run cmd/maintained-apps/main.go --slug="box-drive/windows" --debug | `install_script_path` | string | Filepath to a custom install script (`.ps1`). Overrides the generated install script. Script must be placed in `inputs/winget/scripts/`. For `.msi` apps, the ingestor automatically generates install scripts. Do not add scripts unless you need to override the generated behavior. For `.exe` apps, you must provide PowerShell scripts that run the installer file directly. Fleet stores the installer and sends it to the host at install time; your script must execute it using the `INSTALLER_PATH` environment variable. | | `uninstall_script_path` | string | Filepath to a custom uninstall script (`.ps1`). Overrides the generated uninstall script. Script must be placed in `inputs/winget/scripts/`. For `.msi` apps, the ingestor automatically generates uninstall scripts. Do not add scripts unless you need to override the generated behavior. For `.exe` apps, you must provide a script to uninstall the app. Scripts for `.exe` apps are vendor-specific. Use the vendor’s documented silent uninstall switch or the registered UninstallString (if available), ensuring the script runs silently and returns the installer’s exit code. | | `fuzzy_match_name` | boolean | If the `unique_identifier` doesn't match the `DisplayName`, use `fuzzy_match_name` to specify that Fleet uses "fuzzy matching" to match the Fleet-maintained app and the inventoried software. For example, for Pritunl, the `unique_identifier` is "Pritunl" and the inventories software's `DisplayName` is "Pritunl Client". With `fuzzy_match_name` set to true, Pritunl app will be matched to the inventories software. | +| `ignore_upgrade_code` | boolean | Set to `true` when the vendor gives every MSI build a new `UpgradeCode` (e.g., QGIS). Fleet links a Windows Fleet-maintained app to its software title by upgrade code, so a per-build code would move the app to a new title with each update. With this set, the title is linked by `unique_identifier` instead, so give each app that sets it a distinct `unique_identifier`. | | `requires_client_os` | boolean | Set to `true` when the installer refuses to run on Windows Server SKUs (e.g., Dell Display and Peripheral Manager). Fleet's ingestion ignores this field; CI reads it to route validation to the `windows-11-arm` runner (the only GitHub-hosted client-OS Windows runner) instead of the default Windows Server x64 runner. | #### Windows troubleshooting diff --git a/ee/maintained-apps/ingesters/homebrew/ingester.go b/ee/maintained-apps/ingesters/homebrew/ingester.go index 1f6c61c7039..477fc574fd5 100644 --- a/ee/maintained-apps/ingesters/homebrew/ingester.go +++ b/ee/maintained-apps/ingesters/homebrew/ingester.go @@ -164,6 +164,10 @@ func (i *brewIngester) ingestOne(ctx context.Context, input inputApp) (*maintain out.UniqueIdentifier, ) } + if pathFilter, ok := qgisPathFilters[input.Token]; ok { + // The patch policy generated below inherits this filter. + out.Queries.Exists = fmt.Sprintf("SELECT 1 FROM apps WHERE bundle_identifier = '%s' AND %s;", out.UniqueIdentifier, pathFilter) + } if input.Token == "chatgpt" { // The patch policy generated below inherits this match. out.Queries.Exists = fmt.Sprintf("SELECT 1 FROM apps WHERE %s;", chatGPTBundleMatch("")) @@ -389,10 +393,24 @@ func (i *brewIngester) ingestOne(ctx context.Context, input inputApp) (*maintain chatGPTBundleMatch("a."), ) } + if pathFilter, ok := qgisPathFilters[input.Token]; ok { + // Only this channel's copy counts as open; the other channel doesn't block its install. + out.Queries.Open = fmt.Sprintf( + "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM apps a JOIN processes p ON p.path = concat(a.path, '/Contents/MacOS/', a.bundle_executable) WHERE a.bundle_identifier = '%s' AND a.%s AND a.bundle_executable != '');", + out.UniqueIdentifier, pathFilter, + ) + } return out, nil } +// qgisPathFilters tells QGIS and QGIS LTR apart by where their casks install them: +// both report the org.qgis.qgis3 bundle identifier. +var qgisPathFilters = map[string]string{ + "qgis": "path LIKE '/Applications/QGIS-final-%.app'", + "qgis@ltr": "path = '/Applications/QGIS-LTR.app'", +} + // chatGPTBundleMatch matches the ChatGPT app under both of its bundle identifiers. // OpenAI rebuilt ChatGPT on the Codex app, so current builds report com.openai.codex // while hosts that haven't updated still report com.openai.chat. The discontinued diff --git a/ee/maintained-apps/ingesters/homebrew/ingester_test.go b/ee/maintained-apps/ingesters/homebrew/ingester_test.go index 2a7ab202d33..abb055faf25 100644 --- a/ee/maintained-apps/ingesters/homebrew/ingester_test.go +++ b/ee/maintained-apps/ingesters/homebrew/ingester_test.go @@ -87,7 +87,7 @@ func TestIngestValidations(t *testing.T) { Version: "1.0", } - case "ok", "1password", "docker-desktop", "microsoft-edge", "google-chrome", "webex", "i1profiler", "steam", "swiftdialog", "teleport-suite", "r-app", "kicad", "chatgpt", "4k-slideshow-maker", "4k-stogram", "4k-video-downloader", "4k-video-to-mp3", "4k-youtube-to-mp3", "install_script_path", "uninstall_script_path", "uninstall_script_path_with_pre", "uninstall_script_path_with_post", "patch_policy_path", "open-query": + case "ok", "1password", "docker-desktop", "microsoft-edge", "google-chrome", "webex", "i1profiler", "steam", "swiftdialog", "teleport-suite", "r-app", "qgis", "qgis@ltr", "kicad", "chatgpt", "4k-slideshow-maker", "4k-stogram", "4k-video-downloader", "4k-video-to-mp3", "4k-youtube-to-mp3", "install_script_path", "uninstall_script_path", "uninstall_script_path_with_pre", "uninstall_script_path_with_post", "patch_policy_path", "open-query": cask = brewCask{ Token: appToken, Name: []string{appToken}, @@ -154,6 +154,8 @@ func TestIngestValidations(t *testing.T) { {"", inputApp{Token: "swiftdialog", UniqueIdentifier: "au.csiro.dialog", InstallerFormat: "pkg", Name: "swiftDialog", Slug: "swiftdialog/darwin"}}, {"", inputApp{Token: "teleport-suite", UniqueIdentifier: "com.gravitational.teleport.tsh", InstallerFormat: "pkg", Name: "Teleport Suite", Slug: "teleport-suite/darwin"}}, {"", inputApp{Token: "r-app", UniqueIdentifier: "org.R-project.R", InstallerFormat: "pkg", Name: "R for macOS", Slug: "r/darwin"}}, + {"", inputApp{Token: "qgis", UniqueIdentifier: "org.qgis.qgis3", InstallerFormat: "dmg", Name: "QGIS", Slug: "qgis/darwin"}}, + {"", inputApp{Token: "qgis@ltr", UniqueIdentifier: "org.qgis.qgis3", InstallerFormat: "dmg", Name: "QGIS LTR", Slug: "qgis@ltr/darwin"}}, {"", inputApp{Token: "kicad", UniqueIdentifier: "org.kicad.kicad", InstallerFormat: "dmg", Name: "KiCad", Slug: "kicad/darwin"}}, {"", inputApp{Token: "chatgpt", UniqueIdentifier: "com.openai.chat", InstallerFormat: "zip", Name: "ChatGPT Desktop", Slug: "chatgpt/darwin"}}, {"", inputApp{Token: "4k-slideshow-maker", UniqueIdentifier: "com.openmedia.4kslideshowmaker", InstallerFormat: "dmg", Name: "4K Slideshow Maker", Slug: "4k-slideshow-maker/darwin"}}, //nolint:gosec // G101: cask token, not a credential @@ -266,6 +268,19 @@ func TestIngestValidations(t *testing.T) { "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM apps WHERE bundle_identifier = 'org.R-project.R' AND version_compare(REGEX_MATCH(bundle_short_version, 'R (?:R )?([0-9]+(?:\\.[0-9]+)+) GUI', 1), '1.0') < 0);", out.Queries.Patched, ) + case "qgis": + // QGIS and QGIS LTR share a bundle identifier, so each is scoped to its install path. + require.Equal(t, "SELECT 1 FROM apps WHERE bundle_identifier = 'org.qgis.qgis3' AND path LIKE '/Applications/QGIS-final-%.app';", out.Queries.Exists) + require.Equal(t, + "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM apps WHERE bundle_identifier = 'org.qgis.qgis3' AND path LIKE '/Applications/QGIS-final-%.app' AND version_compare(bundle_short_version, '1.0') < 0);", + out.Queries.Patched, + ) + case "qgis@ltr": + require.Equal(t, "SELECT 1 FROM apps WHERE bundle_identifier = 'org.qgis.qgis3' AND path = '/Applications/QGIS-LTR.app';", out.Queries.Exists) + require.Equal(t, + "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM apps WHERE bundle_identifier = 'org.qgis.qgis3' AND path = '/Applications/QGIS-LTR.app' AND version_compare(bundle_short_version, '1.0') < 0);", + out.Queries.Patched, + ) case "chatgpt": // ChatGPT reports com.openai.codex since OpenAI rebuilt it on the Codex app; // older installs still report com.openai.chat, so both are matched. The @@ -296,6 +311,16 @@ func TestIngestValidations(t *testing.T) { fmt.Sprintf("SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM apps a JOIN processes p ON (p.path = concat(a.path, '/Contents/MacOS/', a.bundle_executable) OR p.path LIKE concat('%%/', a.bundle_identifier, '.code_sign_clone/%%/Contents/MacOS/', a.bundle_executable)) WHERE a.bundle_identifier = '%s' AND a.bundle_executable != '');", out.UniqueIdentifier), out.Queries.Open, ) + case "qgis": + require.Equal(t, + "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM apps a JOIN processes p ON p.path = concat(a.path, '/Contents/MacOS/', a.bundle_executable) WHERE a.bundle_identifier = 'org.qgis.qgis3' AND a.path LIKE '/Applications/QGIS-final-%.app' AND a.bundle_executable != '');", + out.Queries.Open, + ) + case "qgis@ltr": + require.Equal(t, + "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM apps a JOIN processes p ON p.path = concat(a.path, '/Contents/MacOS/', a.bundle_executable) WHERE a.bundle_identifier = 'org.qgis.qgis3' AND a.path = '/Applications/QGIS-LTR.app' AND a.bundle_executable != '');", + out.Queries.Open, + ) case "kicad": // KiCad's editors also run as standalone apps nested in KiCad.app, so they count as open too. require.Equal(t, diff --git a/ee/maintained-apps/ingesters/winget/ingester.go b/ee/maintained-apps/ingesters/winget/ingester.go index 19a96586ee3..7e6c0b005fa 100644 --- a/ee/maintained-apps/ingesters/winget/ingester.go +++ b/ee/maintained-apps/ingesters/winget/ingester.go @@ -382,6 +382,9 @@ func (i *wingetIngester) ingestOne(ctx context.Context, input inputApp) (*mainta } } } + if input.IgnoreUpgradeCode { + upgradeCode = "" + } if uninstallScript == "" && upgradeCode != "" { var err error uninstallScript, err = buildUpgradeCodeBasedUninstallScript(upgradeCode) @@ -657,7 +660,11 @@ type inputApp struct { // (e.g. python.org installers report "3.14.5150.0" for version "3.14.5"). UseDisplayVersionForPatch bool `json:"use_display_version_for_patch"` // Whether to use "no_check" instead of the app's hash (e.g. for non-pinned download URLs) - IgnoreHash bool `json:"ignore_hash"` + IgnoreHash bool `json:"ignore_hash"` + // IgnoreUpgradeCode leaves the MSI UpgradeCode out of the manifest, for apps that mint + // a new one every build (e.g. QGIS). Fleet resolves a Windows FMA's software title by + // its upgrade code, so a per-build code would move the app to a new title on each update. + IgnoreUpgradeCode bool `json:"ignore_upgrade_code"` DefaultCategories []string `json:"default_categories"` Frozen bool `json:"frozen"` PatchPolicyPath string `json:"patch_policy_path"` diff --git a/ee/maintained-apps/ingesters/winget/ingester_test.go b/ee/maintained-apps/ingesters/winget/ingester_test.go index 4d54a81950b..05d94608feb 100644 --- a/ee/maintained-apps/ingesters/winget/ingester_test.go +++ b/ee/maintained-apps/ingesters/winget/ingester_test.go @@ -464,6 +464,29 @@ func TestIngestValidations(t *testing.T) { upgradeCode: "{ABCDEF}", }, }, + { + name: "ignore upgrade code", + inputApp: inputApp{ + Name: "Foo", + UniqueIdentifier: "Foo", + PackageIdentifier: "Foo", + InstallerArch: "x64", + Slug: "foo/windows", + InstallScriptPath: path.Join(tempDir, "install_script.ps1"), + UninstallScriptPath: path.Join(tempDir, "uninstall_script.ps1"), + InstallerType: "msi", + InstallerScope: "machine", + IgnoreUpgradeCode: true, + }, + cfg: serverConfig{ + productCode: "{ABCDEF}", + installerType: "msi", + installerScope: "machine", + installerArch: "x64", + installerProdCode: "{ACBDEF}", + upgradeCode: "{ABCDEF}", + }, + }, { name: "wrong installer type", wantErr: "failed to find installer for app", @@ -516,6 +539,11 @@ func TestIngestValidations(t *testing.T) { if c.wantPatchedContains != "" { require.Contains(t, out.Queries.Patched, c.wantPatchedContains) } + if c.inputApp.IgnoreUpgradeCode { + require.Empty(t, out.UpgradeCode) + } else { + require.Equal(t, c.cfg.upgradeCode, out.UpgradeCode) + } // The managed "is app open" query matches a process named ".exe". require.Equal(t, "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM processes WHERE LOWER(name) = 'foo.exe');", diff --git a/ee/maintained-apps/inputs/homebrew/qgis.json b/ee/maintained-apps/inputs/homebrew/qgis.json new file mode 100644 index 00000000000..09fe87a7c2c --- /dev/null +++ b/ee/maintained-apps/inputs/homebrew/qgis.json @@ -0,0 +1,10 @@ +{ + "name": "QGIS", + "slug": "qgis/darwin", + "unique_identifier": "org.qgis.qgis3", + "token": "qgis", + "installer_format": "dmg", + "install_script_path": "ee/maintained-apps/inputs/homebrew/scripts/qgis-install.sh", + "uninstall_script_path": "ee/maintained-apps/inputs/homebrew/scripts/qgis-uninstall.sh", + "default_categories": ["Productivity"] +} diff --git a/ee/maintained-apps/inputs/homebrew/qgis@ltr.json b/ee/maintained-apps/inputs/homebrew/qgis@ltr.json new file mode 100644 index 00000000000..9544b2a888d --- /dev/null +++ b/ee/maintained-apps/inputs/homebrew/qgis@ltr.json @@ -0,0 +1,10 @@ +{ + "name": "QGIS LTR", + "slug": "qgis@ltr/darwin", + "unique_identifier": "org.qgis.qgis3", + "token": "qgis@ltr", + "installer_format": "dmg", + "install_script_path": "ee/maintained-apps/inputs/homebrew/scripts/qgis-ltr-install.sh", + "uninstall_script_path": "ee/maintained-apps/inputs/homebrew/scripts/qgis-ltr-uninstall.sh", + "default_categories": ["Productivity"] +} diff --git a/ee/maintained-apps/inputs/homebrew/scripts/qgis-install.sh b/ee/maintained-apps/inputs/homebrew/scripts/qgis-install.sh new file mode 100644 index 00000000000..f03c061387e --- /dev/null +++ b/ee/maintained-apps/inputs/homebrew/scripts/qgis-install.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# QGIS is closed if it's running, and unsaved project changes are lost. Each +# release installs as its own QGIS-final-<version>.app, so earlier releases are +# removed once the new one is in place. QGIS LTR (QGIS-LTR.app) is left alone. + +APPDIR="/Applications" +TMPDIR=$(dirname "$(realpath "$INSTALLER_PATH")") + +# QGIS and QGIS LTR share a bundle identifier, so match processes by path. +quit_app_at_path() { + local app_path="$1" + local pattern="^${app_path}/Contents/MacOS/" + pgrep -f "$pattern" >/dev/null || return 0 + echo "Closing $app_path..." + pkill -TERM -f "$pattern" + for _ in {1..10}; do + pgrep -f "$pattern" >/dev/null || return 0 + sleep 1 + done + echo "$app_path did not close; forcing it to quit." + pkill -KILL -f "$pattern" +} + +MOUNT_POINT=$(mktemp -d /tmp/dmg_mount_XXXXXX) +yes | hdiutil attach -plist -nobrowse -readonly -mountpoint "$MOUNT_POINT" "$INSTALLER_PATH" >/dev/null || exit 1 +trap 'hdiutil detach "$MOUNT_POINT" >/dev/null 2>&1 || true' EXIT + +NEW_APP=$(find "$MOUNT_POINT" -maxdepth 1 -name 'QGIS-final-*.app' -print -quit) +if [[ -z "$NEW_APP" ]]; then + echo "No QGIS-final-*.app found in the disk image." + exit 1 +fi +APP_NAME=$(basename "$NEW_APP") + +for app in "$APPDIR"/QGIS-final-*.app; do + [[ -d "$app" ]] && quit_app_at_path "$app" +done + +sudo rm -rf "$TMPDIR/$APP_NAME.bkp" +if [[ -d "$APPDIR/$APP_NAME" ]]; then + sudo mv "$APPDIR/$APP_NAME" "$TMPDIR/$APP_NAME.bkp" || exit $? +fi +if ! sudo cp -R "$NEW_APP" "$APPDIR/"; then + # remove the partial copy so a failed install isn't inventoried as the new + # version, then restore the previous version if there was one + sudo rm -rf "$APPDIR/$APP_NAME" + if [[ -d "$TMPDIR/$APP_NAME.bkp" ]]; then + sudo mv "$TMPDIR/$APP_NAME.bkp" "$APPDIR/$APP_NAME" + fi + exit 1 +fi +sudo rm -rf "$TMPDIR/$APP_NAME.bkp" + +for app in "$APPDIR"/QGIS-final-*.app; do + if [[ -d "$app" && "$(basename "$app")" != "$APP_NAME" ]]; then + echo "Removing earlier release $app" + sudo rm -rf "$app" + fi +done + +echo "Installed $APPDIR/$APP_NAME" diff --git a/ee/maintained-apps/inputs/homebrew/scripts/qgis-ltr-install.sh b/ee/maintained-apps/inputs/homebrew/scripts/qgis-ltr-install.sh new file mode 100644 index 00000000000..6a6901345f7 --- /dev/null +++ b/ee/maintained-apps/inputs/homebrew/scripts/qgis-ltr-install.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# QGIS LTR is closed if it's running, and unsaved project changes are lost. It +# installs as QGIS-LTR.app so it can sit alongside QGIS, which is left alone. + +APPDIR="/Applications" +TMPDIR=$(dirname "$(realpath "$INSTALLER_PATH")") +APP_PATH="$APPDIR/QGIS-LTR.app" + +# QGIS and QGIS LTR share a bundle identifier, so match processes by path. +quit_app_at_path() { + local app_path="$1" + local pattern="^${app_path}/Contents/MacOS/" + pgrep -f "$pattern" >/dev/null || return 0 + echo "Closing $app_path..." + pkill -TERM -f "$pattern" + for _ in {1..10}; do + pgrep -f "$pattern" >/dev/null || return 0 + sleep 1 + done + echo "$app_path did not close; forcing it to quit." + pkill -KILL -f "$pattern" +} + +MOUNT_POINT=$(mktemp -d /tmp/dmg_mount_XXXXXX) +yes | hdiutil attach -plist -nobrowse -readonly -mountpoint "$MOUNT_POINT" "$INSTALLER_PATH" >/dev/null || exit 1 +trap 'hdiutil detach "$MOUNT_POINT" >/dev/null 2>&1 || true' EXIT + +if [[ ! -d "$MOUNT_POINT/QGIS.app" ]]; then + echo "No QGIS.app found in the disk image." + exit 1 +fi + +quit_app_at_path "$APP_PATH" + +sudo rm -rf "$TMPDIR/QGIS-LTR.app.bkp" +if [[ -d "$APP_PATH" ]]; then + sudo mv "$APP_PATH" "$TMPDIR/QGIS-LTR.app.bkp" || exit $? +fi +if ! sudo cp -R "$MOUNT_POINT/QGIS.app" "$APP_PATH"; then + # remove the partial copy so a failed install isn't inventoried as the new + # version, then restore the previous version if there was one + sudo rm -rf "$APP_PATH" + if [[ -d "$TMPDIR/QGIS-LTR.app.bkp" ]]; then + sudo mv "$TMPDIR/QGIS-LTR.app.bkp" "$APP_PATH" + fi + exit 1 +fi +sudo rm -rf "$TMPDIR/QGIS-LTR.app.bkp" + +echo "Installed $APP_PATH" diff --git a/ee/maintained-apps/inputs/homebrew/scripts/qgis-ltr-uninstall.sh b/ee/maintained-apps/inputs/homebrew/scripts/qgis-ltr-uninstall.sh new file mode 100644 index 00000000000..aaa4ad57b56 --- /dev/null +++ b/ee/maintained-apps/inputs/homebrew/scripts/qgis-ltr-uninstall.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Removes QGIS-LTR.app and closes it if it's running. QGIS and per-user QGIS +# data (profiles, plugins, caches), which QGIS also uses, are left in place. + +APP_PATH="/Applications/QGIS-LTR.app" + +# QGIS and QGIS LTR share a bundle identifier, so match processes by path. +quit_app_at_path() { + local app_path="$1" + local pattern="^${app_path}/Contents/MacOS/" + pgrep -f "$pattern" >/dev/null || return 0 + echo "Closing $app_path..." + pkill -TERM -f "$pattern" + for _ in {1..10}; do + pgrep -f "$pattern" >/dev/null || return 0 + sleep 1 + done + echo "$app_path did not close; forcing it to quit." + pkill -KILL -f "$pattern" +} + +quit_app_at_path "$APP_PATH" +sudo rm -rf "$APP_PATH" diff --git a/ee/maintained-apps/inputs/homebrew/scripts/qgis-uninstall.sh b/ee/maintained-apps/inputs/homebrew/scripts/qgis-uninstall.sh new file mode 100644 index 00000000000..9c2e3089866 --- /dev/null +++ b/ee/maintained-apps/inputs/homebrew/scripts/qgis-uninstall.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Removes every QGIS-final-<version>.app and closes QGIS if it's running. QGIS +# LTR and per-user QGIS data (profiles, plugins, caches), which QGIS LTR also +# uses, are left in place. + +APPDIR="/Applications" + +# QGIS and QGIS LTR share a bundle identifier, so match processes by path. +quit_app_at_path() { + local app_path="$1" + local pattern="^${app_path}/Contents/MacOS/" + pgrep -f "$pattern" >/dev/null || return 0 + echo "Closing $app_path..." + pkill -TERM -f "$pattern" + for _ in {1..10}; do + pgrep -f "$pattern" >/dev/null || return 0 + sleep 1 + done + echo "$app_path did not close; forcing it to quit." + pkill -KILL -f "$pattern" +} + +for app in "$APPDIR"/QGIS-final-*.app; do + [[ -d "$app" ]] || continue + quit_app_at_path "$app" + echo "Removing $app" + sudo rm -rf "$app" +done diff --git a/ee/maintained-apps/inputs/winget/qgis.json b/ee/maintained-apps/inputs/winget/qgis.json new file mode 100644 index 00000000000..f6c2c68754e --- /dev/null +++ b/ee/maintained-apps/inputs/winget/qgis.json @@ -0,0 +1,14 @@ +{ + "name": "QGIS", + "slug": "qgis/windows", + "package_identifier": "OSGeo.QGIS", + "unique_identifier": "QGIS", + "fuzzy_match_name": true, + "exists_query": "SELECT 1 FROM programs WHERE name LIKE 'QGIS %' AND publisher = 'QGIS.org' AND version NOT LIKE '3.44.%';", + "installer_arch": "x64", + "installer_type": "msi", + "installer_scope": "machine", + "install_script_path": "ee/maintained-apps/inputs/winget/scripts/qgis_install.ps1", + "uninstall_script_path": "ee/maintained-apps/inputs/winget/scripts/qgis_uninstall.ps1", + "default_categories": ["Productivity"] +} diff --git a/ee/maintained-apps/inputs/winget/qgis@ltr.json b/ee/maintained-apps/inputs/winget/qgis@ltr.json new file mode 100644 index 00000000000..9b6a602c3a9 --- /dev/null +++ b/ee/maintained-apps/inputs/winget/qgis@ltr.json @@ -0,0 +1,15 @@ +{ + "name": "QGIS LTR", + "slug": "qgis@ltr/windows", + "package_identifier": "OSGeo.QGIS_LTR", + "unique_identifier": "QGIS LTR", + "fuzzy_match_name": true, + "exists_query": "SELECT 1 FROM programs WHERE name LIKE 'QGIS %' AND publisher = 'QGIS.org' AND version LIKE '3.44.%';", + "installer_arch": "x64", + "installer_type": "msi", + "installer_scope": "machine", + "ignore_upgrade_code": true, + "install_script_path": "ee/maintained-apps/inputs/winget/scripts/qgis-ltr_install.ps1", + "uninstall_script_path": "ee/maintained-apps/inputs/winget/scripts/qgis-ltr_uninstall.ps1", + "default_categories": ["Productivity"] +} diff --git a/ee/maintained-apps/inputs/winget/scripts/qgis-ltr_install.ps1 b/ee/maintained-apps/inputs/winget/scripts/qgis-ltr_install.ps1 new file mode 100644 index 00000000000..2cd60ba7f6c --- /dev/null +++ b/ee/maintained-apps/inputs/winget/scripts/qgis-ltr_install.ps1 @@ -0,0 +1,48 @@ +# Each QGIS release installs side by side under its own product code, so +# installed QGIS LTR (3.44.x) releases are uninstalled first. Other QGIS +# releases are left in place. + +$ltrSeries = '3.44.' +$logFile = "${env:TEMP}/fleet-install-software.log" + +# MSI exit codes that indicate success. 3010 = ERROR_SUCCESS_REBOOT_REQUIRED, +# 1641 = ERROR_SUCCESS_REBOOT_INITIATED. Treat these as success rather than failure. +$successCodes = @(0, 3010, 1641) + +try { + +$uninstallRoots = @( + 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*', + 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' +) +$entries = @(Get-ItemProperty -Path $uninstallRoots -ErrorAction SilentlyContinue | Where-Object { + $_.DisplayName -like 'QGIS *' -and $_.Publisher -eq 'QGIS.org' -and + ([string]$_.DisplayVersion).StartsWith($ltrSeries) -and + $_.PSChildName -match '^\{[0-9A-Fa-f-]+\}$' +}) +foreach ($entry in $entries) { + Write-Host "Uninstalling $($entry.DisplayName) ($($entry.PSChildName))" + $process = Start-Process msiexec.exe -ArgumentList "/x $($entry.PSChildName) /qn /norestart" -PassThru -Wait + # 1605 = the release was already uninstalled + if (($successCodes + 1605) -notcontains $process.ExitCode) { + Write-Host "Uninstall of $($entry.DisplayName) failed with exit code $($process.ExitCode)" + Exit $process.ExitCode + } +} + +$installProcess = Start-Process msiexec.exe ` + -ArgumentList "/quiet /norestart /lv `"${logFile}`" /i `"${env:INSTALLER_PATH}`"" ` + -PassThru -Verb RunAs -Wait + +Get-Content $logFile -Tail 500 + +if ($successCodes -contains $installProcess.ExitCode) { + Exit 0 +} + +Exit $installProcess.ExitCode + +} catch { + Write-Host "Error: $_" + Exit 1 +} diff --git a/ee/maintained-apps/inputs/winget/scripts/qgis-ltr_uninstall.ps1 b/ee/maintained-apps/inputs/winget/scripts/qgis-ltr_uninstall.ps1 new file mode 100644 index 00000000000..db2dee01ce0 --- /dev/null +++ b/ee/maintained-apps/inputs/winget/scripts/qgis-ltr_uninstall.ps1 @@ -0,0 +1,43 @@ +# Uninstalls every QGIS LTR (3.44.x) release on the host, since each release +# installs side by side under its own product code. Other QGIS releases are +# left in place. + +$ltrSeries = '3.44.' + +# MSI exit codes that indicate success. 3010 = ERROR_SUCCESS_REBOOT_REQUIRED, +# 1641 = ERROR_SUCCESS_REBOOT_INITIATED, 1605 = already uninstalled. +$successCodes = @(0, 3010, 1641, 1605) + +try { + +$uninstallRoots = @( + 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*', + 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' +) +$entries = @(Get-ItemProperty -Path $uninstallRoots -ErrorAction SilentlyContinue | Where-Object { + $_.DisplayName -like 'QGIS *' -and $_.Publisher -eq 'QGIS.org' -and + ([string]$_.DisplayVersion).StartsWith($ltrSeries) -and + $_.PSChildName -match '^\{[0-9A-Fa-f-]+\}$' +}) + +if ($entries.Count -eq 0) { + Write-Host "No QGIS LTR installation found; nothing to uninstall." + Exit 0 +} + +$exitCode = 0 +foreach ($entry in $entries) { + Write-Host "Uninstalling $($entry.DisplayName) ($($entry.PSChildName))" + $process = Start-Process msiexec.exe -ArgumentList "/x $($entry.PSChildName) /qn /norestart" -PassThru -Wait + Write-Host "Uninstall exit code: $($process.ExitCode)" + if ($successCodes -notcontains $process.ExitCode) { + $exitCode = $process.ExitCode + } +} + +Exit $exitCode + +} catch { + Write-Host "Error: $_" + Exit 1 +} diff --git a/ee/maintained-apps/inputs/winget/scripts/qgis_install.ps1 b/ee/maintained-apps/inputs/winget/scripts/qgis_install.ps1 new file mode 100644 index 00000000000..b0e12eeb63a --- /dev/null +++ b/ee/maintained-apps/inputs/winget/scripts/qgis_install.ps1 @@ -0,0 +1,47 @@ +# Each QGIS release installs side by side under its own product code, so +# installed QGIS releases are uninstalled first. QGIS LTR (3.44.x) is left in place. + +$ltrSeries = '3.44.' +$logFile = "${env:TEMP}/fleet-install-software.log" + +# MSI exit codes that indicate success. 3010 = ERROR_SUCCESS_REBOOT_REQUIRED, +# 1641 = ERROR_SUCCESS_REBOOT_INITIATED. Treat these as success rather than failure. +$successCodes = @(0, 3010, 1641) + +try { + +$uninstallRoots = @( + 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*', + 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' +) +$entries = @(Get-ItemProperty -Path $uninstallRoots -ErrorAction SilentlyContinue | Where-Object { + $_.DisplayName -like 'QGIS *' -and $_.Publisher -eq 'QGIS.org' -and + -not ([string]$_.DisplayVersion).StartsWith($ltrSeries) -and + $_.PSChildName -match '^\{[0-9A-Fa-f-]+\}$' +}) +foreach ($entry in $entries) { + Write-Host "Uninstalling $($entry.DisplayName) ($($entry.PSChildName))" + $process = Start-Process msiexec.exe -ArgumentList "/x $($entry.PSChildName) /qn /norestart" -PassThru -Wait + # 1605 = the release was already uninstalled + if (($successCodes + 1605) -notcontains $process.ExitCode) { + Write-Host "Uninstall of $($entry.DisplayName) failed with exit code $($process.ExitCode)" + Exit $process.ExitCode + } +} + +$installProcess = Start-Process msiexec.exe ` + -ArgumentList "/quiet /norestart /lv `"${logFile}`" /i `"${env:INSTALLER_PATH}`"" ` + -PassThru -Verb RunAs -Wait + +Get-Content $logFile -Tail 500 + +if ($successCodes -contains $installProcess.ExitCode) { + Exit 0 +} + +Exit $installProcess.ExitCode + +} catch { + Write-Host "Error: $_" + Exit 1 +} diff --git a/ee/maintained-apps/inputs/winget/scripts/qgis_uninstall.ps1 b/ee/maintained-apps/inputs/winget/scripts/qgis_uninstall.ps1 new file mode 100644 index 00000000000..d75d28a9a2b --- /dev/null +++ b/ee/maintained-apps/inputs/winget/scripts/qgis_uninstall.ps1 @@ -0,0 +1,42 @@ +# Uninstalls every QGIS release on the host, since each release installs side +# by side under its own product code. QGIS LTR (3.44.x) is left in place. + +$ltrSeries = '3.44.' + +# MSI exit codes that indicate success. 3010 = ERROR_SUCCESS_REBOOT_REQUIRED, +# 1641 = ERROR_SUCCESS_REBOOT_INITIATED, 1605 = already uninstalled. +$successCodes = @(0, 3010, 1641, 1605) + +try { + +$uninstallRoots = @( + 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*', + 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' +) +$entries = @(Get-ItemProperty -Path $uninstallRoots -ErrorAction SilentlyContinue | Where-Object { + $_.DisplayName -like 'QGIS *' -and $_.Publisher -eq 'QGIS.org' -and + -not ([string]$_.DisplayVersion).StartsWith($ltrSeries) -and + $_.PSChildName -match '^\{[0-9A-Fa-f-]+\}$' +}) + +if ($entries.Count -eq 0) { + Write-Host "No QGIS installation found; nothing to uninstall." + Exit 0 +} + +$exitCode = 0 +foreach ($entry in $entries) { + Write-Host "Uninstalling $($entry.DisplayName) ($($entry.PSChildName))" + $process = Start-Process msiexec.exe -ArgumentList "/x $($entry.PSChildName) /qn /norestart" -PassThru -Wait + Write-Host "Uninstall exit code: $($process.ExitCode)" + if ($successCodes -notcontains $process.ExitCode) { + $exitCode = $process.ExitCode + } +} + +Exit $exitCode + +} catch { + Write-Host "Error: $_" + Exit 1 +} diff --git a/ee/maintained-apps/outputs/apps.json b/ee/maintained-apps/outputs/apps.json index a14859f3b11..1ceff5bc2f6 100644 --- a/ee/maintained-apps/outputs/apps.json +++ b/ee/maintained-apps/outputs/apps.json @@ -7211,6 +7211,34 @@ "unique_identifier": "QEMU", "description": "QEMU is an open-source machine emulator and virtualizer." }, + { + "name": "QGIS", + "slug": "qgis/darwin", + "platform": "darwin", + "unique_identifier": "org.qgis.qgis3", + "description": "QGIS is a free and open-source geographic information system (GIS) for viewing, editing, and analyzing geospatial data." + }, + { + "name": "QGIS", + "slug": "qgis/windows", + "platform": "windows", + "unique_identifier": "QGIS", + "description": "QGIS is a free and open-source geographic information system (GIS) for viewing, editing, and analyzing geospatial data." + }, + { + "name": "QGIS LTR", + "slug": "qgis@ltr/darwin", + "platform": "darwin", + "unique_identifier": "org.qgis.qgis3", + "description": "QGIS LTR is the long-term release of QGIS, a free and open-source geographic information system (GIS) for viewing, editing, and analyzing geospatial data." + }, + { + "name": "QGIS LTR", + "slug": "qgis@ltr/windows", + "platform": "windows", + "unique_identifier": "QGIS LTR", + "description": "QGIS LTR is the long-term release of QGIS, a free and open-source geographic information system (GIS) for viewing, editing, and analyzing geospatial data." + }, { "name": "QLab", "slug": "qlab/darwin", diff --git a/ee/maintained-apps/outputs/qgis/darwin.json b/ee/maintained-apps/outputs/qgis/darwin.json new file mode 100644 index 00000000000..69d4c0ba2ca --- /dev/null +++ b/ee/maintained-apps/outputs/qgis/darwin.json @@ -0,0 +1,23 @@ +{ + "versions": [ + { + "version": "4.2.3", + "queries": { + "exists": "SELECT 1 FROM apps WHERE bundle_identifier = 'org.qgis.qgis3' AND path LIKE '/Applications/QGIS-final-%.app';", + "patched": "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM apps WHERE bundle_identifier = 'org.qgis.qgis3' AND path LIKE '/Applications/QGIS-final-%.app' AND version_compare(bundle_short_version, '4.2.3') < 0);", + "open": "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM apps a JOIN processes p ON p.path = concat(a.path, '/Contents/MacOS/', a.bundle_executable) WHERE a.bundle_identifier = 'org.qgis.qgis3' AND a.path LIKE '/Applications/QGIS-final-%.app' AND a.bundle_executable != '');" + }, + "installer_url": "https://download.qgis.org/downloads/macos/pr/qgis_pr_final-4_2_3.dmg", + "install_script_ref": "e04037ef", + "uninstall_script_ref": "06c5d7d0", + "sha256": "cf3af3d3d228a0e2a0ab7fb6b37052ae78064d0aef93b12f41f9bd724fd23401", + "default_categories": [ + "Productivity" + ] + } + ], + "refs": { + "06c5d7d0": "#!/bin/bash\n\n# Removes every QGIS-final-<version>.app and closes QGIS if it's running. QGIS\n# LTR and per-user QGIS data (profiles, plugins, caches), which QGIS LTR also\n# uses, are left in place.\n\nAPPDIR=\"/Applications\"\n\n# QGIS and QGIS LTR share a bundle identifier, so match processes by path.\nquit_app_at_path() {\n local app_path=\"$1\"\n local pattern=\"^${app_path}/Contents/MacOS/\"\n pgrep -f \"$pattern\" >/dev/null || return 0\n echo \"Closing $app_path...\"\n pkill -TERM -f \"$pattern\"\n for _ in {1..10}; do\n pgrep -f \"$pattern\" >/dev/null || return 0\n sleep 1\n done\n echo \"$app_path did not close; forcing it to quit.\"\n pkill -KILL -f \"$pattern\"\n}\n\nfor app in \"$APPDIR\"/QGIS-final-*.app; do\n [[ -d \"$app\" ]] || continue\n quit_app_at_path \"$app\"\n echo \"Removing $app\"\n sudo rm -rf \"$app\"\ndone\n", + "e04037ef": "#!/bin/bash\n\n# QGIS is closed if it's running, and unsaved project changes are lost. Each\n# release installs as its own QGIS-final-<version>.app, so earlier releases are\n# removed once the new one is in place. QGIS LTR (QGIS-LTR.app) is left alone.\n\nAPPDIR=\"/Applications\"\nTMPDIR=$(dirname \"$(realpath \"$INSTALLER_PATH\")\")\n\n# QGIS and QGIS LTR share a bundle identifier, so match processes by path.\nquit_app_at_path() {\n local app_path=\"$1\"\n local pattern=\"^${app_path}/Contents/MacOS/\"\n pgrep -f \"$pattern\" >/dev/null || return 0\n echo \"Closing $app_path...\"\n pkill -TERM -f \"$pattern\"\n for _ in {1..10}; do\n pgrep -f \"$pattern\" >/dev/null || return 0\n sleep 1\n done\n echo \"$app_path did not close; forcing it to quit.\"\n pkill -KILL -f \"$pattern\"\n}\n\nMOUNT_POINT=$(mktemp -d /tmp/dmg_mount_XXXXXX)\nyes | hdiutil attach -plist -nobrowse -readonly -mountpoint \"$MOUNT_POINT\" \"$INSTALLER_PATH\" >/dev/null || exit 1\ntrap 'hdiutil detach \"$MOUNT_POINT\" >/dev/null 2>&1 || true' EXIT\n\nNEW_APP=$(find \"$MOUNT_POINT\" -maxdepth 1 -name 'QGIS-final-*.app' -print -quit)\nif [[ -z \"$NEW_APP\" ]]; then\n echo \"No QGIS-final-*.app found in the disk image.\"\n exit 1\nfi\nAPP_NAME=$(basename \"$NEW_APP\")\n\nfor app in \"$APPDIR\"/QGIS-final-*.app; do\n [[ -d \"$app\" ]] && quit_app_at_path \"$app\"\ndone\n\nsudo rm -rf \"$TMPDIR/$APP_NAME.bkp\"\nif [[ -d \"$APPDIR/$APP_NAME\" ]]; then\n sudo mv \"$APPDIR/$APP_NAME\" \"$TMPDIR/$APP_NAME.bkp\" || exit $?\nfi\nif ! sudo cp -R \"$NEW_APP\" \"$APPDIR/\"; then\n # remove the partial copy so a failed install isn't inventoried as the new\n # version, then restore the previous version if there was one\n sudo rm -rf \"$APPDIR/$APP_NAME\"\n if [[ -d \"$TMPDIR/$APP_NAME.bkp\" ]]; then\n sudo mv \"$TMPDIR/$APP_NAME.bkp\" \"$APPDIR/$APP_NAME\"\n fi\n exit 1\nfi\nsudo rm -rf \"$TMPDIR/$APP_NAME.bkp\"\n\nfor app in \"$APPDIR\"/QGIS-final-*.app; do\n if [[ -d \"$app\" && \"$(basename \"$app\")\" != \"$APP_NAME\" ]]; then\n echo \"Removing earlier release $app\"\n sudo rm -rf \"$app\"\n fi\ndone\n\necho \"Installed $APPDIR/$APP_NAME\"\n" + } +} diff --git a/ee/maintained-apps/outputs/qgis/windows.json b/ee/maintained-apps/outputs/qgis/windows.json new file mode 100644 index 00000000000..28181937664 --- /dev/null +++ b/ee/maintained-apps/outputs/qgis/windows.json @@ -0,0 +1,23 @@ +{ + "versions": [ + { + "version": "4.2.2", + "queries": { + "exists": "SELECT 1 FROM programs WHERE name LIKE 'QGIS %' AND publisher = 'QGIS.org' AND version NOT LIKE '3.44.%';", + "patched": "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM programs WHERE name LIKE 'QGIS %' AND publisher = 'QGIS.org' AND version NOT LIKE '3.44.%' AND version_compare(version, '4.2.2') < 0);", + "open": "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM processes WHERE LOWER(name) = 'qgis-bin.exe');" + }, + "installer_url": "https://qgis.org/downloads/QGIS-OSGeo4W-4.2.2-1.msi", + "install_script_ref": "b661d065", + "uninstall_script_ref": "37b1cac3", + "sha256": "dda0db34626053027844f8f90a0acee614fe06fc56eb07d00e9da7f1447472b3", + "default_categories": [ + "Productivity" + ] + } + ], + "refs": { + "37b1cac3": "# Uninstalls every QGIS release on the host, since each release installs side\n# by side under its own product code. QGIS LTR (3.44.x) is left in place.\n\n$ltrSeries = '3.44.'\n\n# MSI exit codes that indicate success. 3010 = ERROR_SUCCESS_REBOOT_REQUIRED,\n# 1641 = ERROR_SUCCESS_REBOOT_INITIATED, 1605 = already uninstalled.\n$successCodes = @(0, 3010, 1641, 1605)\n\ntry {\n\n$uninstallRoots = @(\n 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*',\n 'HKLM:\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*'\n)\n$entries = @(Get-ItemProperty -Path $uninstallRoots -ErrorAction SilentlyContinue | Where-Object {\n $_.DisplayName -like 'QGIS *' -and $_.Publisher -eq 'QGIS.org' -and\n -not ([string]$_.DisplayVersion).StartsWith($ltrSeries) -and\n $_.PSChildName -match '^\\{[0-9A-Fa-f-]+\\}$'\n})\n\nif ($entries.Count -eq 0) {\n Write-Host \"No QGIS installation found; nothing to uninstall.\"\n Exit 0\n}\n\n$exitCode = 0\nforeach ($entry in $entries) {\n Write-Host \"Uninstalling $($entry.DisplayName) ($($entry.PSChildName))\"\n $process = Start-Process msiexec.exe -ArgumentList \"/x $($entry.PSChildName) /qn /norestart\" -PassThru -Wait\n Write-Host \"Uninstall exit code: $($process.ExitCode)\"\n if ($successCodes -notcontains $process.ExitCode) {\n $exitCode = $process.ExitCode\n }\n}\n\nExit $exitCode\n\n} catch {\n Write-Host \"Error: $_\"\n Exit 1\n}\n", + "b661d065": "# Each QGIS release installs side by side under its own product code, so\n# installed QGIS releases are uninstalled first. QGIS LTR (3.44.x) is left in place.\n\n$ltrSeries = '3.44.'\n$logFile = \"${env:TEMP}/fleet-install-software.log\"\n\n# MSI exit codes that indicate success. 3010 = ERROR_SUCCESS_REBOOT_REQUIRED,\n# 1641 = ERROR_SUCCESS_REBOOT_INITIATED. Treat these as success rather than failure.\n$successCodes = @(0, 3010, 1641)\n\ntry {\n\n$uninstallRoots = @(\n 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*',\n 'HKLM:\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*'\n)\n$entries = @(Get-ItemProperty -Path $uninstallRoots -ErrorAction SilentlyContinue | Where-Object {\n $_.DisplayName -like 'QGIS *' -and $_.Publisher -eq 'QGIS.org' -and\n -not ([string]$_.DisplayVersion).StartsWith($ltrSeries) -and\n $_.PSChildName -match '^\\{[0-9A-Fa-f-]+\\}$'\n})\nforeach ($entry in $entries) {\n Write-Host \"Uninstalling $($entry.DisplayName) ($($entry.PSChildName))\"\n $process = Start-Process msiexec.exe -ArgumentList \"/x $($entry.PSChildName) /qn /norestart\" -PassThru -Wait\n # 1605 = the release was already uninstalled\n if (($successCodes + 1605) -notcontains $process.ExitCode) {\n Write-Host \"Uninstall of $($entry.DisplayName) failed with exit code $($process.ExitCode)\"\n Exit $process.ExitCode\n }\n}\n\n$installProcess = Start-Process msiexec.exe `\n -ArgumentList \"/quiet /norestart /lv `\"${logFile}`\" /i `\"${env:INSTALLER_PATH}`\"\" `\n -PassThru -Verb RunAs -Wait\n\nGet-Content $logFile -Tail 500\n\nif ($successCodes -contains $installProcess.ExitCode) {\n Exit 0\n}\n\nExit $installProcess.ExitCode\n\n} catch {\n Write-Host \"Error: $_\"\n Exit 1\n}\n" + } +} diff --git a/ee/maintained-apps/outputs/qgis@ltr/darwin.json b/ee/maintained-apps/outputs/qgis@ltr/darwin.json new file mode 100644 index 00000000000..10c843c74a8 --- /dev/null +++ b/ee/maintained-apps/outputs/qgis@ltr/darwin.json @@ -0,0 +1,23 @@ +{ + "versions": [ + { + "version": "3.44.15", + "queries": { + "exists": "SELECT 1 FROM apps WHERE bundle_identifier = 'org.qgis.qgis3' AND path = '/Applications/QGIS-LTR.app';", + "patched": "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM apps WHERE bundle_identifier = 'org.qgis.qgis3' AND path = '/Applications/QGIS-LTR.app' AND version_compare(bundle_short_version, '3.44.15') < 0);", + "open": "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM apps a JOIN processes p ON p.path = concat(a.path, '/Contents/MacOS/', a.bundle_executable) WHERE a.bundle_identifier = 'org.qgis.qgis3' AND a.path = '/Applications/QGIS-LTR.app' AND a.bundle_executable != '');" + }, + "installer_url": "https://download.qgis.org/downloads/macos/ltr/qgis_ltr_final-3_44_15.dmg", + "install_script_ref": "739271d0", + "uninstall_script_ref": "e0ff26e6", + "sha256": "302547ebee16d4d38ddfd509469cc86e337b23c545307cdbe13c2c2d233ab7cb", + "default_categories": [ + "Productivity" + ] + } + ], + "refs": { + "739271d0": "#!/bin/bash\n\n# QGIS LTR is closed if it's running, and unsaved project changes are lost. It\n# installs as QGIS-LTR.app so it can sit alongside QGIS, which is left alone.\n\nAPPDIR=\"/Applications\"\nTMPDIR=$(dirname \"$(realpath \"$INSTALLER_PATH\")\")\nAPP_PATH=\"$APPDIR/QGIS-LTR.app\"\n\n# QGIS and QGIS LTR share a bundle identifier, so match processes by path.\nquit_app_at_path() {\n local app_path=\"$1\"\n local pattern=\"^${app_path}/Contents/MacOS/\"\n pgrep -f \"$pattern\" >/dev/null || return 0\n echo \"Closing $app_path...\"\n pkill -TERM -f \"$pattern\"\n for _ in {1..10}; do\n pgrep -f \"$pattern\" >/dev/null || return 0\n sleep 1\n done\n echo \"$app_path did not close; forcing it to quit.\"\n pkill -KILL -f \"$pattern\"\n}\n\nMOUNT_POINT=$(mktemp -d /tmp/dmg_mount_XXXXXX)\nyes | hdiutil attach -plist -nobrowse -readonly -mountpoint \"$MOUNT_POINT\" \"$INSTALLER_PATH\" >/dev/null || exit 1\ntrap 'hdiutil detach \"$MOUNT_POINT\" >/dev/null 2>&1 || true' EXIT\n\nif [[ ! -d \"$MOUNT_POINT/QGIS.app\" ]]; then\n echo \"No QGIS.app found in the disk image.\"\n exit 1\nfi\n\nquit_app_at_path \"$APP_PATH\"\n\nsudo rm -rf \"$TMPDIR/QGIS-LTR.app.bkp\"\nif [[ -d \"$APP_PATH\" ]]; then\n sudo mv \"$APP_PATH\" \"$TMPDIR/QGIS-LTR.app.bkp\" || exit $?\nfi\nif ! sudo cp -R \"$MOUNT_POINT/QGIS.app\" \"$APP_PATH\"; then\n # remove the partial copy so a failed install isn't inventoried as the new\n # version, then restore the previous version if there was one\n sudo rm -rf \"$APP_PATH\"\n if [[ -d \"$TMPDIR/QGIS-LTR.app.bkp\" ]]; then\n sudo mv \"$TMPDIR/QGIS-LTR.app.bkp\" \"$APP_PATH\"\n fi\n exit 1\nfi\nsudo rm -rf \"$TMPDIR/QGIS-LTR.app.bkp\"\n\necho \"Installed $APP_PATH\"\n", + "e0ff26e6": "#!/bin/bash\n\n# Removes QGIS-LTR.app and closes it if it's running. QGIS and per-user QGIS\n# data (profiles, plugins, caches), which QGIS also uses, are left in place.\n\nAPP_PATH=\"/Applications/QGIS-LTR.app\"\n\n# QGIS and QGIS LTR share a bundle identifier, so match processes by path.\nquit_app_at_path() {\n local app_path=\"$1\"\n local pattern=\"^${app_path}/Contents/MacOS/\"\n pgrep -f \"$pattern\" >/dev/null || return 0\n echo \"Closing $app_path...\"\n pkill -TERM -f \"$pattern\"\n for _ in {1..10}; do\n pgrep -f \"$pattern\" >/dev/null || return 0\n sleep 1\n done\n echo \"$app_path did not close; forcing it to quit.\"\n pkill -KILL -f \"$pattern\"\n}\n\nquit_app_at_path \"$APP_PATH\"\nsudo rm -rf \"$APP_PATH\"\n" + } +} diff --git a/ee/maintained-apps/outputs/qgis@ltr/windows.json b/ee/maintained-apps/outputs/qgis@ltr/windows.json new file mode 100644 index 00000000000..2135eab5c88 --- /dev/null +++ b/ee/maintained-apps/outputs/qgis@ltr/windows.json @@ -0,0 +1,23 @@ +{ + "versions": [ + { + "version": "3.44.14", + "queries": { + "exists": "SELECT 1 FROM programs WHERE name LIKE 'QGIS %' AND publisher = 'QGIS.org' AND version LIKE '3.44.%';", + "patched": "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM programs WHERE name LIKE 'QGIS %' AND publisher = 'QGIS.org' AND version LIKE '3.44.%' AND version_compare(version, '3.44.14') < 0);", + "open": "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM processes WHERE LOWER(name) = 'qgis-ltr-bin.exe');" + }, + "installer_url": "https://qgis.org/downloads/QGIS-OSGeo4W-3.44.14-1.msi", + "install_script_ref": "c1308e76", + "uninstall_script_ref": "6ce7e210", + "sha256": "0a579f980dcec85be2ecb47c5f08234ca6ce7b625c3cb9543eded1f43d445b46", + "default_categories": [ + "Productivity" + ] + } + ], + "refs": { + "6ce7e210": "# Uninstalls every QGIS LTR (3.44.x) release on the host, since each release\n# installs side by side under its own product code. Other QGIS releases are\n# left in place.\n\n$ltrSeries = '3.44.'\n\n# MSI exit codes that indicate success. 3010 = ERROR_SUCCESS_REBOOT_REQUIRED,\n# 1641 = ERROR_SUCCESS_REBOOT_INITIATED, 1605 = already uninstalled.\n$successCodes = @(0, 3010, 1641, 1605)\n\ntry {\n\n$uninstallRoots = @(\n 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*',\n 'HKLM:\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*'\n)\n$entries = @(Get-ItemProperty -Path $uninstallRoots -ErrorAction SilentlyContinue | Where-Object {\n $_.DisplayName -like 'QGIS *' -and $_.Publisher -eq 'QGIS.org' -and\n ([string]$_.DisplayVersion).StartsWith($ltrSeries) -and\n $_.PSChildName -match '^\\{[0-9A-Fa-f-]+\\}$'\n})\n\nif ($entries.Count -eq 0) {\n Write-Host \"No QGIS LTR installation found; nothing to uninstall.\"\n Exit 0\n}\n\n$exitCode = 0\nforeach ($entry in $entries) {\n Write-Host \"Uninstalling $($entry.DisplayName) ($($entry.PSChildName))\"\n $process = Start-Process msiexec.exe -ArgumentList \"/x $($entry.PSChildName) /qn /norestart\" -PassThru -Wait\n Write-Host \"Uninstall exit code: $($process.ExitCode)\"\n if ($successCodes -notcontains $process.ExitCode) {\n $exitCode = $process.ExitCode\n }\n}\n\nExit $exitCode\n\n} catch {\n Write-Host \"Error: $_\"\n Exit 1\n}\n", + "c1308e76": "# Each QGIS release installs side by side under its own product code, so\n# installed QGIS LTR (3.44.x) releases are uninstalled first. Other QGIS\n# releases are left in place.\n\n$ltrSeries = '3.44.'\n$logFile = \"${env:TEMP}/fleet-install-software.log\"\n\n# MSI exit codes that indicate success. 3010 = ERROR_SUCCESS_REBOOT_REQUIRED,\n# 1641 = ERROR_SUCCESS_REBOOT_INITIATED. Treat these as success rather than failure.\n$successCodes = @(0, 3010, 1641)\n\ntry {\n\n$uninstallRoots = @(\n 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*',\n 'HKLM:\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*'\n)\n$entries = @(Get-ItemProperty -Path $uninstallRoots -ErrorAction SilentlyContinue | Where-Object {\n $_.DisplayName -like 'QGIS *' -and $_.Publisher -eq 'QGIS.org' -and\n ([string]$_.DisplayVersion).StartsWith($ltrSeries) -and\n $_.PSChildName -match '^\\{[0-9A-Fa-f-]+\\}$'\n})\nforeach ($entry in $entries) {\n Write-Host \"Uninstalling $($entry.DisplayName) ($($entry.PSChildName))\"\n $process = Start-Process msiexec.exe -ArgumentList \"/x $($entry.PSChildName) /qn /norestart\" -PassThru -Wait\n # 1605 = the release was already uninstalled\n if (($successCodes + 1605) -notcontains $process.ExitCode) {\n Write-Host \"Uninstall of $($entry.DisplayName) failed with exit code $($process.ExitCode)\"\n Exit $process.ExitCode\n }\n}\n\n$installProcess = Start-Process msiexec.exe `\n -ArgumentList \"/quiet /norestart /lv `\"${logFile}`\" /i `\"${env:INSTALLER_PATH}`\"\" `\n -PassThru -Verb RunAs -Wait\n\nGet-Content $logFile -Tail 500\n\nif ($successCodes -contains $installProcess.ExitCode) {\n Exit 0\n}\n\nExit $installProcess.ExitCode\n\n} catch {\n Write-Host \"Error: $_\"\n Exit 1\n}\n" + } +} diff --git a/frontend/pages/SoftwarePage/components/icons/index.ts b/frontend/pages/SoftwarePage/components/icons/index.ts index 9f8ad3b6c1b..4bfa69a68df 100644 --- a/frontend/pages/SoftwarePage/components/icons/index.ts +++ b/frontend/pages/SoftwarePage/components/icons/index.ts @@ -849,6 +849,7 @@ import PyCharmCe from "./png/PyCharmCe.png"; import Python313 from "./png/Python313.png"; import Python314 from "./png/Python314.png"; import Qemu from "./png/Qemu.png"; +import Qgis from "./png/Qgis.png"; import Qlab from "./png/Qlab.png"; import Qlmarkdown from "./png/Qlmarkdown.png"; import QspacePro from "./png/QspacePro.png"; @@ -2038,6 +2039,8 @@ export const SOFTWARE_NAME_TO_ICON_MAP = { "python 3.13": Python313, "python 3.14": Python314, qemu: Qemu, + qgis: Qgis, + "qgis ltr": Qgis, qlab: Qlab, "qspace pro": QspacePro, quip: Quip, diff --git a/frontend/pages/SoftwarePage/components/icons/png/Qgis.png b/frontend/pages/SoftwarePage/components/icons/png/Qgis.png new file mode 100644 index 00000000000..80f7035552c Binary files /dev/null and b/frontend/pages/SoftwarePage/components/icons/png/Qgis.png differ diff --git a/pkg/patch_policy/patch_policy.go b/pkg/patch_policy/patch_policy.go index 949b8813bc6..3d6480c9463 100644 --- a/pkg/patch_policy/patch_policy.go +++ b/pkg/patch_policy/patch_policy.go @@ -270,6 +270,8 @@ var windowsOpenQueryOverrides = map[string]string{ //nolint:gosec // G101 false "ProtonVPN": "IN ('proton vpn.exe','protonvpn.exe')", "PyCharm Community Edition": "IN ('pycharm.exe','pycharm64.exe')", "PyCharm Professional": "IN ('pycharm.exe','pycharm64.exe')", + "QGIS": "= 'qgis-bin.exe'", + "QGIS LTR": "= 'qgis-ltr-bin.exe'", "Raspberry Pi Imager": "= 'rpi-imager.exe'", "Rider": "IN ('rider.exe','rider64.exe')", "RStudio": "IN ('rgui.exe','rsession.exe','rstudio.exe')", diff --git a/website/assets/images/app-icon-qgis-60x60@2x.png b/website/assets/images/app-icon-qgis-60x60@2x.png new file mode 100644 index 00000000000..80f7035552c Binary files /dev/null and b/website/assets/images/app-icon-qgis-60x60@2x.png differ diff --git a/website/assets/images/app-icon-qgis@ltr-60x60@2x.png b/website/assets/images/app-icon-qgis@ltr-60x60@2x.png new file mode 100644 index 00000000000..80f7035552c Binary files /dev/null and b/website/assets/images/app-icon-qgis@ltr-60x60@2x.png differ