Added more complete PrefixManagement class, and added skeletons for new KernelManagement Functions.

This commit is contained in:
Tonoxis
2021-06-18 00:42:19 -04:00
parent 4a0a6cec9f
commit ab97178233
4 changed files with 91 additions and 9 deletions

6
.gitignore vendored
View File

@@ -360,4 +360,8 @@ MigrationBackup/
.ionide/ .ionide/
# Fody - auto-generated XML schema # Fody - auto-generated XML schema
FodyWeavers.xsd FodyWeavers.xsd
# Composer
vendor/
composer.json.lock

View File

@@ -69,7 +69,7 @@ class KernelManagement
{ {
$kernelPath = realpath($this->cPrefixPath."/boot/kernel"); $kernelPath = realpath($this->cPrefixPath."/boot/kernel");
} }
// TODO: Finish Function
} }
private function loadConfiguration() private function loadConfiguration()
@@ -125,6 +125,32 @@ class KernelManagement
} }
private function __getBootSlot()
{
// This will allow us to know what boot slot we're supposed to be flashing into, perhaps we can make a treble compatible system updater with this?
$bootSlot = trim(`getprop ro.boot.slot_suffix`);
if(empty($bootSlot))
{
$bootSlot = "";
}
return $bootSlot;
}
public function installKernelTree($branch = 'flo', $repository = "https://tonoxisisle.services/git/tononixOS/ubports_kernel_google_msm", $kernelName = "3.4.y-tononixOS")
{
}
public function removeKernelTree($kernelName)
{
}
public function buildKernel($kernelName)
{
}
public function detectBootConfiguration() public function detectBootConfiguration()
{ {
if(!file_exists($this->cPrefixPath."/boot/old_boot.img")) if(!file_exists($this->cPrefixPath."/boot/old_boot.img"))
@@ -141,6 +167,8 @@ class KernelManagement
$this->aBootConfiguration['secondaddr'] = $aboot->get("secondaddr"); $this->aBootConfiguration['secondaddr'] = $aboot->get("secondaddr");
$this->aBootConfiguration['tagsaddr'] = $aboot->get("tagsaddr"); $this->aBootConfiguration['tagsaddr'] = $aboot->get("tagsaddr");
$this->aBootConfiguration['cmdline'] = $aboot->get("cmdline"); $this->aBootConfiguration['cmdline'] = $aboot->get("cmdline");
$bootSlot = $this->__getBootSlot();
if(!empty($bootSlot)) $this->aBootConfiguration['bootslot'] = $bootSlot;
$this->saveConfiguration(); $this->saveConfiguration();
} }

View File

@@ -1,27 +1,75 @@
<?php <?php
namespace libTononix; namespace libTononix;
use \Nette\Utils\Finder;
use \Noodlehaus\Config;
use \Noodlehaus\Parser\Xml;
use \Noodlehaus\Parser\Properties;
use \Noodlehaus\Parser\Json;
class PrefixManagement class PrefixManagement
{ {
protected $cPrefixPath; protected $cPrefixPath;
private $oConfiguration;
function __construct($prefix = "/home/phablet/.local/system") function __construct($prefix = "/home/phablet/.local/system")
{ {
$this->cPrefixPath = $prefix; $this->cPrefixPath = $prefix;
if(!is_dir($this->cPrefixPath)) if(!is_dir($this->cPrefixPath))
{ {
return false; $this->cPrefixPath = $this->tryDetectPrefix();
} }
$this->setupEnvironment();
// $this->oConfiguration = new \Noodlehaus\Config($this->cPrefixPath."/etc/tononixOS/prefix.conf", new \Noodlehaus\Parser\Xml);
} }
function tryDetectPrefix() function tryDetectPrefix()
{ {
$files = Finder::findFiles('*.stage3-finished')->from(getenv("HOME")); foreach(\Nette\Utils\Finder::findFiles('*.stage3-finished')->from(getenv("HOME"))->exclude(['.config','.vscode','.nano','.presage','.ellipsis','.antigen','.android','.npm','.ssh','.pki','anbox-data']) as $key => $file)
return $files; {
return $key;
}
return $false;
}
function setupEnvironment()
{
setenv("EPREFIX=".$this->cPrefixPath);
setenv("BPREFIX=".$this->cPrefixPath);
setenv("SHELL=".$this->cPrefixPath."/usr/bin/bash");
$pathArray = array($this->cPrefixPath."/usr/local/bin",
$this->cPrefixPath."/usr/local/sbin",
$this->cPrefixPath."/usr/bin",
$this->cPrefixPath."/usr/sbin",
$this->cPrefixPath."/bin",
$this->cPrefixPath."/sbin");
$pathString = implode(":",$pathArray);
$pathString = $pathString . ":" . getenv("PATH");
setenv("PATH=$pathString");
}
function installPackage($packageAtom)
{
exec('emerge --oneshot --update $packageAtom', $emergeLog, $retVal);
return array("log"=>$emergeLog,
"return" => $retVal);
}
function removePackage($packageAtom)
{
exec('emerge --depclean --verbose '.$packageAtom, $emergeLog, $retVal);
return array("log"=>$emergeLog,
"return" => $retVal);
}
function syncPackageLists()
{
exec('emerge --sync', $emergeLog, $retVal);
return array("log"=>$emergeLog,
"return" => $retVal);
} }

View File

@@ -1,6 +1,8 @@
{ {
"require": { "require": {
"hassankhan/config": "^2.2", "hassankhan/config": "^2.2",
"nette/finder": "^2.5" "nette/finder": "^2.5",
"czproject/git-php": "^4.0",
"sebastian/version": "^3.0"
} }
} }