-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscoop.go
70 lines (62 loc) · 1.42 KB
/
scoop.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"fmt"
"log"
"github.com/urfave/cli/v2"
)
func cmdScoop() *cli.Command {
return &cli.Command{
Name: "scoop",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "version",
Usage: "version",
},
},
Action: func(c *cli.Context) error {
return scoop(c.String("version"))
},
}
}
func scoop(version string) error {
url32 := fmt.Sprintf("https://github.com/keys-pub/keys-ext/releases/download/v%s/keys_%s_windows_i386.tar.gz", version, version)
hash32, err := downloadCalculateHash(url32)
if err != nil {
return err
}
url64 := fmt.Sprintf("https://github.com/keys-pub/keys-ext/releases/download/v%s/keys_%s_windows_x86_64.tar.gz", version, version)
hash64, err := downloadCalculateHash(url64)
if err != nil {
return err
}
scoop := fmt.Sprintf(`
{
"version": "%s",
"architecture": {
"32bit": {
"url": "%s",
"bin": [
"keys.exe",
"keysd.exe"
],
"hash": "%s"
},
"64bit": {
"url": "%s",
"bin": [
"keys.exe",
"keysd.exe"
],
"hash": "%s"
}
},
"homepage": "https://keys.pub",
"license": "MIT"
}
`, version, url32, hash32, url64, hash64)
log.Printf("%s:\n", scoop)
if err := updateRepo("keys-pub", "scoop-bucket", "keys.json", []byte(scoop), version); err != nil {
return err
}
return nil
}