{
    "version": "4.6",
    "description": "A Delphi compatible cross-platform IDE for Rapid Application Development.",
    "homepage": "https://www.lazarus-ide.org",
    "license": {
        "identifier": "GPL-2.0-or-later | FPC-modified-LGPL-2.0-or-later",
        "url": "https://wiki.lazarus.freepascal.org/licensing"
    },
    "notes": [
        "To register file associations, please execute the following command:",
        "reg import \"$dir\\install-associations.reg\""
    ],
    "architecture": {
        "64bit": {
            "url": "https://downloads.sourceforge.net/project/lazarus/Lazarus%20Windows%2064%20bits/Lazarus%204.6/lazarus-4.6-fpc-3.2.2-win64.exe",
            "hash": "e53ef697644bfa9588cee833edd2c76af42f79331fff2eb9f730fef86fbda00f"
        },
        "32bit": {
            "url": "https://downloads.sourceforge.net/project/lazarus/Lazarus%20Windows%2032%20bits/Lazarus%204.6/lazarus-4.6-fpc-3.2.2-win32.exe",
            "hash": "0bcfdde9d533058f3b730034c4575b4412821f2117cba77d078eee41836af10a"
        }
    },
    "innosetup": true,
    "installer": {
        "script": [
            "$executable_dir = Get-ChildItem -Path \"$dir\\fpc\" -Filter 'fpcmkcfg.exe' -Depth 3 -File |",
            "        Select-Object -ExpandProperty DirectoryName -First 1",
            "$fpc_dir = $executable_dir -replace '(?<=fpc.+)[\\\\/]bin.+', ''",
            "$process_args = @('-d', \"basepath=$fpc_dir\", '-o', \"$executable_dir\\fpc.cfg\")",
            "Start-Process -FilePath \"$executable_dir\\fpcmkcfg.exe\" -ArgumentList $process_args -NoNewWindow -Wait"
        ]
    },
    "post_install": [
        "$lazarus_dir = $dir -replace '\\\\', '\\\\'",
        "Get-ChildItem -Path \"$bucketsdir\\$bucket\\scripts\\$app\" -Filter '*.reg' -File | ForEach-Object -Process {",
        "    $content = Get-Content -Path $_.FullName -Encoding utf8",
        "    if ($global) { $content = $content -replace 'HKEY_CURRENT_USER(?=.+Classes)', 'HKEY_LOCAL_MACHINE' }",
        "    $content -replace '{{lazarus_dir}}', $lazarus_dir | Set-Content -Path \"$dir\\$($_.Name)\" -Encoding unicode",
        "}"
    ],
    "env_set": {
        "LazDir": "$dir",
        "LazarusDir": "$dir"
    },
    "bin": [
        "lazarus.exe",
        "lazbuild.exe"
    ],
    "shortcuts": [
        [
            "lazarus.exe",
            "Lazarus"
        ],
        [
            "startlazarus.exe",
            "Lazarus (debug)",
            "--debug"
        ]
    ],
    "uninstaller": {
        "script": [
            "if ($cmd -ne 'uninstall') { return }",
            "Get-ChildItem -Path $dir -Filter 'un*.reg' -File | ForEach-Object -Process {",
            "    $registry_file = '\"{0}\"' -f $_.FullName",
            "    Start-Process -FilePath 'reg.exe' -ArgumentList @('import', $registry_file) -WindowStyle Hidden -Wait",
            "}"
        ]
    },
    "checkver": {
        "url": "https://www.lazarus-ide.org/index.php?page=downloads",
        "regex": "lazarus-([\\d.]+)-fpc-(?<fpc>[\\d.]+)-win"
    },
    "autoupdate": {
        "architecture": {
            "64bit": {
                "url": "https://downloads.sourceforge.net/project/lazarus/Lazarus%20Windows%2064%20bits/Lazarus%20$version/lazarus-$version-fpc-$matchFpc-win64.exe"
            },
            "32bit": {
                "url": "https://downloads.sourceforge.net/project/lazarus/Lazarus%20Windows%2032%20bits/Lazarus%20$version/lazarus-$version-fpc-$matchFpc-win32.exe"
            }
        },
        "hash": {
            "url": "https://www.lazarus-ide.org/index.php?page=checksums",
            "regex": "$sha256.*?$basename"
        }
    }
}
