8 Commits

Author SHA1 Message Date
Rick Blair
bda5bd7f10 Initial commit of PeachPie template into Project. 2021-11-12 00:13:45 -05:00
Tonoxis
81906ef8b9 Attempting to shut up composer during tos builds. 2021-09-09 23:27:00 -04:00
Tonoxis
ee8cd323f5 Changed how $prefix works 2021-09-09 23:13:53 -04:00
Tonoxis
e788fa9720 Attempt #3 2021-09-09 22:48:28 -04:00
Tonoxis
232b31a5a1 Attempt #2 2021-09-09 22:47:49 -04:00
Tonoxis
41f8a96478 Attempting to fix installation methods. 2021-09-09 22:45:43 -04:00
Tonoxis
4ff01ee9eb Forgot to make build script do a composer install before running compile. 2021-09-09 22:35:35 -04:00
Tonoxis
e09664a715 Added tononixOS package handling class. 2021-09-09 21:38:40 -04:00
14 changed files with 489 additions and 414 deletions

12
.gitignore vendored
View File

@@ -1,5 +1,7 @@
build/ build/
vendor/ vendor/
vendor-bin/ vendor-bin/
composer.lock composer.lock
vendor/* vendor/*
.vs/
obj/

10
README.md Normal file
View File

@@ -0,0 +1,10 @@
## console-app
Template for creating .NET core console applications in PHP.
### How to run
1. Install peachpie templates
2. `dotnet new console -lang PHP`
3. `dotnet restore`
4. Modify `program.php` (optional)
5. `dotnet run`

498
RoboFile.php Executable file → Normal file
View File

@@ -1,250 +1,250 @@
<?php <?php
require_once(__DIR__."/vendor/autoload.php"); // Pull in Composer Autoload require_once(__DIR__."/vendor/autoload.php"); // Pull in Composer Autoload
define("APPNAME", "tononixOS Kernel Update Client"); // Define the application name so our universal application stub can find it. define("APPNAME", "tononixOS Kernel Update Client"); // Define the application name so our universal application stub can find it.
/** /**
* Application Name: tononixOS Kernel Update Client * Application Name: tononixOS Kernel Update Client
* Application Desc: Allows tononixOS devices to update their kernel via source with no user intervention, similar to Gentoo's Genkernel * Application Desc: Allows tononixOS devices to update their kernel via source with no user intervention, similar to Gentoo's Genkernel
* Application Ver: v1.0.2 * Application Ver: v1.0.2
*/ */
/** /**
* TODO: Device detection * TODO: Device detection
* TODO: Use of device-configs for cloning kernel repositories * TODO: Use of device-configs for cloning kernel repositories
* TODO: Build own tononixOS self-update mechanism * TODO: Build own tononixOS self-update mechanism
*/ */
class RoboFile extends \Robo\Tasks class RoboFile extends \Robo\Tasks
{ {
public $dir; public $dir;
public $device_name; public $device_name;
public $device_manufacturer; public $device_manufacturer;
public function __construct() public function __construct()
{ {
\Robo\Robo::loadConfiguration([__DIR__."/config.yml",getenv("HOME")."/.local/system/etc/tononixOS/config.yml","/etc/tononixOS/config.yml"]); \Robo\Robo::loadConfiguration([__DIR__."/config.yml",getenv("HOME")."/.local/system/etc/tononixOS/config.yml","/etc/tononixOS/config.yml"]);
$this->dir = array("kernel-source" => \Robo\Robo::Config()->get("tononix.directories.kernel-source"), $this->dir = array("kernel-source" => \Robo\Robo::Config()->get("tononix.directories.kernel-source"),
"kernel-source-symlink" => \Robo\Robo::Config()->get("tononix.directories.kernel-source-symlink"), "kernel-source-symlink" => \Robo\Robo::Config()->get("tononix.directories.kernel-source-symlink"),
"kernel-install" => \Robo\Robo::Config()->get("tononix.directories.kernel-install"), "kernel-install" => \Robo\Robo::Config()->get("tononix.directories.kernel-install"),
"kernel-device" => \Robo\Robo::Config()->get("tononix.device.boot-partiton")); "kernel-device" => \Robo\Robo::Config()->get("tononix.device.boot-partiton"));
if(!empty(\Robo\Robo::Config()->get("tononix.debug"))) define("DEBUG", true); if(!empty(\Robo\Robo::Config()->get("tononix.debug"))) define("DEBUG", true);
$device_info = \AndroidDevice::__getDeviceInfo(); $device_info = \AndroidDevice::__getDeviceInfo();
if($device_info == false) { if($device_info == false) {
$this->device_name = \Robo\Robo::Config()->get("tononix.device.name"); $this->device_name = \Robo\Robo::Config()->get("tononix.device.name");
$this->device_manufacturer = \Robo\Robo::Config()->get("tononix.device.manufacturer"); $this->device_manufacturer = \Robo\Robo::Config()->get("tononix.device.manufacturer");
} else { } else {
$this->device_name = $device_info['device_name']; $this->device_name = $device_info['device_name'];
$this->device_manufacturer = $device_info['device_manufacturer']; $this->device_manufacturer = $device_info['device_manufacturer'];
} }
} }
public function kernelSourceRetrieve($opts = ['branch' => "flo", 'repository' => "https://tonoxisisle.services/git/tononixOS/ubports_kernel_google_msm", 'kernel-name' => '3.4.y-tononixOS-flo']) public function kernelSourceRetrieve($opts = ['branch' => "flo", 'repository' => "https://tonoxisisle.services/git/tononixOS/ubports_kernel_google_msm", 'kernel-name' => '3.4.y-tononixOS-flo'])
{ {
$genkernel = true; $genkernel = true;
if (!file_exists(getenv("HOME")."/.local/system/etc/genkernel.conf")) { if (!file_exists(getenv("HOME")."/.local/system/etc/genkernel.conf")) {
$this->say("Gentoo Prefix not detected, not using Genkernel to build kernel..."); $this->say("Gentoo Prefix not detected, not using Genkernel to build kernel...");
$genkernel = false; $genkernel = false;
} }
if($genkernel == false) if($genkernel == false)
{ {
if(!file_exists($this->dir['kernel-source']."/".$opts['kernel-name'])) { if(!file_exists($this->dir['kernel-source']."/".$opts['kernel-name'])) {
$this->say("Retrieving kernel sources from: ".$opts['repository']." using branch ".$opts['branch']."..."); $this->say("Retrieving kernel sources from: ".$opts['repository']." using branch ".$opts['branch']."...");
$this->taskGitStack() $this->taskGitStack()
->stopOnFail() ->stopOnFail()
->cloneRepo($opts['repository'], $this->dir['kernel-source'].$opts['kernel-name'], $opts['branch']) ->cloneRepo($opts['repository'], $this->dir['kernel-source'].$opts['kernel-name'], $opts['branch'])
->run(); ->run();
} else { } else {
$this->say("Updating kernel sources from: ".$opts['repository']." using branch ".$opts['branch']."..."); $this->say("Updating kernel sources from: ".$opts['repository']." using branch ".$opts['branch']."...");
$this->taskGitStack() $this->taskGitStack()
->stopOnFail() ->stopOnFail()
->dir($this->dir['kernel-source']."/".$opts['kernel-name']) ->dir($this->dir['kernel-source']."/".$opts['kernel-name'])
->pull("origin", $opts['branch']) ->pull("origin", $opts['branch'])
->run(); ->run();
} }
$this->_symlink($this->dir['kernel-source'].$opts['kernel-name'], $this->dir['kernel-source-symlink']); $this->_symlink($this->dir['kernel-source'].$opts['kernel-name'], $this->dir['kernel-source-symlink']);
} else { } else {
if(!file_exists(getenv("HOME")."/.local/system/usr/src/".$opts['kernel-name'])) { if(!file_exists(getenv("HOME")."/.local/system/usr/src/".$opts['kernel-name'])) {
$this->say("Retrieving kernel sources from: ".$opts['repository']." using branch ".$opts['branch']."..."); $this->say("Retrieving kernel sources from: ".$opts['repository']." using branch ".$opts['branch']."...");
$this->taskGitStack() $this->taskGitStack()
->stopOnFail() ->stopOnFail()
->cloneRepo($opts['repository'], getenv("HOME")."/.local/system/usr/src/".$opts['kernel-name'], $opts['branch']) ->cloneRepo($opts['repository'], getenv("HOME")."/.local/system/usr/src/".$opts['kernel-name'], $opts['branch'])
->run(); ->run();
} else { } else {
$this->say("Updating kernel sources from: ".$opts['repository']." using branch ".$opts['branch']."..."); $this->say("Updating kernel sources from: ".$opts['repository']." using branch ".$opts['branch']."...");
$this->taskGitStack() $this->taskGitStack()
->stopOnFail() ->stopOnFail()
->dir(getenv("HOME")."/.local/system/usr/src/".$opts['kernel-name']) ->dir(getenv("HOME")."/.local/system/usr/src/".$opts['kernel-name'])
->pull("origin", $opts['branch']) ->pull("origin", $opts['branch'])
->run(); ->run();
} }
$this->_symlink(getenv("HOME")."/.local/system/usr/src/".$opts['kernel-name'], $this->dir['kernel-source-symlink']); $this->_symlink(getenv("HOME")."/.local/system/usr/src/".$opts['kernel-name'], $this->dir['kernel-source-symlink']);
} }
} }
public function kernelSourceBuild() public function kernelSourceBuild()
{ {
$genkernel = true; $genkernel = true;
if(!file_exists($this->dir['kernel-source-symlink'])) { if(!file_exists($this->dir['kernel-source-symlink'])) {
$this->say("Kernel source was not found in ".$this->dir['kernel-source-symlink'].", pulling down kernel sources for device..."); $this->say("Kernel source was not found in ".$this->dir['kernel-source-symlink'].", pulling down kernel sources for device...");
$this->kernelSourceRetrieve(); $this->kernelSourceRetrieve();
} }
if(!file_exists(getenv("HOME")."/.local/system/etc/genkernel.conf")) if(!file_exists(getenv("HOME")."/.local/system/etc/genkernel.conf"))
{ {
$this->say("Gentoo Prefix not detected, not using Genkernel to build kernel..."); $this->say("Gentoo Prefix not detected, not using Genkernel to build kernel...");
$genkernel = false; $genkernel = false;
} }
$this->say("Building kernel...."); $this->say("Building kernel....");
if($genkernel == true) { if($genkernel == true) {
$this->_exec("genkernel --config=".getenv("HOME")."/.local/system/etc/genkernel.conf bzImage"); $this->_exec("genkernel --config=".getenv("HOME")."/.local/system/etc/genkernel.conf bzImage");
} else { } else {
if(!$this->device_name) if(!$this->device_name)
{ {
$this->_copy($this->dir['kernel-source-symlink']."/arch/arm/configs/tononixos_defconfig", $this->dir['kernel-source-symlink']."/.config"); $this->_copy($this->dir['kernel-source-symlink']."/arch/arm/configs/tononixos_defconfig", $this->dir['kernel-source-symlink']."/.config");
} else { } else {
$this->_copy($this->dir['kernel-source-symlink']."/arch/arm/configs/tononixos_".$this->device_name."_defconfig", $this->dir['kernel-source-symlink']."/.config"); $this->_copy($this->dir['kernel-source-symlink']."/arch/arm/configs/tononixos_".$this->device_name."_defconfig", $this->dir['kernel-source-symlink']."/.config");
} }
putenv("ARCH=arm"); putenv("ARCH=arm");
putenv("SUBARCH=arm"); putenv("SUBARCH=arm");
$this->taskExec("make -j4")->dir($this->dir['kernel-source-symlink'])->run(); $this->taskExec("make -j4")->dir($this->dir['kernel-source-symlink'])->run();
$this->_copy($this->dir['kernel-source-symlink']."/arch/arm/boot/zImage", $this->dir['kernel-install']."/kernel"); $this->_copy($this->dir['kernel-source-symlink']."/arch/arm/boot/zImage", $this->dir['kernel-install']."/kernel");
} }
} }
public function kernelInstall($opts = ['flash_kernel' => false, 'keep-image-after-flash' => true]) public function kernelInstall($opts = ['flash_kernel' => false, 'keep-image-after-flash' => true])
{ {
$genkernel = true; $genkernel = true;
if(!file_exists(getenv("HOME")."/.local/system/etc/genkernel.conf")) if(!file_exists(getenv("HOME")."/.local/system/etc/genkernel.conf"))
{ {
$genkernel = false; $genkernel = false;
$this->say("Gentoo Prefix not detected, ignoring prefix assumptions..."); $this->say("Gentoo Prefix not detected, ignoring prefix assumptions...");
} else { } else {
$bootdir = getenv("HOME")."/.local/system/boot"; $bootdir = getenv("HOME")."/.local/system/boot";
} }
\Robo\Robo::loadConfiguration([getenv("HOME")."/.config/tononix/device-configs/".$this->device_manufacturer."/".$this->device_name."yml",getenv("HOME")."/.local/system/etc/tononixOS/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml","/etc/tononixOS/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml",__DIR__."/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml"]); \Robo\Robo::loadConfiguration([getenv("HOME")."/.config/tononix/device-configs/".$this->device_manufacturer."/".$this->device_name."yml",getenv("HOME")."/.local/system/etc/tononixOS/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml","/etc/tononixOS/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml",__DIR__."/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml"]);
$kernelBootPartiton = \Robo\Robo::Config()->get("device.partition_info.boot").\AndroidDevice::__getBootSlot(); $kernelBootPartiton = \Robo\Robo::Config()->get("device.partition_info.boot").\AndroidDevice::__getBootSlot();
if(\AndroidDevice::__getBootSlot()) if(\AndroidDevice::__getBootSlot())
{ {
$this->say("Extracting inital ramdisk from current boot image in boot-slot: ".\AndroidDevice::__getBootSlot()."..."); $this->say("Extracting inital ramdisk from current boot image in boot-slot: ".\AndroidDevice::__getBootSlot()."...");
if($genkernel == false) if($genkernel == false)
{ {
$this->_exec("dd if=".$kernelBootPartition." of=".$this->dir['kernel-install']."/boot_current-krnlupdate.img"); $this->_exec("dd if=".$kernelBootPartition." of=".$this->dir['kernel-install']."/boot_current-krnlupdate.img");
$this->taskExec("abootimg -x boot_current-krnlupdate.img")->dir($this->dir['kernel-install'])->run(); $this->taskExec("abootimg -x boot_current-krnlupdate.img")->dir($this->dir['kernel-install'])->run();
$this->_remove([$this->dir['kernel-install']."/zImage"]); $this->_remove([$this->dir['kernel-install']."/zImage"]);
if(!file_exists($this->dir['kernel-install']."/kernel")) { if(!file_exists($this->dir['kernel-install']."/kernel")) {
$this->yell("No kernel has been build yet.. Kicking off kernel build..."); $this->yell("No kernel has been build yet.. Kicking off kernel build...");
$this->kernelSourceBuild(); $this->kernelSourceBuild();
} }
$this->say("Creating new boot.img with new kernel image..."); $this->say("Creating new boot.img with new kernel image...");
$this->taskExec("abootimg --create newboot.img -f ./bootimg.cfg -k ./kernel -r ./initrd.img")->dir($this->dir['kernel-install'])->run(); $this->taskExec("abootimg --create newboot.img -f ./bootimg.cfg -k ./kernel -r ./initrd.img")->dir($this->dir['kernel-install'])->run();
if($opts['flash-kernel'] == true) if($opts['flash-kernel'] == true)
{ {
$this->kernelFlash(array("boot-image"=>$this->dir['kernel-install']."/newboot.img")); $this->kernelFlash(array("boot-image"=>$this->dir['kernel-install']."/newboot.img"));
$this->_move($this->dir['kernel-install']."/newboot.img", $this->dir['kernel-install']."/boot.img"); $this->_move($this->dir['kernel-install']."/newboot.img", $this->dir['kernel-install']."/boot.img");
} }
} else { } else {
$this->_exec("dd if=".$kernelBootPartition." of=".getenv("HOME")."/.local/system/boot/boot_current-krnlupdate.img"); $this->_exec("dd if=".$kernelBootPartition." of=".getenv("HOME")."/.local/system/boot/boot_current-krnlupdate.img");
$this->taskExec("abootimg -x boot_current-krnlupdate.img")->dir($this->dir['kernel-install'])->run(); $this->taskExec("abootimg -x boot_current-krnlupdate.img")->dir($this->dir['kernel-install'])->run();
$this->_remove([getenv("HOME")."/.local/system/boot/zImage"]); $this->_remove([getenv("HOME")."/.local/system/boot/zImage"]);
if(!file_exists(getenv("HOME")."/.local/system/boot/kernel")) { if(!file_exists(getenv("HOME")."/.local/system/boot/kernel")) {
$this->yell("No kernel has been built yet... Kicking off kernel build using GenKernel..."); $this->yell("No kernel has been built yet... Kicking off kernel build using GenKernel...");
$this->kernelSourceBuild(); $this->kernelSourceBuild();
} }
$this->say("Creating new boot.img with new kernel image..."); $this->say("Creating new boot.img with new kernel image...");
$this->taskExec("abootimg --create newboot.img -f ./bootimg.cfg -k ./kernel -r ./initrd.img")->dir(getenv("HOME")."/.local/system/boot")->run(); $this->taskExec("abootimg --create newboot.img -f ./bootimg.cfg -k ./kernel -r ./initrd.img")->dir(getenv("HOME")."/.local/system/boot")->run();
if($opts['flash-kernel'] == true) if($opts['flash-kernel'] == true)
{ {
$this->kernelFlash(array("boot-image"=>getenv("HOME")."/.local/system/boot/newboot.img")); $this->kernelFlash(array("boot-image"=>getenv("HOME")."/.local/system/boot/newboot.img"));
$this->_move(getenv("HOME")."/.local/system/boot/newboot.img",getenv("HOME")."/.local/system/boot/boot.img"); $this->_move(getenv("HOME")."/.local/system/boot/newboot.img",getenv("HOME")."/.local/system/boot/boot.img");
} }
} }
} }
} }
public function kernelFlash($opts = ['boot-image' => "", 'boot-partition' => ""]) public function kernelFlash($opts = ['boot-image' => "", 'boot-partition' => ""])
{ {
\Robo\Robo::loadConfiguration([getenv("HOME")."/.config/tononix/device-configs/".$this->device_manufacturer."/".$this->device_name."yml",getenv("HOME")."/.local/system/etc/tononixOS/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml","/etc/tononixOS/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml",__DIR__."/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml"]); \Robo\Robo::loadConfiguration([getenv("HOME")."/.config/tononix/device-configs/".$this->device_manufacturer."/".$this->device_name."yml",getenv("HOME")."/.local/system/etc/tononixOS/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml","/etc/tononixOS/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml",__DIR__."/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml"]);
$kernelBootPartition = \Robo\Robo::Config()->get("device.partition_info.boot").\AndroidDevices::__getBootSlot(); $kernelBootPartition = \Robo\Robo::Config()->get("device.partition_info.boot").\AndroidDevices::__getBootSlot();
$genkernel = true; $genkernel = true;
if (!file_exists(getenv("HOME")."/.local/system/etc/genkernel.conf")) { if (!file_exists(getenv("HOME")."/.local/system/etc/genkernel.conf")) {
$genkernel = false; $genkernel = false;
$this->say("Gentoo Prefix not detected, ignoring prefix assumptions..."); $this->say("Gentoo Prefix not detected, ignoring prefix assumptions...");
} }
if($genkernel == false) if($genkernel == false)
{ {
$bootImage = $this->dir['kernel-install']."/boot.img"; $bootImage = $this->dir['kernel-install']."/boot.img";
} else { } else {
$bootImage = getenv("HOME")."/.local/system/boot/boot.img"; $bootImage = getenv("HOME")."/.local/system/boot/boot.img";
} }
if(!empty($opts['boot-image'])) $bootImage = $opts['boot-image']; if(!empty($opts['boot-image'])) $bootImage = $opts['boot-image'];
if(!empty($opts['boot-partition'])) $kernelBootPartition = $opts['boot-partition']; if(!empty($opts['boot-partition'])) $kernelBootPartition = $opts['boot-partition'];
$this->say("Writing kernel boot image: ".$bootImage." to: ".$kernelBootPartition); $this->say("Writing kernel boot image: ".$bootImage." to: ".$kernelBootPartition);
$this->taskExec("dd if=".$bootImage." of=".$kernelBootPartition); $this->taskExec("dd if=".$bootImage." of=".$kernelBootPartition);
} }
public function kernelBackup($opts = ['boot-partition' => ""]) public function kernelBackup($opts = ['boot-partition' => ""])
{ {
$genkernel = true; $genkernel = true;
if (!file_exists(getenv("HOME")."/.local/system/etc/genkernel.conf")) { if (!file_exists(getenv("HOME")."/.local/system/etc/genkernel.conf")) {
$genkernel = false; $genkernel = false;
$this->say("Gentoo Prefix not detected, ignoring prefix assumptions..."); $this->say("Gentoo Prefix not detected, ignoring prefix assumptions...");
} }
if($genkernel == false) if($genkernel == false)
{ {
$bootImage = $this->dir['kernel-install']."/boot.img"; $bootImage = $this->dir['kernel-install']."/boot.img";
} else { } else {
$bootImage = getenv("HOME")."/.local/system/boot/boot.img"; $bootImage = getenv("HOME")."/.local/system/boot/boot.img";
} }
\Robo\Robo::loadConfiguration([getenv("HOME")."/.config/tononix/device-configs/".$this->device_manufacturer."/".$this->device_name."yml",getenv("HOME")."/.local/system/etc/tononixOS/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml","/etc/tononixOS/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml",__DIR__."/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml"]); \Robo\Robo::loadConfiguration([getenv("HOME")."/.config/tononix/device-configs/".$this->device_manufacturer."/".$this->device_name."yml",getenv("HOME")."/.local/system/etc/tononixOS/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml","/etc/tononixOS/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml",__DIR__."/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml"]);
$kernelBootPartition = \Robo\Robo::Config()->get("device.partition_info.boot").\AndroidDevice::__getBootSlot(); $kernelBootPartition = \Robo\Robo::Config()->get("device.partition_info.boot").\AndroidDevice::__getBootSlot();
if(!empty($opts['boot-partition'])) $kernelBootPartition = $opts['boot-partition']; if(!empty($opts['boot-partition'])) $kernelBootPartition = $opts['boot-partition'];
$this->say("Creating backup of currently working kernel and configuration (if available)...."); $this->say("Creating backup of currently working kernel and configuration (if available)....");
if($genkernel == false) if($genkernel == false)
{ {
if(!file_exists($this->dir['kernel-install']."/backups")) $this->_mkdir($this->dir['kernel-install']."/backups"); if(!file_exists($this->dir['kernel-install']."/backups")) $this->_mkdir($this->dir['kernel-install']."/backups");
} else { } else {
if(!file_exists(getenv("HOME")."/.local/system/boot/backups")) $this->_mkdir(getenv("HOME")."/.local/system/boot/backups"); if(!file_exists(getenv("HOME")."/.local/system/boot/backups")) $this->_mkdir(getenv("HOME")."/.local/system/boot/backups");
} }
$collection = $this->collectionBuilder(); $collection = $this->collectionBuilder();
$tmpDir = $collection->tmpDir()->getPath(); $tmpDir = $collection->tmpDir()->getPath();
$collection->say("Making a copy of working kernel configuration..."); $collection->say("Making a copy of working kernel configuration...");
$collection->taskFilesystemStack()->copy("/proc/config.gz", "$tmpDir/config.gz"); $collection->taskFilesystemStack()->copy("/proc/config.gz", "$tmpDir/config.gz");
$collection->say("Copying the current boot image..."); $collection->say("Copying the current boot image...");
$collection->taskExec("dd if=".$kernelBootPartition." of=$tmpDir/boot.img"); $collection->taskExec("dd if=".$kernelBootPartition." of=$tmpDir/boot.img");
if ($genkernel == false) { if ($genkernel == false) {
$collection->say("Packaging kernel backup in ".$this->dir['kernel-install']."/backups/..."); $collection->say("Packaging kernel backup in ".$this->dir['kernel-install']."/backups/...");
$collection->taskPack($this->dir['kernel-install']."/backups/boot.img-".date("mdY-gha").".tar.gz") $collection->taskPack($this->dir['kernel-install']."/backups/boot.img-".date("mdY-gha").".tar.gz")
->add("$tmpDir/config.gz") ->add("$tmpDir/config.gz")
->add("$tmpDir/boot.img"); ->add("$tmpDir/boot.img");
} else { } else {
$collection->say("Packaging kernel backup in ".getenv("HOME")."/.local/system/boot/backups/..."); $collection->say("Packaging kernel backup in ".getenv("HOME")."/.local/system/boot/backups/...");
$collection->taskPack(getenv("HOME")."/.local/system/boot/backups/boot.img-".date("mdY-gha").".tar.gz") $collection->taskPack(getenv("HOME")."/.local/system/boot/backups/boot.img-".date("mdY-gha").".tar.gz")
->add("$tmpDir/config.gz") ->add("$tmpDir/config.gz")
->add("$tmpDir/boot.img"); ->add("$tmpDir/boot.img");
} }
$collection->run(); $collection->run();
} }
public function kernelRestore($opts = ['backup-package' => "", 'boot-partition' => ""]) public function kernelRestore($opts = ['backup-package' => "", 'boot-partition' => ""])
{ {
\Robo\Robo::loadConfiguration([getenv("HOME")."/.config/tononix/device-configs/".$this->device_manufacturer."/".$this->device_name."yml",getenv("HOME")."/.local/system/etc/tononixOS/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml","/etc/tononixOS/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml",__DIR__."/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml"]); \Robo\Robo::loadConfiguration([getenv("HOME")."/.config/tononix/device-configs/".$this->device_manufacturer."/".$this->device_name."yml",getenv("HOME")."/.local/system/etc/tononixOS/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml","/etc/tononixOS/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml",__DIR__."/device-configs/".$this->device_manufacturer."/".$this->device_name.".yml"]);
$kernelBootPartition = \Robo\Robo::Config()->get("device.partition_info.boot").\AndroidDevice::__getBootSlot(); $kernelBootPartition = \Robo\Robo::Config()->get("device.partition_info.boot").\AndroidDevice::__getBootSlot();
if(!empty($opts['boot-partition'])) $kernelBootPartition = $opts['boot-partition']; if(!empty($opts['boot-partition'])) $kernelBootPartition = $opts['boot-partition'];
if(!empty($opts['backup-package'])) { if(!empty($opts['backup-package'])) {
$this->yell("No package specified, cannot proceed."); $this->yell("No package specified, cannot proceed.");
die(); die();
} }
die("TODO: This function has not been implemented yet..."); die("TODO: This function has not been implemented yet...");
} }
} }

