mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
ROMFS pruner: Kick out excluded files
This commit is contained in:
@@ -56,6 +56,8 @@ def main():
|
|||||||
parser = argparse.ArgumentParser(description="ROMFS pruner.")
|
parser = argparse.ArgumentParser(description="ROMFS pruner.")
|
||||||
parser.add_argument('--folder', action="store",
|
parser.add_argument('--folder', action="store",
|
||||||
help="ROMFS scratch folder.")
|
help="ROMFS scratch folder.")
|
||||||
|
parser.add_argument('--board', action="store",
|
||||||
|
help="Board architecture for this run")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# go through temp folder
|
# go through temp folder
|
||||||
@@ -80,8 +82,11 @@ def main():
|
|||||||
|
|
||||||
# read file line by line
|
# read file line by line
|
||||||
pruned_content = ""
|
pruned_content = ""
|
||||||
|
board_excluded = False
|
||||||
with open(file_path, "rU") as f:
|
with open(file_path, "rU") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
|
if re.search(r'\b{0} exclude\b'.format(args.board),line):
|
||||||
|
board_excluded = True;
|
||||||
# handle mixer files differently than startup files
|
# handle mixer files differently than startup files
|
||||||
if file_path.endswith(".mix"):
|
if file_path.endswith(".mix"):
|
||||||
if line.startswith(("Z:", "M:", "R: ", "O:", "S:", "H:", "T:", "P:")):
|
if line.startswith(("Z:", "M:", "R: ", "O:", "S:", "H:", "T:", "P:")):
|
||||||
@@ -90,10 +95,15 @@ def main():
|
|||||||
if not line.isspace() \
|
if not line.isspace() \
|
||||||
and not line.strip().startswith("#"):
|
and not line.strip().startswith("#"):
|
||||||
pruned_content += line.strip() + "\n"
|
pruned_content += line.strip() + "\n"
|
||||||
|
# delete the file if it doesn't contain the architecture
|
||||||
|
# write out the pruned content else
|
||||||
|
if not board_excluded:
|
||||||
# overwrite old scratch file
|
# overwrite old scratch file
|
||||||
with open(file_path, "wb") as f:
|
with open(file_path, "wb") as f:
|
||||||
pruned_content = re.sub("\r\n", "\n", pruned_content)
|
pruned_content = re.sub("\r\n", "\n", pruned_content)
|
||||||
f.write(pruned_content.encode("ascii", errors='strict'))
|
f.write(pruned_content.encode("ascii", errors='strict'))
|
||||||
|
else:
|
||||||
|
os.remove(file_path)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user