Skip to content

Commit

Permalink
add script for pushing to repo
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanArbuckle committed Jan 1, 2021
1 parent 724a5f0 commit 8f30db3
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ include $(THEOS_MAKE_PATH)/tweak.mk

after-carplayenable-stage::
mkdir -p $(THEOS_STAGING_DIR)/var/mobile/Library/Preferences/
cp BLACKLISTED_APPS.plist $(THEOS_STAGING_DIR)/var/mobile/Library/Preferences/com.ethanarbuckle.carplay-blacklisted-apps.plist
cp BLACKLISTED_APPS.plist $(THEOS_STAGING_DIR)/var/mobile/Library/Preferences/com.carplayenable.blacklisted-apps.plist

after-install::
install.exec "killall -9 SpringBoard CarPlay"
Expand Down
6 changes: 3 additions & 3 deletions control
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Package: com.ethanarbuckle.carplayenable
Package: com.cortex.carplayenable
Name: carplayenable
Depends: mobilesubstrate
Version: 0.1.0
Architecture: iphoneos-arm
Description: Use any app with CarPlay
Maintainer: Ethan Arbuckle
Author: Ethan Arbuckle
Maintainer: Cortex
Author: Cortex
Section: Tweaks
8 changes: 8 additions & 0 deletions repo/Release
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Origin: repo.ghostbin
Label: repo.ghostbin
Suite: testing
Version: 1.0
Codename: repo.ghostbin
Architectures: iphoneos-arm
Components: main
Description: repo.ghostbin
85 changes: 85 additions & 0 deletions repo/push_deb_to_repo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import subprocess
from typing import Optional
import sys
from pathlib import Path
import hashlib
import tempfile
import gzip


REPO_IP_ADDRESS = "206.189.219.64"
REPO_PATH = "/var/www/repo.ghostbin.co"
DEBS_FOLDER = "debs"


def run_local_command(command: str) -> Optional[str]:
output = subprocess.check_output(command, shell=True)
return output.decode("utf-8") if output else None

def run_remote_command(command: str) -> Optional[str]:
full_command = f"ssh root@{REPO_IP_ADDRESS} \"{command}\""
return run_local_command(full_command)

def send_file(local_file: str, remote_path: str) -> None:
run_local_command(f"scp \"{local_file}\" root@{REPO_IP_ADDRESS}:\"{REPO_PATH}/{remote_path}\"")


def run(deb_to_upload: Path) -> None:

# Confirm connection
try:
if "var" not in run_remote_command("ls /"):
raise Exception()
# Create debs folder
run_remote_command(f"mkdir -p {REPO_PATH}/{DEBS_FOLDER}")
except:
raise RuntimeError(f"Failed to connect to {REPO_IP_ADDRESS}")

# Upload the Release file
release_file_path = Path(__file__).parent / "Release"
send_file(release_file_path.as_posix(), "Release")

# Generate the Package info
package_info = run_local_command(f"dpkg -I {deb_to_upload.as_posix()} control")

# Generate hashes and add them to package info
with open(deb_to_upload.as_posix(), mode="rb") as debf:
deb_contents = debf.read()
# Add md5
md5_hash = hashlib.md5(deb_contents).hexdigest()
package_info += f"MD5sum: {md5_hash}\n"
# Add sha1
sha1_hash = hashlib.sha1(deb_contents).hexdigest()
package_info += f"SHA1: {sha1_hash}\n"
# Add sha256
sha256_hash = hashlib.sha256(deb_contents).hexdigest()
package_info += f"SHA256: {sha256_hash}\n"

# Add deb name to package file
remote_deb_location = f"debs/{deb_to_upload.name}"
package_info += f"Filename: {remote_deb_location}\n"

# Gzip package file and upload
# with tempfile.NamedTemporaryFile(mode="wb") as packagef
with open("Packages.gz", mode="wb") as packagef, gzip.GzipFile(fileobj=packagef, mode="wb") as gzout:
# Write contents to temp file
gzout.write(package_info.encode("utf-8"))
gzout.flush()
gzout.close()
packagef.close()
# Send to server
send_file(packagef.name, "Packages.gz")

# Upload deb
send_file(deb_to_upload.as_posix(), remote_deb_location)

print("done")


if __name__ == "__main__":

if len(sys.argv) < 2 or ".deb" not in sys.argv[1]:
raise Exception("No deb provided")

provided_deb = Path(sys.argv[1])
run(provided_deb)
6 changes: 3 additions & 3 deletions src/CRCarplayWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ - (void)setupLiveAppView
});

// Ask the app to rotate to landscape
[[objc_getClass("NSDistributedNotificationCenter") defaultCenter] postNotificationName:@"com.ethanarbuckle.carplayenable.orientation" object:appIdentifier userInfo:@{@"orientation": @(self.orientation)}];
[[objc_getClass("NSDistributedNotificationCenter") defaultCenter] postNotificationName:@"com.carplayenable.orientation" object:appIdentifier userInfo:@{@"orientation": @(self.orientation)}];
});
});

Expand Down Expand Up @@ -372,7 +372,7 @@ - (void)dismiss
// Notify the application process to stop enforcing an orientation lock
int resetOrientationLock = -1;
NSString *hostedIdentifier = getIvar(self.appViewController, @"_identifier");
[[objc_getClass("NSDistributedNotificationCenter") defaultCenter] postNotificationName:@"com.ethanarbuckle.carplayenable.orientation" object:hostedIdentifier userInfo:@{@"orientation": @(resetOrientationLock)}];
[[objc_getClass("NSDistributedNotificationCenter") defaultCenter] postNotificationName:@"com.carplayenable.orientation" object:hostedIdentifier userInfo:@{@"orientation": @(resetOrientationLock)}];

