-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathinstall.go
66 lines (53 loc) · 1.72 KB
/
install.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
package nsis
import (
"github.com/itchio/butler/installer/bfs"
"github.com/pkg/errors"
"github.com/itchio/butler/installer"
)
/*
* Install performs installation for an NSIS package.
*
* NSIS docs: http://nsis.sourceforge.net/Docs/Chapter3.html
* When ran without elevate, some NSIS installers will silently fail.
* So, we run them with elevate all the time.
*/
func (m *Manager) Install(params *installer.InstallParams) (*installer.InstallResult, error) {
consumer := params.Consumer
// we need the installer on disk to run it. this'll err if it's not,
// and the caller is in charge of downloading it and calling us again.
f, err := installer.AsLocalFile(params.File)
if err != nil {
return nil, errors.WithStack(err)
}
angelParams := &bfs.SaveAngelsParams{
Consumer: consumer,
Folder: params.InstallFolderPath,
Receipt: params.ReceiptIn,
}
cancel := make(chan struct{})
defer close(cancel)
bfs.StartAsymptoticProgress(consumer, cancel)
angelResult, err := bfs.SaveAngels(angelParams, func() error {
cmdTokens := []string{
f.Name(),
"/S", // run the installer silently
"/NCRC", // disable CRC-check, we do hash checking ourselves
}
pathArgs := getSeriouslyMisdesignedNsisPathArguments("/D=", params.InstallFolderPath)
cmdTokens = append(cmdTokens, pathArgs...)
consumer.Infof("→ Launching nsis installer")
exitCode, err := installer.RunElevatedCommand(consumer, cmdTokens)
err = installer.CheckExitCode(exitCode, err)
if err != nil {
return errors.Wrap(err, "making sure nsis installer ran correctly")
}
return nil
})
if err != nil {
return nil, errors.Wrap(err, "running nsis installer")
}
res := &installer.InstallResult{
Files: angelResult.Files,
}
return res, nil
}