View File

@@ -1 +1 @@
v1.0.2 v1.0.2

View File

@@ -1,17 +1,17 @@
{ {
"main": "init.php", "main": "init.php",
"output": "build/krnlupdate.phar", "output": "build/krnlupdate.phar",
"files": ["init.php", "files": ["init.php",
"RoboFile.php", "RoboFile.php",
"VERSION"], "VERSION"],
"directories": ["device-configs/","lib","vendor"], "directories": ["device-configs/","lib","vendor"],
"blacklist": ["build"], "blacklist": ["build"],
"banner": [ "banner": [
"This file is a part of the tononixOS application suite.", "This file is a part of the tononixOS application suite.",
"", "",
"(c) Richard Blair <dreamcaster23@gmail.com>", "(c) Richard Blair <dreamcaster23@gmail.com>",
"" ""
] ]
} }

20
build.sh Executable file → Normal file
View File

@@ -1,10 +1,10 @@
#!/bin/bash #!/bin/bash
composer install composer install
if [[ $1 != "" ]]; then if [[ $1 != "" ]]; then
bumpver update $1 bumpver update $1
else else
bumpver update --patch bumpver update --patch
fi fi
vendor/bin/box compile vendor/bin/box compile
cp VERSION build/VERSION cp VERSION build/VERSION

