Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- from string import Template
- from sys import argv
- PATCHROOT = "~/CWMARS/files/patches/rel_3_7_3/"
- t1 = Template("""patch -p1 < ${patchfile}""");
- t2 = Template("""[ ! -d ${destdir} ] && mkdir -p ${destdir}
- patch -p1 -o ${destfile} < ${patchfile}""");
- with open(argv[1], "r") as f:
- while True:
- line = f.readline()
- if not line:
- break
- input = line.strip()
- patchpath = PATCHROOT + input
- destfile = input.removesuffix(".patch")
- destdir = None
- if "bootstrap" in destfile:
- destfile = destfile.replace("bootstrap", "bootstrap_cons")
- destdir = destfile[0:destfile.rfind("/")]
- elif "templates" in destfile:
- destfile = destfile.replace("templates", "templates_cons")
- destdir = destfile[0:destfile.rfind("/")]
- if destdir == None:
- print(t1.substitute(patchfile=patchpath))
- else:
- print(t2.substitute(patchfile=patchpath,destdir=destdir,destfile=destfile))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement