{
    "homepage": "https://cloud.r-project.org/bin/windows/Rtools",
    "description": "Tools for building packages for R under Microsoft Windows, or for building R itself. (R 3.3.x - R 3.6.x)",
    "license": "BSD-3-Clause",
    "version": "3.5.0.4",
    "url": "https://cloud.r-project.org/bin/windows/Rtools/Rtools35.exe",
    "hash": "18fd63bb9c903e1f9bfce5c9a2600bd24213295760592dbc130b73a61e9d9414",
    "innosetup": true,
    "installer": {
        "script": [
            "'r', 'mro' | ForEach-Object {",
            "   if ((Select-CurrentVersion $_ $global) -match '^3') {",
            "       $renvloc = (versiondir $_ (Select-CurrentVersion $_ $global) $global) + '\\etc\\Renviron.site'",
            "       if (Test-Path $renvloc) {",
            "           $renv = Get-Content $renvloc -Encoding ASCII",
            "       } else {",
            "           $renv = @()",
            "       }",
            "       if ($architecture -eq '32bit') {",
            "           $rtoolspath = \"$dir\\bin;$dir\\mingw_32\\bin\"",
            "       } else {",
            "           $rtoolspath = \"$dir\\bin;$dir\\mingw_64\\bin\"",
            "       }",
            "       if ($renv -cmatch 'PATH=') {",
            "           $renv = $renv -replace 'PATH=\"(.*)', ('PATH=\"' + $rtoolspath + ';$1')",
            "       } else {",
            "           $renv += '`r`nPATH=\"' + $rtoolspath + ';${PATH}\"'",
            "       }",
            "       $renv | Set-Content $renvloc -Encoding ASCII",
            "   }",
            "}",
            "if (Test-Path 'C:\\Rtools') {",
            "   if ($null -eq (Get-Item 'C:\\Rtools').LinkType) {",
            "       Rename-Item -Path 'C:\\Rtools' -NewName 'Rtools.old' -Force",
            "   } else {",
            "       Remove-Item -Path 'C:\\Rtools' -Force",
            "   }",
            "}",
            "New-Item -Path 'C:\\Rtools' -Target \"$dir\" -ItemType Junction | Out-Null"
        ]
    },
    "uninstaller": {
        "script": [
            "'r', 'mro' | ForEach-Object {",
            "   if ((Select-CurrentVersion $_ $global) -match '^3') {",
            "       $renvloc = (versiondir $_ (Select-CurrentVersion $_ $global) $global) + '\\etc\\Renviron.site'",
            "       if (Test-Path $renvloc) {",
            "           $renv = Get-Content $renvloc -Encoding ASCII",
            "       } else {",
            "           $renv = @()",
            "       }",
            "       $renv = $renv -replace '[^;\"]*rtools.*?;', ''",
            "       $renv | Set-Content $renvloc -Encoding ASCII",
            "   }",
            "}",
            "if ((Test-Path 'C:\\Rtools') -and ($null -ne (Get-Item 'C:\\Rtools').LinkType)) {",
            "   Remove-Item -Path 'C:\\Rtools' -Force",
            "}",
            "if (Test-Path 'C:\\Rtools.old') {",
            "   Rename-Item -Path 'C:\\Rtools.old' -NewName 'Rtools' -Force",
            "}"
        ]
    }
}
