FOSSology  4.4.0
Open Source License Compliance by Open Source Software
bootstrap.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2011 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
37 function bootstrap()
38 {
39  $TR = NULL;
40  if(!defined('TESTROOT'))
41  {
42  $TR = getenv('TESTROOT');
43  if($TR = NULL )
44  {
45  echo "FATAL! bootstrap cannot determine TESTROOT\n";
46  }
47 
48  }
49  $rcfile = TESTROOT. '/fossologyTest.rc';
50 
51  $sysconfdir = getenv('SYSCONFDIR');
52  if ($sysconfdir === false)
53  {
54  if (file_exists($rcfile)) $sysconfdir = file_get_contents($rcfile);
55  if ($sysconfdir === false)
56  {
57  /* NO SYSCONFDIR specified */
58  $text = _("FATAL: System Configuration Error, no SYSCONFDIR.");
59  echo "<hr><h3>$text</h3><hr>";
60  exit(1);
61  }
62  }
63 
64  $sysconfdir = trim($sysconfdir);
65  $GLOBALS['SYSCONFDIR'] = $sysconfdir;
66 
67  /************* Parse fossology.conf *******************/
68  $ConfFile = "{$sysconfdir}/fossology.conf";
69  $SysConf = parse_ini_file($ConfFile, true);
70 
71  /* evaluate all the DIRECTORIES group for variable substitutions.
72  * For example, if PREFIX=/usr/local and BINDIR=$PREFIX/bin, we
73  * want BINDIR=/usr/local/bin
74  */
75  foreach($SysConf['DIRECTORIES'] as $var=>$assign)
76  {
77  /* Evaluate the individual variables because they may be referenced
78  * in subsequent assignments.
79  */
80  $toeval = "\$$var = \"$assign\";";
81  eval($toeval);
82 
83  /* now reassign the array value with the evaluated result */
84  $SysConf['DIRECTORIES'][$var] = ${$var};
85  $GLOBALS[$var] = ${$var};
86  }
87 
88  if (empty($MODDIR))
89  {
90  $text = _("FATAL: System initialization failure: MODDIR not defined in fossology.conf");
91  echo $text. "\n";
92  exit;
93  }
94  return $SysConf;
95 }
bootstrap()
Bootstrap the fossology test system.
Definition: bootstrap.php:37
char * trim(char *ptext)
Trimming whitespace.
Definition: fossconfig.c:690