]> git.cameronkatri.com Git - snaprestore.git/commitdiff
Remove uicache dependency v0.2
authorCameron Katri <me@cameronkatri.com>
Mon, 7 Dec 2020 00:23:50 +0000 (19:23 -0500)
committerCameron Katri <me@cameronkatri.com>
Mon, 7 Dec 2020 00:32:57 +0000 (19:32 -0500)
Don't use NSTask
Reorganize

.gitignore
Makefile
NSTask.h [deleted file]
README.md
include/IOKit [new symlink]
include/libkern [new symlink]
src/ent.xml [moved from ent.xml with 100% similarity]
src/snaprestore.control [moved from snaprestore.control with 72% similarity]
src/snaprestore.m [moved from snaprestore.m with 77% similarity]

index 91b2e23934a28b3ba8a20a3d7e21511453218c52..be56d4297ad60a6c79f7f02c7518ac72f9bff81c 100644 (file)
@@ -1,4 +1,4 @@
-snaprestore
+build
 staging
 *.deb
 compile_commands.json
index f164042a4f64df76c0f14b965d953197cd1a2f95..a6255fb5d167be236881eaac84223ff285af6d39 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,43 +1,44 @@
-CC               = aarch64-apple-darwin-clang
-STRIP            = aarch64-apple-darwin-strip
-LDID             = ldid
-CFLAGS           = -arch arm64  -isysroot /home/cameron/Documents/SDK/iPhoneOS14.2.sdk -miphoneos-version-min=13.0 -isystem /home/cameron/Documents/Procursus/build_base/iphoneos-arm64/1600/usr/include -isystem /home/cameron/Documents/Procursus/build_base/iphoneos-arm64/1600/usr/local/include -F/home/cameron/Documents/Procursus/build_base/iphoneos-arm64/1600/System/Library/Frameworks
-INSTALL          = install
-FAKEROOT         = fakeroot
+CC              ?= aarch64-apple-darwin-clang
+STRIP           ?= aarch64-apple-darwin-strip
+LDID            ?= ldid
+CFLAGS          ?= -arch arm64  -isysroot /home/cameron/Documents/SDK/iPhoneOS14.2.sdk -miphoneos-version-min=13.0 -Iinclude
+INSTALL         ?= install
+FAKEROOT        ?= fakeroot
 PREFIX          ?= /usr
 DESTDIR         ?= 
 
 DEB_MAINTAINER  ?= Cameron Katri <me@cameronkatri.com>
 DEB_ARCH        ?= iphoneos-arm
-SNAPRESTORE_V   := 0.1
+SNAPRESTORE_V   := 0.2
 DEB_SNAPRESTORE := $(SNAPRESTORE_V)
 
-all: snaprestore
+all: build/snaprestore
 
-snaprestore: snaprestore.m ent.xml NSTask.h
-       $(CC) $(CFLAGS) -o snaprestore snaprestore.m -framework IOKit -framework Foundation -fobjc-arc
-       $(STRIP) snaprestore
-       $(LDID) -Sent.xml snaprestore
+build/snaprestore: src/snaprestore.m src/ent.xml
+       mkdir -p build
+       $(CC) $(CFLAGS) -o build/snaprestore src/snaprestore.m -framework IOKit -framework Foundation -framework MobileCoreServices -fobjc-arc
+       $(STRIP) build/snaprestore
+       $(LDID) -Ssrc/ent.xml build/snaprestore
 
-install: snaprestore
-       $(INSTALL) -Dm755 snaprestore $(DESTDIR)$(PREFIX)/bin/snaprestore
+install: build/snaprestore
+       $(INSTALL) -Dm755 build/snaprestore $(DESTDIR)$(PREFIX)/bin/snaprestore
        $(INSTALL) -Dm644 LICENSE $(DESTDIR)$(PREFIX)/share/snaprestore/LICENSE
 
-package: snaprestore
+package: build/snaprestore
        rm -rf staging
