FOSSology  4.4.0
Open Source License Compliance by Open Source Software
fo_mapping_license.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2013 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
15 /*
16 $PREFIX = "/usr/local/";
17 require_once("$PREFIX/share/fossology/lib/php/common.php");
18 */
19 
20 /*
21 $Usage = "Usage: " . basename($argv[0]) . "
22  -s old license
23  -t new license
24  -h help
25  ";
26 
27 $options = getopt("s:t:h");
28 
29 if (empty($options) || !is_array($options))
30 {
31  print $Usage;
32  return 1;
33 }
34 */
35 
43 function renameLicenses21to22($verbose)
44 {
45  /* PLEASE PUT THE LICENSE MAP THERE */
46  /* will replace old_shortname with new_shortname in the later process */
47  $shortname_array = array(
48  /* old_shortname => new_shortname */
49  'Adaptive' => 'APL-1.0',
50  'Adaptive_v1.0' => 'APL-1.0',
51  'Adobe-AFM' => 'AdobeAFM',
52  'Affero' => 'AGPL',
53  'Affero_v1' => 'AGPL-1.0',
54  'Affero_v3' => 'AGPL-3.0',
55  'Affero_v3+' => 'AGPL-3.0+',
56  'AFL 1.1' => 'AFL-1.1',
57  'AFL 1.2' => 'AFL-1.2',
58  'AFL 2.0' => 'AFL-2.0',
59  'AFL 2.1' => 'AFL-2.1',
60  'AFL 3.0' => 'AFL-3.0',
61  'AFL_v1.1' => 'AFL-1.1',
62  'AFL_v1.2' => 'AFL-1.2',
63  'AFL_v2.0' => 'AFL-2.0',
64  'AFL_v2.1' => 'AFL-2.1',
65  'AFL_v3.0' => 'AFL-3.0',
66  'AGPL 1.0' => 'AGPL-1.0',
67  'AGPL 3.0' => 'AGPL-3.0',
68  'Alfresco FLOSS' => 'Alfresco-FLOSS',
69  'Apache 1.1' => 'Apache-1.1',
70  'Apache2.0' => 'Apache-2.0',
71  'Apache_v1.0' => 'Apache-1.0',
72  'Apache_v1.1' => 'Apache-1.1',
73  'Apache_v2.0' => 'Apache-2.0',
74  'Apache_v2-possibility' => 'Apache-2.0-possibility',
75  'Apple' => 'APSL-2.0',
76  'APSL1.0' => 'APSL-1.0',
77  'APSL1.1' => 'APSL-1.1',
78  'APSL1.2' => 'APSL-1.2',
79  'APSL_v1.0' => 'APSL-1.0',
80  'APSL_v1.1' => 'APSL-1.1',
81  'APSL_v1.2' => 'APSL-1.2',
82  'APSL_v2.0' => 'APSL-2.0',
83  'Aptana' => 'Aptana-1.0',
84  'Aptana-PL_v1.0' => 'Aptana-1.0',
85  'Artistic1.0' => 'Artistic-1.0',
86  'Artistic2.0' => 'Artistic-2.0',
87  'Artistic_v2.0' => 'Artistic-2.0',
88  'Ascender' => 'Ascender-EULA',
89  'ATI EULA' => 'ATI-EULA',
90  'ATT-Source_v1.2d' => 'ATT-Source-1.2d',
91  'BitTorrent' => 'BitTorrent-1.1',
92  'BitTorrent1.0' => 'BitTorrent-1.0',
93  'BitTorrent_v1.1' => 'BitTorrent-1.1',
94  'Boost' => 'BSL-1.0',
95  'Boost-style' => 'BST-style',
96  'Boost_v1.0' => 'BST-1.0',
97  'BSD Doc' => 'BSD-Doc',
98  'CA1.1' => 'CATOSL-1.1',
99  'CCA' => 'CC-BY',
100  'CCA1.0' => 'CC-BY-1.0',
101  'CCA2.5' => 'CC-BY-2.5',
102  'CCA3.0' => 'CC-BY-3.0',
103  'CCA-SA' => 'CC-BY-SA',
104  'CCA-SA1.0' => 'CC-BY-SA-1.0',
105  'CCA-SA2.5' => 'CC-BY-SA-2.5',
106  'CCA-SA3.0' => 'CC-BY-SA-3.0',
107  'CCA-SA_v1.0' => 'CC-BY-SA-1.0',
108  'CCA-SA_v2.5' => 'CC-BY-SA-2.5',
109  'CCA-SA_v3.0' => 'CC-BY-SA-3.0',
110  'CCA_v2.5' => 'CC-BY-2.5',
111  'CC-GPL' => 'GPL',
112  'CCGPL2.1' => 'LGPL-2.1',
113  'CC-GPL_v2' => 'GPL-2.0',
114  'CC-LGPL' => 'LGPL',
115  'CC-LGPL_v2.1' => 'LGPL-2.1',
116  'CCPL' => 'CC-BY',
117  'CCPL_v2.0' => 'CC-BY-2.0',
118  'CCPL_v2.5' => 'CC-BY-2.5',
119  'CCPL_v3.0' => 'CC-BY-3.0',
120  'CDDL1.0' => 'CDDL-1.0',
121  'CDDL_v1.0' => 'CDDL-1.0',
122  'CeCILL1.0' => 'CECILL-1.0',
123  'Cecill1.1' => 'CECILL-1.1',
124  'CeCILL2.0' => 'CECILL-2.0',
125  'CeCILL-B' => 'CECILL-B',
126  'CeCILL-C' => 'CECILL-C',
127  'CeCILL_v1.1' => 'CECILL-1.1',
128  'CeCILL_v2' => 'CECILL-2.0',
129  'CeCILL_v2.0' => 'CECILL-2.0',
130  'Condor' => 'Condor-1.1',
131  'CPAL 1.0' => 'CPAL-1.0',
132  'CPAL_v1.0' => 'CPAL-1.0',
133  'CPL0.5' => 'CPL-0.5',
134  'CPL1.0' => 'CPL-1.0',
135  'CPL_v0.5' => 'CPL-0.5',
136  'CPL_v1.0' => 'CPL-1.0',
137  'CPOL1.2' => 'CPOL-1.02',
138  'CUA' => 'CUA-OPL-1.0',
139  'CUA_v1.0' => 'CUA-OPL-1.0',
140  'DataGrid' => 'EUDatagrid',
141  'DOCBOOK' => 'Docbook',
142  'ECL1.0' => 'ECL-1.0',
143  'ECL2.0' => 'ECL-2.0',
144  'Eclipse' => 'EPL-1.0',
145  'Eclipse_v1.0' => 'EPL-1.0',
146  'Eiffel1.0' => 'EFL-1.0',
147  'Eiffel2.0' => 'EFL-2.0',
148  'Eiffel_v1' => 'EFL-1.0',
149  'Eiffel_v2' => 'EFL-2.0',
150  'Entessa1.0' => 'Entessa',
151  'EU-DataGrid' => 'EUDatagrid',
152  'Fedora-CLA' => 'FedoraCLA',
153  'Frameworx1.0' => 'Frameworx-1.0',
154  'Frameworx_v1.0' => 'Frameworx-1.0',
155  'FreeArt' => 'Free-Art-1.3',
156  'Free-Art_v1.0' => 'Free-Art-1.0',
157  'Free-Art_v1.3' => 'Free-Art-1.3',
158  'Freetype' => 'FTL',
159  'FreeType' => 'FTL',
160  'Freetype-style' => 'FTL-style',
161  'GFDL' => 'GFDL-1.1',
162  'GFDL1.2' => 'GFDL-1.2',
163  'GFDL1.3' => 'GFDL-1.3',
164  'GFDL_v1.1' => 'GFDL-1.1',
165  'GFDL_v1.1+' => 'GFDL-1.1+',
166  'GFDL_v1.2' => 'GFDL-1.2',
167  'GFDL_v1.2+' => 'GFDL-1.2+',
168  'Ghostscript-GPL_v1.1' => 'Ghostscript-GPL-1.1',
169  'GPL1.0' => 'GPL-1.0',
170  'GPL2.0' => 'GPL-2.0',
171  'GPL3.0' => 'GPL-3.0',
172  'GPL_v1' => 'GPL-1.0',
173  'GPL_v1+' => 'GPL-1.0+',
174  'GPL_v1-possibility' => 'GPL-1.0-possibility',
175  'GPL_v2' => 'GPL-2.0',
176  'GPL_v2+' => 'GPL-2.0+',
177  'GPL_v2.1' => 'GPL-2.1',
178  'GPL_v2.1+' => 'GPL-2.1+',
179  'GPLv2+KDEupgradeClause' => 'GPL-2.0+KDEupgradeClause',
180  'GPL_v2-possibility' => 'GPL-2.0-possibility',
181  'GPL_v2:v3' => 'GPL-2.0:3.0',
182  'GPL_v3' => 'GPL-3.0',
183  'GPL_v3+' => 'GPL-3.0+',
184  'gSOAP' => 'gSOAP-1.3a',
185  'gSOAP_v1.3' => 'gSOAP-1.3b',
186  'Helix/RealNetworks EULA' => 'Helix/RealNetworks-EULA',
187  'IBM' => 'IPL-1.0',
188  'IBM-PL' => 'IPL',
189  'IBM-PL_v1.0' => 'IPL-1.0',
190  'IDPL_v1.0' => 'IDPL-1.0',
191  'InnerNet_v2.00' => 'InnerNet-2.00',
192  'Intel-EULA' => 'Intel',
193  'Intel' => 'Intel-EULA',
194  'Interbase-PL' => 'Interbase',
195  'Jabber' => 'Jabber-1.0',
196  'LaTeX1.0' => 'LPPL-1.0',
197  'LaTeX1.1' => 'LPPL-1.1',
198  'LaTeX1.2' => 'LPPL-1.2',
199  'LaTeX1.3' => 'LPPL-1.3',
200  'LaTeX1.3a' => 'LPPL-1.3a',
201  'LaTeX1.3b' => 'LPPL-1.3b',
202  'LaTeX1.3c' => 'LPPL-1.3c',
203  'LDP_v1A' => 'LDP-1A',
204  'LDP_v2.0' => 'LDP-2.0',
205  'LGPL2.1' => 'LGPL-2.1',
206  'LGPL3.0' => 'LGPL-3.0',
207  'LGPL_v1' => 'LGPL-1.0',
208  'LGPL_v1+' => 'LGPL-1.0+',
209  'LGPL_v2' => 'LGPL-2.0',
210  'LGPL_v2+' => 'LGPL-2.0+',
211  'LGPL_v2.1' => 'LGPL-2.1',
212  'LGPL_v2.1+' => 'LGPL-2.1+',
213  'LGPL_v2.1-possibility' => 'LGPL-2.1-possibility',
214  'LGPL_v2-possibility' => 'LGPL-2.0-possibility',
215  'LGPL_v3' => 'LGPL-3.0',
216  'LGPL_v3?' => 'LGPL-3?',
217  'LGPL_v3+' => 'LGPL-3.0+',
218  'LGPL_v3-possibility' => 'LGPL-3.0-possibility',
219  'LPPL_v1.0' => 'LPPL-1.0',
220  'LPPL_v1.0+' => 'LPPL-1.0+',
221  'LPPL_v1.1' => 'LPPL-1.1',
222  'LPPL_v1.1+' => 'LPPL-1.1+',
223  'LPPL_v1.2' => 'LPPL-1.2',
224  'LPPL_v1.2+' => 'LPPL-1.2+',
225  'LPPL_v1.3' => 'LPPL-1.3',
226  'LPPL_v1.3+' => 'LPPL-1.3+',
227  'LPPL_v1.3a' => 'LPPL-1.3a',
228  'LPPL_v1.3a+' => 'LPPL-1.3a+',
229  'LPPL_v1.3b' => 'LPPL-1.3b',
230  'LPPL_v1.3b+' => 'LPPL-1.3b+',
231  'LPPL_v1.3c' => 'LPPL-1.3c',
232  'LPPL_v1.3c+' => 'LPPL-1.3c+',
233  'Lucent1.0' => 'LPL-1.0',
234  'Lucent1.02' => 'LPL-1.02',
235  'Lucent_v1.0' => 'LPL-1.0',
236  'Lucent_v1.02' => 'LPL-1.02',
237  'Majordomo' => 'Majordomo-1.1',
238  'Majordomo_v1.1' => 'Majordomo-1.1',
239  'MetroLink1.0' => 'MetroLink-1.0',
240  'Motosoto_v0.9.1' => 'Motosoto',
241  'Mozilla1.0' => 'MPL-1.0',
242  'Mozilla1.1' => 'MPL-1.1',
243  'MozillaEULA1.1' => 'MPL-EULA-1.1',
244  'MozillaEULA2.0' => 'MPL-EULA-2.0',
245  'MozillaEULA3.0' => 'MPL-EULA-3.0',
246  'MPL-EULA_v1.1' => 'MPL-EULA-1.1',
247  'MPL-EULA_v3.0' => 'MPL-EULA-3.0',
248  'MPL/TPL_v1.0' => 'MPL/TPL-1.0',
249  'MPL_v1.0' => 'MPL-1.0',
250  'MPL_v1.1' => 'MPL-1.1',
251  'MPL_v1.1+' => 'MPL-1.1+',
252  'MPL_v2.0' => 'MPL-2.0',
253  'Ms-EULA' => 'MS-EULA',
254  'Ms-indemnity' => 'MS-indemnity',
255  'Ms-IP' => 'MS-IP',
256  'Ms-LPL' => 'MS-LPL',
257  'Ms-LRL' => 'MS-LRL',
258  'Ms-PL' => 'MS-PL',
259  'Ms-RL' => 'MS-RL',
260  'MySQL_v0.3' => 'MySQL-0.3',
261  'NASA1.3' => 'NASA-1.3',
262  'NASA_v1.3' => 'NASA-1.3',
263  'Naumen' => 'NAUMEN',
264  'NAUMEN' => 'Naumen',
265  'Nethack' => 'NGPL',
266  'Netizen' => 'NOSL',
267  'Netizen1.0' => 'NOSL',
268  'Netscape' => 'NPL-1.0',
269  'Netscape1.1' => 'NPL-1.1',
270  'Nokia_v1.0a' => 'Nokia-1.0a',
271  'NoLicenseFound' => 'No_license_found',
272  'NPL_v1.0' => 'NPL-1.0',
273  'NPL_v1.1' => 'NPL-1.1',
274  'Nvidia-EULA' => 'NvidiaEULA',
275  'NvidiaEULA' => 'Nvidia-EULA',
276  'OCLC_v1.0' => 'OCLC-1.0',
277  'OCLC_v2.0' => 'OCLC-2.0',
278  'OpenLDAP' => 'OLDAP',
279  'OpenLDAP2.8' => 'OLDAP-2.8',
280  'OpenLDAP_v1.2' => 'OLDAP-1.2',
281  'OpenLDAP_v2.7' => 'OLDAP-2.7',
282  'OpenLDAP_v2.8' => 'OLDAP-2.8',
283  'OpenPL' => 'OPL-1.0',
284  'Open-PL_v1.0' => 'Open-PL-1.0',
285  'OpenPublication' => 'Open-PL-1.0',
286  'Open-Publication' => 'Open-PL-1.0',
287  'Open-Publication-style' => 'Open-PL-style',
288  'Open-Publication_v1.0' => 'Open-PL-1.0',
289  'OpenSoftware' => 'OSL-1.0',
290  'OpenSoftware1.1' => 'OSL-1.1',
291  'OpenSoftware2.0' => 'OSL-2.0',
292  'OpenSoftware2.1' => 'OSL-2.1',
293  'OpenSoftware3.0' => 'OSL-3.0',
294  'Oracle-Dev' => 'OracleDev',
295  'OracleDev' => 'Oracle-Dev',
296  'OSL_v1.0' => 'OSL-1.0',
297  'OSL_v1.1' => 'OSL-1.1',
298  'OSL_v2.0' => 'OSL-2.0',
299  'OSL_v2.1' => 'OSL-2.1',
300  'OSL_v3.0' => 'OSL-3.0',
301  'Phorum2.0' => 'Phorum-2.0',
302  'PHP2.02' => 'PHP-2.02',
303  'PHP3.01' => 'PHP-3.01',
304  'PHP_v2.0' => 'PHP-2.0',
305  'PHP_v2.0.2' => 'PHP-2.0.2',
306  'PHP_v3.0' => 'PHP-3.0',
307  'PHP_v3.01' => 'PHP-3.01',
308  'Pixware-EULA' => 'Pixware',
309  'Pixware' => 'Pixware-EULA',
310  'Public-Use_v1.0' => 'Public-Use-1.0',
311  'Python2.0.1' => 'Python-2.0.1',
312  'Python2.1.3' => 'Python-2.1.3',
313  'Python2.2.3' => 'Python-2.2.3',
314  'Python2.3.7' => 'Python-2.3.7',
315  'Python2.4.4' => 'Python-2.4.4',
316  'Python2.5' => 'Python-2.5',
317  'Python2.6.5' => 'Python-2.6.5',
318  'Python2.7' => 'Python-2.7',
319  'Python3.1.1' => 'Python-3.1.1',
320  'Python_v2' => 'Python-2.0',
321  'Python_v2.0.1' => 'Python-2.0.1',
322  'Python_v2.1.1' => 'Python-2.1.1',
323  'Python_v2.1.3' => 'Python-2.1.3',
324  'Python_v2.2' => 'Python-2.2',
325  'Python_v2.2.3' => 'Python-2.2.3',
326  'Python_v2.3' => 'Python-2.3',
327  'Python_v2.3.7' => 'Python-2.3.7',
328  'Python_v2.4.4' => 'Python-2.4.4',
329  'QPL' => 'QPL-1.0',
330  'QPL_v1.0' => 'QPL-1.0',
331  'QT' => 'QT(Commercial)',
332  'Qt(Commercial)' => 'QT(Commercial)',
333  'RCSL_v3.0' => 'RCSL',
334  'RealNetworks-EULA' => 'RealNetworks',
335  'RealNetworks' => 'RealNetworks-EULA',
336  'RedHat-EULA' => 'RedHatEULA',
337  'RedHatEULA' => 'RedHat-EULA',
338  'Ricoh' => 'RSCPL',
339  'Ricoh_v1.0' => 'RSCPL-1.0',
340  'RPL1.1' => 'RPL-1.1',
341  'RPL1.5' => 'RPL-1.5',
342  'RPL_v1.1' => 'RPL-1.1',
343  'RPL_v1.5' => 'RPL-1.5',
344  'RPSL1.0' => 'RPSL-1.0',
345  'RPSL_v1.0' => 'RPSL-1.0',
346  'SCSL-TSA_v1.0' => 'SCSL-TSA-1.0',
347  'SCSL_v2.3' => 'SCSL-2.3',
348  'SCSL_v3.0' => 'SCSL-3.0',
349  'SGI-2.0' => 'SGI-B-2.0',
350  'SGI-B' => 'SGI-B-1.0',
351  'SGI-B1.1' => 'SGI-B-1.1',
352  'SGI-B2.0' => 'SGI-B-2.0',
353  'SGI_GLX_v1.0' => 'SGI_GLX-1.0',
354  'SGI_v1.0' => 'SGI-B-1.0',
355  'SGI_v1.1' => 'SGI_B-1.1',
356  'SGI_v2.0' => 'SGI-B-2.0',
357  'SISSL_v1.1' => 'SISSL-1.1',
358  'Skype' => 'Skype-EULA',
360  'SleepycatOracle' => 'Oracle-Berkeley-DB',
361  'Sleepycat(Oracle)' => 'Oracle-Berkeley-DB',
362  'SNIA1.1' => 'SNIA-1.1',
363  'SNIA_v1.0' => 'SNIA-1.0',
364  'SNIA_v1.1' => 'SNIA-1.1',
365  'SugarCRM' => 'SugarCRM-1.1.3',
366  'SunPL1.0' => 'SPL-1.0',
367  'Sun-PL_v1.0' => 'SPL-1.0',
368  'TrollTech' => 'Trolltech',
369  'UCWare' => 'UCWare-EULA',
370  'Vim' => 'VIM',
371  'VMWare' => 'VMWare-EULA',
372  'Vovida' => 'VSL-1.0',
373  'wxWindows' => 'WXwindows',
374  'Ximian_v1.0' => 'Ximian-1.0',
375  'Yahoo-EULA' => 'Yahoo',
376  'Yahoo' => 'Yahoo-EULA',
377  'Zend_v2.0' => 'Zend-2.0',
378  'ZLib' => 'Zlib',
379  'ZoneAlarm' => 'ZoneAlarm-EULA',
380  'Zope' => 'ZPL',
381  'Zope-PL_v2.0' => 'ZPL-2.0',
382  'ZPL1.1' => 'ZPL-1.1',
383  'ZPL2.0' => 'ZPL-2.0',
384  'ZPL2.1' => 'ZPL-2.1'
385  );
386  renameLicenses($shortname_array, $verbose);
387 }
388 
396 {
397  $shortname_array = array(
398  'Adaptec(RESTRICTED)' => 'Adaptec.RESTRICTED',
399  'AGFA(RESTRICTED)' => 'AGFA.RESTRICTED',
400  'Alfresco/FLOSS' => 'Alfresco-FLOSS',
401  'AndroidSDK(Commercial)' => 'AndroidSDK.Commercial',
402  'AndroidFraunhofer(Commercial)' => 'AndroidFraunhofer.Commercial',
403  'Apple(FontForge)' => 'Apple.FontForge',
404  'Apple(Sample)' => 'Apple.Sample',
405  'ATT-Source_v1.2d' => 'ATT-Source-1.2d',
406  'ATT(Non-commercial)' => 'ATT.Non-commercial',
407  'Baekmuk(Hwan)' => 'Baekmuk.Hwan',
408  'Broadcom(Commercial)' => 'Broadcom.Commercial',
409  'BSD(non-commercial)' => 'BSD.non-commercial',
410  'Genivia(Commercial)' => 'Genivia.Commercial',
411  "Gov''t-work" => 'Govt-work',
412  "Gov''t-rights" => 'Govt-rights',
413  'GNU-style(EXECUTE)' => 'GNU-style.EXECUTE',
414  'GNU-style(interactive)' => 'GNU-style.interactive',
415  'Helix/RealNetworks EULA' => 'Helix.RealNetworks-EULA',
416  'Helix/RealNetworks-EULA' => 'Helix.RealNetworks-EULA',
417  'Intel(Commercial)' => 'Intel.Commercial',
418  'Intel(RESTRICTED)' => 'Intel.RESTRICTED',
419  'IoSoft(COMMERCIAL)' => 'IoSoft.COMMERCIAL',
420  'JPEG/netpbm' => 'JPEG.netpbm',
421  'MIT/BSD' => 'MIT.BSD',
422  'MPL/TPL_v1.0' => 'MPL.TPL-1.0',
423  'MPL/TPL' => 'MPL.TPL',
424  'MySQL/FLOSS' => 'MySQL.FLOSS',
425  'Non-commercial!' => 'Non-commercial',
426  'Non-profit!' => 'Non-profit',
427  'Not-Free!' => 'Not-Free',
428  'Not-for-sale!' => 'Not-for-sale',
429  'Not-OpenSource!' => 'Not-OpenSource',
430  "O''Reilly" => 'OReilly',
431  "O''Reilly-style" => 'OReilly-style',
432  'Proprietary!' => 'Proprietary',
433  'QT' => 'QT.Commercial',
434  'Qt(Commercial)' => 'QT.Commercial',
435  'QT(Commercial)' => 'QT.Commercial',
436  'RedHat(Non-commercial)' => 'RedHat.Non-commercial',
437  'SCO(commercial)' => 'SCO.commercial',
438  'See-doc(OTHER)' => 'See-doc.OTHER',
439  'See-file(COPYING)' => 'See-file.COPYING',
440  'See-file(LICENSE)' => 'See-file.LICENSE',
441  'See-file(README)' => 'See-file.README',
442  'Sun(Non-commercial)' => 'Sun.Non-commercial',
443  'Sun(RESTRICTED)' => 'Sun.RESTRICTED',
444  "URA(gov''t)" => 'URA.govt',
445  'U-Wash(Free-Fork)' => 'U-Wash.Free-Fork',
446  'USC(Non-commercial)' => 'USC.Non-commercial',
447  'WTI(Not-free)' => 'WTI.Not-free',
448  'YaST(SuSE)' => 'YaST.SuSE'
449  );
450  renameLicenses($shortname_array, $verbose);
451 }
452 
459 function renameLicenses($shortname_array, $Verbose)
460 {
461  foreach ($shortname_array as $old_shortname => $new_shortname)
462  {
463  $old_rf_pk = check_shortname($old_shortname);
464  $new_rf_pk = check_shortname($new_shortname);
465  if (-1 != $old_rf_pk && -1 != $new_rf_pk)
466  {
467  $res = update_license($old_rf_pk, $new_rf_pk);
468  if (0 == $res)
469  {
470  if($Verbose)
471  print "update successfully, substitute rf_id(license_name) from $old_rf_pk($old_shortname) to $new_rf_pk($new_shortname).\n";
472  }
473  }
474  else if (-1 != $old_rf_pk && -1 == $new_rf_pk)
475  {
476  $res = change_license_name($old_shortname, $new_shortname);
477  if (0 == $res)
478  {
479  if($Verbose)
480  print "change license name successfully, substitute license shortname from $old_shortname to $new_shortname.\n";
481  }
482 
483  }
484  else if (-1 == $old_rf_pk)
485  {
486  if($Verbose)
487  print "the $old_shortname is not existing.\n";
488  }
489  }
490 
491  if($Verbose)
492  print "End!\n";
493 }
494 
502 function check_shortname($shortname)
503 {
504  global $PG_CONN;
505  $sql = "SELECT rf_pk from license_ref where rf_shortname = '$shortname'";
506  $result = pg_query($PG_CONN, $sql);
507  DBCheckResult($result, $sql, __FILE__, __LINE__);
508  $row = pg_fetch_assoc($result);
509  pg_free_result($result);
510  if ($row && $row['rf_pk']) return $row['rf_pk'];
511  else return -1;
512 }
513 
525 function update_license($old_rf_pk, $new_rf_pk)
526 {
527  global $PG_CONN;
528 
529  $updateTables = array(
530  "clearing_event",
531  "license_file",
532  "license_set_bulk",
533  "upload_clearing_license"
534  );
535 
537  $sql = "BEGIN;";
538  $result_begin = pg_query($PG_CONN, $sql);
539  DBCheckResult($result_begin, $sql, __FILE__, __LINE__);
540  pg_free_result($result_begin);
541 
542  /* Update all relevant tables, substituting the old_rf_id with the new_rf_id */
543  foreach ($updateTables as $table) {
544  $sql = "update $table set rf_fk = $new_rf_pk where rf_fk = $old_rf_pk;";
545  $result_license_file = pg_query($PG_CONN, $sql);
546  DBCheckResult($result_license_file, $sql, __FILE__, __LINE__);
547  pg_free_result($result_license_file);
548  }
549 
550  /* Check if license_file_audit table exists */
551  $sql = "select count(tablename) from pg_tables where tablename like 'license_file_audit';";
552  $result_count_license_file_audit = pg_query($PG_CONN, $sql);
553  DBCheckResult($result_count_license_file_audit, $sql, __FILE__, __LINE__);
554  $row = pg_fetch_row($result_count_license_file_audit);
555  if($row[0] > 0){
556  /* Update license_file_audit table, substituting the old_rf_id with the new_rf_id */
557  $sql = "update license_file_audit set rf_fk = $new_rf_pk where rf_fk = $old_rf_pk;";
558  $result_license_file_audit = pg_query($PG_CONN, $sql);
559  DBCheckResult($result_license_file_audit, $sql, __FILE__, __LINE__);
560  pg_free_result($result_license_file_audit);
561  }
562 
564  $sql = "DELETE FROM license_ref where rf_pk = $old_rf_pk;";
565  $result_delete = pg_query($PG_CONN, $sql);
566  DBCheckResult($result_delete, $sql, __FILE__, __LINE__);
567  pg_free_result($result_delete);
568 
570  $sql = "COMMIT;";
571  $result_end = pg_query($PG_CONN, $sql);
572  DBCheckResult($result_end, $sql, __FILE__, __LINE__);
573  pg_free_result($result_end);
574 
575  return 0;
576 }
577 
586 function change_license_name($old_shortname, $new_shortname)
587 {
588  global $PG_CONN;
589 
590  $sql = "update license_ref set rf_shortname = '$new_shortname' where rf_shortname = '$old_shortname';";
591  $result = pg_query($PG_CONN, $sql);
592  DBCheckResult($result, $sql, __FILE__, __LINE__);
593  pg_free_result($result);
594 
595  return 0;
596 }
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
Definition: common-db.php:187
check_shortname($shortname)
check if the shortname is existing in license_ref table
renameLicenses($shortname_array, $Verbose)
Rename old shortname to new shortname.
update_license($old_rf_pk, $new_rf_pk)
update license from old to new 1) update license_file set rf_fk=new_rf_pk where rf_fk=old_rf_pk 2) up...
change_license_name($old_shortname, $new_shortname)
change license shortname
renameLicensesForSpdxValidation($verbose)
Create map of old_shortname to new_shortname for SPDX and call renameLicenses.
renameLicenses21to22($verbose)
Create map of old_shortname to new_shortname for 2.1 to 2.2 and call renameLicenses.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN