feat: remove watch apps

This commit is contained in:
zx
2024-09-06 00:04:23 -04:00
parent 9d3f12f447
commit df3ec4ba2b
4 changed files with 43 additions and 0 deletions

View File

@@ -27,6 +27,11 @@ def main() -> None:
help="a tweak to inject/item to be added to the bundle"
)
parser.add_argument(
"-w", "--no-watch", action="store_true",
help="remove all watch apps"
)
parser.add_argument(
"-c", "--compress", metavar="level", type=int, default=6,
help="the compression level of the ipa (0-9, defaults to 6)",

View File

@@ -41,6 +41,9 @@ def main(parser: ArgumentParser) -> None:
if args.f is not None:
app.executable.inject(args.f, tmpdir)
if args.no_watch:
app.remove_watch_apps()
# create subdirectories if necessary
if "/" in args.o:
os.makedirs(os.path.dirname(args.o), exist_ok=True)

View File

@@ -1,3 +1,6 @@
import os
import shutil
from cyan.tbhutils import get_plist
from .executable import Executable
@@ -12,3 +15,26 @@ class AppBundle:
path
)
def remove(self, name: str) -> bool:
path = f"{self.path}/{name}"
if not os.path.exists(path):
return False
try:
shutil.rmtree(path)
except NotADirectoryError:
os.remove(path)
return True
def remove_watch_apps(self) -> None:
removed = False
for name in ("Watch", "WatchKit", "com.apple.WatchPlaceholder"):
if self.remove(name):
removed = True
if removed:
print("[*] removed watch app")
else:
print("[?] watch app not present")