3030SPDX_REPLACE_WORDS = ["(" , ")" ]
3131KEY_AND = r"(?<=\s)and(?=\s)"
3232KEY_OR = r"(?<=\s)or(?=\s)"
33+ GPL_LICENSE_PATTERN = r'((a|l)?gpl|gfdl)' # GPL, LGPL, AGPL, GFDL
34+
35+
36+ def is_gpl_family_license (licenses : list ) -> bool :
37+ if not licenses :
38+ return False
39+
40+ for license_name in licenses :
41+ if not license_name :
42+ continue
43+
44+ license_lower = license_name .lower ()
45+ if re .search (GPL_LICENSE_PATTERN , license_lower ):
46+ logger .debug (f"GPL family license detected: { license_name } " )
47+ return True
48+
49+ return False
50+
51+
52+ def should_remove_copyright_for_gpl_license_text (licenses : list , is_license_text : bool ) -> bool :
53+ return is_license_text and is_gpl_family_license (licenses )
3354
3455
3556def get_error_from_header (header_item : list ) -> Tuple [bool , str ]:
@@ -100,8 +121,6 @@ def parsing_scancode_32_earlier(scancode_file_list: list, has_error: bool = Fals
100121 pass
101122 copyright_value_list .append (copyright_data )
102123
103- result_item .copyright = copyright_value_list
104-
105124 # Set the license value
106125 license_detected = []
107126 if licenses is None or licenses == "" :
@@ -165,14 +184,21 @@ def parsing_scancode_32_earlier(scancode_file_list: list, has_error: bool = Fals
165184 if len (license_detected ) > 0 :
166185 result_item .licenses = license_detected
167186
187+ if is_manifest_file (file_path ):
188+ result_item .is_license_text = True
189+
190+ # Remove copyright info for license text file of GPL family
191+ if should_remove_copyright_for_gpl_license_text (license_detected , result_item .is_license_text ):
192+ logger .debug (f"Removing copyright for GPL family license text file: { file_path } " )
193+ result_item .copyright = []
194+ else :
195+ result_item .copyright = copyright_value_list
196+
168197 if len (license_expression_list ) > 0 :
169198 license_expression_list = list (
170199 set (license_expression_list ))
171200 result_item .comment = ',' .join (license_expression_list )
172201
173- if is_manifest_file (file_path ):
174- result_item .is_license_text = True
175-
176202 if is_exclude_file (file_path , prev_dir , prev_dir_value ):
177203 result_item .exclude = True
178204 scancode_file_item .append (result_item )
@@ -227,7 +253,6 @@ def parsing_scancode_32_later(
227253 except Exception :
228254 pass
229255 copyright_value_list .append (copyright_data )
230- result_item .copyright = copyright_value_list
231256
232257 license_detected = []
233258 licenses = file .get ("license_detections" , [])
@@ -263,6 +288,20 @@ def parsing_scancode_32_later(
263288 license_list [lic_matched_key ] = lic_info
264289 license_detected .append (found_lic )
265290 result_item .licenses = license_detected
291+
292+ result_item .exclude = is_exclude_file (file_path )
293+ result_item .is_license_text = file .get ("percentage_of_license_text" , 0 ) > 90 or is_notice_file (file_path )
294+
295+ if is_manifest_file (file_path ) and len (license_detected ) > 0 :
296+ result_item .is_license_text = True
297+
298+ # Remove copyright info for license text file of GPL family
299+ if should_remove_copyright_for_gpl_license_text (license_detected , result_item .is_license_text ):
300+ logger .debug (f"Removing copyright for GPL family license text file: { file_path } " )
301+ result_item .copyright = []
302+ else :
303+ result_item .copyright = copyright_value_list
304+
266305 if len (license_detected ) > 1 :
267306 license_expression_spdx = file .get ("detected_license_expression_spdx" , "" )
268307 license_expression = file .get ("detected_license_expression" , "" )
@@ -271,12 +310,6 @@ def parsing_scancode_32_later(
271310 if license_expression :
272311 result_item .comment = license_expression
273312
274- result_item .exclude = is_exclude_file (file_path )
275- result_item .is_license_text = file .get ("percentage_of_license_text" , 0 ) > 90 or is_notice_file (file_path )
276-
277- if is_manifest_file (file_path ) and len (license_detected ) > 0 :
278- result_item .is_license_text = True
279-
280313 scancode_file_item .append (result_item )
281314 except Exception as ex :
282315 msg .append (f"Error Parsing item: { ex } " )
0 commit comments