Skip to content

Commit

Permalink
tried to make some fixes for partition sizes, may not have worked, ma…
Browse files Browse the repository at this point in the history
…y be trimmed out later. re-added stashing to combat size issues instead
  • Loading branch information
Kevin Bradley committed Oct 14, 2011
1 parent f2230bf commit 476eb6e
Show file tree
Hide file tree
Showing 8 changed files with 810 additions and 265 deletions.
4 changes: 4 additions & 0 deletions FWBundle.h
Expand Up @@ -44,6 +44,10 @@ enum {

@property (nonatomic, retain) NSString *fwRoot;

- (void)setMinimumSystemPartition:(int)newSize;
- (NSString *)restoreDictionaryPath;
- (NSMutableDictionary *)mutableFWDictionary;
- (NSString *)buildManifestPath;
+ (FWBundle *)bundleWithName:(NSString *)bundleName;
+ (FWBundle *)bundleForFile:(NSString *)theFile;
- (void)logDescription;
Expand Down
96 changes: 96 additions & 0 deletions FWBundle.m
Expand Up @@ -59,6 +59,7 @@ - (NSString *)SHA
return [[self infoDictionary] valueForKey:SHA_ONE];
}


- (NSDictionary *)buildManifest
{
NSArray *buildIdentities = [[self fwDictionary] objectForKey:@"BuildIdentities"];
Expand All @@ -83,6 +84,39 @@ - (NSString *)iBECName
return [[[[self buildManifest] valueForKey:@"iBEC"] valueForKey:@"Info"] valueForKey:@"Path"];
}

- (NSString *)buildManifestPath
{
NSString *buildM = [TMP_ROOT stringByAppendingPathComponent:@"BuildManifest.plist"];
if ([FM fileExistsAtPath:buildM])
{
return buildM;

}
return nil;
}

- (NSString *)restoreDictionaryPath
{
NSString *restore = [TMP_ROOT stringByAppendingPathComponent:@"Restore.plist"];
if ([FM fileExistsAtPath:restore])
{
return restore;

}
return nil;
}

- (NSMutableDictionary *)mutableFWDictionary
{
NSString *buildM = [TMP_ROOT stringByAppendingPathComponent:@"BuildManifest.plist"];
if ([FM fileExistsAtPath:buildM])
{
NSMutableDictionary *outputDict = [[NSMutableDictionary alloc] initWithContentsOfFile:buildM];
return [outputDict autorelease];

}
return nil;
}

- (NSDictionary *)fwDictionary
{
Expand Down Expand Up @@ -183,6 +217,68 @@ - (NSString *)outputName
return [[self bundleName] stringByAppendingString:@"_SP_Restore.ipsw"];
}

/*
BuildManifest.plist -> BuildIdentities - > Item 01 -> info -> MinimumSystemPartition
BuildManifest.plist -> BuildIdentities - > Item 01 -> info -> MinimumSystemPartition
Restore.plist -> MinimumSystemPartition -> DMG_NAME
*/

- (BOOL)shouldUpdatePartitionSize
{
return [self is4point4];
}

- (void)setMinimumSystemPartition:(int)newSize
{
NSFileManager *man = [NSFileManager defaultManager];
NSString *outputFile = [self buildManifestPath];

if ([man fileExistsAtPath:outputFile])
{
NSMutableDictionary *fullDict = [self mutableFWDictionary];
id buildIdentities = [fullDict objectForKey:@"BuildIdentities"];
id one = [buildIdentities lastObject];
id infoDict = [one valueForKey:@"Info"];
int buildIndex = [buildIdentities count]-1;

[infoDict setValue:[NSNumber numberWithInt:newSize] forKey:@"MinimumSystemPartition"];
[one setObject:infoDict forKey:@"Info"];
[buildIdentities replaceObjectAtIndex:buildIndex withObject:one];
[fullDict setObject:buildIdentities forKey:@"BuildIdentities"];

[fullDict writeToFile:outputFile atomically:YES];

//On to the restore file

NSString *restoreFile = [self restoreDictionaryPath];
if ([man fileExistsAtPath:restoreFile])
{
NSMutableDictionary *restoreDict = [[NSMutableDictionary alloc] initWithContentsOfFile:restoreFile];
id msp = [restoreDict valueForKey:@"MinimumSystemPartition"];
NSString *fsKey = [[msp allKeys] lastObject];
[msp setValue:[NSNumber numberWithInt:newSize] forKey:fsKey];
[restoreDict writeToFile:restoreFile atomically:YES];

[restoreDict release];
restoreDict = nil;

} else {

NSLog(@"no file at %@", restoreFile);

}


} else {

NSLog(@"editing build manifest for setMinimumSystemPartition failed!!!!! BAIL");
}

}

- (NSString *)oldramdiskSize
{
if ([[self bundleName] isEqualToString:@"AppleTV2,1_4.3_8F5148c"])
Expand Down
10 changes: 10 additions & 0 deletions nitoUtility.m
Expand Up @@ -411,10 +411,12 @@ + (void)createTempSetup
- (void)editOptions:(NSString *)optionsFile withFSSize:(int)fsSize
{

NSLog(@"editing options: %@", optionsFile);
NSMutableDictionary *optionsDict = [[NSMutableDictionary alloc] initWithContentsOfFile:optionsFile];
[optionsDict setObject:[NSNumber numberWithBool:NO] forKey:@"UpdateBaseband"];
[optionsDict setObject:[NSNumber numberWithBool:YES] forKey:@"CreateFilesystemPartitions"];
[optionsDict setObject:[NSNumber numberWithInt:fsSize] forKey:@"SystemPartitionSize"];
[optionsDict setObject:[NSNumber numberWithInt:fsSize] forKey:@"MinimumSystemPartition"];
[optionsDict writeToFile:optionsFile atomically:YES];
[optionsDict release];

Expand Down Expand Up @@ -560,6 +562,14 @@ - (int)performPatchesFromBundle:(FWBundle *)theBundle onRamdisk:(NSDictionary *)
[self editOptions:optionPath withFSSize:fsSize];
}

//update appletv partition size stuff
NSString *optionPathATV = [mountedImage stringByAppendingPathComponent:@"usr/local/share/restore/options.k66.plist"];
if ([[NSFileManager defaultManager] fileExistsAtPath:optionPathATV])
{
int fsSize = [[theBundle filesystemSize] intValue];
[self editOptions:optionPathATV withFSSize:fsSize];
}

if (status == 0)
{
NSLog(@"performed patches successfully!");
Expand Down
6 changes: 3 additions & 3 deletions pwnHelperClass.m
Expand Up @@ -597,9 +597,9 @@ - (int)patchDmg:(NSString *)theDMG
[self installSSHKey:[[self processDict] valueForKey:@"sshKey"] withRoot:mountImage];
}

//[self changeStatus:@"Stash it away man!..."];
//NSLog(@"Stash it away man!...");
//[self stash:[[self processDict] valueForKey:@"stash"] withRoot:mountImage];
[self changeStatus:@"Stash it away man!..."];
NSLog(@"Stash it away man!...");
[self stash:[[self processDict] valueForKey:@"stash"] withRoot:mountImage];

NSDictionary *ep = [currentBundle extraPatch];
if (ep != nil)
Expand Down
2 changes: 1 addition & 1 deletion tetherKit-Info.plist
Expand Up @@ -25,7 +25,7 @@
<key>CFBundleURLTypes</key>
<array/>
<key>CFBundleVersion</key>
<string>165</string>
<string>180</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>
Expand Down

0 comments on commit 476eb6e

Please sign in to comment.