-       $(INSTALL) -Dm755 snaprestore staging$(PREFIX)/bin/snaprestore
+       $(INSTALL) -Dm755 build/snaprestore staging$(PREFIX)/bin/snaprestore
        $(INSTALL) -Dm644 LICENSE staging$(PREFIX)/share/snaprestore/LICENSE
        $(FAKEROOT) chown -R 0:0 staging
        SIZE=$$(du -s staging | cut -f 1); \
-       $(INSTALL) -Dm755 snaprestore.control staging/DEBIAN/control; \
+       $(INSTALL) -Dm755 src/snaprestore.control staging/DEBIAN/control; \
        sed -i ':a; s/@DEB_SNAPRESTORE@/$(DEB_SNAPRESTORE)/g; ta' staging/DEBIAN/control; \
        sed -i ':a; s/@DEB_MAINTAINER@/$(DEB_MAINTAINER)/g; ta' staging/DEBIAN/control; \
        sed -i ':a; s/@DEB_ARCH@/$(DEB_ARCH)/g; ta' staging/DEBIAN/control; \
        cd staging && find . -type f ! -regex '.*.hg.*' ! -regex '.*?debian-binary.*' ! -regex '.*?DEBIAN.*' -printf '"%P" ' | xargs md5sum > DEBIAN/md5sum; \
        cd ..; \
        echo "Installed-Size: $$SIZE" >> staging/DEBIAN/control
-       $(FAKEROOT) dpkg-deb -z9 -b staging .
+       $(FAKEROOT) dpkg-deb -z9 -b staging build
        rm -rf staging
 
 clean: 
-       rm -f snaprestore
+       rm -f build/snaprestore
diff --git a/NSTask.h b/NSTask.h
deleted file mode 100644 (file)
index 7b51c23..0000000
--- a/NSTask.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-* This header is generated by classdump-dyld 1.0
-* on Thursday, January 25, 2018 at 11:20:38 PM Eastern European Standard Time
-* Operating System: Version 11.1.2 (Build 15B202)
-* Image Source: /System/Library/Frameworks/Foundation.framework/Foundation
-* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
-*/
-
-#import <Foundation/Foundation.h>
-
-@interface NSTask : NSObject
-
-@property (copy) NSURL * executableURL;
-@property (copy) NSArray * arguments;
-@property (copy) NSDictionary * environment;
-@property (copy) NSURL * currentDirectoryURL;
-@property (retain) id standardInput;
-@property (retain) id standardOutput;
-@property (retain) id standardError;
-@property (readonly) int processIdentifier;
-@property (getter=isRunning, readonly) BOOL running;
-@property (readonly) int terminationStatus;
-@property (readonly) long long terminationReason;
-@property (copy) id terminationHandler;
-@property (assign) long long qualityOfService;
-+ (id)currentTaskDictionary;
-+ (id)launchedTaskWithDictionary:(id)arg1;
-+ (id)launchedTaskWithLaunchPath:(id)arg1 arguments:(id)arg2;
-+ (id)launchedTaskWithExecutableURL:(id)arg1 arguments:(id)arg2 error:(out id*)arg3 terminationHandler:(/*^block*/id)arg4;
-- (void)waitUntilExit;
-- (id)currentDirectoryPath;
-- (void)setCurrentDirectoryPath:(id)arg1;
-- (id)launchPath;
-- (void)setLaunchPath:(id)arg1;
-- (void)launch;
-- (BOOL)launchAndReturnError:(id*)arg1;
-- (void)interrupt;
-- (long long)suspendCount;
-- (BOOL)suspend;
-- (BOOL)resume;
-- (void)terminate;
-- (NSArray *)arguments;
-@end
index a30191afa76648ef20bd9a9111b85798165b2e97..f91175b77dbcf4408ab116ef49554bdb5cad3363 100644 (file)
--- a/README.md
+++ b/README.md
@@ -2,4 +2,7 @@
 
 `Usage: snaprestore [volume] [snapshot]`
 
