Merge pull request #2447 from fufesou/fix_remove_unused_resource_files
remove unused resource files when packing
This commit is contained in:
		
						commit
						5b9142b450
					
				
							
								
								
									
										29
									
								
								build.py
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								build.py
									
									
									
									
									
								
							| @ -38,13 +38,15 @@ def get_version(): | |||||||
| def parse_rc_features(feature): | def parse_rc_features(feature): | ||||||
|     available_features = { |     available_features = { | ||||||
|         'IddDriver': { |         'IddDriver': { | ||||||
|             'zip_url': 'https://github.com/fufesou/RustDeskIddDriver/releases/download/v0.1/RustDeskIddDriver_x64_pic_en.zip', |             'zip_url': 'https://github.com/fufesou/RustDeskIddDriver/releases/download/v0.1/RustDeskIddDriver_x64.zip', | ||||||
|             'checksum_url': 'https://github.com/fufesou/RustDeskTempTopMostWindow/releases/download/v0.1/checksum_md5', |             'checksum_url': 'https://github.com/fufesou/RustDeskIddDriver/releases/download/v0.1/checksum_md5', | ||||||
|  |             'exclude': ['README.md'], | ||||||
|         }, |         }, | ||||||
|         'PrivacyMode': { |         'PrivacyMode': { | ||||||
|             'zip_url': 'https://github.com/fufesou/RustDeskTempTopMostWindow/releases/download/v0.1' |             'zip_url': 'https://github.com/fufesou/RustDeskTempTopMostWindow/releases/download/v0.1' | ||||||
|                        '/TempTopMostWindow_x64_pic_en.zip', |                        '/TempTopMostWindow_x64_pic_en.zip', | ||||||
|             'checksum_url': 'https://github.com/fufesou/RustDeskTempTopMostWindow/releases/download/v0.1/checksum_md5', |             'checksum_url': 'https://github.com/fufesou/RustDeskTempTopMostWindow/releases/download/v0.1/checksum_md5', | ||||||
|  |             'include': ['WindowInjection.dll'], | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     apply_features = {} |     apply_features = {} | ||||||
| @ -142,8 +144,9 @@ def generate_build_script_for_docker(): | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def download_extract_features(features, res_dir): | def download_extract_features(features, res_dir): | ||||||
|     proxy = '' |     import re | ||||||
| 
 | 
 | ||||||
|  |     proxy = '' | ||||||
|     def req(url): |     def req(url): | ||||||
|         if not proxy: |         if not proxy: | ||||||
|             return url |             return url | ||||||
| @ -154,6 +157,11 @@ def download_extract_features(features, res_dir): | |||||||
|             return r |             return r | ||||||
| 
 | 
 | ||||||
|     for (feat, feat_info) in features.items(): |     for (feat, feat_info) in features.items(): | ||||||
|  |         includes = feat_info['include'] if 'include' in feat_info and feat_info['include'] else [] | ||||||
|  |         includes = [ re.compile(p) for p in includes ] | ||||||
|  |         excludes = feat_info['exclude'] if 'exclude' in feat_info and feat_info['exclude'] else [] | ||||||
|  |         excludes = [ re.compile(p) for p in excludes ] | ||||||
|  | 
 | ||||||
|         print(f'{feat} download begin') |         print(f'{feat} download begin') | ||||||
|         download_filename = feat_info['zip_url'].split('/')[-1] |         download_filename = feat_info['zip_url'].split('/')[-1] | ||||||
|         checksum_md5_response = urllib.request.urlopen( |         checksum_md5_response = urllib.request.urlopen( | ||||||
| @ -170,6 +178,21 @@ def download_extract_features(features, res_dir): | |||||||
|                 zip_file = zipfile.ZipFile(filename) |                 zip_file = zipfile.ZipFile(filename) | ||||||
|                 zip_list = zip_file.namelist() |                 zip_list = zip_file.namelist() | ||||||
|                 for f in zip_list: |                 for f in zip_list: | ||||||
|  |                     file_exclude = False | ||||||
|  |                     for p in excludes: | ||||||
|  |                         if p.match(f) is not None: | ||||||
|  |                             file_exclude = True | ||||||
|  |                             break | ||||||
|  |                     if file_exclude: | ||||||
|  |                         continue | ||||||
|  | 
 | ||||||
|  |                     file_include = False if includes else True | ||||||
|  |                     for p in includes: | ||||||
|  |                         if p.match(f) is not None: | ||||||
|  |                             file_include = True | ||||||
|  |                             break | ||||||
|  |                     if file_include: | ||||||
|  |                         print(f'extract file {f}') | ||||||
|                         zip_file.extract(f, res_dir) |                         zip_file.extract(f, res_dir) | ||||||
|                 zip_file.close() |                 zip_file.close() | ||||||
|                 os.remove(download_filename) |                 os.remove(download_filename) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user