Reorganisation de tout le systéme de build + debuggage os loader au autre scripts

This commit is contained in:
Marc
2022-02-26 19:23:34 +01:00
parent fc41d4bec0
commit 24c03e8090
25 changed files with 188 additions and 107 deletions
+2 -2
View File
@@ -55,7 +55,7 @@ if [ x$feature_default_font_path = xy ] ; then
else
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set=root c461e81d-f7a8-4d29-a874-f441afe07e45
search --no-floppy --label --set=root root
font="/usr/share/grub/unicode.pf2"
fi
@@ -71,7 +71,7 @@ terminal_input console
terminal_output gfxterm
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set=root c461e81d-f7a8-4d29-a874-f441afe07e45
search --no-floppy --label --set=root root
insmod gfxmenu
loadfont ($root)/usr/share/grub/themes/sleek/DejaVuSans-48.pf2
loadfont ($root)/usr/share/grub/themes/sleek/DejaVuSans-Regular-14.pf2
+31 -2
View File
@@ -1,5 +1,5 @@
//@ts-check
const { exec, fork } = require('child_process');
const { exec, fork, spawn } = require('child_process');
/**
* @param {string} path
* @deprecated
@@ -20,4 +20,33 @@ async function fHook(path) {
})
}
module.exports = { hookTo, fHook }
/**
* @param { string } cmd
* @param { import('child_process').SpawnOptionsWithoutStdio } [option]
*/
async function spawnAndWait(cmd, option) {
const child = spawn(cmd, option)
child.stdout.pipe(process.stdout)
child.stderr.pipe(process.stderr)
process.stdin.pipe(child.stdin)
await new Promise((res, rej) => {
child.on('exit', () => {
res()
})
})
process.stdin.unpipe(child.stdin)
}
/**
* @param { string } path
* @param { string[] } [args]
* @param { import('child_process').SpawnOptionsWithoutStdio } [options]
*/
async function startjs(path, args = [], options = {}) {
const arguments = args.map(arg => {return arg.includes(' ') ? `"${arg}"` : arg}).join(' ')
return spawnAndWait(`/usr/local/bin/node ${path} ${arguments}`, options)
}
module.exports = { hookTo, fHook, spawnAndWait, startjs }
+7 -2
View File
@@ -1,5 +1,6 @@
//@ts-check
const fs = require('fs')
function panic() {
console.log("/!\\ INIT PANIK /!\\ LOSE CHIBRE")
while(1) {}
@@ -16,7 +17,11 @@ async function main() {
await initd()
//chainload into sheebr
await fHook("/usr/bin/sheebr.js")
if(fs.existsSync("/usr/bin/sheebr.js")) {
await fHook("/usr/bin/sheebr.js")
} else {
console.log('wrong shell path')
}
reboot.disableCtrlAltSupr()
reboot.powerOff()
+12 -1
View File
@@ -40,4 +40,15 @@ function getFlags(interface) {
return ip.getFlags(interface);
}
module.exports = { setFlags, getFlags, flags }
/**
* @param { string } interface
* @param { Uint8Array } address
*/
function setIpv4(interface, address) {
if( address.length !== 4) {
throw new Error('invalid address length');
}
ip.setIpv4(interface, address.join('.'));
}
module.exports = { setFlags, getFlags, setIpv4, flags }
+1 -1
View File
@@ -1,7 +1,7 @@
const audio = require('../../core/audio')
async function init() {
audio('/chibrax/sheeebr.wav')
audio('/core/sheeebr.wav')
}
const after = [ "filesystem.js" ] // list of init script to load before
+4 -23
View File
@@ -4,28 +4,7 @@ const { getline } = require('../lib/sheebr/utils')
const fs = require('fs')
let environment = require('../lib/sheebr/environment')
let aliases = require("../lib/sheebr/aliases")
let { spawn } = require('child_process')
//utiliser ce code au lieux de execSync permet d'afficher le stdout au fur et a mesure ce qui fait qu'on a les logs quand une application throw une erreur
/**
* @param { string } cmd
* @param { import('child_process').SpawnOptionsWithoutStdio } [option]
*/
async function spawnAndWait(cmd, option) {
const child = spawn(cmd, option)
child.stdout.pipe(process.stdout)
child.stderr.pipe(process.stderr)
process.stdin.pipe(child.stdin)
await new Promise((res, rej) => {
child.on('exit', () => {
res()
})
})
process.stdin.unpipe(child.stdin)
}
const { startjs } = require('../../core/hook')
let current_dir = process.cwd()
@@ -90,7 +69,9 @@ async function evaluateProgram(args){
if(files.includes(`${args[0]}.js`)){
found = true;
try {
await spawnAndWait(`${environment.node} ${path + '/' + args[0]}.js ${args.map(arg => {return arg.includes(' ') ? `"${arg}"` : arg}).join(' ')}`, {cwd: current_dir, env: environment, shell: true});
const cmd = `${path + '/' + args[0]}.js`
const options = {cwd: current_dir, env: environment, shell: true}
await startjs(cmd, args, options)
tobreak = true;
} catch(e) {
console.log("Program crashed")
@@ -9,7 +9,6 @@ let environment = {
ln: [1, 36],
ex: [1, 32]
}),
node: "/usr/local/bin/node"
}
module.exports = environment