[self.rootWindow setHidden:YES];
objcInvoke_1(self.appViewController, @"_setCurrentMode:", 0);
Expand Down Expand Up @@ -450,7 +450,7 @@ - (void)handleRotate
id appScene = objcInvoke(objcInvoke([self appViewController], @"sceneHandle"), @"scene");
NSString *sceneAppBundleID = objcInvoke(objcInvoke(objcInvoke(appScene, @"client"), @"process"), @"bundleIdentifier");

[[objc_getClass("NSDistributedNotificationCenter") defaultCenter] postNotificationName:@"com.ethanarbuckle.carplayenable.orientation" object:sceneAppBundleID userInfo:@{@"orientation": @(desiredOrientation)}];
[[objc_getClass("NSDistributedNotificationCenter") defaultCenter] postNotificationName:@"com.carplayenable.orientation" object:sceneAppBundleID userInfo:@{@"orientation": @(desiredOrientation)}];
[self resizeAppViewForOrientation:desiredOrientation fullscreen:self.isFullscreen forceUpdate:NO];
}

Expand Down
2 changes: 1 addition & 1 deletion src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
NSLog(@"LOG_LIFECYCLE_EVENT %@", func); \
}

#define BLACKLIST_PLIST_PATH @"/var/mobile/Library/Preferences/com.ethanarbuckle.carplay-blacklisted-apps.plist"
#define BLACKLIST_PLIST_PATH @"/var/mobile/Library/Preferences/com.carplayenable.blacklisted-apps.plist"

#define getIvar(object, ivar) [object valueForKey:ivar]
#define setIvar(object, ivar, value) [object setValue:value forKey:ivar]
Expand Down
2 changes: 1 addition & 1 deletion src/crash_reporting/reporting.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define CRASH_REPORT_URL @"https://us-central1-decoded-cove-239422.cloudfunctions.net/process_crash_reports"
#define UPLOADED_LOGS_PLIST_PATH @"/var/mobile/Library/Preferences/com.ethanarbuckle.carplay-uploaded-crashlogs.plist"
#define UPLOADED_LOGS_PLIST_PATH @"/var/mobile/Library/Preferences/com.carplayenable.uploaded-crashlogs.plist"

void symbolicateAndUploadCrashlogs(void);
4 changes: 2 additions & 2 deletions src/hooks/CarPlay.xm
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ When an app is launched via Carplay dashboard
{
LOG_LIFECYCLE_EVENT;
// Notify SpringBoard of the launch. SpringBoard will host the application + UI
[[objc_getClass("NSDistributedNotificationCenter") defaultCenter] postNotificationName:@"com.ethanarbuckle.carplayenable" object:nil userInfo:@{@"identifier": objcInvoke(arg1, @"bundleIdentifier")}];
[[objc_getClass("NSDistributedNotificationCenter") defaultCenter] postNotificationName:@"com.carplayenable" object:nil userInfo:@{@"identifier": objcInvoke(arg1, @"bundleIdentifier")}];

// Add this item into the App History (so it shows up in the dock's "recents")
id sharedApp = [UIApplication sharedApplication];
Expand Down Expand Up @@ -239,7 +239,7 @@ will launch their normal Carplay mode UI
assertGotExpectedObject(icon, @"SBIcon");
NSString *bundleID = objcInvoke(icon, @"applicationBundleID");

[[objc_getClass("NSDistributedNotificationCenter") defaultCenter] postNotificationName:@"com.ethanarbuckle.carplayenable" object:nil userInfo:@{@"identifier": bundleID}];
[[objc_getClass("NSDistributedNotificationCenter") defaultCenter] postNotificationName:@"com.carplayenable" object:nil userInfo:@{@"identifier": bundleID}];

id sharedApp = [UIApplication sharedApplication];
id appHistory = objcInvoke(sharedApp, @"_currentAppHistory");
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/SpringBoard.xm
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Invoked when SpringBoard finishes launching
{
LOG_LIFECYCLE_EVENT;
// Setup to receive App Launch notifications from the CarPlay process
[[objc_getClass("NSDistributedNotificationCenter") defaultCenter] addObserver:self selector:NSSelectorFromString(@"handleCarPlayLaunchNotification:") name:@"com.ethanarbuckle.carplayenable" object:nil];
[[objc_getClass("NSDistributedNotificationCenter") defaultCenter] addObserver:self selector:NSSelectorFromString(@"handleCarPlayLaunchNotification:") name:@"com.carplayenable" object:nil];

NSMutableArray *appIdentifiersToIgnoreLockAssertions = [[NSMutableArray alloc] init];
objc_setAssociatedObject(self, &kPropertyKey_lockAssertionIdentifiers, appIdentifiersToIgnoreLockAssertions, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/UIApplication.xm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ When the app is launched
{
id _self = %orig;
// Register for "orientation change" notifications
[[objc_getClass("NSDistributedNotificationCenter") defaultCenter] addObserver:_self selector:NSSelectorFromString(@"handleRotationRequest:") name:@"com.ethanarbuckle.carplayenable.orientation" object:[[NSBundle mainBundle] bundleIdentifier]];
[[objc_getClass("NSDistributedNotificationCenter") defaultCenter] addObserver:_self selector:NSSelectorFromString(@"handleRotationRequest:") name:@"com.carplayenable.orientation" object:[[NSBundle mainBundle] bundleIdentifier]];
return _self;
}

Expand Down

0 comments on commit 8f30db3

Please sign in to comment.