Skip to content

Commit

Permalink
[Schema] Add metalink mode to hashmode (ScoopInstaller#3170)
Browse files Browse the repository at this point in the history
* [Schema] Add metalink mode

Schema is missing property for metalink

See: https://github.com/lukesampson/scoop/blob/57b0b0e1eb2c946ca74541b2464d3e61e195e979/lib/autoupdate.ps1#L213-L218

* Make fosshub and sourceforge same as other methods
  • Loading branch information
Ash258 authored and Richard Kuhnt committed Mar 4, 2019
1 parent 98ff1c0 commit bc89854
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 8 additions & 4 deletions lib/autoupdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,10 @@ function get_hash_for_app([String] $app, $config, [String] $version, [String] $u

if (!$hashfile_url -and $url -match "^(?:.*fosshub.com\/).*(?:\/|\?dwl=)(?<filename>.*)$") {
$hashmode = 'fosshub'
$hash = find_hash_in_textfile $url $substitutions ($Matches.filename+'.*?"sha256":"([a-fA-F0-9]{64})"')
}

if (!$hashfile_url -and $url -match "(?:downloads\.)?sourceforge.net\/projects?\/(?<project>[^\/]+)\/(?:files\/)?(?<file>.*)") {
$hashmode = 'sourceforge'
# change the URL because downloads.sourceforge.net doesn't have checksums
$hashfile_url = (strip_filename (strip_fragment "https://sourceforge.net/projects/$($matches['project'])/files/$($matches['file'])")).TrimEnd('/')
$hash = find_hash_in_textfile $hashfile_url $substitutions '"$basename":.*?"sha1":\s"([a-fA-F0-9]{40})"'
}

switch ($hashmode) {
Expand All @@ -216,6 +212,14 @@ function get_hash_for_app([String] $app, $config, [String] $version, [String] $u
$hash = find_hash_in_textfile "$url.meta4" $substitutions
}
}
'fosshub' {
$hash = find_hash_in_textfile $url $substitutions ($Matches.filename+'.*?"sha256":"([a-fA-F0-9]{64})"')
}
'sourceforge' {
# change the URL because downloads.sourceforge.net doesn't have checksums
$hashfile_url = (strip_filename (strip_fragment "https://sourceforge.net/projects/$($matches['project'])/files/$($matches['file'])")).TrimEnd('/')
$hash = find_hash_in_textfile $hashfile_url $substitutions '"$basename":.*?"sha1":\s"([a-fA-F0-9]{40})"'
}
}

if ($hash) {
Expand Down
5 changes: 4 additions & 1 deletion schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@
"download",
"extract",
"json",
"rdf"
"rdf",
"metalink",
"fosshub",
"sourceforge"
]
},
"type": {
Expand Down

0 comments on commit bc89854

Please sign in to comment.