-not tested, obviously
+Fair amount of testing  
+Renames snapshot to original name  
+Removes jailbreak apps from icon cache  
+Works on any jailbreak (hopefully)
diff --git a/include/IOKit b/include/IOKit
new file mode 120000 (symlink)
index 0000000..0900dbf
--- /dev/null
@@ -0,0 +1 @@
+/home/cameron/Documents/SDK/MacOSX11.0.sdk/System/Library/Frameworks/IOKit.framework/Headers
\ No newline at end of file
diff --git a/include/libkern b/include/libkern
new file mode 120000 (symlink)
index 0000000..a19ad08
--- /dev/null
@@ -0,0 +1 @@
+/home/cameron/Documents/SDK/MacOSX11.0.sdk/usr/include/libkern
\ No newline at end of file
similarity index 100%
rename from ent.xml
rename to src/ent.xml
similarity index 72%
rename from snaprestore.control
rename to src/snaprestore.control
index 2624641af40181ff300821626d7eb312d4d16e1e..7a7c32937d92a977c0213e23946f304a4601a3a9 100644 (file)
@@ -4,5 +4,4 @@ Maintainer: @DEB_MAINTAINER@
 Architecture: @DEB_ARCH@
 Version: @DEB_SNAPRESTORE@
 Description: Easily restore rootfs from the command line
-       I wholeheartly don't recommend it
-Depends: uikittools (>= 2.0.3)
+       Usage: snaprestore [volume] [snapshot]
similarity index 77%
rename from snaprestore.m
rename to src/snaprestore.m
index 51b9c85d975faa7928ae7013eca8475ad7460cb2..deda1bc55916e39dafd80e27bedefaa2ba095273 100644 (file)
@@ -3,7 +3,18 @@
 #import <IOKit/IOKitLib.h>
 #import <sys/snapshot.h>
 #import <getopt.h>
-#import "NSTask.h"
+
+@interface LSApplicationWorkspace : NSObject
++ (id)defaultWorkspace;
+- (BOOL)_LSPrivateRebuildApplicationDatabasesForSystemApps:(BOOL)arg1 internal:(BOOL)arg2 user:(BOOL)arg3;
+- (BOOL)registerApplicationDictionary:(NSDictionary *)applicationDictionary;
+- (BOOL)registerBundleWithInfo:(NSDictionary *)bundleInfo options:(NSDictionary *)options type:(unsigned long long)arg3 progress:(id)arg4 ;
+- (BOOL)registerApplication:(NSURL *)url;
+- (BOOL)registerPlugin:(NSURL *)url;
+- (BOOL)unregisterApplication:(NSURL *)url;
+- (NSArray *)installedPlugins;
+-(void)_LSPrivateSyncWithMobileInstallation;
+@end
 
 void usage(char *name) {
        printf(
@@ -68,6 +79,13 @@ NSMutableSet *findApps(const char *root, const char *mnt) {
        return ret;
 }
 
+int unregisterPath(NSString *path) {
+       path = [path stringByResolvingSymlinksInPath];
+       NSURL *url = [NSURL fileURLWithPath:path];
+       LSApplicationWorkspace *workspace = [LSApplicationWorkspace defaultWorkspace];
+       return [workspace unregisterApplication:url];
+}
+
 int rename(const char *vol, const char *snap) {
        int fd = open(vol, O_RDONLY, 0);
 
@@ -93,17 +111,10 @@ int main(int argc, char *argv[]) {
        printf("Mounted %s at %s\n", snap, mnt);
        NSMutableSet *appSet = findApps(vol, mnt);
        if ([appSet count]) {
-               printf("Refreshing icon cache...\n");
-               NSMutableArray *argArray = [[NSMutableArray alloc] init];
                for (NSString *app in appSet) {
-                       [argArray addObject:@"-u"];
-                       [argArray addObject:app];
+                       printf("unregistering %s\n", [app UTF8String]);
+                       unregisterPath(app);
                }
-               NSTask *task = [[NSTask alloc] init];
-               [task setLaunchPath:@"/usr/bin/uicache"];
-               [task setArguments:argArray];
-               [task launch];
-               [task waitUntilExit];
        }
        printf("Renaming snapshot...\n");
        rename(vol, snap);