Skip to content

Commit 06e005e

Browse files
committed
added minimal option for diff
1 parent 3f7341b commit 06e005e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ It is available a script to build and configure the Python script
1919

2020
options:
2121

22+
-d : use diff with option minimal to reduce the patch size"
2223
-v : verify che correctness of the patch
2324
-V : verify che correctness of the txt patch
2425
-t FILENAME: write the patch in txt format

bpatch.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ def generate_hex_fw(filename, fw_path, fw_header_path, header_fw_size):
554554
if len(sys.argv) < 5:
555555
print("Usage: python3 patch.py encode OLD_FW NEW_FW PATCH [OPTIONS]")
556556
print("Options:"
557+
"\n\t-d : use diff with option minimal to reduce the patch size"
557558
"\n\t-v : verify che correctness of the patch"
558559
"\n\t-V : verify che correctness of the txt patch"
559560
"\n\t-t FILENAME: write the patch in txt format"
@@ -570,6 +571,7 @@ def generate_hex_fw(filename, fw_path, fw_header_path, header_fw_size):
570571
# default values
571572
verify = False
572573
verify_py = False
574+
minimal = False
573575
path_patch_txt = ""
574576
path_patch_bin_txt = ""
575577
path_report_txt = ""
@@ -593,6 +595,9 @@ def generate_hex_fw(filename, fw_path, fw_header_path, header_fw_size):
593595
path_report_txt = sys.argv[i + 1]
594596
elif sys.argv[i] == '-R':
595597
path_report_csv = sys.argv[i + 1]
598+
elif sys.argv[i] == '-d':
599+
minimal = True
600+
596601

597602
except IndexError:
598603
print("Error during parsing arguments")
@@ -614,7 +619,10 @@ def generate_hex_fw(filename, fw_path, fw_header_path, header_fw_size):
614619
if header_custom:
615620
to_remove.extend(["old_fw_header.tmp", "new_fw_header.tmp"])
616621
# compute diff
617-
os.system("diff old_fw.tmp new_fw.tmp > diff.tmp")
622+
if minimal:
623+
os.system("diff -d old_fw.tmp new_fw.tmp > diff.tmp")
624+
else:
625+
os.system("diff old_fw.tmp new_fw.tmp > diff.tmp")
618626
os.system("grep -E '^[0-9,]+[acd][0-9,]+$' diff.tmp > diff_c.tmp")
619627
os.system("grep '^>' diff.tmp | sed 's/^> //' > diff_a.tmp")
620628

0 commit comments

Comments
 (0)