2020-09-27 12:22:10 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import json
|
|
|
|
import os
|
2020-09-27 14:01:32 -05:00
|
|
|
import subprocess
|
|
|
|
import pathlib
|
2020-09-27 12:22:10 -05:00
|
|
|
|
2020-09-29 17:55:01 -05:00
|
|
|
updir = "sxcu"
|
2020-09-27 14:01:32 -05:00
|
|
|
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
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2020-09-27 12:22:10 -05:00
|
|
|
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:
|
2020-09-27 14:01:32 -05:00
|
|
|
dns = fname[:-5]
|
|
|
|
print("Forward DNS: " + dns)
|
|
|
|
revdns1 = dns.split('.')
|
|
|
|
revdns1.reverse()
|
|
|
|
revdns = '.'.join(revdns1)
|
|
|
|
print("Reverse DNS: " + revdns)
|
|
|
|
|
2020-09-27 12:22:10 -05:00
|
|
|
with open("{0}/{1}".format(updir, fname), "r", encoding="utf-8-sig") as f:
|
|
|
|
rawjson = f.read()
|
|
|
|
|
|
|
|
conv = json.loads(rawjson)
|
2020-09-27 14:01:32 -05:00
|
|
|
print("Loaded json")
|
2020-09-27 12:22:10 -05:00
|
|
|
|
2020-09-27 12:29:42 -05:00
|
|
|
if "FileFormName" in conv.keys():
|
|
|
|
try:
|
|
|
|
conv.pop("Version")
|
|
|
|
except KeyError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
|
|
|
conv.pop("Name")
|
|
|
|
except KeyError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
|
|
|
conv.pop("DestinationType")
|
|
|
|
except KeyError:
|
|
|
|
pass
|
2020-09-27 14:01:32 -05:00
|
|
|
|
|
|
|
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:
|
2020-09-27 12:29:42 -05:00
|
|
|
f.write(json.dumps(conv))
|
2020-09-27 14:01:32 -05:00
|
|
|
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")
|
|
|
|
|
2020-09-27 14:17:16 -05:00
|
|
|
subprocess.check_call(['dpkg-deb', '-b', 'pkgs/{0}-uploadconfig'.format(revdns)])
|
2020-09-27 14:01:32 -05:00
|
|
|
print("Called dpkg-deb")
|
|
|
|
|
2020-09-27 12:29:42 -05:00
|
|
|
|
|
|
|
else:
|
|
|
|
print("Skipped {0}".format(fname))
|