Skip to content

Commit

Permalink
tweak: support tvOS 16.5
Browse files Browse the repository at this point in the history
  • Loading branch information
bitxeno committed Jul 24, 2023
1 parent 866d0d2 commit 3109792
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion doc/scripts/anisette-server
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ start_it_up()

shut_it_down()
{
start-stop-daemon --stop --pidfile $PIDFILE
start-stop-daemon --stop --pidfile $PIDFILE --retry 5 --remove-pidfile
}


Expand Down
2 changes: 1 addition & 1 deletion doc/scripts/usbmuxd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ start_it_up()

shut_it_down()
{
start-stop-daemon --stop --pidfile $PIDFILE
start-stop-daemon --stop --pidfile $PIDFILE --retry 5 --remove-pidfile
}


Expand Down
13 changes: 8 additions & 5 deletions manager/device_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (dm *DeviceManager) GetMountImageInfo(udid string) (*model.UsbmuxdImage, er
if strings.Contains(err.Error(), "lookup_image returned -256") {
if err = dm.RestartUsbmuxd(); err == nil {
time.Sleep(5 * time.Second)
if imageMounted, err = dm.CheckHasMountImage(udid); err != nil {
if imageMounted, err = dm.CheckHasMountImage(udid); err == nil {
imageInfo.ImageMounted = imageMounted
return imageInfo, nil
}
Expand Down Expand Up @@ -149,11 +149,10 @@ func (dm *DeviceManager) CheckHasMountImage(udid string) (bool, error) {

data, err := cmd.CombinedOutput()
if err != nil {
return false, fmt.Errorf("%s%s", string(data), err.Error())
return false, fmt.Errorf("%s\n%s", string(data), err.Error())
}

output := string(data)

if strings.Contains(output, "ERROR") {
return false, fmt.Errorf("%s", output)
}
Expand All @@ -164,6 +163,10 @@ func (dm *DeviceManager) CheckHasMountImage(udid string) (bool, error) {

func (dm *DeviceManager) RestartUsbmuxd() error {
cmd := exec.Command("/etc/init.d/usbmuxd", "restart")
_, err := cmd.CombinedOutput()
return err
data, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("%s\n%s", string(data), err.Error())
}

return nil
}
15 changes: 10 additions & 5 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,17 @@ func MountDeveloperDiskImage(ctx context.Context, id string) error {
// 尝试挂载
// 对应版本的DeveloperDiskImage不存在的话,尝试下载
imageVersionDir := filepath.Join(cfg.Server.WorkDir, "DeveloperDiskImage", imageInfo.DeveloperDiskImageVersion)
if _, err := os.Stat(imageVersionDir); os.IsNotExist(err) {
dmg := filepath.Join(imageVersionDir, "DeveloperDiskImage.dmg")
signature := filepath.Join(imageVersionDir, "DeveloperDiskImage.dmg.signature")

if _, err := os.Stat(dmg); os.IsNotExist(err) {
if err := downloadDeveloperDiskImage(imageInfo, imageVersionDir); err != nil {
log.Err(err).Msg("Download Developer disk image error: ")
return err
}
}

// 开始执行挂载
dmg := filepath.Join(imageVersionDir, "DeveloperDiskImage.dmg")
signature := filepath.Join(imageVersionDir, "DeveloperDiskImage.dmg.signature")
cmd := exec.CommandContext(ctx, "ideviceimagemounter", "-u", device.UDID, "-n", dmg, signature)
data, err := cmd.CombinedOutput()
if err != nil {
Expand Down Expand Up @@ -130,7 +131,9 @@ func downloadDeveloperDiskImage(imageInfo *model.UsbmuxdImage, imageVersionDir s
_ = os.MkdirAll(imageVersionDir, os.ModePerm)
for _, f := range files {
if filepath.Base(f) == "DeveloperDiskImage.dmg" || filepath.Base(f) == "DeveloperDiskImage.dmg.signature" {
_ = os.Rename(f, filepath.Join(imageVersionDir, filepath.Base(f)))
if err = os.Rename(filepath.Join(tmpUnzipPath, f), filepath.Join(imageVersionDir, filepath.Base(f))); err != nil {
return err
}
}
}
return nil
Expand All @@ -151,7 +154,9 @@ func downloadDeveloperDiskImage(imageInfo *model.UsbmuxdImage, imageVersionDir s
_ = os.MkdirAll(imageVersionDir, os.ModePerm)
for _, f := range files {
if filepath.Base(f) == "DeveloperDiskImage.dmg" || filepath.Base(f) == "DeveloperDiskImage.dmg.signature" {
_ = os.Rename(f, filepath.Join(imageVersionDir, filepath.Base(f)))
if err = os.Rename(filepath.Join(tmpUnzipPath, f), filepath.Join(imageVersionDir, filepath.Base(f))); err != nil {
return err
}
}
}
return nil
Expand Down
1 change: 1 addition & 0 deletions view/src/page/install/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export default {
toast.error("安装失败,请查看日志了解详细信息");
return;
}
_this.log.output += "DeveloperDiskImage has mounted.\n";
let formData = new FormData();
for (let i = 0; i < _this.files.length; i++) {
Expand Down

0 comments on commit 3109792

Please sign in to comment.