10 require_once(dirname(dirname(dirname(__DIR__))) .
"/vendor/autoload.php");
17 function __construct($sysConf)
19 $this->sysConf = $sysConf;
22 public function init()
24 $sysConf = $this->sysConf;
26 $confFile = $sysConf.
"/fossology.conf";
27 $fakeInstallationDir =
"$sysConf/inst";
29 $projectGroup = `
id -g -n`;
30 $projectUser = `
id -u -n`;
31 $config =
"[FOSSOLOGY]\ndepth = 0\npath = $sysConf/repo\n" .
32 "[DIRECTORIES]\nMODDIR = $fakeInstallationDir\n" .
33 "PROJECTGROUP = $projectGroup\n" .
34 "PROJECTUSER = $projectUser\n" .
35 "PREFIX = $fakeInstallationDir\n" .
36 "BINDIR = \$PREFIX/bin\n" .
37 "SBINDIR = \$PREFIX/sbin\n" .
38 "LIBEXECDIR = \$PREFIX/lib\n";
39 file_put_contents($confFile, $config);
41 if (! is_dir($fakeInstallationDir)) {
42 mkdir($fakeInstallationDir, 0777,
true);
44 $libDir = dirname(dirname(dirname(__DIR__))) .
"/lib";
45 system(
"ln -sf $libDir $fakeInstallationDir/lib");
47 if (! is_dir(
"$fakeInstallationDir/www/ui")) {
48 mkdir(
"$fakeInstallationDir/www/ui/", 0777,
true);
49 touch(
"$fakeInstallationDir/www/ui/ui-menus.php");
53 $topDir = dirname(__DIR__,4).
'/build/install';
54 system(
"install -D $topDir/VERSION $sysConf");
57 public function clear()
59 system(
"rm $this->sysConf/inst -rf");
60 $versionFile = $this->sysConf.
"/VERSION";
61 if (file_exists($versionFile)) {
64 $confFile = $this->sysConf .
"/fossology.conf";
65 if (file_exists($confFile)) {
70 public function install($srcDir)
72 $sysConfDir = $this->sysConf;
73 exec(
"make MODDIR=$sysConfDir DESTDIR= BINDIR=$sysConfDir SYSCONFDIR=$sysConfDir -C $srcDir --file=TestInstall.make install", $unused, $rt);
77 public function uninstall($srcDir)
79 $sysConfDir = $this->sysConf;
80 exec(
"make MODDIR=$sysConfDir DESTDIR= BINDIR=$sysConfDir SYSCONFDIR=$sysConfDir -C $srcDir --file=TestInstall.make uninstall", $unused, $rt);
81 $modEnabled =
"$sysConfDir/mods-enabled";
82 if (is_dir($modEnabled)) {
88 public function cpRepo()
90 $testRepoDir = __DIR__;
91 system(
"cp -a $testRepoDir/repo $this->sysConf/");
94 public function rmRepo()
96 system(
"rm $this->sysConf/repo -rf");