From 5d02aba5d47caefb416ac04425ab216eab77970c Mon Sep 17 00:00:00 2001 From: Ave Ozkal Date: Wed, 23 Jan 2019 01:27:53 +0300 Subject: [PATCH] customversion: Make customversion display more details --- .gitignore | 1 + patches/customversion/832.patch | 2 +- patches/customversion/addpatch.py | 31 +++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 patches/customversion/addpatch.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cf64670 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +patches/customversion/*-custom.patch diff --git a/patches/customversion/832.patch b/patches/customversion/832.patch index 7a2e8ee..eca44e2 100644 --- a/patches/customversion/832.patch +++ b/patches/customversion/832.patch @@ -14,7 +14,7 @@ diff -crB -x dist -x build com.discord-832-base/smali/com/discord/widgets/settin invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; -! const-string v0, " - 8.3.2 (832), with Cutthecord patches applied" +! const-string v0, " - 8.3.2 (832), with Cutthecord patches" invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; \ No newline at end of file diff --git a/patches/customversion/addpatch.py b/patches/customversion/addpatch.py new file mode 100644 index 0000000..3071723 --- /dev/null +++ b/patches/customversion/addpatch.py @@ -0,0 +1,31 @@ +#!/bin/env python3 +import sys +import os +import datetime +import socket + +fname = sys.argv[1] + +# Read in the file +with open(fname, 'r') as file: + filedata = file.read() + +customtext = "" + +for arg in range(2, len(sys.argv)): + customtext += " {},".format(sys.argv[arg]) +customtext = customtext.strip(",") + +timestamp = str(datetime.datetime.utcnow()) + " UTC" + +customtext += ", built on {}@{} at {}".format(os.getlogin(), + socket.gethostname(), + timestamp) + +# Replace the target string +filedata = filedata.replace('with Cutthecord patches"', + 'with Cutthecord patches{}"'.format(customtext)) + +# Write the file out again +with open(fname.replace(".patch", "-custom.patch"), 'w') as file: + file.write(filedata)