[Feature]add MT2731_MP2_MR2_SVN388 baseline version
Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/src/bach/build.bach/tools/compress/compimg.py b/src/bach/build.bach/tools/compress/compimg.py
new file mode 100755
index 0000000..dea31ed
--- /dev/null
+++ b/src/bach/build.bach/tools/compress/compimg.py
@@ -0,0 +1,62 @@
+#!/usr/bin/python3
+
+import os
+import subprocess
+from argparse import ArgumentParser, RawTextHelpFormatter
+
+class bcolors:
+ HEADER = '\033[95m'
+ OKBLUE = '\033[94m'
+ OKGREEN = '\033[92m'
+ WARNING = '\033[93m'
+ FAIL = '\033[91m'
+ ENDC = '\033[0m'
+ BOLD = '\033[1m'
+ UNDERLINE = '\033[4m'
+
+def parse_arg():
+ arg_parser = ArgumentParser(description = "compress img with MD, DSP",
+ formatter_class = RawTextHelpFormatter)
+
+ arg_parser.add_argument("img_folder", help = "Folder of BACH image")
+ arg_parser.print_help()
+ print()
+ return arg_parser.parse_args()
+
+def check_req(keyword, content):
+ if not keyword in content:
+ print(bcolors.FAIL + keyword + " doesn't exist" + bcolors.ENDC)
+ print()
+ return 1
+ return 0
+
+def check_bundle(content):
+ checksum = 0
+ checksum = checksum | check_req("modem.img", content)
+ checksum = checksum | check_req(".EDB", content)
+ checksum = checksum | check_req("dsp.bin", content)
+ assert checksum == 0, bcolors.FAIL + "\n Please add them into image folder\n You can copy them from BACH official release" + bcolors.ENDC + "\n"
+
+def tar_files(source):
+ cmd = "tar jcvf source.tar.bz2" + source
+ print(cmd)
+ subprocess.call(cmd, shell=True)
+ print(bcolors.OKGREEN + "compressed file is in " + os.getcwd() + bcolors.ENDC)
+
+if __name__ == '__main__':
+ console_args = parse_arg()
+ directory = "./" + console_args.img_folder
+ if not os.path.isdir(directory):
+ print(console_args.img_folder + " doesn't exist")
+ exit(1)
+
+ compress_files = " "
+ for filename in os.listdir(directory):
+ if not os.path.isdir(directory + "/" + filename):
+ compress_files += filename + " "
+
+ check_bundle(compress_files)
+ os.chdir(directory)
+ tar_files(compress_files)
+ # TODO: show final tar file location
+