View File

@@ -1,15 +1,15 @@
[bumpver] [bumpver]
current_version = "v1.0.2" current_version = "v1.0.2"
version_pattern = "vMAJOR.MINOR[.PATCH][-TAG]" version_pattern = "vMAJOR.MINOR[.PATCH][-TAG]"
commit_message = "bump version {old_version} -> {new_version}" commit_message = "bump version {old_version} -> {new_version}"
commit = true commit = true
tag = true tag = true
push = false push = false
[bumpver.file_patterns] [bumpver.file_patterns]
"VERSION" = [ "VERSION" = [
'{version}' '{version}'
] ]
"RoboFile.php" = [ "RoboFile.php" = [
' * Application Ver: {version}' ' * Application Ver: {version}'
] ]

View File

@@ -1,26 +1,26 @@
{ {
"name": "tononixos/tononixos_application_krnlupdate", "name": "tononixos/tononixos_application_krnlupdate",
"description": "Updates kernel images on tononixOS devices.", "description": "Updates kernel images on tononixOS devices.",
"type": "project", "type": "project",
"minimum-stability": "dev", "minimum-stability": "dev",
"authors": [ "authors": [
{ {
"name": "Tonoxis", "name": "Tonoxis",
"email": "toxus@tonoxisisle.services" "email": "toxus@tonoxisisle.services"
} }
], ],
"repositories": [ "repositories": [
{ {
"type": "vcs", "type": "vcs",
"url": "https://tonoxisisle.services/git/tononixOS/tononixOS_library_android-devices" "url": "https://tonoxisisle.services/git/tononixOS/tononixOS_library_android-devices"
} }
], ],
"require": { "require": {
"consolidation/robo": "^3.0", "consolidation/robo": "^3.0",
"tononixos/tononixos_library_android-devices": "master" "tononixos/tononixos_library_android-devices": "master"
}, },
"require-dev": { "require-dev": {
"bamarni/composer-bin-plugin": "^1.4" "bamarni/composer-bin-plugin": "^1.4"
} }
} }

