Skip to content

Commit

Permalink
Add libroot for GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
danpashin committed Jun 12, 2024
1 parent 7ec98cc commit c9accaa
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "contrib/libroot"]
path = contrib/libroot
url = https://github.com/opa334/libroot
1 change: 1 addition & 0 deletions contrib/libroot
Submodule libroot added at 102348
25 changes: 24 additions & 1 deletion twackup-gui/Twackup.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 54;
objectVersion = 70;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -46,6 +46,7 @@
0B86618A2930AF7100EA4301 /* Dpkg.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8661882930AF7100EA4301 /* Dpkg.swift */; };
0B86618B2930AF7100EA4301 /* FFIPackage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8661892930AF7100EA4301 /* FFIPackage.swift */; };
0B86CDA82C18D8F000F3B4A0 /* ConsoleLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B86CDA72C18D8F000F3B4A0 /* ConsoleLogger.swift */; };
0B86CDCD2C199FA500F3B4A0 /* Jailbreaks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B86CDCC2C199FA500F3B4A0 /* Jailbreaks.swift */; };
0B88C3072930B2FB00BA5312 /* PackageSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B88C3062930B2FB00BA5312 /* PackageSection.swift */; };
0B88C30B2930B58D00BA5312 /* PackageDetailVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B88C30A2930B58D00BA5312 /* PackageDetailVC.swift */; };
0B88C30D2930B88800BA5312 /* PackageTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B88C30C2930B88800BA5312 /* PackageTableViewCell.swift */; };
Expand Down Expand Up @@ -115,6 +116,7 @@
0B8661882930AF7100EA4301 /* Dpkg.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Dpkg.swift; sourceTree = "<group>"; };
0B8661892930AF7100EA4301 /* FFIPackage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FFIPackage.swift; sourceTree = "<group>"; };
0B86CDA72C18D8F000F3B4A0 /* ConsoleLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConsoleLogger.swift; sourceTree = "<group>"; };
0B86CDCC2C199FA500F3B4A0 /* Jailbreaks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Jailbreaks.swift; sourceTree = "<group>"; };
0B88C3062930B2FB00BA5312 /* PackageSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PackageSection.swift; sourceTree = "<group>"; };
0B88C30A2930B58D00BA5312 /* PackageDetailVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PackageDetailVC.swift; sourceTree = "<group>"; };
0B88C30C2930B88800BA5312 /* PackageTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PackageTableViewCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -146,6 +148,20 @@
F4A8FB183915E3D413DF2C45 /* Pods-Twackup.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Twackup.debug.xcconfig"; path = "Target Support Files/Pods-Twackup/Pods-Twackup.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
0B86CDCB2C1999AA00F3B4A0 /* PBXFileSystemSynchronizedBuildFileExceptionSet */ = {
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
membershipExceptions = (
libroot/src/dyn.c,
);
target = 0B8661642930ADA300EA4301 /* Twackup */;
};
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */

/* Begin PBXFileSystemSynchronizedRootGroup section */
0B86CDC72C19996300F3B4A0 /* contrib */ = {isa = PBXFileSystemSynchronizedRootGroup; exceptions = (0B86CDCB2C1999AA00F3B4A0 /* PBXFileSystemSynchronizedBuildFileExceptionSet */, ); explicitFileTypes = {}; explicitFolders = (); name = contrib; path = ../contrib; sourceTree = "<group>"; };
/* End PBXFileSystemSynchronizedRootGroup section */

/* Begin PBXFrameworksBuildPhase section */
0B8661622930ADA300EA4301 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
Expand All @@ -172,6 +188,7 @@
isa = PBXGroup;
children = (
0B0DBB6E2934FA58002F3BB2 /* String.swift */,
0B86CDCC2C199FA500F3B4A0 /* Jailbreaks.swift */,
);
path = Helpers;
sourceTree = "<group>";
Expand Down Expand Up @@ -199,6 +216,7 @@
isa = PBXGroup;
children = (
0B9EB5E1294B8C7700DED54D /* .swiftlint.yml */,
0B86CDC72C19996300F3B4A0 /* contrib */,
0B8661832930AF4E00EA4301 /* common-include */,
0B8661672930ADA300EA4301 /* Twackup */,
0B8661662930ADA300EA4301 /* Products */,
Expand Down Expand Up @@ -590,6 +608,7 @@
0B86CDA82C18D8F000F3B4A0 /* ConsoleLogger.swift in Sources */,
0B88C31E2930DEA200BA5312 /* PackageDetailView.swift in Sources */,
0B85ABB7294C8E4C00B6C5CF /* DetailedLabelSUI.swift in Sources */,
0B86CDCD2C199FA500F3B4A0 /* Jailbreaks.swift in Sources */,
0BAAD9922937BE360089C8FB /* RJTHudProgressView.m in Sources */,
0B88C3152930CE2E00BA5312 /* PackageListModel.swift in Sources */,
0B0DBB6F2934FA58002F3BB2 /* String.swift in Sources */,
Expand Down Expand Up @@ -699,6 +718,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = "\"$(PROJECT_DIR)/../contrib/libroot/src";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
Expand Down Expand Up @@ -754,6 +774,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = "\"$(PROJECT_DIR)/../contrib/libroot/src";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
Expand Down Expand Up @@ -789,6 +810,7 @@
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
/var/jb/usr/lib,
);
MARKETING_VERSION = 2.0.2;
OTHER_LDFLAGS = (
Expand Down Expand Up @@ -847,6 +869,7 @@
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
/var/jb/usr/lib,
);
MARKETING_VERSION = 2.0.2;
OTHER_LDFLAGS = (
Expand Down
1 change: 1 addition & 0 deletions twackup-gui/Twackup/Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#import "twackup.h"
#import "RJTHUD.h"
#import "libroot.h"

@interface UIScrollView (Private)
@property (assign, nonatomic, readonly, getter=_minimumContentOffset) CGPoint minimumContentOffset;
Expand Down
12 changes: 2 additions & 10 deletions twackup-gui/Twackup/Sources/App Lifecycle/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
private var consoleLoggerIsSet = false

private(set) lazy var mainModel: MainModel = {
let rootfullDir = "/var/lib/dpkg"
let rootlessDir = "/var/jb/var/lib/dpkg"

var dpkgDir = rootfullDir
if !FileManager.default.fileExists(atPath: rootfullDir) {
dpkgDir = rootlessDir
}

let dpkg = Dpkg(path: dpkgDir, preferences: preferences)
return MainModel(database: Database(), dpkg: dpkg, preferences: preferences )
let dpkg = Dpkg(path: jbRootPath("/var/lib/dpkg"), preferences: preferences)
return MainModel(database: Database(), dpkg: dpkg, preferences: preferences)
}()

func application(
Expand Down
18 changes: 18 additions & 0 deletions twackup-gui/Twackup/Sources/Helpers/Jailbreaks.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Jailbreaks.swift
// Twackup
//
// Created by Daniil on 12.06.2024.
//

func jbRootPath(_ cPath: UnsafePointer<CChar>?) -> String {
guard let resolved = libroot_dyn_jbrootpath(cPath, nil) else { return "" }
let result = String(cString: resolved)
free(resolved)

return result
}

func jbRootPath(_ path: any StringProtocol) -> String {
path.withCString { jbRootPath($0) }
}

0 comments on commit c9accaa

Please sign in to comment.