summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2013-02-06 11:59:22 +0000
committerJay Freeman (saurik) <saurik@saurik.com>2013-02-06 11:59:22 +0000
commitee2ee18b3e415082a686e7b7ce9297d12e031bf9 (patch)
treefa4c02f6f4c4b841f2f107f22e83e3251ef3d1aa
parent1bd75e96ee074964a2d7c4fd1d9bc8ddb0c2be7e (diff)
Attempt to repair old caches on install.
-rw-r--r--.gitignore1
-rw-r--r--extrainst_.mm148
-rw-r--r--makefile5
3 files changed, 153 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index c2d7f42..f891275 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
_
cfversion
debs
+extrainst_
gssc
iomfsetgamma
sbdidlaunch
diff --git a/extrainst_.mm b/extrainst_.mm
new file mode 100644
index 0000000..5a473b3
--- /dev/null
+++ b/extrainst_.mm
@@ -0,0 +1,148 @@
+/* UIKit Tools - command-line utilities for UIKit
+ * Copyright (C) 2008-2012 Jay Freeman (saurik)
+*/
+
+/* Modified BSD License {{{ */
+/*
+ * Redistribution and use in source and binary
+ * forms, with or without modification, are permitted
+ * provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the
+ * above copyright notice, this list of conditions
+ * and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the
+ * above copyright notice, this list of conditions
+ * and the following disclaimer in the documentation
+ * and/or other materials provided with the
+ * distribution.
+ * 3. The name of the author may not be used to endorse
+ * or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/* }}} */
+
+#import <Foundation/Foundation.h>
+
+#include <notify.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "csstore.hpp"
+
+@interface NSObject (Cydia)
+- (NSDictionary *) dictionaryOfInfoDictionaries;
+@end
+
+@implementation NSObject (Cydia)
+
+- (NSDictionary *) dictionaryOfInfoDictionaries {
+ return nil;
+}
+
+@end
+
+@interface NSArray (Cydia)
+- (NSDictionary *) dictionaryOfInfoDictionaries;
+@end
+
+@implementation NSArray (Cydia)
+
+- (NSDictionary *) dictionaryOfInfoDictionaries {
+ // XXX: implement?
+ return nil;
+}
+
+@end
+
+@interface NSDictionary (Cydia)
+- (NSDictionary *) dictionaryOfInfoDictionaries;
+@end
+
+@implementation NSDictionary (Cydia)
+
+- (NSDictionary *) dictionaryOfInfoDictionaries {
+ return self;
+}
+
+@end
+
+bool FinishCydia(const char *finish) {
+ if (finish == NULL)
+ return true;
+
+ const char *cydia(getenv("CYDIA"));
+ if (cydia == NULL)
+ return false;
+
+ int fd([[[[NSString stringWithUTF8String:cydia] componentsSeparatedByString:@" "] objectAtIndex:0] intValue]);
+ FILE *fout(fdopen(fd, "w"));
+ fprintf(fout, "finish:%s\n", finish);
+ fclose(fout);
+ return true;
+}
+
+void FixCache(NSString *home, NSString *plist) {
+ printf("attempting to fix weather app issue:\n");
+
+ DeleteCSStores([home UTF8String]);
+ unlink([plist UTF8String]);
+
+ system("launchctl stop com.apple.mobile.installd");
+ system("launchctl start com.apple.mobile.installd");
+
+ printf("waiting for application/icon cache rebuild...\n");
+ printf("this will timeout (harmlessly) after 90 seconds\n");
+
+ for (unsigned i(0); i != 90; ++i) {
+ if (i != 0 && (i % 10) == 0)
+ printf("after %i seconds, still waiting for rebuild...\n", i);
+ if ([[NSMutableDictionary dictionaryWithContentsOfFile: plist] objectForKey: @"User"] != nil)
+ break;
+ sleep(1);
+ }
+
+ if (!FinishCydia("reboot"))
+ printf("you must reboot to finalize your cache.\n");
+}
+
+int main(int argc, const char *argv[]) {
+ if (argc < 2 || (
+ strcmp(argv[1], "install") != 0 &&
+ strcmp(argv[1], "upgrade") != 0 &&
+ true)) return 0;
+
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ if (kCFCoreFoundationVersionNumber >= 700) { // XXX: iOS 6.x
+ NSString *home(@"/var/mobile");
+ NSString *plist([NSString stringWithFormat:@"%@/Library/Caches/com.apple.mobile.installation.plist", home]);
+
+ NSDictionary *cache([NSDictionary dictionaryWithContentsOfFile:plist]);
+ NSObject *system([cache objectForKey:@"System"]);
+ NSDictionary *dictionary([system dictionaryOfInfoDictionaries]);
+ NSDictionary *weather([dictionary objectForKey:@"com.apple.weather"]);
+
+ if (weather != nil && [weather objectForKey:@"Container"] == nil)
+ FixCache(home, plist);
+ }
+
+ [pool release];
+ return 0;
+}
diff --git a/makefile b/makefile
index ae9f547..b1f82c5 100644
--- a/makefile
+++ b/makefile
@@ -14,8 +14,10 @@ uicache := -framework Foundation -framework UIKit # XXX: UIKit -> MobileCoreServ
uiduid := -framework Foundation -framework UIKit
uiopen := -framework Foundation -framework UIKit
uishoot := -framework CoreFoundation -framework Foundation -framework UIKit
+extrainst_ := -framework CoreFoundation -framework Foundation
uicache: csstore.cpp
+extrainst_: csstore.cpp
%: %.mm
$${PKG_TARG}-g++ -Wall -Werror -o $@ $^ $($@) -F"$${PKG_ROOT}"/System/Library/PrivateFrameworks -lobjc
@@ -29,12 +31,13 @@ iomfsetgamma: iomfsetgamma.c
$${PKG_TARG}-gcc -Wall -Werror -o $@ $< -F"$${PKG_ROOT}"/System/Library/PrivateFrameworks -framework IOKit -framework IOMobileFramebuffer
ldid -S$(wildcard $@.xml) $@
-package: all
+package: all extrainst_
rm -rf _
mkdir -p _/usr/bin
cp -a $(uikittools) _/usr/bin
mkdir -p _/DEBIAN
./control.sh _ >_/DEBIAN/control
+ cp -a extrainst_ _/DEBIAN/
mkdir -p debs
ln -sf debs/uikittools_$$(./version.sh)_iphoneos-arm.deb uikittools.deb
dpkg-deb -b _ uikittools.deb