FOSSology  4.4.0
Open Source License Compliance by Open Source Software
fossinit.php File Reference

This program applies core-schema.dat to the database (which must exist) and updates the license_ref table. More...

Go to the source code of this file.

Functions

 explainUsage ()
 Print Usage statement. More...
 
 insertInToLicenseRefTableUsingJson ($tableName)
 insert into license_ref table using json file. More...
 
 isLicenseExists ($dbManager, $rf_shortname, $isCandidate=true)
 
 mergeCandidateLicense ($dbManager, $candidateLicense)
 
 insertNewLicense ($dbManager, $license, $wasCandidate=false)
 

Variables

 $AllPossibleOpts = "abc:d:ef:ghijklmnopqr:stuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
 
 $longOpts
 
 $Verbose = false
 
 $DatabaseName = "fossology"
 
 $UpdateLiceneseRef = false
 
 $sysconfdir = ''
 
 $delDbPattern = 'the option -rfosstest will drop data bases with datname like "fosstest%"'
 
 $forceDecision = false
 
 $forcePfile = false
 
 $Options = getopt($AllPossibleOpts, $longOpts)
 
 foreach ( $Options as $optKey=> $optVal) = bootstrap($sysconfdir)
 
 $SysConf = bootstrap($sysconfdir)
 
 $SysConf ["DBCONF"]["dbname"] = $DatabaseName
 
 $GLOBALS ["SysConf"] = array_merge($GLOBALS["SysConf"], $SysConf)
 
 $projectGroup = $SysConf['DIRECTORIES']['PROJECTGROUP'] ?: 'fossy'
 
 $gInfo = posix_getgrnam($projectGroup)
 
 $groups = `groups`
 
 if (!preg_match("/\s$projectGroup\s/", $groups) &&(posix_getgid() !=$gInfo[ 'gid']))
 
 $GLOBALS ["PG_CONN"] = get_pg_conn($SYSCONFDIR, $SysConf)
 
 $pgDriver = new Postgres($PG_CONN)
 
 $previousSchema = $libschema->getCurrSchema()
 
 $isUpdating = array_key_exists('TABLE', $previousSchema) && array_key_exists('users', $previousSchema['TABLE'])
 
if($dbManager->existsTable('sysconfig')) $migrateColumns
 
 $FailMsg = $libschema->applySchema($SchemaFilePath, $Verbose, $DatabaseName, $migrateColumns)
 
 $Filename = "$MODDIR/www/ui/init.ui"
 
 $flagRemoved = !file_exists($Filename)
 
if(! $flagRemoved) if(! $flagRemoved) else
 
 $FAILED_LICENSE_IMPORT = array()
 
if(array_key_exists('r', $Options)) $currSchema = $libschema->getCurrSchema()
 
 $sysconfig = $dbManager->createMap('sysconfig','variablename','conf_value')
 
global $LIBEXECDIR
 
 $release = array_key_exists('Release', $sysconfig) ? $sysconfig['Release'] : 0
 
if(version_compare($release, '4.3.0', '<')) if($UpdateLiceneseRef) if(! $isUpdating|| $sysconfig['Release']=='2.6') if($sysconfig['Release']=='2.6.3') $expiredDbReleases = array('2.6.3', '2.6.3.1', '2.6.3.2')
 
if($isUpdating &&(empty($sysconfig['Release'])||in_array($sysconfig['Release'], $expiredDbReleases))) $expiredDbReleases [] = '2.6.3.3'
 
 $checker = new SanityChecker($dbManager,$Verbose)
 
 $errors = $checker->check()
 

Detailed Description

This program applies core-schema.dat to the database (which must exist) and updates the license_ref table.

Returns
0 for success, 1 for failure.

Definition in file fossinit.php.

Function Documentation

◆ explainUsage()

explainUsage ( )

Print Usage statement.

Returns
No return, this calls exit.

Definition at line 13 of file fossinit.php.

◆ insertInToLicenseRefTableUsingJson()

insertInToLicenseRefTableUsingJson (   $tableName)

insert into license_ref table using json file.

Parameters
$tableName

import licenseRef.json

Definition at line 468 of file fossinit.php.

◆ insertNewLicense()

insertNewLicense (   $dbManager,
  $license,
  $wasCandidate = false 
)

Insert new license to license_ref

Parameters
DbManager$dbManagerDbManager to be used
array$licenseLicense row to be added
boolean$wasCandidateWas the new license already a candidate? (required for rf_pk)
Returns
integer New license ID

Definition at line 785 of file fossinit.php.

◆ isLicenseExists()

isLicenseExists (   $dbManager,
  $rf_shortname,
  $isCandidate = true 
)

Check if the given shortname exists in DB.

Parameters
DbManager$dbManagerDbManager used
string$rf_shortnameShortname of the license to check
boolean$isCandidatecheck given shortname in candidate table
Returns
False if the license does not exists else DB row

Definition at line 700 of file fossinit.php.

◆ mergeCandidateLicense()

mergeCandidateLicense (   $dbManager,
  $candidateLicense 
)

Merge the candidate license to the main license_ref table.

Parameters
DbManager$dbManagerDbManager used
array$candidateLicenseShortname of the license to check
Returns
integer License ID

Definition at line 724 of file fossinit.php.

Variable Documentation

◆ $longOpts

$longOpts
Initial value:
= [
"force-decision",
"force-pfile",
"force-encode"
]

Definition at line 48 of file fossinit.php.

◆ $migrateColumns

if ( $dbManager->existsTable( 'sysconfig')) $migrateColumns
Initial value:
= array('clearing_decision'=>array('reportinfo','clearing_pk','type_fk','comment'),
'license_ref_bulk'=>array('rf_fk','removing'))

Definition at line 166 of file fossinit.php.

◆ else

if ( $isUpdating &&empty( $sysconfig[ 'Release'])) if (! $isUpdating) else
Initial value:
{
print "Database schema update completed successfully.\n"

Definition at line 218 of file fossinit.php.

◆ if

if ( $isUpdating &&!empty( $sysconfig) &&$sysconfig[ 'Release']=='2.6.3.1') if($dbManager->existsTable("author")) ( preg_match"/\s$projectGroup\s/", $groups) &&(posix_getgid() !=$gInfo[ 'gid'])

delete from copyright where pfile_fk not in (select pfile_pk from pfile) add foreign constraint on copyright pfile_fk if not exist comment out for 2.5.0 require_once("$LIBEXECDIR/dbmigrate_2.0-2.5-pre.php"); Migrate_20_25($Verbose);

Definition at line 114 of file fossinit.php.