forked from openatx/wdaproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer.go
33 lines (28 loc) · 1020 Bytes
/
installer.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
package main
import (
"bytes"
"os/exec"
plist "github.com/DHowett/go-plist"
)
type Package struct {
Name string `plist:"CFBundleDisplayName" json:"name"`
BundleId string `plist:"CFBundleIdentifier" json:"bundleId"`
Version string `plist:"CFBundleVersion" json:"version"`
MinOSVersion string `plist:"MinimumOSVersion" json:"miniOSVersion"`
SupportedDevices []string `plist:"UISupportedDevices" json:"UISupportedDevices"`
}
func ListPackages(udid string) (pkgs []Package, err error) {
pkgs = make([]Package, 0)
c := exec.Command("ideviceinstaller", "--udid", udid, "-l", "-o", "xml")
data, err := c.Output()
if err != nil {
return nil, err
}
err = plist.NewDecoder(bytes.NewReader(data)).Decode(&pkgs)
return
}
func UninstallPackage(udid, bundleId string) (output string, err error) {
c := exec.Command("ideviceinstaller", "--udid", udid, "--uninstall", bundleId)
data, err := c.CombinedOutput()
return string(data), err
}