diff --git a/LibChecker/lib_checker.py b/LibChecker/lib_checker.py index f01c0721d2c47546401a348530b35706222c5ef0..fa365a8599b545624aeb8ba702224b90464cc494 100755 --- a/LibChecker/lib_checker.py +++ b/LibChecker/lib_checker.py @@ -119,29 +119,6 @@ def get_platform_info(): # else: # g_ostype = "server" g_ostype = g_inputostype - # print(g_ostype) - -def get_env_info(): - #p_srcpkgver = os.popen('apt-cache showsrc %s | grep \^Version | cut -d '"\ "' -f 2 ' %(src_pkgname)) - #info_list = [x for x in subprocess.getoutput('cat /etc/os-release').split('\n') if '=' in x] - #info_list = os.popen('cat /etc/os-release') - - print("系统信息:") - - #l1 = os.system("cat /etc/os-release") - str1 = os.popen("cat /etc/os-release").read() - str2 = str1.split("\n") - - for s1 in str2: - print("\t", s1) - - #info = dict() - #for i in info_list: - #info[i.split('=')[0].strip()] = i.split('=')[-1].strip().replace('\"', '').replace('\"', '') - - #print(info_list) - - #return info def get_stdjsons_info(json_file_path): @@ -152,8 +129,6 @@ def get_stdjsons_info(json_file_path): g_jsonfile_dict = f_dict lib_basedict = f_dict['libs']['category']['base']['packages'] - # print(type(f_dict.keys())) - # print(f_dict) print("标准信息:") print("\t标准简要信息:") print("\t\t标准号: %s" % f_dict['std_description']['std_number']) @@ -161,10 +136,8 @@ def get_stdjsons_info(json_file_path): print("\t库检查器信息:") print("\t\t检查位置: %s" % f_dict['libs']['lib_location']) - # print("Start Checking: .....: Chapter: %s Category: %s;" %(f_dict['libs']['category']['base']['description']['chapters_number'], f_dict['libs']['category']['base']['description']['chapters_Name'])) def libchecker_environment_init(): - # print("Enter function: libchecker_environment_init") global g_counter_flags # g_inputstrategy = args.strategy # g_inputlevel = args.level @@ -175,7 +148,6 @@ def libchecker_environment_init(): g_counter_flags = {'pkg_counter': {'total': {'all' : 0, 'l1' : 0, 'l2' : 0, 'l3' : 0} , 'passed': {'all': 0, 'l1' : 0, 'l2' : 0, 'l3' : 0}, 'warning': {'all': 0, 'l1' : 0, 'l2' : 0, 'l3' : 0}, 'failed': {'all' : 0, 'l1' : 0, 'l2' : 0, 'l3' : 0} }, 'lib_counter': {'total': 0, 'passed': 0, 'warning': 0, 'failed': 0}} #get_platform_info() - get_env_info() # get_stdjsons_info('../Jsons/lib_list_1.0I-20220914-uos.json') @@ -209,8 +181,6 @@ def check_per_pkg_info(src_pkgname): else: print("Please input --ostype=[desktop,server,embde,...] and --pkgmngr=[apt-deb,yum-rpm,src-bin,...]") - # yum list gcc | awk '{print $2}' | sed -n '3p' - srcpkgver = p_srcpkgver.read().rstrip('\n') p_srcpkgver.close() @@ -219,11 +189,9 @@ def check_per_pkg_info(src_pkgname): g_counter_flags['pkg_counter']['total']['all'] += 1 print("\t\t系统实现: ") - # print(g_pkgversiodict) if (len(srcpkgver) == 0): print("\t\t\t\t没有发现") - # print("\t\t共享库信息:") g_notfind_set_flag = 1 else: print("\t\t\t\t实现包名 -> ", src_pkgname.ljust(20),"实现版本 -> ",srcpkgver) @@ -251,26 +219,11 @@ def check_per_pkg_info(src_pkgname): g_counter_flags['pkg_counter']['passed']['all'] += 1 - # print("\t\tsections_number -->", g_jsonfile_dict[src_pkgname]['sections_number']) - # print(l_tmp_dict[key]['alias'][0]['name']) - # print(g_jsonfile_dict['libs']['category']['base']['packages'].keys()) - - # for list_item in g_jsonfile_dict['libs']['category']['base']['packages'][src_pkgname]['share_objs']['desktop'] - # print("\t\t\t\tlib_soname -> ", list_item,"; " "location -> ",check_sharelib_info('/lib', list_item)) def check_pkginfo_for_desktop(src_pkgname): for src_pkgname in g_jsonfile_dict: check_per_pkg_info(g_jsonfile_dict['libs']['category']['base']['packages'][src_pkgname]['alias'][0]['name']) - # print(g_jsonfile_dict['libs']['category']['base']['packages'][src_pkgname]['alias'][0]['name']) - # print(g_jsonfile_dict['libs']['category']['base']['packages'].keys()) - # print(g_jsonfile_dict[src_pkgname]['libs']['alias'][0]['name']) - # print(g_jsonfile_dict[src_pkgname]) - # print(type(g_jsonfile_dict['libs'][src_pkgname])) - # print(g_jsonfile_dict['libs']['category']['base']['packages']['glibc']['alias'][0]['name']) - # print(src_pkgname) - # print(type(src_pkgname)) - def check_sharelib_info(path_dir, lib_soname): @@ -297,7 +250,6 @@ def check_sharelib_info(path_dir, lib_soname): # return "(\""+ g_lib_location_path + "\")" return g_lib_location_path -# def libchecker_checking_loop(): def libchecker_checking_loop(): global g_notfind_set_flag global g_chapter_dict @@ -648,8 +600,6 @@ def libchecker_read_stdjson(json_file_path): g_pkginfodict_from_json = read_pkginfo_from_stdjson(json_file_path) g_libinfodict_from_json = read_libinfo_from_stdjson(json_file_path) -# print(g_pkginfodict_from_json) -# print(g_libinfodict_from_json) ## 2.3 read metadata info from json file def libchecker_read_std_json(json_file_path): @@ -663,17 +613,8 @@ def libchecker_read_std_json(json_file_path): for i in file_data['libs']['base']: print(i) print(type(file_data['libs']['base'][i])) - #print(file_data['libs']['base'][i]) -# objs_dict = file_data['libs']['base'][i] objs_dict.update({ i : file_data['libs']['base'][i]}) -# print(objs_dict) -# print(type(objs_dict)) -# print(len(objs_dict)) -# print(objs_dict.keys()) - -# j = 'gcc' -# print(objs_dict[j]['lib_name']) del objs_dict['##chapters_number'] del objs_dict['chapters_number'] @@ -687,7 +628,6 @@ def libchecker_read_std_json(json_file_path): aliasname = objs_dict[key]['aliasname'] g_pkginfodict_from_json.update({ aliasname : objs_dict[key]['version']['desktop_version']}) # src package name : pkg version -# print(objs_dict[key]['aliasname']) g_bind_pkglib_from_json.update({ key : objs_dict[key]['desktop-share_objs']}) # src package name : library soname print(g_pkginfodict_from_json) @@ -699,10 +639,6 @@ def libchecker_read_std_json(json_file_path): fobj.close() -# print(f_dict['libs']['base']['glibc']['necessity'].keys()) -# print(f_dict["libchecker"][1]) -# print(f_dict["libchecker"][1]['name']) - # 3. Find Meatdate Info from Current OS ## 3.1 get src package info def get_srcname_from_os(): @@ -789,8 +725,6 @@ def compare_library_version(str1, str2): # @ ret: string: > # @ ret: string: = # @ ret: string: < -# list1 = str(str1).split(".") -# list2 = str(str2).split(".") if str1 == str2: @@ -1051,9 +985,6 @@ def get_libinfo_from_os(): g_libinfodict_from_os[i] = max([s for s in lib_soname_lists if i in s]) return g_libinfodict_from_os -#print(g_pkginfodict_from_json) -#print(g_libinfodict_from_json) -#print(g_bind_pkglib_from_json) def get_liblists_from_os(): print("Enter function: get_liblist_from_os") @@ -1091,26 +1022,6 @@ def get_libinfo_from_os_by_srcpkg(): return g_libinfodict_from_os -#g_pkginfodict_from_os = {} -#g_libinfodict_from_os = {} - -#g_libchecker_comp_status = {} -#print(get_realname_from_srcpkg('ncurses')) -#print(get_soname_from_srcpkg('ncurses')) -#print(get_linkname_from_srcpkg('ncurses')) -#print(read_pkginfo_from_json('std-lib.json')) -#print(read_libinfo_from_json('std-lib.json')) -#print(read_pkginfo_from_json('std-lib.json')) - -#get_libinfo_from_os() -#print(get_libinfo_from_os()) - -#pick_linkname_from_soname('ncurses') -#print(get_soname_from_srcpkg('ncurses')) -#print(pick_linkname_from_soname('ncurses.so.1.9')) -#print(compare_version_serial_number("1.4.3", "2.4.3")) -#libchecker_compare_metainfo() - # 4. Compare Package and Libraries Info ## 4.1 comapre packages between os and json-dict g_pkginfodict_from_json def get_pkg_compare_info(): @@ -1218,7 +1129,6 @@ def libchecker_output_json_file(): # global g_chapter_dict # global g_jsonfile_dict - # print("Enter function: libchecker_output_json_file()") output_info = {} output_data = json.loads(json.dumps(output_info)) @@ -1230,54 +1140,13 @@ def libchecker_output_json_file(): # mateinfo_share_libs = {} # mateinfo_all_info = {} out_data_deep = {} - - # result_dict = libchecker_compare_liblist() - - - # for chapter_class in g_jsonfile_dict['libs']['category']: # chapter_class - # print(chapter_class) - # for key in g_jsonfile_dict['libs']['category'][chapter_class]['packages']: # package_class - # print("\t", key) - #mateinfo.update = { key : g_jsonfile_dict['libs']['category'][chapter_class][key]['packages']['sections_number'] } - # for key1 in g_jsonfile_dict['libs']['category'][chapter_class]['packages'][key]: # sections_number class - # print("\t\t", key1) - # print("\t\t", key1) - # print("\t\t\t",g_jsonfile_dict['libs']['category'][chapter_class]['packages'][key]['sections_number']) -# print("\t\t\t", key1) - # mateinfo_sections_number.update({ key : g_jsonfile_dict['libs']['category'][chapter_class]['packages'][key]['sections_number']}) -# for key1 in g_jsonfile_dict['libs']['category'][chapter_class]['packages']: -# mateinfo_pkgcheck_result.update({ key1 : g_jsonfile_dict['libs']['category'][chapter_class]['packages'][key1]['version']['desktop']}) -# for key1 in g_jsonfile_dict['libs']['category'][chapter_class]['packages']: -# mateinfo_objcheck_result.update({ key1 : g_jsonfile_dict['libs']['category'][chapter_class]['packages'][key1]['share_objs']['desktop']}) - #, "Chapter " : g_jsonfile_dict['libs']['category'][chapter_class][key]['packages']['sections_number']} - #, "Necessity" : chapter_class['packages']['necessity'], "Share Objs" : chapter_class['packages']['share_objs'], "Otherinfo" : "none"} - # mateinfo = { "Package ": g_jsonfile_dict['libs']['category'][chapter_class]['packages'][key]}i - # mateinfo_sections_number.update({ key1 : g_jsonfile_dict['libs']['category'][chapter_class]['packages'][key]['sections_number']}) - - # mateinfo_packages_dict.update({key : mateinfo_sections_number}) - # mateinfo_packages_dict.update({key : mateinfo_sections_number}) - # mateinfo_sections_number.clear() - - # mateinfo_all_info.update({ key : g_jsonfile_dict['libs']['category'][chapter_class]['packages'][key]['sections_number']}) - #mateinfo_packages_dict.update({key : "test"}) - - # mateinfo_all_info.update({chapter_class : mateinfo_packages_dict}) - - #out_data_deep.update({chapter_class : mateinfo_packages_dict}) - # out_data_deep.update({chapter_class : g_genresults_to_json}) - #mateinfo_packages_dict.clear() - - #output_data = {"LibChecker Result" : out_data_deep} + output_data = {"LibChecker Result" : g_genresults_to_json} - - - json_output = json.dumps(out_data_deep, ensure_ascii = False) with open("Outputs/libchecker-output.json","w") as f: json.dump(output_data,f) - #json.dump(out_data_deep,f) def libchecker_json_file_output(): @@ -1321,85 +1190,11 @@ def libchecker_json_file_output(): with open("Output/libchecker-output.json","w") as f: json.dump(output_data,f) -#print(get_realname_from_debpkg('libncurses5')) -#print(get_soname_from_debpkg('libncurses5')) -#print(get_linkname_from_debpkg('libncurses5')) -#print(get_debpkg_from_srcpkg('ncurses')) -#get_pkginfo_from_os('libc6') -#libchecker_read_json_file('std-lib.json') - -#gen_json_file() -#read_json_file('std-lib.json') -#read_json_file('libchecker-out.json') -#libchecker_json_file_output() -#print(compare_library_version("lib.so.6", "lib.so.6")) -#test_function() - -#for key in g_pkginfodict_from_json: -# liblists = get_linkname_from_srcpkg(key) -# for i in g_libinfodict_from_json.keys(): - -#read_json_file('../StdLists/lib_list_1.0I-20220826.json') - -#print(read_pkginfo_from_stdjson('../StdLists/lib_list_1.0I-20220830-uos.json')) -#print(read_libinfo_from_stdjson('../StdLists/lib_list_1.0I-20220830-uos.json')) -#libchecker_read_stdjson('../StdLists/lib_list_1.0I-20220830-uos.json')i - -##libchecker_read_stdjson('StdLists/lib_list_1.0I-20220830-uos.json') -#print(g_pkginfodict_from_json) -#print(g_libinfodict_from_json) -#print(g_bind_pkglib_from_json) - -#g_pkginfodict_from_os = {} -#g_libinfodict_from_os = {} - -#g_libchecker_comp_status = {} -#print(get_realname_from_srcpkg('ncurses')) -#print(get_soname_from_srcpkg('ncurses')) -#print(get_linkname_from_srcpkg('ncurses')) -#print(read_pkginfo_from_json('std-lib.json')) -#print(read_libinfo_from_json('std-lib.json')) -#print(read_pkginfo_from_json('std-lib.json')) - -#get_libinfo_from_os() -#print(get_libinfo_from_os()) - -#pick_linkname_from_soname('ncurses') -#print(get_soname_from_srcpkg('ncurses')) -#print(pick_linkname_from_soname('ncurses.so.1.9')) -#print(compare_version_serial_number("1.4.3", "2.4.3")) -#libchecker_compare_metainfo() -#libchecker_read_std_json('stdlists/lib_list_1.0I.json') -#def read_pkginfo_from_json(json_file_path): -#print(get_pkginfo_from_os()) -#print(get_libinfo_from_os()) - - -#print(get_libinfo_from_os_by_srcpkg()) -#print(g_libinfodict_from_json) -##get_liblists_from_os() -#print(get_liblists_from_stdjson('../StdLists/lib_list_1.0I-20220830-uos.json')) -##get_liblists_from_stdjson('StdLists/lib_list_1.0I-20220830-uos.json') - -#print("g_liblist_from_json") -#print(g_liblist_from_json) -#print("g_liblist_from_os") -#print(g_liblist_from_os) - -##libchecker_compare_liblist() -##libchecker_output_json_file() - libchecker_environment_init() libchecker_checking_loop() -#print(get_env_info()) -#get_env_info() #libchecker_output_json_file() libchecker_over_jobs() -#check_sharelib_info('/lib', 'libanl.so.1' ) - -#print(g_jsonfile_dict['glibc']['share_objs']['desktop']) -# for list_item in g_jsonfile_dict['libs']['category']['base']['packages'][src_pkgname]['share_objs']['desktop'] - +#check_sharelib_info('/lib', 'libanl.so.1' ) \ No newline at end of file