32 lines
827 B
Python
32 lines
827 B
Python
|
#!/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)
|