View File

@@ -1,11 +1,11 @@
device: device:
friendly_name: Nexus 7 (2013) LTE friendly_name: Nexus 7 (2013) LTE
name: deb name: deb
manufacturer: asus manufacturer: asus
repositories: repositories:
kernel: https://tonoxisisle.services/git/TononixOS/ubports_kernel_google_msm kernel: https://tonoxisisle.services/git/TononixOS/ubports_kernel_google_msm
kernel-branch: flo # The Nexus 7 LTE uses the same kernel as the Nexus 7 WiFi kernel-branch: flo # The Nexus 7 LTE uses the same kernel as the Nexus 7 WiFi
partition_info: partition_info:
boot: /dev/disk/by-partlabel/boot boot: /dev/disk/by-partlabel/boot
system: /dev/disk/by-partlabel/system system: /dev/disk/by-partlabel/system

View File

@@ -1,11 +1,11 @@
device: device:
friendly_name: Nexus 7 (2013) WiFi friendly_name: Nexus 7 (2013) WiFi
name: flo name: flo
manufacturer: asus manufacturer: asus
repositories: repositories:
kernel: https://tonoxisisle.services/git/TononixOS/ubports_kernel_google_msm kernel: https://tonoxisisle.services/git/TononixOS/ubports_kernel_google_msm
branch: flo branch: flo
partition_info: partition_info:
boot: /dev/disk/by-partlabel/boot boot: /dev/disk/by-partlabel/boot
system: /dev/disk/by-partlabel/system system: /dev/disk/by-partlabel/system

