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