2019-01-25 12:48:05 +00:00
|
|
|
#!/bin/env python3
|
2019-01-25 13:19:05 +00:00
|
|
|
import os
|
2019-01-25 12:48:05 +00:00
|
|
|
import sys
|
|
|
|
|
|
|
|
fname = sys.argv[1]
|
2019-01-25 13:19:05 +00:00
|
|
|
persistdir = "/home/ave/distokrepos/versionlogs/"
|
|
|
|
|
|
|
|
|
2019-01-25 13:23:07 +00:00
|
|
|
def counterup(branch="base"):
|
2019-01-25 13:19:05 +00:00
|
|
|
# HACKY
|
2019-01-25 13:23:07 +00:00
|
|
|
cfname = persistdir + fname.split("/")[-1].replace(".patch", "") + branch
|
2019-01-25 13:21:27 +00:00
|
|
|
if os.path.isfile(cfname):
|
2019-01-25 13:19:05 +00:00
|
|
|
with open(cfname, 'r') as file:
|
|
|
|
countdata = file.read()
|
|
|
|
else:
|
2019-01-31 08:45:29 +00:00
|
|
|
countdata = 1000
|
2019-01-25 13:19:05 +00:00
|
|
|
|
|
|
|
countdata = int(countdata) + 1
|
|
|
|
|
|
|
|
with open(cfname, 'w') as file:
|
|
|
|
file.write(str(countdata))
|
|
|
|
|
|
|
|
return countdata
|
|
|
|
|
2019-01-25 12:48:05 +00:00
|
|
|
|
|
|
|
# Read in the file
|
|
|
|
with open(fname, 'r') as file:
|
|
|
|
filedata = file.read()
|
|
|
|
|
2019-06-21 08:29:30 +00:00
|
|
|
name = sys.argv[2].replace("__", " ")
|
2019-01-25 12:48:05 +00:00
|
|
|
|
2019-02-07 19:25:10 +00:00
|
|
|
branch = sys.argv[3]
|
2019-01-25 12:48:05 +00:00
|
|
|
|
2019-01-25 13:23:07 +00:00
|
|
|
buildnum = str(counterup(branch))
|
|
|
|
|
2019-01-25 12:48:05 +00:00
|
|
|
# Replace the target string
|
|
|
|
filedata = filedata.replace("CTCBRANCH", branch)\
|
2019-01-25 13:19:05 +00:00
|
|
|
.replace("CTCBUILD", buildnum)\
|
2019-01-25 12:48:05 +00:00
|
|
|
.replace("CTCNAME", name)
|
|
|
|
|
|
|
|
# Write the file out again
|
|
|
|
with open(fname.replace(".patch", "-custom.patch"), 'w') as file:
|
|
|
|
file.write(filedata)
|