@@ -769,6 +769,27 @@ def find_meta_lic_files():
769769 if lic_list :
770770 lic = ',' .join (lic_list )
771771 meta_lic_files [key ] = lic
772+
773+
774+ def create_and_move_notice_zip (notice_files , zip_file_path , destination_folder ):
775+ notice_files_list = [file_path .strip () for file_path in notice_files .split ("," )]
776+ num_of_notice_file = len (notice_files_list )
777+ final_destination_file_name = ""
778+ if len (notice_files_list ) == 0 :
779+ print (f"There is no notice file at all." )
780+ elif len (notice_files_list ) == 1 :
781+ single_file_path = notice_files_list [0 ]
782+ destination_path = os .path .join (destination_folder , os .path .basename (single_file_path ))
783+ shutil .copy (single_file_path , destination_path )
784+ final_destination_file_name = destination_path
785+ print (f"Notice file is copied to '{ destination_path } '." )
786+ else :
787+ with zipfile .ZipFile (zip_file_path , 'w' ) as zipf :
788+ for single_file_path in notice_files_list :
789+ zipf .write (single_file_path , arcname = os .path .basename (single_file_path ))
790+ final_destination_file_name = zip_file_path
791+
792+ return num_of_notice_file , final_destination_file_name
772793
773794
774795def main ():
@@ -792,6 +813,7 @@ def main():
792813 now = datetime .now ().strftime ('%y%m%d_%H%M' )
793814 log_txt_file = os .path .join (python_script_dir , f"fosslight_log_android_{ now } .txt" )
794815 result_excel_file_name = os .path .join (python_script_dir , f"fosslight_report_android_{ now } " )
816+ result_notice_zip_file_name = os .path .join (python_script_dir , f"notice_to_fosslight-hub_{ now } .zip" )
795817 remove_list_file = ""
796818
797819 parser = argparse .ArgumentParser (description = 'FOSSLight Android' , prog = 'fosslight_android' , add_help = False )
@@ -875,13 +897,21 @@ def main():
875897 set_oss_name_by_repository ()
876898 if analyze_source :
877899 from ._src_analysis import find_item_to_analyze
878- final_bin_info = find_item_to_analyze (final_bin_info , python_script_dir , now , path_to_exclude )
879-
900+ final_bin_info = find_item_to_analyze (final_bin_info , python_script_dir , now , path_to_exclude )
901+
902+ num_of_notice_file , destination_file = create_and_move_notice_zip (notice_files , result_notice_zip_file_name , python_script_dir )
903+
880904 scan_item = ScannerItem (PKG_NAME , now )
881905 scan_item .set_cover_pathinfo (android_src_path , "" )
882906
883907 scan_item .set_cover_comment (f"Total number of binaries: { len (final_bin_info )} " )
884- scan_item .set_cover_comment (f"\n Notice: { notice_files } " )
908+ if num_of_notice_file == 0 :
909+ logger .info (f"There is no notice file at all." )
910+ scan_item .set_cover_comment (f"\n There is no notice file at all." )
911+ else :
912+ logger .info (f"Notice file to upload FOSSLight Hub: { destination_file } " )
913+ scan_item .set_cover_comment (f"\n Notice file to upload FOSSLight Hub: { destination_file } " )
914+
885915 scan_item .append_file_items (final_bin_info , PKG_NAME )
886916 success , msg , result_file = write_output_file (result_excel_file_name , RESULT_FILE_EXTENSION ,
887917 scan_item , HEADER , HIDDEN_HEADER )
0 commit comments