21 require_once(dirname(dirname(dirname(__DIR__))) .
"/vendor/autoload.php");
28 function __construct($sysConf)
30 $this->sysConf = $sysConf;
33 public function init()
35 $sysConf = $this->sysConf;
37 $confFile = $sysConf.
"/fossology.conf";
38 $fakeInstallationDir =
"$sysConf/inst";
40 $projectGroup = `
id -g -n`;
41 $config =
"[FOSSOLOGY]\ndepth = 0\npath = $sysConf/repo\n" 42 .
"[DIRECTORIES]\nMODDIR = $fakeInstallationDir\nPROJECTGROUP = $projectGroup";
43 file_put_contents($confFile, $config);
45 if (! is_dir($fakeInstallationDir)) {
46 mkdir($fakeInstallationDir, 0777,
true);
48 $libDir = dirname(dirname(dirname(__DIR__))) .
"/lib";
49 system(
"ln -sf $libDir $fakeInstallationDir/lib");
51 if (! is_dir(
"$fakeInstallationDir/www/ui")) {
52 mkdir(
"$fakeInstallationDir/www/ui/", 0777,
true);
53 touch(
"$fakeInstallationDir/www/ui/ui-menus.php");
57 $topDir = dirname(dirname(dirname(dirname(__DIR__))));
58 system(
"install -D $topDir/VERSION $sysConf");
61 public function clear()
63 system(
"rm $this->sysConf/inst -rf");
64 $versionFile = $this->sysConf.
"/VERSION";
65 if (file_exists($versionFile)) {
68 $confFile = $this->sysConf .
"/fossology.conf";
69 if (file_exists($confFile)) {
74 public function install($srcDir)
76 $sysConfDir = $this->sysConf;
77 exec(
"make MODDIR=$sysConfDir DESTDIR= BINDIR=$sysConfDir SYSCONFDIR=$sysConfDir -C $srcDir install", $unused, $rt);
81 public function uninstall($srcDir)
83 $sysConfDir = $this->sysConf;
84 exec(
"make MODDIR=$sysConfDir DESTDIR= BINDIR=$sysConfDir SYSCONFDIR=$sysConfDir -C $srcDir uninstall", $unused, $rt);
85 $modEnabled =
"$sysConfDir/mods-enabled";
86 if (is_dir($modEnabled)) {
92 public function cpRepo()
94 $testRepoDir = __DIR__;
95 system(
"cp -a $testRepoDir/repo $this->sysConf/");
98 public function rmRepo()
100 system(
"rm $this->sysConf/repo -rf");