FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
bootstrap.php
Go to the documentation of this file.
1 <?php
2 /***********************************************************
3  Copyright (C) 2011 Hewlett-Packard Development Company, L.P.
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 ***********************************************************/
18 
49 function bootstrap()
50 {
51  $TR = NULL;
52  if(!defined('TESTROOT'))
53  {
54  $TR = getenv('TESTROOT');
55  if($TR = NULL )
56  {
57  echo "FATAL! bootstrap cannot determine TESTROOT\n";
58  }
59 
60  }
61  $rcfile = TESTROOT. '/fossologyTest.rc';
62 
63  $sysconfdir = getenv('SYSCONFDIR');
64  if ($sysconfdir === false)
65  {
66  if (file_exists($rcfile)) $sysconfdir = file_get_contents($rcfile);
67  if ($sysconfdir === false)
68  {
69  /* NO SYSCONFDIR specified */
70  $text = _("FATAL: System Configuration Error, no SYSCONFDIR.");
71  echo "<hr><h3>$text</h3><hr>";
72  exit(1);
73  }
74  }
75 
76  $sysconfdir = trim($sysconfdir);
77  $GLOBALS['SYSCONFDIR'] = $sysconfdir;
78 
79  /************* Parse fossology.conf *******************/
80  $ConfFile = "{$sysconfdir}/fossology.conf";
81  $SysConf = parse_ini_file($ConfFile, true);
82 
83  /* evaluate all the DIRECTORIES group for variable substitutions.
84  * For example, if PREFIX=/usr/local and BINDIR=$PREFIX/bin, we
85  * want BINDIR=/usr/local/bin
86  */
87  foreach($SysConf['DIRECTORIES'] as $var=>$assign)
88  {
89  /* Evaluate the individual variables because they may be referenced
90  * in subsequent assignments.
91  */
92  $toeval = "\$$var = \"$assign\";";
93  eval($toeval);
94 
95  /* now reassign the array value with the evaluated result */
96  $SysConf['DIRECTORIES'][$var] = ${$var};
97  $GLOBALS[$var] = ${$var};
98  }
99 
100  if (empty($MODDIR))
101  {
102  $text = _("FATAL: System initialization failure: MODDIR not defined in fossology.conf");
103  echo $text. "\n";
104  exit;
105  }
106  return $SysConf;
107 }
108 ?>
bootstrap()
Bootstrap the fossology test system.
Definition: bootstrap.php:49
char * trim(char *ptext)
Trimming whitespace.
Definition: fossconfig.c:695