mirror of
https://github.com/Lakr233/vphone-cli.git
synced 2026-04-05 13:09:06 +08:00
Remove dead code from PR #127 IPA install feature
- Remove unused installIPAWithTrollStoreLite() and bundleIdentifier(fromIPA:) (host only uses built-in installer path now) - Remove canInstallIPA / ipaInstallUnavailableMessage (redundant with isConnected) - Inline vp_resolve_ldid_path() trivial wrapper in vphoned_install.m - Drop tslite_install from host-side timeout table
This commit is contained in:
@@ -25,9 +25,6 @@ class VPhoneControl {
|
||||
private(set) var isConnected = false
|
||||
private(set) var guestName = ""
|
||||
private(set) var guestCaps: [String] = []
|
||||
static let ipaInstallUnavailableMessage =
|
||||
"Guest is not jailbroken or no IPA installer is available. Skipping IPA install."
|
||||
|
||||
/// Path to the signed vphoned binary. When set, enables auto-update.
|
||||
var guestBinaryURL: URL?
|
||||
|
||||
@@ -94,51 +91,6 @@ class VPhoneControl {
|
||||
}
|
||||
}
|
||||
|
||||
var canInstallIPA: Bool {
|
||||
isConnected
|
||||
}
|
||||
|
||||
private static func bundleIdentifier(fromIPA url: URL) throws -> String {
|
||||
let process = Process()
|
||||
process.executableURL = URL(fileURLWithPath: "/usr/bin/python3")
|
||||
process.arguments = [
|
||||
"-c",
|
||||
"""
|
||||
import plistlib, sys, zipfile
|
||||
ipa_path = sys.argv[1]
|
||||
with zipfile.ZipFile(ipa_path, "r") as zf:
|
||||
plist_name = next((name for name in zf.namelist() if name.startswith("Payload/") and name.endswith(".app/Info.plist")), None)
|
||||
if not plist_name:
|
||||
raise SystemExit("missing app Info.plist in IPA")
|
||||
info = plistlib.loads(zf.read(plist_name))
|
||||
bundle_id = info.get("CFBundleIdentifier")
|
||||
if not bundle_id:
|
||||
raise SystemExit("missing CFBundleIdentifier in IPA")
|
||||
print(bundle_id)
|
||||
""",
|
||||
url.path,
|
||||
]
|
||||
|
||||
let stdout = Pipe()
|
||||
let stderr = Pipe()
|
||||
process.standardOutput = stdout
|
||||
process.standardError = stderr
|
||||
|
||||
try process.run()
|
||||
process.waitUntilExit()
|
||||
|
||||
let output = String(data: stdout.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)?
|
||||
.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
||||
if process.terminationStatus == 0, !output.isEmpty {
|
||||
return output
|
||||
}
|
||||
|
||||
let errorOutput = String(data: stderr.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)?
|
||||
.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
||||
let detail = errorOutput.isEmpty ? "failed to parse CFBundleIdentifier from IPA" : errorOutput
|
||||
throw ControlError.protocolError(detail)
|
||||
}
|
||||
|
||||
private static func signCertURL() -> URL? {
|
||||
let fm = FileManager.default
|
||||
let candidates = [
|
||||
@@ -147,7 +99,7 @@ with zipfile.ZipFile(ipa_path, "r") as zf:
|
||||
URL(fileURLWithPath: fm.currentDirectoryPath).appendingPathComponent("scripts/vphoned/signcert.p12"),
|
||||
URL(fileURLWithPath: fm.currentDirectoryPath).appendingPathComponent("../scripts/vphoned/signcert.p12"),
|
||||
]
|
||||
for candidate in candidates.compactMap({ $0 }) {
|
||||
for candidate in candidates.compactMap(\.self) {
|
||||
if fm.fileExists(atPath: candidate.path) {
|
||||
return candidate
|
||||
}
|
||||
@@ -545,43 +497,6 @@ with zipfile.ZipFile(ipa_path, "r") as zf:
|
||||
return "Installed \(localURL.lastPathComponent) through the built-in IPA installer."
|
||||
}
|
||||
|
||||
func installIPAWithTrollStoreLite(localURL: URL) async throws -> String {
|
||||
let data: Data
|
||||
do {
|
||||
data = try Data(contentsOf: localURL)
|
||||
} catch {
|
||||
throw ControlError.protocolError("failed to read IPA: \(error)")
|
||||
}
|
||||
let bundleIdentifier = try Self.bundleIdentifier(fromIPA: localURL)
|
||||
|
||||
let remoteDir = "/var/mobile/Documents/vphone-installs"
|
||||
let remoteName = "\(UUID().uuidString)-\(localURL.lastPathComponent)"
|
||||
let remotePath = "\(remoteDir)/\(remoteName)"
|
||||
defer {
|
||||
Task {
|
||||
try? await deleteFile(path: remotePath)
|
||||
}
|
||||
}
|
||||
|
||||
try await createDirectory(path: remoteDir)
|
||||
try await uploadFile(path: remotePath, data: data)
|
||||
|
||||
do {
|
||||
let (resp, _) = try await sendRequest([
|
||||
"t": "tslite_install",
|
||||
"path": remotePath,
|
||||
"bundle_id": bundleIdentifier,
|
||||
"registration": "User",
|
||||
])
|
||||
if let detail = resp["msg"] as? String, !detail.isEmpty {
|
||||
return detail
|
||||
}
|
||||
return "Installed \(localURL.lastPathComponent) through TrollStore Lite."
|
||||
} catch {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Location
|
||||
|
||||
func sendLocation(
|
||||
@@ -714,7 +629,7 @@ with zipfile.ZipFile(ipa_path, "r") as zf:
|
||||
|
||||
private static func timeoutForRequest(type: String) -> TimeInterval {
|
||||
switch type {
|
||||
case "file_get", "file_put", "tslite_install", "ipa_install":
|
||||
case "file_get", "file_put", "ipa_install":
|
||||
transferRequestTimeout
|
||||
case "devmode", "file_list", "file_delete", "file_rename", "file_mkdir":
|
||||
slowRequestTimeout
|
||||
|
||||
@@ -19,15 +19,6 @@ extension VPhoneMenuController {
|
||||
return
|
||||
}
|
||||
|
||||
guard control.canInstallIPA else {
|
||||
showAlert(
|
||||
title: "Install IPA",
|
||||
message: VPhoneControl.ipaInstallUnavailableMessage,
|
||||
style: .warning
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
let panel = NSOpenPanel()
|
||||
panel.canChooseFiles = true
|
||||
panel.canChooseDirectories = false
|
||||
|
||||
@@ -115,14 +115,6 @@ class VPhoneVirtualMachineView: VZVirtualMachineView {
|
||||
showAlert(title: "Install IPA", message: "Guest is not connected.", style: .warning)
|
||||
return
|
||||
}
|
||||
guard control.canInstallIPA else {
|
||||
showAlert(
|
||||
title: "Install IPA",
|
||||
message: VPhoneControl.ipaInstallUnavailableMessage,
|
||||
style: .warning
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
do {
|
||||
let result = try await control.installIPA(localURL: url)
|
||||
|
||||
Reference in New Issue
Block a user