72
init.php Executable file → Normal file
View File

@@ -1,37 +1,37 @@
<?php <?php
require_once(__DIR__."/RoboFile.php"); require_once(__DIR__."/RoboFile.php");
// If we're running from phar load the phar autoload file. // If we're running from phar load the phar autoload file.
$pharPath = \Phar::running(true); $pharPath = \Phar::running(true);
if ($pharPath) { if ($pharPath) {
$autoloaderPath = "$pharPath/vendor/autoload.php"; $autoloaderPath = "$pharPath/vendor/autoload.php";
} else { } else {
if (file_exists(__DIR__.'/vendor/autoload.php')) { if (file_exists(__DIR__.'/vendor/autoload.php')) {
$autoloaderPath = __DIR__.'/vendor/autoload.php'; $autoloaderPath = __DIR__.'/vendor/autoload.php';
} elseif (file_exists(__DIR__.'/../../autoload.php')) { } elseif (file_exists(__DIR__.'/../../autoload.php')) {
$autoloaderPath = __DIR__ . '/../../autoload.php'; $autoloaderPath = __DIR__ . '/../../autoload.php';
} else { } else {
die("Could not find autoloader. Run 'composer install'."); die("Could not find autoloader. Run 'composer install'.");
} }
} }
$classLoader = require $autoloaderPath; $classLoader = require $autoloaderPath;
// Customization variables // Customization variables
$appName = APPNAME; $appName = APPNAME;
$appVersion = trim(file_get_contents(__DIR__ . '/VERSION')); $appVersion = trim(file_get_contents(__DIR__ . '/VERSION'));
$commandClasses = [ \RoboFile::class ]; $commandClasses = [ \RoboFile::class ];
$selfUpdateRepository = 'tononixos/tononix_application_krnlupdate'; $selfUpdateRepository = 'tononixos/tononix_application_krnlupdate';
$configurationFilename = 'config.yml'; $configurationFilename = 'config.yml';
// Define our Runner, and pass it the command classes we provide. // Define our Runner, and pass it the command classes we provide.
$runner = new \Robo\Runner($commandClasses); $runner = new \Robo\Runner($commandClasses);
$runner $runner
// ->setSelfUpdateRepository($selfUpdateRepository) // This is now disabled as tononixOS uses the Tonoxis Isle Git service for it's code storage. // ->setSelfUpdateRepository($selfUpdateRepository) // This is now disabled as tononixOS uses the Tonoxis Isle Git service for it's code storage.
->setConfigurationFilename($configurationFilename) ->setConfigurationFilename($configurationFilename)
->setClassLoader($classLoader); ->setClassLoader($classLoader);
// Execute the command and return the result. // Execute the command and return the result.
$output = new \Symfony\Component\Console\Output\ConsoleOutput(); $output = new \Symfony\Component\Console\Output\ConsoleOutput();
$statusCode = $runner->execute($argv, $appName, $appVersion, $output); $statusCode = $runner->execute($argv, $appName, $appVersion, $output);
exit($statusCode); exit($statusCode);

