mirror of
https://github.com/NohamR/pyzule-rw.git
synced 2026-10-10 18:39:41 +00:00
refactor: use python zipfile
this might cause some issues with some specific apps bc of that stupid 1980 error thingy, but idc
This commit is contained in:
@@ -27,11 +27,20 @@ def main() -> None:
|
||||
help="a tweak to inject/item to be added to the bundle"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-c", "--compress", metavar="level", type=int, default=6,
|
||||
help="the compression level of the ipa (0-9, defaults to 6)",
|
||||
action="store", choices=range(0, 10)
|
||||
)
|
||||
parser.add_argument(
|
||||
"--ignore-encrypted", action="store_true",
|
||||
help="skip main binary encryption check"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-v", "--version", action="version", version="cyan v1.0b"
|
||||
)
|
||||
|
||||
from cyan import logic
|
||||
logic.main(parser)
|
||||
|
||||
|
||||
@@ -42,24 +42,16 @@ def main(parser: ArgumentParser) -> None:
|
||||
if args.f is not None:
|
||||
app.executable.inject(args.f, tmpdir)
|
||||
|
||||
# done!
|
||||
if OUTPUT_IS_IPA:
|
||||
print("[*] generating ipa..")
|
||||
|
||||
run(
|
||||
["bash", f"{tbhtypes.Executable.install_dir}/tools/compressIPA.sh"],
|
||||
env={
|
||||
"TMPDIR": tmpdir,
|
||||
"OUTPUT": args.o
|
||||
}
|
||||
)
|
||||
|
||||
print(f"[*] generated ipa at {args.o}")
|
||||
else:
|
||||
# create subdirectories if necessary
|
||||
if "/" in args.o:
|
||||
# create subdirectories if necessary
|
||||
if "/" in args.o:
|
||||
os.makedirs(os.path.dirname(args.o), exist_ok=True)
|
||||
|
||||
# done !
|
||||
if OUTPUT_IS_IPA:
|
||||
print("[*] generating ipa..")
|
||||
tbhutils.make_ipa(tmpdir, args.o, args.compress)
|
||||
print(f"[*] generated ipa at {args.o}")
|
||||
else:
|
||||
if os.path.isdir(args.o):
|
||||
shutil.rmtree(args.o)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import zipfile
|
||||
import platform
|
||||
import plistlib
|
||||
import subprocess
|
||||
from glob import glob
|
||||
from glob import glob, iglob
|
||||
from argparse import Namespace
|
||||
from importlib import resources # type: ignore
|
||||
from typing import Optional, Any
|
||||
@@ -150,3 +150,14 @@ def extract_deb(deb: str, tweaks: dict[str, str], tmpdir: str) -> None:
|
||||
print(f"[*] extracted {os.path.basename(deb)}")
|
||||
del tweaks[os.path.basename(deb)]
|
||||
|
||||
|
||||
def make_ipa(tmpdir: str, output: str, level: int) -> None:
|
||||
# ensure names are written as Payload/...
|
||||
os.chdir(tmpdir)
|
||||
|
||||
with zipfile.ZipFile(
|
||||
output, "w", zipfile.ZIP_DEFLATED, compresslevel=level
|
||||
) as zf:
|
||||
for f in iglob("Payload/**", recursive=True):
|
||||
zf.write(f)
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
cd $TMPDIR
|
||||
mkdir -p `dirname $OUTPUT`
|
||||
rm $OUTPUT &> /dev/null
|
||||
zip -r $OUTPUT Payload > /dev/null
|
||||
|
||||
Reference in New Issue
Block a user