mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-09-02 16:42:38 +02:00
Add an installer for the iOS Deb release to allow compatibility with rootless jailbreaks
This commit is contained in:
33
Makefile
33
Makefile
@@ -244,7 +244,7 @@ CORE_FILTER += Core/debugger.c Core/sm83_disassembler.c Core/symbol_hash.c
|
|||||||
LDFLAGS += -arch arm64
|
LDFLAGS += -arch arm64
|
||||||
OCFLAGS += -x objective-c -fobjc-arc -Wno-deprecated-declarations -isysroot $(SYSROOT)
|
OCFLAGS += -x objective-c -fobjc-arc -Wno-deprecated-declarations -isysroot $(SYSROOT)
|
||||||
LDFLAGS += -miphoneos-version-min=11.0 -isysroot $(SYSROOT)
|
LDFLAGS += -miphoneos-version-min=11.0 -isysroot $(SYSROOT)
|
||||||
REREGISTER_LDFLAGS := $(LDFLAGS) -lobjc -framework CoreServices -framework Foundation
|
IOS_INSTALLER_LDFLAGS := $(LDFLAGS) -lobjc -framework CoreServices -framework Foundation
|
||||||
LDFLAGS += -lobjc -framework UIKit -framework Foundation -framework CoreGraphics -framework Metal -framework MetalKit -framework AudioToolbox -framework AVFoundation -framework QuartzCore -framework CoreMotion -framework CoreVideo -framework CoreMedia -framework CoreImage -framework UserNotifications -weak_framework CoreHaptics
|
LDFLAGS += -lobjc -framework UIKit -framework Foundation -framework CoreGraphics -framework Metal -framework MetalKit -framework AudioToolbox -framework AVFoundation -framework QuartzCore -framework CoreMotion -framework CoreVideo -framework CoreMedia -framework CoreImage -framework UserNotifications -weak_framework CoreHaptics
|
||||||
CODESIGN := codesign -fs -
|
CODESIGN := codesign -fs -
|
||||||
else
|
else
|
||||||
@@ -325,7 +325,7 @@ quicklook: $(BIN)/SameBoy.qlgenerator
|
|||||||
sdl: $(SDL_TARGET) $(BIN)/SDL/dmg_boot.bin $(BIN)/SDL/mgb_boot.bin $(BIN)/SDL/cgb0_boot.bin $(BIN)/SDL/cgb_boot.bin $(BIN)/SDL/agb_boot.bin $(BIN)/SDL/sgb_boot.bin $(BIN)/SDL/sgb2_boot.bin $(BIN)/SDL/LICENSE $(BIN)/SDL/registers.sym $(BIN)/SDL/background.bmp $(BIN)/SDL/Shaders $(BIN)/SDL/Palettes
|
sdl: $(SDL_TARGET) $(BIN)/SDL/dmg_boot.bin $(BIN)/SDL/mgb_boot.bin $(BIN)/SDL/cgb0_boot.bin $(BIN)/SDL/cgb_boot.bin $(BIN)/SDL/agb_boot.bin $(BIN)/SDL/sgb_boot.bin $(BIN)/SDL/sgb2_boot.bin $(BIN)/SDL/LICENSE $(BIN)/SDL/registers.sym $(BIN)/SDL/background.bmp $(BIN)/SDL/Shaders $(BIN)/SDL/Palettes
|
||||||
bootroms: $(BIN)/BootROMs/agb_boot.bin $(BIN)/BootROMs/cgb_boot.bin $(BIN)/BootROMs/cgb0_boot.bin $(BIN)/BootROMs/dmg_boot.bin $(BIN)/BootROMs/mgb_boot.bin $(BIN)/BootROMs/sgb_boot.bin $(BIN)/BootROMs/sgb2_boot.bin
|
bootroms: $(BIN)/BootROMs/agb_boot.bin $(BIN)/BootROMs/cgb_boot.bin $(BIN)/BootROMs/cgb0_boot.bin $(BIN)/BootROMs/dmg_boot.bin $(BIN)/BootROMs/mgb_boot.bin $(BIN)/BootROMs/sgb_boot.bin $(BIN)/BootROMs/sgb2_boot.bin
|
||||||
tester: $(TESTER_TARGET) $(BIN)/tester/dmg_boot.bin $(BIN)/tester/cgb_boot.bin $(BIN)/tester/agb_boot.bin $(BIN)/tester/sgb_boot.bin $(BIN)/tester/sgb2_boot.bin
|
tester: $(TESTER_TARGET) $(BIN)/tester/dmg_boot.bin $(BIN)/tester/cgb_boot.bin $(BIN)/tester/agb_boot.bin $(BIN)/tester/sgb_boot.bin $(BIN)/tester/sgb2_boot.bin
|
||||||
_ios: $(BIN)/SameBoy-iOS.app $(OBJ)/reregister
|
_ios: $(BIN)/SameBoy-iOS.app $(OBJ)/installer
|
||||||
ios-ipa: $(BIN)/SameBoy-iOS.ipa
|
ios-ipa: $(BIN)/SameBoy-iOS.ipa
|
||||||
ios-deb: $(BIN)/SameBoy-iOS.deb
|
ios-deb: $(BIN)/SameBoy-iOS.deb
|
||||||
ifeq ($(PLATFORM),windows32)
|
ifeq ($(PLATFORM),windows32)
|
||||||
@@ -344,7 +344,7 @@ CORE_SOURCES := $(filter-out $(CORE_FILTER),$(shell ls Core/*.c))
|
|||||||
CORE_HEADERS := $(shell ls Core/*.h)
|
CORE_HEADERS := $(shell ls Core/*.h)
|
||||||
SDL_SOURCES := $(shell ls SDL/*.c) $(OPEN_DIALOG) $(patsubst %,SDL/audio/%.c,$(SDL_AUDIO_DRIVERS))
|
SDL_SOURCES := $(shell ls SDL/*.c) $(OPEN_DIALOG) $(patsubst %,SDL/audio/%.c,$(SDL_AUDIO_DRIVERS))
|
||||||
TESTER_SOURCES := $(shell ls Tester/*.c)
|
TESTER_SOURCES := $(shell ls Tester/*.c)
|
||||||
IOS_SOURCES := $(filter-out iOS/reregister.m, $(shell ls iOS/*.m)) $(shell ls AppleCommon/*.m)
|
IOS_SOURCES := $(filter-out iOS/installer.m, $(shell ls iOS/*.m)) $(shell ls AppleCommon/*.m)
|
||||||
COCOA_SOURCES := $(shell ls Cocoa/*.m) $(shell ls HexFiend/*.m) $(shell ls JoyKit/*.m) $(shell ls AppleCommon/*.m)
|
COCOA_SOURCES := $(shell ls Cocoa/*.m) $(shell ls HexFiend/*.m) $(shell ls JoyKit/*.m) $(shell ls AppleCommon/*.m)
|
||||||
QUICKLOOK_SOURCES := $(shell ls QuickLook/*.m) $(shell ls QuickLook/*.c)
|
QUICKLOOK_SOURCES := $(shell ls QuickLook/*.m) $(shell ls QuickLook/*.c)
|
||||||
|
|
||||||
@@ -449,9 +449,8 @@ ifeq ($(CONF), release)
|
|||||||
$(STRIP) $@
|
$(STRIP) $@
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(OBJ)/reregister: iOS/reregister.m iOS/reregister.entitlements
|
$(OBJ)/installer: iOS/installer.m
|
||||||
$(CC) $< -o $@ $(REREGISTER_LDFLAGS) $(CFLAGS)
|
$(CC) $< -o $@ $(IOS_INSTALLER_LDFLAGS) $(CFLAGS)
|
||||||
codesign -fs - --entitlements iOS/reregister.entitlements $@
|
|
||||||
|
|
||||||
# Cocoa Port
|
# Cocoa Port
|
||||||
|
|
||||||
@@ -697,20 +696,22 @@ $(BIN)/SameBoy-iOS.deb: $(OBJ)/debian-binary $(OBJ)/control.tar.gz $(OBJ)/data.t
|
|||||||
-@$(MKDIR) -p $(dir $@)
|
-@$(MKDIR) -p $(dir $@)
|
||||||
(cd $(OBJ) && ar cr $(abspath $@) $(notdir $^))
|
(cd $(OBJ) && ar cr $(abspath $@) $(notdir $^))
|
||||||
|
|
||||||
$(OBJ)/data.tar.gz: ios iOS/jailbreak.entitlements
|
$(OBJ)/data.tar.gz: ios iOS/jailbreak.entitlements iOS/installer.entitlements
|
||||||
$(MKDIR) -p $(OBJ)/Applications
|
$(MKDIR) -p $(OBJ)/private/var/containers/
|
||||||
cp -rf $(BIN)/SameBoy-iOS.app $(OBJ)/Applications/SameBoy-iOS.app
|
cp -rf $(BIN)/SameBoy-iOS.app $(OBJ)/private/var/containers/SameBoy-iOS.app
|
||||||
cp build/obj-ios/reregister $(OBJ)/Applications/SameBoy-iOS.app
|
cp build/obj-ios/installer $(OBJ)/private/var/containers/SameBoy-iOS.app
|
||||||
codesign -fs - --entitlements iOS/jailbreak.entitlements $(OBJ)/Applications/SameBoy-iOS.app
|
codesign -fs - --entitlements iOS/installer.entitlements $(OBJ)/private/var/containers/SameBoy-iOS.app/installer
|
||||||
(cd $(OBJ) && tar -czf $(abspath $@) --format ustar --uid 501 --gid 501 --numeric-owner ./Applications)
|
codesign -fs - --entitlements iOS/jailbreak.entitlements $(OBJ)/private/var/containers/SameBoy-iOS.app
|
||||||
rm -rf $(OBJ)/Applications
|
(cd $(OBJ) && tar -czf $(abspath $@) --format ustar --uid 501 --gid 501 --numeric-owner ./private)
|
||||||
|
rm -rf $(OBJ)/private/
|
||||||
|
|
||||||
$(OBJ)/control.tar.gz: iOS/deb-postinst iOS/deb-control
|
$(OBJ)/control.tar.gz: iOS/deb-postinst iOS/deb-prerm iOS/deb-control
|
||||||
-@$(MKDIR) -p $(dir $@)
|
-@$(MKDIR) -p $(dir $@)
|
||||||
sed "s/@VERSION/$(VERSION)/" < iOS/deb-control > $(OBJ)/control
|
sed "s/@VERSION/$(VERSION)/" < iOS/deb-control > $(OBJ)/control
|
||||||
ln iOS/deb-postinst $(OBJ)/postinst
|
ln iOS/deb-postinst $(OBJ)/postinst
|
||||||
(cd $(OBJ) && tar -czf $(abspath $@) --format ustar --uid 501 --gid 501 --numeric-owner ./control ./postinst)
|
ln iOS/deb-prerm $(OBJ)/prerm
|
||||||
rm $(OBJ)/control $(OBJ)/postinst
|
(cd $(OBJ) && tar -czf $(abspath $@) --format ustar --uid 501 --gid 501 --numeric-owner ./control ./postinst ./prerm)
|
||||||
|
rm $(OBJ)/control $(OBJ)/postinst $(OBJ)/prerm
|
||||||
|
|
||||||
$(OBJ)/debian-binary:
|
$(OBJ)/debian-binary:
|
||||||
-@$(MKDIR) -p $(dir $@)
|
-@$(MKDIR) -p $(dir $@)
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
Package: com.github.liji32.sameboy.ios
|
Package: com.github.liji32.sameboy.ios
|
||||||
Name: SameBoy
|
Name: SameBoy
|
||||||
Depends: firmware (>= 11.0)
|
Depends: firmware (>= 11.0)
|
||||||
Architecture: iphoneos-arm
|
Architecture: all
|
||||||
Description: A Game Boy emulator for iOS
|
Description: A Game Boy emulator for iOS
|
||||||
Maintainer: Lior Halphon
|
Maintainer: Lior Halphon
|
||||||
Author: Lior Halphon
|
Author: Lior Halphon
|
||||||
|
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
/Applications/SameBoy-iOS.app/reregister
|
/private/var/containers/SameBoy-iOS.app/installer install
|
||||||
|
2
iOS/deb-prerm
Executable file
2
iOS/deb-prerm
Executable file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
/Applications/SameBoy-iOS.app/installer uninstall || /var/jb/Applications/SameBoy-iOS.app/installer uninstall
|
@@ -15,5 +15,7 @@
|
|||||||
<true/>
|
<true/>
|
||||||
<key>platform-application</key>
|
<key>platform-application</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>com.apple.private.security.no-container</key>
|
||||||
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
105
iOS/installer.m
Normal file
105
iOS/installer.m
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <dlfcn.h>
|
||||||
|
#import <objc/runtime.h>
|
||||||
|
|
||||||
|
@interface LSApplicationProxy : NSObject
|
||||||
|
@property (readonly, getter=isContainerized) bool containerized;
|
||||||
|
@property (readonly) NSString *bundleIdentifier;
|
||||||
|
@property (readonly) NSURL * bundleURL;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface LSApplicationWorkspace : NSObject
|
||||||
|
+ (instancetype)defaultWorkspace;
|
||||||
|
- (NSArray <LSApplicationProxy *> *)allInstalledApplications;
|
||||||
|
- (bool)unregisterApplication:(NSURL *)url;
|
||||||
|
- (bool)registerApplicationDictionary:(NSDictionary *)dict;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface MCMAppDataContainer : NSObject
|
||||||
|
+ (MCMAppDataContainer *)containerWithIdentifier:(NSString *)identifier
|
||||||
|
createIfNecessary:(bool)create
|
||||||
|
existed:(bool *)existed
|
||||||
|
error:(NSError **)error;
|
||||||
|
@property(readonly) NSURL *url;
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
if (argc != 2) return 1;
|
||||||
|
// Make sure MobileContainerManager is loaded
|
||||||
|
if (!dlopen("/System/Library/PrivateFrameworks/MobileContainerManager.framework/MobileContainerManager", RTLD_NOW)) return 1;
|
||||||
|
|
||||||
|
bool uninstall = false;
|
||||||
|
if (strcmp(argv[1], "uninstall") == 0) {
|
||||||
|
uninstall = true;
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[1], "install") != 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *installPath = @"/var/jb/Applications/SameBoy-iOS.app";
|
||||||
|
if (access("/Applications/", W_OK) == 0) {
|
||||||
|
installPath = @"/Applications/SameBoy-iOS.app";
|
||||||
|
}
|
||||||
|
NSLog(@"Install path is %@", installPath);
|
||||||
|
|
||||||
|
for (LSApplicationProxy *app in [[LSApplicationWorkspace defaultWorkspace] allInstalledApplications]) {
|
||||||
|
if (![app.bundleIdentifier isEqualToString:[NSBundle mainBundle].bundleIdentifier]) continue;
|
||||||
|
if (![app.bundleURL.path.stringByResolvingSymlinksInPath isEqual:installPath.stringByResolvingSymlinksInPath]) {
|
||||||
|
// Already installed elsewhere
|
||||||
|
NSLog(@"Already installed at %@", app.bundleURL.path);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSLog(@"Unregistering previous installation");
|
||||||
|
// We're registered but not containerized (or just uninstalling), unregister ourselves first
|
||||||
|
if (![[LSApplicationWorkspace defaultWorkspace] unregisterApplication:app.bundleURL]) return 1;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't modify files if we're at the correct path already
|
||||||
|
if (uninstall || ![[NSBundle mainBundle].bundlePath.stringByResolvingSymlinksInPath isEqual:installPath.stringByResolvingSymlinksInPath]) {
|
||||||
|
// Remove any previous copy
|
||||||
|
NSError *error = nil;
|
||||||
|
if (!access(installPath.UTF8String, F_OK)) {
|
||||||
|
NSLog(@"Removing previous installation");
|
||||||
|
[[NSFileManager defaultManager] removeItemAtPath:installPath error:&error];
|
||||||
|
if (error) {
|
||||||
|
NSLog(@"Error: %@", error);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we're uninstalling, we're done
|
||||||
|
if (uninstall) return 0;
|
||||||
|
|
||||||
|
NSLog(@"Installing...");
|
||||||
|
|
||||||
|
[[NSFileManager defaultManager] moveItemAtPath:[NSBundle mainBundle].bundlePath toPath:installPath error:&error];
|
||||||
|
if (error) {
|
||||||
|
NSLog(@"Error: %@", error);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NSLog(@"Registering...");
|
||||||
|
|
||||||
|
NSString *container = [objc_getClass("MCMAppDataContainer") containerWithIdentifier:[NSBundle mainBundle].bundleIdentifier
|
||||||
|
createIfNecessary:true
|
||||||
|
existed:nil
|
||||||
|
error:nil].url.path;
|
||||||
|
|
||||||
|
return ![[LSApplicationWorkspace defaultWorkspace] registerApplicationDictionary:@{
|
||||||
|
@"ApplicationType": @"System",
|
||||||
|
@"CFBundleIdentifier": [NSBundle mainBundle].bundleIdentifier,
|
||||||
|
@"CompatibilityState": @NO,
|
||||||
|
@"Container": container,
|
||||||
|
@"IsDeletable": @NO,
|
||||||
|
@"Path": installPath,
|
||||||
|
@"_LSBundlePlugins": @{},
|
||||||
|
@"IsContainerized": @YES,
|
||||||
|
}];
|
||||||
|
}
|
@@ -1,54 +0,0 @@
|
|||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import <dlfcn.h>
|
|
||||||
#import <objc/runtime.h>
|
|
||||||
|
|
||||||
@interface LSApplicationProxy : NSObject
|
|
||||||
@property (nonatomic, readonly, getter=isContainerized) bool containerized;
|
|
||||||
@property (nonatomic, readonly) NSString *bundleIdentifier;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@interface LSApplicationWorkspace : NSObject
|
|
||||||
+ (instancetype)defaultWorkspace;
|
|
||||||
- (NSArray <LSApplicationProxy *> *)allInstalledApplications;
|
|
||||||
- (bool)unregisterApplication:(NSURL *)url;
|
|
||||||
- (bool)registerApplicationDictionary:(NSDictionary *)dict;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@interface MCMAppDataContainer : NSObject
|
|
||||||
+ (MCMAppDataContainer *)containerWithIdentifier:(NSString *)identifier
|
|
||||||
createIfNecessary:(bool)create
|
|
||||||
existed:(bool *)existed
|
|
||||||
error:(NSError **)error;
|
|
||||||
@property(readonly, nonatomic) NSURL *url;
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// Make sure MobileContainerManager is loaded
|
|
||||||
if (!dlopen("/System/Library/PrivateFrameworks/MobileContainerManager.framework/MobileContainerManager", RTLD_NOW)) return 1;
|
|
||||||
for (LSApplicationProxy *app in [[LSApplicationWorkspace defaultWorkspace] allInstalledApplications]) {
|
|
||||||
if (![app.bundleIdentifier isEqualToString:[NSBundle mainBundle].bundleIdentifier]) continue;
|
|
||||||
if (app.containerized) return 0; // Everything's fine, no need to reregister
|
|
||||||
// We're registered but not containerized, unregister ourselves first
|
|
||||||
if (![[LSApplicationWorkspace defaultWorkspace] unregisterApplication:[NSBundle mainBundle].bundleURL]) return 1;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
NSString *container = [objc_getClass("MCMAppDataContainer") containerWithIdentifier:[NSBundle mainBundle].bundleIdentifier
|
|
||||||
createIfNecessary:true
|
|
||||||
existed:nil
|
|
||||||
error:nil].url.path;
|
|
||||||
|
|
||||||
return ![[LSApplicationWorkspace defaultWorkspace] registerApplicationDictionary:@{
|
|
||||||
@"ApplicationType": @"System",
|
|
||||||
@"CFBundleIdentifier": [NSBundle mainBundle].bundleIdentifier,
|
|
||||||
@"CompatibilityState": @NO,
|
|
||||||
@"Container": container,
|
|
||||||
@"IsDeletable": @NO,
|
|
||||||
@"Path": [NSBundle mainBundle].bundlePath,
|
|
||||||
@"_LSBundlePlugins": @{},
|
|
||||||
@"IsContainerized": @YES,
|
|
||||||
}];
|
|
||||||
}
|
|
Reference in New Issue
Block a user