16
krnlupdate.msbuildproj Normal file
View File

@@ -0,0 +1,16 @@
<Project Sdk="Peachpie.NET.Sdk/1.0.6">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<StartupObject>init.php</StartupObject>
<Description>A build system that provides build and update services to tononixOS.</Description>
<PackageId>tononixOS_krnlupdate</PackageId>
<Authors>Rick Blair &lt;ShadowEO@outlook.com&gt;</Authors>
<Company>Tonoxis Isle Services</Company>
<Product>tononixOS Kernel Build/Update System</Product>
<Copyright>Tonoxis Isle Services (c) 2018-*</Copyright>
</PropertyGroup>
<ItemGroup>
<Compile Include="**/*.php" />
</ItemGroup>
</Project>

View File

@@ -1,37 +1,37 @@
<?php <?php
class AndroidDevice class AndroidDevice
{ {
/** /**
* @name __getBootSlot * @name __getBootSlot
* @param void * @param void
* @description Attempts to determine the current bootslot for Treble compatibile devices. * @description Attempts to determine the current bootslot for Treble compatibile devices.
* @return false The system is not a treble compatible device * @return false The system is not a treble compatible device
* @return a|b System Bootslot * @return a|b System Bootslot
*/ */
public static function __getBootSlot() public static function __getBootSlot()
{ {
if(empty(`which getprop`)) if(empty(`which getprop`))
{ {
return false; return false;
} }
$bootSlot = trim(`getprop ro.boot.slot_suffix`); $bootSlot = trim(`getprop ro.boot.slot_suffix`);
if(empty($bootSlot)) if(empty($bootSlot))
{ {
return false; return false;
} }
return $bootSlot; return $bootSlot;
} }
public static function __getDeviceInfo() public static function __getDeviceInfo()
{ {
if(empty(`which getprop`)) if(empty(`which getprop`))
{ {
return false; return false;
} }
$device = array("device_name" => trim(`getprop ro.product.vendor.name`), $device = array("device_name" => trim(`getprop ro.product.vendor.name`),
"device_manufacturer" => trim(`getprop ro.product.vendor.manufacturer`)); "device_manufacturer" => trim(`getprop ro.product.vendor.manufacturer`));
return $device; return $device;
} }
} }

View File

@@ -0,0 +1,47 @@
<?php
namespace Packaging\Tasks;
class Package extends \Robo\Tasks
{
/**
* Installs the package
*
* @option prefix Location to install package to
*/
function packageInstall($opts = ['prefix' => "/usr"])
{
if(!file_exists(getcwd()."/build/krnlupdate.phar"))
{
$this->packageBuild();
}
$this->_copy(getcwd()."/build/krnlupdate.phar", $opts['prefix']."/usr/sbin/krnlupdate.phar");
}
/**
* Removes the package
*
* @option prefix Location to remove package from
*/
function packageRemove($opts = ['prefix' => "/usr"])
{
$this->_remove($opts['prefix']."/usr/sbin/krnlupdate.phar");
}
/**
* Builds the package
*/
function packageBuild()
{
$this->taskComposerInstall()
->dir(getcwd())
->args("--quiet")
->run();
$this->taskExec("box compile")
->printOutput(false)
->run();
}
}