2019-01-22 22:27:53 +00:00
|
|
|
#!/bin/env python3
|
|
|
|
import sys
|
2019-01-22 23:13:22 +00:00
|
|
|
import getpass
|
2019-01-22 22:27:53 +00:00
|
|
|
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(",")
|
|
|
|
|
2019-01-22 22:29:16 +00:00
|
|
|
timestamp = str(datetime.datetime.utcnow()).split('.')[0] + " UTC"
|
2019-01-22 22:27:53 +00:00
|
|
|
|
2019-01-22 23:13:22 +00:00
|
|
|
try:
|
|
|
|
uname = getpass.getuser()
|
|
|
|
except:
|
|
|
|
uname = "unknown"
|
|
|
|
|
|
|
|
hostname = socket.gethostname().split(".")[0]
|
|
|
|
|
|
|
|
customtext += ", built on {}@{} at {}".format(uname,
|
|
|
|
hostname,
|
2019-01-22 22:27:53 +00:00
|
|
|
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)
|