Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New App Request] TortoiseSVN (On Proposals list) #97

Open
AScott-WWF opened this issue Jul 2, 2024 · 0 comments
Open

[New App Request] TortoiseSVN (On Proposals list) #97

AScott-WWF opened this issue Jul 2, 2024 · 0 comments

Comments

@AScott-WWF
Copy link

N.B. As TortoiseSVN files are hosted on SourceForge, a certain amount of URL manipulation needs to be carried out.
Also to ensure the files are served from different SourceForge mirrors, a list of Mirrors is contained in $SFMirrorList the mirror is randomly chosen into $SFMirror before generating the URLs - therefore each run of the script is likely to present different SourceForge domains to the file locations.

Script:

# Get-TortoiseSVN.ps1

# Define AppName
$AppName = "TortoiseSVN"

# Main script to fetch and process links
$ReleaseUrl = "https://tortoisesvn.net/downloads.html"
$InstallInstructionsUrl = "https://tortoisesvn.net/faq.html#uninstallfirst"

Write-Verbose "Obtaining $($AppName) Release Versions from $($ReleaseUrl)...`n"

$AppVersions = @(
        @{Architecture = 'x86'; Type = 'msi'; Pattern = 'Download TortoiseSVN \d+\.\d+\.\d+ - 32-bit, linked to SVN'; VersionPattern = 'TortoiseSVN-(\d+\.\d+\.\d+\.\d+)-'}
        @{Architecture = 'x64'; Type = 'msi'; Pattern = 'Download TortoiseSVN \d+\.\d+\.\d+ - 64-bit, linked to SVN'; VersionPattern = 'TortoiseSVN-(\d+\.\d+\.\d+\.\d+)-'}
        @{Architecture = 'ARM64'; Type = 'msi'; Pattern = 'Download TortoiseSVN \d+\.\d+\.\d+ - ARM64, linked to SVN'; VersionPattern = 'TortoiseSVN-(\d+\.\d+\.\d+\.\d+)-'}
)

# As Tortoise SVN downloads are hosted on SourceForge, the download should be pulled from of their mirrors randomly
# List of SourceForge Mirrors
$SFMirrorList =@('netcologne','kumisystems','netix','unlimited','deac-riga','deac-fra','yer','psychz','pilotfiber','netactuate','icolo','altushost-swe','liquidtelecom',
'cfhcable','gigenet','webwerks','cytranet-dal','versaweb','phoenixnap','tenet','sinalbr','jaist','zenlayer','udomain','nchc','razaoinfo','sitsa','onboardcloud','freefr',
'excellmedia','ixpeering')

$SFMirror = Get-Random -InputObject $SFMirrorList # Select random mirror
#Write-Verbose "SourceForge Mirror :: $($SFMirror)`n" #N.B. Uris will likely be different on each run

foreach ($AppVersion in $AppVersions) {
    $SearchCount = 1 # This may need increasing as future versions are released

    #Build each link with File Type specific versions
    $SFURL = (Get-Link -Uri $ReleaseUrl -MatchProperty outerHTML -Pattern $($AppVersion.Pattern)) # Linked SourceForge URL
    # Manipulate address of returned URL to gain actual file download
        $StripendURL = ($($SFURL) -split "/download")[0] #if exists, remove trailing /download and everything subsequent
        $CarveURL = $($StripendURL) -replace "s/tortoisesvn/files","/tortoisesvn" # Carve up URL - to use with other SourceForge Mirrors
        $URL = ($($CarveURL) -replace "sourceforge.net","$($SFMirror).dl.sourceforge.net")+"?viasf=1" # Define SourceForge Mirror to download file from and append '?viasf=1'
 
    [version]$Version = (Get-Version -String $URL -Pattern $AppVersion.VersionPattern)
    $ReleaseNotesUrl = "https://tortoisesvn.net/tsvn_$($Version.Major).$($Version.Minor)_releasenotes.html"

    do {
        if ($URL) {
            New-NevergreenApp -Name $AppName -Version $Version -Uri $URL -Architecture $AppVersion.Architecture -Type $($AppVersion.Type)
            break
        }

        $SearchCount--
    } until ($SearchCount -eq 0)

    if ($SearchCount -eq 0) {
        Write-Warning "Could not find release for $($AppName) $($AppVersion.Type)"
    }
}

Write-Verbose "$($AppName) (Version: $($Version)) Release notes are available here: $($ReleaseNotesUrl)"
Write-Verbose "$($AppName) Install instructions are available here: $($InstallInstructionsUrl)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant