Skip to content

Commit

Permalink
Tweak compatibility stuff
Browse files Browse the repository at this point in the history
step 1 to #7 fr
  • Loading branch information
Lrdsnow committed Apr 18, 2024
1 parent 76759b6 commit 49eae5f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
1 change: 0 additions & 1 deletion PurePKG/Views/TweakView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ struct TweakView: View {
queued = appData.queued.all.contains(pkg.id)
installed = appData.installed_pkgs.contains(where: { $0.id == pkg.id })
installedPKG = appData.installed_pkgs.first(where: { $0.id == pkg.id })
print(pkg)
}
}

Expand Down
53 changes: 30 additions & 23 deletions Shared/Jailbreak.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ enum jbType {
case unknown
}

enum TweakCompatibility {
case supported
case conversionReq
case unsupported
}

public class Jailbreak {
static func roothide_jbroot() -> URL? {
let fileManager = FileManager.default
Expand Down Expand Up @@ -182,44 +188,45 @@ public class Jailbreak {
("Serotonin", URL(fileURLWithPath: "/var/mobile/Serotonin.jp2"))
]
for (name, url) in jburls {
log("\(url.path)")
if FileManager.default.fileExists(atPath: url.path) {
log("jb: \(name)")
return name
} else {
log("does not exist")
}
} else {}
}
return nil
}

static func tweakArchSupported(_ pkgarch: String, _ appData: AppData? = nil) -> Bool {
/* ill uncomment this when i actually add conversion lol
let jbtype = self.type()
}

extension Package {
func tweakCompatibility(_ appData: AppData? = nil) -> TweakCompatibility {
#if targetEnvironment(simulator)
return .supported
#else
let jbtype = Jailbreak.type()
if jbtype == .rootful {
if pkgarch == "iphoneos-arm" {
return true
if self.arch == "iphoneos-arm" {
return .supported
} else {
return false
return .unsupported
}
} else if jbtype == .rootless {
if pkgarch == "iphoneos-arm" || pkgarch == "iphoneos-arm64" {
return true
if self.arch == "iphoneos-arm" {
return .supported
} else if self.arch == "iphoneos-arm64" {
return .conversionReq
} else {
return false
return .unsupported
}
} else if jbtype == .roothide {
if pkgarch == "iphoneos-arm" || pkgarch == "iphoneos-arm64" || pkgarch == "iphoneos-arm64e" {
return true
if self.arch == "iphoneos-arm" {
return .supported
} else if self.arch == "iphoneos-arm64" || self.arch == "iphoneos-arm64e" {
return .conversionReq
} else {
return false
return .unsupported
}
} else {
return .unsupported
}
*/
#if targetEnvironment(simulator)
return true
#else
return self.arch(appData) == pkgarch
#endif
}
}
2 changes: 1 addition & 1 deletion Shared/RepoHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public class RepoHandler {
}
var Tweak = Package()
Tweak.arch = lowercasedTweak["architecture"] ?? ""
if Tweak.arch == Jailbreak.arch() {
if Tweak.tweakCompatibility() == .supported {
Tweak.id = lowercasedTweak["package"] ?? "uwu.lrdsnow.unknown"
Tweak.desc = lowercasedTweak["description"] ?? "Description"
Tweak.author = lowercasedTweak["author"] ?? lowercasedTweak["maintainer"] ?? "Unknown Author"
Expand Down

0 comments on commit 49eae5f

Please sign in to comment.