From e57d1ff8ae9061fbbe48c81960979873bbf4cb68 Mon Sep 17 00:00:00 2001 From: Ave Ozkal Date: Fri, 25 Jan 2019 16:19:05 +0300 Subject: [PATCH] branding: Move from timestamp to build counter --- patches/branding/835.patch | 2 +- patches/branding/addpatch.py | 27 +++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/patches/branding/835.patch b/patches/branding/835.patch index c1b2bb2..c583883 100644 --- a/patches/branding/835.patch +++ b/patches/branding/835.patch @@ -45,7 +45,7 @@ diff -crB -x dist -x build com.discord-835-base/AndroidManifest.xml com.discord- --- 1,4 ---- -! +! diff --git a/patches/branding/addpatch.py b/patches/branding/addpatch.py index 46029e9..4b51bb9 100644 --- a/patches/branding/addpatch.py +++ b/patches/branding/addpatch.py @@ -1,25 +1,44 @@ #!/bin/env python3 +import os import sys -import time fname = sys.argv[1] +persistdir = "/home/ave/distokrepos/versionlogs/" + + +def counterup(): + # HACKY + cfname = persistdir + fname.split("/")[-1].replace(".patch", "") + if os.path.isfile(fname): + with open(cfname, 'r') as file: + countdata = file.read() + else: + countdata = 0 + + countdata = int(countdata) + 1 + + with open(cfname, 'w') as file: + file.write(str(countdata)) + + return countdata + # Read in the file with open(fname, 'r') as file: filedata = file.read() -timestamp = str(time.time()).split(".")[0] +buildnum = counterup() name = "CutTheCord" branch = "base" if "customtheme" in sys.argv: branch = "themed" - name += " Themed" + # name += " Themed" # Replace the target string filedata = filedata.replace("CTCBRANCH", branch)\ - .replace("CTCTIMESTAMP", timestamp)\ + .replace("CTCBUILD", buildnum)\ .replace("CTCNAME", name) # Write the file out again