From 7407adf7c1d111a5a50bf554aeb049fdde26c472 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Sun, 27 Sep 2020 14:01:32 -0500 Subject: [PATCH] Automatically make deb --- json_process.py | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/json_process.py b/json_process.py index 5beaa59..3029884 100644 --- a/json_process.py +++ b/json_process.py @@ -2,17 +2,39 @@ import json import os +import subprocess +import pathlib updir = "CustomUploaders" +control_format = """Package: dev.somnium.{0}-uploadconfig +Name: {1} Config +Depends: dev.somnium.notatio +Version: 1.0.0 +Architecture: iphoneos-arm +Description: {2} upload config for the Notatio upload tweak. +Maintainer: Somnium Tweaks +Author: Somnium Tweaks +Section: Notatio Uploaders +""" + + files = [f for f in os.listdir(updir) if os.path.isfile("{0}/{1}".format(updir, f))] files2 = [f for f in files if f.endswith(".sxcu")] for fname in files2: + dns = fname[:-5] + print("Forward DNS: " + dns) + revdns1 = dns.split('.') + revdns1.reverse() + revdns = '.'.join(revdns1) + print("Reverse DNS: " + revdns) + with open("{0}/{1}".format(updir, fname), "r", encoding="utf-8-sig") as f: rawjson = f.read() conv = json.loads(rawjson) + print("Loaded json") if "FileFormName" in conv.keys(): try: @@ -29,9 +51,24 @@ for fname in files2: conv.pop("DestinationType") except KeyError: pass - - with open("{0}/{1}".format(updir + "-converted", fname), "w+") as f: + + pathlib.Path("pkgs/{0}-uploadconfig/DEBIAN".format(revdns)).mkdir(parents=True, exist_ok=True) + pathlib.Path("pkgs/{0}-uploadconfig/Library/Application Support/Notatio".format(revdns)).mkdir(parents=True, exist_ok=True) + + with open("pkgs/{0}-uploadconfig/DEBIAN/control".format(revdns), "w+") as f: + f.write(control_format.format(revdns, dns, dns)) + print("Created DEBIAN/control") + + with open("/tmp/{0}".format(revdns), "w+") as f: f.write(json.dumps(conv)) + print("Dumped json to /tmp/{0}".format(revdns)) + + subprocess.check_call(['json2plist', '-i', '/tmp/{0}'.format(revdns), '-o', 'pkgs/{0}-uploadconfig/Library/Application Support/Notatio/{1}.plist'.format(revdns, dns)]) + print("Called json2plist") + + subprocess.check_call(['dpkg-deb', '-b', 'pkgs/{0}-uploadconfig']) + print("Called dpkg-deb") + else: print("Skipped {0}".format(fname))