-
Notifications
You must be signed in to change notification settings - Fork 54
/
uninstall.go
69 lines (54 loc) · 1.58 KB
/
uninstall.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
package inno
import (
"path/filepath"
"github.com/itchio/butler/filtering"
"github.com/itchio/butler/installer"
"github.com/itchio/dash"
"github.com/pkg/errors"
)
func (m *Manager) Uninstall(params installer.UninstallParams) error {
consumer := params.Consumer
folder := params.InstallFolderPath
consumer.Infof("%s: probing with configurator", folder)
verdict, err := dash.Configure(folder, &dash.ConfigureParams{
Consumer: params.Consumer,
Filter: filtering.FilterPaths,
})
if err != nil {
return errors.WithStack(err)
}
var chosen *dash.Candidate
for _, c := range verdict.Candidates {
if c.Flavor != dash.FlavorNativeWindows {
consumer.Infof("%s: ignoring (not native windows)", c.Path)
continue
}
if c.WindowsInfo == nil {
consumer.Infof("%s: ignoring (nil windows info)", c.Path)
continue
}
if c.WindowsInfo.InstallerType != "inno" {
consumer.Infof("%s: ignoring (wrong installer type '%s')", c.Path, c.WindowsInfo.InstallerType)
continue
}
consumer.Infof("%s: is our chosen uninstaller", c.Path)
chosen = c
break
}
if chosen == nil {
return errors.New("could not find inno uninstaller in folder")
}
uninstallerPath := filepath.Join(folder, chosen.Path)
cmdTokens := []string{
uninstallerPath,
"/VERYSILENT", // be vewwy vewwy quiet
}
consumer.Infof("→ Launching inno uninstaller")
// N.B: InnoSetup uninstallers are smart enough to elevate themselves.
exitCode, err := installer.RunCommand(consumer, cmdTokens)
err = installer.CheckExitCode(exitCode, err)
if err != nil {
return errors.WithStack(err)
}
return nil
}