|
@@ -67,9 +67,7 @@
|
|
#import <xpc/xpc.h>
|
|
#import <xpc/xpc.h>
|
|
|
|
|
|
#import "NSTask.h"
|
|
#import "NSTask.h"
|
|
-#include <spawn.h>
|
|
|
|
-#include <sys/wait.h>
|
|
|
|
-
|
|
|
|
|
|
+#import "libjb.h"
|
|
#include "csstore.hpp"
|
|
#include "csstore.hpp"
|
|
|
|
|
|
#if TARGET_OS_IPHONE
|
|
#if TARGET_OS_IPHONE
|
|
@@ -187,40 +185,12 @@ static Class $LSApplicationWorkspace;
|
|
LSApplicationWorkspace *workspace;
|
|
LSApplicationWorkspace *workspace;
|
|
static bool force;
|
|
static bool force;
|
|
|
|
|
|
-extern char **environ;
|
|
|
|
-static NSString *prefixPath = @"/fs/jb";
|
|
|
|
-
|
|
|
|
-BOOL _determineUsePrefixes(void) {
|
|
|
|
- return ([[NSFileManager defaultManager] contentsOfDirectoryAtPath:prefixPath error:nil].count > 0);
|
|
|
|
|
|
+NSString *prefixPath(void) {
|
|
|
|
+ return [JBManager jbPrefix];
|
|
}
|
|
}
|
|
|
|
|
|
NSString *applicationPath(void) {
|
|
NSString *applicationPath(void) {
|
|
- return _determineUsePrefixes() ? [prefixPath stringByAppendingPathComponent:@"Applications"] : @"/Applications";
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-int my_system(const char *cmd) {
|
|
|
|
- pid_t pid;
|
|
|
|
- char *argv[] = {"bash", "-c", (char*)cmd, NULL};
|
|
|
|
- int status;
|
|
|
|
- fprintf(stderr, "Run command: %s\n", cmd);
|
|
|
|
- BOOL prefixes = _determineUsePrefixes();
|
|
|
|
- NSString *shPath = @"/bin/sh";
|
|
|
|
- if (prefixes) {
|
|
|
|
- shPath = [prefixPath stringByAppendingPathComponent:shPath];
|
|
|
|
- }
|
|
|
|
- status = posix_spawn(&pid, [shPath UTF8String], NULL, NULL, argv, environ);;
|
|
|
|
- if (status == 0) {
|
|
|
|
- printf("Child pid: %i\n", pid);
|
|
|
|
- if (waitpid(pid, &status, 0) != -1) {
|
|
|
|
- printf("Child exited with status %i\n", status);
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- perror("waitpid");
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- printf("posix_spawn: %s\n", strerror(status));
|
|
|
|
- }
|
|
|
|
- return status;
|
|
|
|
|
|
+ return [prefixPath() stringByAppendingPathComponent:@"/Applications"];
|
|
}
|
|
}
|
|
|
|
|
|
NSArray *getAllApplications()
|
|
NSArray *getAllApplications()
|
|
@@ -277,6 +247,8 @@ NSString *pathInApplications(NSString *path) {
|
|
} else if ([path hasPrefix:@"/var/stash"] && [pathComponents[4] isEqualToString:@"Applications"]) {
|
|
} else if ([path hasPrefix:@"/var/stash"] && [pathComponents[4] isEqualToString:@"Applications"]) {
|
|
// Matches /var/stash/*/Applications/
|
|
// Matches /var/stash/*/Applications/
|
|
return [@"/Applications/" stringByAppendingPathComponent:pathComponents[5]];
|
|
return [@"/Applications/" stringByAppendingPathComponent:pathComponents[5]];
|
|
|
|
+ } else if ([path hasPrefix:prefixPath()] && [prefixPath() length] > 1) {
|
|
|
|
+ return path;
|
|
}
|
|
}
|
|
return nil;
|
|
return nil;
|
|
}
|
|
}
|
|
@@ -459,14 +431,14 @@ int standard_uicache(void)
|
|
NSString *home(NSHomeDirectory());
|
|
NSString *home(NSHomeDirectory());
|
|
NSString *path([NSString stringWithFormat:@"%@/Library/Caches/com.apple.mobile.installation.plist", home]);
|
|
NSString *path([NSString stringWithFormat:@"%@/Library/Caches/com.apple.mobile.installation.plist", home]);
|
|
|
|
|
|
- my_system("killall -SIGSTOP " FRONTBOARD);
|
|
|
|
|
|
+ system("killall -SIGSTOP " FRONTBOARD);
|
|
sleep(1);
|
|
sleep(1);
|
|
|
|
|
|
@try {
|
|
@try {
|
|
|
|
|
|
DeleteCSStores([home UTF8String]);
|
|
DeleteCSStores([home UTF8String]);
|
|
|
|
|
|
- my_system("killall lsd");
|
|
|
|
|
|
+ system("killall lsd");
|
|
|
|
|
|
if ([workspace respondsToSelector:@selector(invalidateIconCache:)])
|
|
if ([workspace respondsToSelector:@selector(invalidateIconCache:)])
|
|
while (![workspace invalidateIconCache:nil])
|
|
while (![workspace invalidateIconCache:nil])
|
|
@@ -564,16 +536,16 @@ int standard_uicache(void)
|
|
unlink([[NSString stringWithFormat:@"%@/Library/Caches/com.apple.springboard-imagecache-smallicons", home] UTF8String]);
|
|
unlink([[NSString stringWithFormat:@"%@/Library/Caches/com.apple.springboard-imagecache-smallicons", home] UTF8String]);
|
|
unlink([[NSString stringWithFormat:@"%@/Library/Caches/com.apple.springboard-imagecache-smallicons.plist", home] UTF8String]);
|
|
unlink([[NSString stringWithFormat:@"%@/Library/Caches/com.apple.springboard-imagecache-smallicons.plist", home] UTF8String]);
|
|
|
|
|
|
- my_system([[NSString stringWithFormat:@"rm -rf %@/Library/Caches/SpringBoardIconCache", home] UTF8String]);
|
|
|
|
- my_system([[NSString stringWithFormat:@"rm -rf %@/Library/Caches/SpringBoardIconCache-small", home] UTF8String]);
|
|
|
|
|
|
+ system([[NSString stringWithFormat:@"rm -rf %@/Library/Caches/SpringBoardIconCache", home] UTF8String]);
|
|
|
|
+ system([[NSString stringWithFormat:@"rm -rf %@/Library/Caches/SpringBoardIconCache-small", home] UTF8String]);
|
|
|
|
|
|
- my_system([[NSString stringWithFormat:@"rm -rf %@/Library/Caches/com.apple.IconsCache", home] UTF8String]);
|
|
|
|
|
|
+ system([[NSString stringWithFormat:@"rm -rf %@/Library/Caches/com.apple.IconsCache", home] UTF8String]);
|
|
}
|
|
}
|
|
|
|
|
|
- my_system("killall installd");
|
|
|
|
|
|
+ system("killall installd");
|
|
|
|
|
|
} @finally {
|
|
} @finally {
|
|
- my_system("killall -SIGCONT " FRONTBOARD);
|
|
|
|
|
|
+ system("killall -SIGCONT " FRONTBOARD);
|
|
}
|
|
}
|
|
|
|
|
|
notify_post("com.apple.mobile.application_installed");
|
|
notify_post("com.apple.mobile.application_installed");
|
|
@@ -593,7 +565,8 @@ pid_t pidOfCydia(void) {
|
|
xpc_dictionary_apply((xpc_object_t)response, ^bool(const char *key, xpc_object_t value) {
|
|
xpc_dictionary_apply((xpc_object_t)response, ^bool(const char *key, xpc_object_t value) {
|
|
if (xpc_get_type(value) == XPC_TYPE_DICTIONARY) {
|
|
if (xpc_get_type(value) == XPC_TYPE_DICTIONARY) {
|
|
const char *program = xpc_dictionary_get_string(value, "Program");
|
|
const char *program = xpc_dictionary_get_string(value, "Program");
|
|
- if (program && strcmp(program, "/Applications/Cydia.app/Cydia") == 0) {
|
|
|
|
|
|
+ NSString *cydiaPath = [applicationPath() stringByAppendingPathComponent:@"Cydia.app/Cydia"];
|
|
|
|
+ if (program && strcmp(program, [cydiaPath UTF8String]) == 0) {
|
|
pid = (pid_t)xpc_dictionary_get_int64(value, "PID");
|
|
pid = (pid_t)xpc_dictionary_get_int64(value, "PID");
|
|
if (verbose) fprintf(stderr, "Found Cydia running with PID: %d\n", pid);
|
|
if (verbose) fprintf(stderr, "Found Cydia running with PID: %d\n", pid);
|
|
return false;
|
|
return false;
|
|
@@ -682,7 +655,7 @@ int optimized_uicache(void) {
|
|
pid_t cydia_pid;
|
|
pid_t cydia_pid;
|
|
// Check for updated components
|
|
// Check for updated components
|
|
NSTask *find = [NSTask new];
|
|
NSTask *find = [NSTask new];
|
|
- [find setLaunchPath:@"/fs/jb/usr/bin/find"];
|
|
|
|
|
|
+ [find setLaunchPath:[prefixPath() stringByAppendingPathComponent:@"/usr/bin/find"]];
|
|
[find setStandardOutput:[NSPipe pipe]];
|
|
[find setStandardOutput:[NSPipe pipe]];
|
|
NSString *stampPath = [NSString stringWithFormat:@"/var/tmp/uicache.stamp.%@", app.applicationIdentifier];
|
|
NSString *stampPath = [NSString stringWithFormat:@"/var/tmp/uicache.stamp.%@", app.applicationIdentifier];
|
|
[fm createFileAtPath:stampPath contents:nil attributes:@{NSFileModificationDate: lastRegistered}];
|
|
[fm createFileAtPath:stampPath contents:nil attributes:@{NSFileModificationDate: lastRegistered}];
|
|
@@ -769,7 +742,6 @@ int main(int argc, const char *argv[])
|
|
NSString *app_id = NULL;
|
|
NSString *app_id = NULL;
|
|
char ch;
|
|
char ch;
|
|
bool have_path = false;
|
|
bool have_path = false;
|
|
- force = true;
|
|
|
|
while ((ch = getopt_long(argc, (char *const *)argv, "afl::p:ru:vh?", long_options, &option_index)) != -1) {
|
|
while ((ch = getopt_long(argc, (char *const *)argv, "afl::p:ru:vh?", long_options, &option_index)) != -1) {
|
|
switch (ch)
|
|
switch (ch)
|
|
{
|
|
{
|
|
@@ -783,7 +755,6 @@ int main(int argc, const char *argv[])
|
|
usage();
|
|
usage();
|
|
break;
|
|
break;
|
|
case 'l':
|
|
case 'l':
|
|
- force = true;
|
|
|
|
if (optarg) {
|
|
if (optarg) {
|
|
app_id = @(optarg);
|
|
app_id = @(optarg);
|
|
} else if (argv[optind] != NULL && argv[optind][0] != '-') {
|
|
} else if (argv[optind] != NULL && argv[optind][0] != '-') {
|
|
@@ -808,7 +779,6 @@ int main(int argc, const char *argv[])
|
|
verbose++;
|
|
verbose++;
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
- force = true;
|
|
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -853,8 +823,8 @@ int main(int argc, const char *argv[])
|
|
usleep(1000);
|
|
usleep(1000);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- my_system("launchctl stop " FRONTBOARD_ID);
|
|
|
|
- my_system("launchctl stop com.apple.backboardd");
|
|
|
|
|
|
+ system("launchctl stop " FRONTBOARD_ID);
|
|
|
|
+ system("launchctl stop com.apple.backboardd");
|
|
}
|
|
}
|
|
#elif TARGET_OS_TV
|
|
#elif TARGET_OS_TV
|
|
[[[PBSSystemServiceConnection sharedConnection] systemServiceProxy] relaunchBackboardd];
|
|
[[[PBSSystemServiceConnection sharedConnection] systemServiceProxy] relaunchBackboardd];
|