16 Commits
v1.0 ... master

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
bd20f73100 Transferred ownership of library dependency to tononixOS org, updating composer.json 2021-08-10 19:14:37 -04:00
a3d7d5a3bf bump version v1.0.1 -> v1.0.2 2021-08-10 19:12:33 -04:00
339a256bdf Fixed uncommitted error 2021-08-10 19:12:20 -04:00
e8d77693c0 Split off Android devices library to separate package. 2021-08-10 19:11:32 -04:00
f2991e1d10 Made BumpVer replace the forgotten version number inside the main RoboFile.php file. 2021-08-10 18:17:03 -04:00
8c430753fa bump version v1.0 -> v1.0.1 2021-08-10 18:06:46 -04:00
f603433607 Fixed an issue with the build script. 2021-08-10 18:06:25 -04:00
9d3c84b45d Added build script, BumpVer configuration, and disabled the Robo framework's built-in self-update system since we do not use Github. 2021-08-10 18:04:31 -04:00
15 changed files with 489 additions and 380 deletions

11
.gitignore vendored
View File

@@ -1,4 +1,7 @@
build/ build/
vendor/ vendor/
vendor-bin/ vendor-bin/
composer.lock composer.lock
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`

491
RoboFile.php Executable file → Normal file
View File

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

View File

@@ -1 +1 @@
{$GITTAG} 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>",
"" ""
] ]
} }

10
build.sh Normal file
View File

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

15
bumpver.toml Normal file
View File

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

View File

@@ -1,18 +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", {
"email": "toxus@tonoxisisle.services" "name": "Tonoxis",
} "email": "toxus@tonoxisisle.services"
], }
"require": { ],
"consolidation/robo": "^3.0" "repositories": [
}, {
"require-dev": { "type": "vcs",
"bamarni/composer-bin-plugin": "^1.4" "url": "https://tonoxisisle.services/git/tononixOS/tononixOS_library_android-devices"
} }
} ],
"require": {
"consolidation/robo": "^3.0",
"tononixos/tononixos_library_android-devices": "master"
},
"require-dev": {
"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 = "tononixOS Kernel Update Client"; $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) // ->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();
}
}

7
vendor/autoload.php vendored
View File

@@ -1,7 +0,0 @@
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderIniteef511e4731ef08dd3acba7ed3674cbc::getLoader();