Scoop-extras: WinSCP hash check fails

Created on 4 Jan 2019  路  6Comments  路  Source: lukesampson/scoop-extras

Hi,

I'm attempting to create a new manifest for WinSCP:

{
    "homepage": "https://winscp.net",
    "description": "A Free SFTP, SCP and FTP client for Windows",
    "license": {
        "identifier": "GPL-3.0-or-later",
        "url": "https://winscp.net/eng/docs/license"
    },
    "version": "5.13.6",
    "url": "https://winscp.net/download/WinSCP-5.13.6-Portable.zip#/dl.7z",
    "hash": "58ce38809f9850897f0b1f2f7f19aa93af46192fa6141cd82c479c4d50fce237",
    "persist": "WinSCP.ini",
    "extract_dir": "Files/7-Zip",
    "bin": "7z.exe",
    "checkver": {
        "url": "https://winscp.net/eng/downloads.php",
        "regex": "Download <strong>WinSCP<\/strong> ([\\d.]+)"
    },
    "autoupdate": {
        "url": "https://winscp.net/download/WinSCP-$version-Portable.zip",
        "hash": {
            "url": "https://winscp.net/download/WinSCP-$version-Portable.zip#checksums",
            "find": "SHA-256:\\s+([a-fA-F0-9]{64})"
        },
        "extract_dir": "WinSCP-$version"
    },
    "shortcuts": [
        [
            "WinSCP.exe",
            "WinSCP"
        ]
    ]
}

when testing I however notice that the hash keeps changing:

Installing 'winscp' (5.13.6) [64bit]
Downloading https://winscp.net/download/WinSCP-5.13.6-Portable.zip#/dl.7z (-1 B)...
Checking hash of WinSCP-5.13.6-Portable.zip ... ERROR Hash check failed!
App:         winscp
URL:         https://winscp.net/download/WinSCP-5.13.6-Portable.zip#/dl.7z
First bytes: 3C 21 44 4F 43 54 59 50
Expected:    58ce38809f9850897f0b1f2f7f19aa93af46192fa6141cd82c479c4d50fce237
Actual:      f19e7a3f66da059e9c37e3deb7b3190c79e97774e4e44b566244522ef433d5a1

Please try again or create a new issue by using the following link and paste your console output:
https://github.com/lukesampson/scoop/issues/new?title=winscp%405.13.6%3a+hash+check+failed

PS C:\Users\vanwe> scoop uninstall winscp
Uninstalling 'winscp' (5.13.6).
'winscp' was uninstalled.

PS C:\Users\vanwe> 
PS C:\Users\vanwe> scoop install winscp
Installing 'winscp' (5.13.6) [64bit]
Downloading https://winscp.net/download/WinSCP-5.13.6-Portable.zip#/dl.7z (-1 B)...
Checking hash of WinSCP-5.13.6-Portable.zip ... ERROR Hash check failed!
App:         winscp
URL:         https://winscp.net/download/WinSCP-5.13.6-Portable.zip#/dl.7z
First bytes: 3C 21 44 4F 43 54 59 50
Expected:    58ce38809f9850897f0b1f2f7f19aa93af46192fa6141cd82c479c4d50fce237
Actual:      7c012fd965c64272f6872d3e5eb99dbc0d8eb443f83a719de64c91a196653d82

Please try again or create a new issue by using the following link and paste your console output:
https://github.com/lukesampson/scoop/issues/new?title=winscp%405.13.6%3a+hash+check+failed

Any idea why it keeps changing and what I need to do in order to fix this?

Additional question; what's the best way to check if Scoop is already installed by using PowerShell commands?

Thanks!

Most helpful comment

It's because you are downloading webpage instead of file. (test it with curl 'https://winscp.net/download/WinSCP-5.13.6-Portable.zip' -o 'cosi.html'; cat cosi.html or (curl 'https://winscp.net/download/WinSCP-5.13.6-Portable.zip').Content.

Use direct url from sourceforge instead (https://downloads.sourceforge.net/project/winscp/WinSCP/5.13.6/WinSCP-5.13.6-Portable.zip)

All 6 comments

It's because you are downloading webpage instead of file. (test it with curl 'https://winscp.net/download/WinSCP-5.13.6-Portable.zip' -o 'cosi.html'; cat cosi.html or (curl 'https://winscp.net/download/WinSCP-5.13.6-Portable.zip').Content.

Use direct url from sourceforge instead (https://downloads.sourceforge.net/project/winscp/WinSCP/5.13.6/WinSCP-5.13.6-Portable.zip)

Your hash extraction in autoupdate will not work. Find hashes in here or use sourceforge automatic extraction.

Additional question; what's the best way to check if Scoop is already installed by using PowerShell commands?

Get-Command 'scoop' will return only if scoop is in path. Otherwise you should look for some scoop relate files in drives.

Your hash extraction in autoupdate will not work. Find hashes in here or use sourceforge automatic extraction.

Thanks, if I use that file for hash extracting it will have multiple matches.. will that cause issues? if yes, where can I find an example on sourgeforge automatic extraction? couldn't find any reference on the wiki pages

In addition:
"persist": "WinSCP.ini"
creates a directory, yet I'm attempting to persist a file here (a file that hasn't been created yet, it get's created later when the user starts saving connections)

  1. Use something like (?sm)$basename\\s*- MD5: ([A-Fa-f\\d]{32}) Maybe that multiline setting is not need, test it.
  2. Use normal flow with testing already persisted file. (my docs, which i use for training)
    "pre_install || installer: { script" : [
        "$file = 'WinSCP.ini'",
        "if (-not (Test-Path \"$persist_dir\\$file\")) {",
        "    Write-Host 'File' $file 'does not exists. Creating.' -f Yellow",
        "    Set-Content \"$dir\\$file\" $null -Encoding Ascii", //Instead of $null you could use some default settings, if you have any
        "}"
    ]

See: https://github.com/lukesampson/scoop-extras/blob/9c1ffe3af354dae877d3a3b125290cd96b907792/winscp.json#L9-L13

that's all I needed to know, thanks for your input (and docs)!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lx4r picture lx4r  路  8Comments

Spiraster picture Spiraster  路  6Comments

lepicsaintloup picture lepicsaintloup  路  10Comments

janpio picture janpio  路  13Comments

zhoujin7 picture zhoujin7  路  4Comments