mirror of https://github.com/opa334/TrollStore.git
1.4.4
This commit is contained in:
parent
755d1d8724
commit
59eae957e9
|
@ -1,6 +1,6 @@
|
||||||
Package: com.opa334.trollstoreroothelper
|
Package: com.opa334.trollstoreroothelper
|
||||||
Name: trollstoreroothelper
|
Name: trollstoreroothelper
|
||||||
Version: 1.4.3
|
Version: 1.4.4
|
||||||
Architecture: iphoneos-arm
|
Architecture: iphoneos-arm
|
||||||
Description: An awesome tool of some sort!!
|
Description: An awesome tool of some sort!!
|
||||||
Maintainer: opa334
|
Maintainer: opa334
|
||||||
|
|
|
@ -620,96 +620,99 @@ int installApp(NSString* appPackagePath, BOOL sign, BOOL force, BOOL isTSUpdate)
|
||||||
if(signRet != 0) return signRet;
|
if(signRet != 0) return signRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
LSApplicationProxy* existingAppProxy = [LSApplicationProxy applicationProxyForIdentifier:appId];
|
loadMCMFramework();
|
||||||
if(existingAppProxy.installed)
|
|
||||||
|
BOOL existed;
|
||||||
|
NSError* mcmError;
|
||||||
|
MCMAppContainer* appContainer = [objc_getClass("MCMAppContainer") containerWithIdentifier:appId createIfNecessary:YES existed:&existed error:&mcmError];
|
||||||
|
if(!appContainer || mcmError)
|
||||||
{
|
{
|
||||||
// App update
|
NSLog(@"[installApp] failed to create app container for %@: %@", appId, mcmError);
|
||||||
// Replace existing bundle with new version
|
return 170;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the existing app bundle is empty
|
if(existed)
|
||||||
BOOL appBundleExists = existingAppProxy.bundleURL && [existingAppProxy.bundleURL checkResourceIsReachableAndReturnError:nil];
|
{
|
||||||
|
NSLog(@"[installApp] got existing app container: %@", appContainer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"[installApp] created app container: %@", appContainer);
|
||||||
|
}
|
||||||
|
|
||||||
// LSBundleProxy also has a bundleContainerURL property, but unforunately it is unreliable and just nil most of the time
|
// check if the bundle is empty
|
||||||
NSURL* bundleContainerURL = existingAppProxy.bundleURL.URLByDeletingLastPathComponent;
|
BOOL isEmpty = YES;
|
||||||
|
NSArray* bundleItems = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:appContainer.url.path error:nil];
|
||||||
// Make sure the installed app is a TrollStore app or the container is empty (or the force flag is set)
|
for(NSString* bundleItem in bundleItems)
|
||||||
NSURL* trollStoreMarkURL = [bundleContainerURL URLByAppendingPathComponent:@"_TrollStore"];
|
{
|
||||||
if(appBundleExists && ![trollStoreMarkURL checkResourceIsReachableAndReturnError:nil] && !force)
|
if([bundleItem.pathExtension isEqualToString:@"app"])
|
||||||
{
|
{
|
||||||
NSLog(@"[installApp] already installed and not a TrollStore app... bailing out");
|
isEmpty = NO;
|
||||||
return 171;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Terminate app if it's still running
|
NSLog(@"[installApp] container is empty? %d", isEmpty);
|
||||||
if(!isTSUpdate)
|
|
||||||
|
// Make sure there isn't already an app store app installed with the same identifier
|
||||||
|
NSURL* trollStoreMarkURL = [appContainer.url URLByAppendingPathComponent:@"_TrollStore"];
|
||||||
|
if(existed && !isEmpty && ![trollStoreMarkURL checkResourceIsReachableAndReturnError:nil] && !force)
|
||||||
|
{
|
||||||
|
NSLog(@"[installApp] already installed and not a TrollStore app... bailing out");
|
||||||
|
return 171;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark app as TrollStore app
|
||||||
|
BOOL marked = [[NSFileManager defaultManager] createFileAtPath:trollStoreMarkURL.path contents:[NSData data] attributes:nil];
|
||||||
|
if(!marked)
|
||||||
|
{
|
||||||
|
NSLog(@"[installApp] failed to mark %@ as TrollStore app", appId);
|
||||||
|
return 177;
|
||||||
|
}
|
||||||
|
|
||||||
|
fixPermissionsOfAppBundle(appBundlePath);
|
||||||
|
|
||||||
|
// Wipe old version if needed
|
||||||
|
if(existed)
|
||||||
|
{
|
||||||
|
if(![appId isEqualToString:@"com.opa334.TrollStore"])
|
||||||
{
|
{
|
||||||
BKSTerminateApplicationForReasonAndReportWithDescription(appId, 5, false, @"TrollStore - App updated");
|
BKSTerminateApplicationForReasonAndReportWithDescription(appId, 5, false, @"TrollStore - App updated");
|
||||||
}
|
}
|
||||||
|
|
||||||
NSLog(@"[installApp] replacing existing app with new version");
|
NSLog(@"[installApp] found existing TrollStore app, cleaning directory");
|
||||||
|
NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtURL:appContainer.url includingPropertiesForKeys:nil options:0 errorHandler:nil];
|
||||||
// Delete existing .app directory if it exists
|
NSURL* fileURL;
|
||||||
if(appBundleExists)
|
while(fileURL = [enumerator nextObject])
|
||||||
{
|
{
|
||||||
[[NSFileManager defaultManager] removeItemAtURL:existingAppProxy.bundleURL error:nil];
|
// do not under any circumstance delete this file as it makes iOS loose the app registration
|
||||||
}
|
if([fileURL.lastPathComponent isEqualToString:@".com.apple.mobile_container_manager.metadata.plist"] || [fileURL.lastPathComponent isEqualToString:@"_TrollStore"])
|
||||||
|
{
|
||||||
|
NSLog(@"[installApp] skipping removal of %@", fileURL);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Install new version into existing app bundle
|
[[NSFileManager defaultManager] removeItemAtURL:fileURL error:nil];
|
||||||
NSError* copyError;
|
|
||||||
BOOL suc = [[NSFileManager defaultManager] copyItemAtPath:appBundlePath toPath:[bundleContainerURL.path stringByAppendingPathComponent:appBundlePath.lastPathComponent] error:©Error];
|
|
||||||
if(!suc)
|
|
||||||
{
|
|
||||||
NSLog(@"[installApp] Error copying new version during update: %@", copyError);
|
|
||||||
return 178;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Install app
|
||||||
|
NSString* newAppBundlePath = [appContainer.url.path stringByAppendingPathComponent:appBundlePath.lastPathComponent];
|
||||||
|
NSLog(@"[installApp] new app path: %@", newAppBundlePath);
|
||||||
|
|
||||||
|
NSError* copyError;
|
||||||
|
BOOL suc = [[NSFileManager defaultManager] copyItemAtPath:appBundlePath toPath:newAppBundlePath error:©Error];
|
||||||
|
if(suc)
|
||||||
|
{
|
||||||
|
NSLog(@"[installApp] App %@ installed, adding to icon cache now...", appId);
|
||||||
|
registerPath((char*)newAppBundlePath.fileSystemRepresentation, 0, YES);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Initial app install
|
NSLog(@"[installApp] Failed to copy app bundle for app %@, error: %@", appId, copyError);
|
||||||
// Do initial placeholder installation using LSApplicationWorkspace
|
return 178;
|
||||||
|
|
||||||
NSError* installError;
|
|
||||||
BOOL suc = NO;
|
|
||||||
@try
|
|
||||||
{
|
|
||||||
suc = [[LSApplicationWorkspace defaultWorkspace] installApplication:[NSURL fileURLWithPath:appPackagePath] withOptions:@{
|
|
||||||
LSInstallTypeKey : @1,
|
|
||||||
@"PackageType" : @"Placeholder"
|
|
||||||
} error:&installError];
|
|
||||||
}
|
|
||||||
@catch(NSException* e)
|
|
||||||
{
|
|
||||||
NSLog(@"[installApp] encountered expection %@ while trying to do placeholder install", e);
|
|
||||||
suc = NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!suc)
|
|
||||||
{
|
|
||||||
NSLog(@"[installApp] encountered error %@ while trying to do placeholder install", installError);
|
|
||||||
return 180;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get newly installed proxy
|
|
||||||
existingAppProxy = [LSApplicationProxy applicationProxyForIdentifier:appId];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark app as TrollStore app
|
|
||||||
NSURL* bundleContainerURL = existingAppProxy.bundleURL.URLByDeletingLastPathComponent;
|
|
||||||
NSURL* trollStoreMarkURL = [bundleContainerURL URLByAppendingPathComponent:@"_TrollStore"];
|
|
||||||
if(![[NSFileManager defaultManager] fileExistsAtPath:trollStoreMarkURL.path])
|
|
||||||
{
|
|
||||||
BOOL marked = [[NSFileManager defaultManager] createFileAtPath:trollStoreMarkURL.path contents:[NSData data] attributes:nil];
|
|
||||||
if(!marked)
|
|
||||||
{
|
|
||||||
NSLog(@"[installApp] failed to mark %@ as TrollStore app", appId);
|
|
||||||
return 177;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// At this point the (new version of the) app is installed but still needs to be registered
|
|
||||||
// Also permissions need to be fixed
|
|
||||||
fixPermissionsOfAppBundle(existingAppProxy.bundleURL.path);
|
|
||||||
registerPath((char*)existingAppProxy.bundleURL.path.fileSystemRepresentation, 0, YES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int uninstallApp(NSString* appPath, NSString* appId)
|
int uninstallApp(NSString* appPath, NSString* appId)
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
<string>iPhoneOS</string>
|
<string>iPhoneOS</string>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.4.3</string>
|
<string>1.4.4</string>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>UIDeviceFamily</key>
|
<key>UIDeviceFamily</key>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Package: com.opa334.trollstorehelper
|
Package: com.opa334.trollstorehelper
|
||||||
Name: TrollStore Helper
|
Name: TrollStore Helper
|
||||||
Version: 1.4.3
|
Version: 1.4.4
|
||||||
Architecture: iphoneos-arm
|
Architecture: iphoneos-arm
|
||||||
Description: Helper utility to install and manage TrollStore!
|
Description: Helper utility to install and manage TrollStore!
|
||||||
Maintainer: opa334
|
Maintainer: opa334
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
<string>iPhoneOS</string>
|
<string>iPhoneOS</string>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.4.3</string>
|
<string>1.4.4</string>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>UIDeviceFamily</key>
|
<key>UIDeviceFamily</key>
|
||||||
|
|
|
@ -67,9 +67,6 @@
|
||||||
case 179:
|
case 179:
|
||||||
errorDescription = @"The app you tried to install has the same identifier as a system app already installed on the device. The installation has been prevented to protect you from possible bootloops or other issues.";
|
errorDescription = @"The app you tried to install has the same identifier as a system app already installed on the device. The installation has been prevented to protect you from possible bootloops or other issues.";
|
||||||
break;
|
break;
|
||||||
case 180:
|
|
||||||
errorDescription = @"The LSApplicationWorkspace app installation failed.";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NSError* error = [NSError errorWithDomain:TrollStoreErrorDomain code:code userInfo:@{NSLocalizedDescriptionKey : errorDescription}];
|
NSError* error = [NSError errorWithDomain:TrollStoreErrorDomain code:code userInfo:@{NSLocalizedDescriptionKey : errorDescription}];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Package: com.opa334.trollstore
|
Package: com.opa334.trollstore
|
||||||
Name: TrollStore
|
Name: TrollStore
|
||||||
Version: 1.4.3
|
Version: 1.4.4
|
||||||
Architecture: iphoneos-arm
|
Architecture: iphoneos-arm
|
||||||
Description: An awesome application!
|
Description: An awesome application!
|
||||||
Maintainer: opa334
|
Maintainer: opa334
|
||||||
|
|
Loading…
Reference in New Issue