-
Notifications
You must be signed in to change notification settings - Fork 11
/
mount.go
94 lines (78 loc) · 2.02 KB
/
mount.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package main
import (
"encoding/base64"
"fmt"
"iconsole/services"
"strings"
"github.com/urfave/cli"
)
func actionList(ctx *cli.Context) error {
args := ctx.Args()
udid := ctx.String("UDID")
imageType := ctx.String("type")
if len(args) > 0 {
if strings.ToLower(args[0]) == "help" {
return cli.ShowSubcommandHelp(ctx)
}
}
if device, err := getDevice(udid); err != nil {
return err
} else if ms, err := services.NewMountService(device); err != nil {
return err
} else if images, err := ms.Images(imageType); err != nil {
return err
} else {
fmt.Printf("ImageSignatures[%d]:\n", len(images.ImageSignature))
for i, is := range images.ImageSignature {
fmt.Printf("%2d: %s\n", i, base64.StdEncoding.EncodeToString(is))
}
}
return nil
}
func actionMount(ctx *cli.Context) error {
udid := ctx.String("UDID")
imageType := ctx.String("type")
args := ctx.Args()
var dmgFile, dmgFileSignature string
if len(args) == 2 {
dmgFile = args[0]
dmgFileSignature = args[1]
} else {
return cli.ShowSubcommandHelp(ctx)
}
path := "/private/var/mobile/Media/PublicStaging/staging.dimage"
if device, err := getDevice(udid); err != nil {
return err
} else if ms, err := services.NewMountService(device); err != nil {
return err
} else if err := ms.UploadImage(dmgFile, dmgFileSignature, imageType); err != nil {
return err
} else if err := ms.Mount(path, imageType, dmgFileSignature); err != nil {
return err
}
return nil
}
func initMountCommand() cli.Command {
flags := append(globalFlags, cli.StringFlag{
Name: "type, t",
Usage: "Image type default Developer",
EnvVar: "IMAGE_TYPE",
Value: "Developer",
})
return cli.Command{
Name: "mount",
Usage: "Mount developer image",
UsageText: "iconsole mount [-u serial_number|udid] <DMG_FILE> <DMG_FILE_SIGNATURE>",
Action: actionMount,
Flags: flags,
Subcommands: []cli.Command{
{
Name: "list",
ShortName: "l",
Usage: "Show developer lists",
Action: actionList,
Flags: flags,
},
},
}
}