Compare commits
10 Commits
a04c10d4c1
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| da9992e649 | |||
| bcdb26422a | |||
| 0211dd1f5d | |||
| 721c919c7b | |||
| db49f8d205 | |||
| 7f9119d218 | |||
| 39459df357 | |||
| a6f0b3367c | |||
| 24c03e8090 | |||
| fc41d4bec0 |
@@ -1,9 +1,13 @@
|
|||||||
rootfs.iso
|
rootfs.iso
|
||||||
chibrax.tar.gz
|
chibrax.tar.gz
|
||||||
rootfs
|
rootfs
|
||||||
|
libfs
|
||||||
linux-firmware
|
linux-firmware
|
||||||
disk.img
|
disk.img
|
||||||
diskoffset
|
diskoffset
|
||||||
package-lock.json
|
package-lock.json
|
||||||
build
|
build
|
||||||
node_modules
|
node_modules
|
||||||
|
ovmf_vars.fd
|
||||||
|
bun.lockb
|
||||||
|
.vscode
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
[submodule "linux-firmware"]
|
||||||
|
path = linux-firmware
|
||||||
|
url = https://gitlab.marcbarbier.fr/linuxjs/firmware-os
|
||||||
|
[submodule "kernel"]
|
||||||
|
path = kernel
|
||||||
|
url = https://gitlab.marcbarbier.fr/linuxjs/kernel-linux.js
|
||||||
Vendored
-98
@@ -1,98 +0,0 @@
|
|||||||
{
|
|
||||||
"python.linting.enabled": false,
|
|
||||||
"files.associations": {
|
|
||||||
"*.ejs": "html",
|
|
||||||
"*.inc": "cpp",
|
|
||||||
"internet": "cpp",
|
|
||||||
"socket": "cpp",
|
|
||||||
"functional": "c",
|
|
||||||
"cmath": "cpp",
|
|
||||||
"cstdlib": "cpp",
|
|
||||||
"hash_map": "cpp",
|
|
||||||
"cwchar": "cpp",
|
|
||||||
"cctype": "cpp",
|
|
||||||
"clocale": "cpp",
|
|
||||||
"cstdarg": "cpp",
|
|
||||||
"cstddef": "cpp",
|
|
||||||
"cstdint": "cpp",
|
|
||||||
"cstdio": "cpp",
|
|
||||||
"cstring": "cpp",
|
|
||||||
"ctime": "cpp",
|
|
||||||
"cwctype": "cpp",
|
|
||||||
"bitset": "cpp",
|
|
||||||
"deque": "cpp",
|
|
||||||
"forward_list": "cpp",
|
|
||||||
"list": "cpp",
|
|
||||||
"map": "cpp",
|
|
||||||
"set": "cpp",
|
|
||||||
"string": "cpp",
|
|
||||||
"unordered_map": "cpp",
|
|
||||||
"unordered_set": "cpp",
|
|
||||||
"vector": "cpp",
|
|
||||||
"algorithm": "cpp",
|
|
||||||
"array": "cpp",
|
|
||||||
"chrono": "cpp",
|
|
||||||
"iterator": "cpp",
|
|
||||||
"memory": "cpp",
|
|
||||||
"memory_resource": "cpp",
|
|
||||||
"numeric": "cpp",
|
|
||||||
"optional": "cpp",
|
|
||||||
"random": "cpp",
|
|
||||||
"ratio": "cpp",
|
|
||||||
"string_view": "cpp",
|
|
||||||
"system_error": "cpp",
|
|
||||||
"tuple": "cpp",
|
|
||||||
"type_traits": "cpp",
|
|
||||||
"utility": "cpp",
|
|
||||||
"atomic": "cpp",
|
|
||||||
"bit": "cpp",
|
|
||||||
"codecvt": "cpp",
|
|
||||||
"complex": "cpp",
|
|
||||||
"concepts": "cpp",
|
|
||||||
"condition_variable": "cpp",
|
|
||||||
"fstream": "cpp",
|
|
||||||
"iomanip": "cpp",
|
|
||||||
"iosfwd": "cpp",
|
|
||||||
"iostream": "cpp",
|
|
||||||
"istream": "cpp",
|
|
||||||
"limits": "cpp",
|
|
||||||
"mutex": "cpp",
|
|
||||||
"numbers": "cpp",
|
|
||||||
"ostream": "cpp",
|
|
||||||
"sstream": "cpp",
|
|
||||||
"stdexcept": "cpp",
|
|
||||||
"stop_token": "cpp",
|
|
||||||
"streambuf": "cpp",
|
|
||||||
"thread": "cpp",
|
|
||||||
"typeindex": "cpp",
|
|
||||||
"valarray": "cpp",
|
|
||||||
"variant": "cpp",
|
|
||||||
"cfenv": "cpp",
|
|
||||||
"cinttypes": "cpp",
|
|
||||||
"compare": "cpp",
|
|
||||||
"exception": "cpp",
|
|
||||||
"initializer_list": "cpp",
|
|
||||||
"new": "cpp",
|
|
||||||
"typeinfo": "cpp",
|
|
||||||
"*.tcc": "cpp",
|
|
||||||
"__bit_reference": "cpp",
|
|
||||||
"__bits": "cpp",
|
|
||||||
"__config": "cpp",
|
|
||||||
"__debug": "cpp",
|
|
||||||
"__errc": "cpp",
|
|
||||||
"__hash_table": "cpp",
|
|
||||||
"__locale": "cpp",
|
|
||||||
"__mutex_base": "cpp",
|
|
||||||
"__node_handle": "cpp",
|
|
||||||
"__nullptr": "cpp",
|
|
||||||
"__split_buffer": "cpp",
|
|
||||||
"__string": "cpp",
|
|
||||||
"__threading_support": "cpp",
|
|
||||||
"__tree": "cpp",
|
|
||||||
"__tuple": "cpp",
|
|
||||||
"ios": "cpp",
|
|
||||||
"locale": "cpp",
|
|
||||||
"queue": "cpp",
|
|
||||||
"stack": "cpp"
|
|
||||||
},
|
|
||||||
}
|
|
||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
{
|
|
||||||
"targets": [
|
|
||||||
{
|
|
||||||
"target_name": "syscall",
|
|
||||||
'cflags': [ '-Wall' ],
|
|
||||||
"sources": [
|
|
||||||
"clibs/syscall.cc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"target_name": "ioctl",
|
|
||||||
'cflags': [ '-Wall' ],
|
|
||||||
"sources": [
|
|
||||||
"clibs/ioctl.cc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"target_name": "mount",
|
|
||||||
'cflags': [ '-Wall' ],
|
|
||||||
"sources": [
|
|
||||||
"clibs/mount.cc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"target_name": "ip",
|
|
||||||
'cflags': [ '-Wall', '-Wextra' ],
|
|
||||||
"sources": [
|
|
||||||
"clibs/ip.cc"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -5,84 +5,87 @@ then echo "Please don't run this as root"
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 2> /dev/null veut dire que l'on veut pas voire les erreurs
|
unset LD_LIBRARY_PATH
|
||||||
sudo umount rootfs/proc -R 2> /dev/null
|
export LD_LIBRARY_PATH=$(pwd)/libfs/usr/lib
|
||||||
sudo rm -rf rootfs/ 2> /dev/null
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/libfs/usr/lib32
|
||||||
sudo rm root.iso 2> /dev/null
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/libfs/usr/lib64
|
||||||
sudo rm chibrax.tar.gz 2> /dev/null
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/libfs/usr/local/lib64
|
||||||
mkdir -p rootfs/
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/libfs/usr/local/lib
|
||||||
mkdir -p rootfs/boot
|
#host system for backup
|
||||||
mkdir -p rootfs/chibrax
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib64
|
||||||
mkdir -p rootfs/usr/local/bin
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib
|
||||||
mkdir -p rootfs/usr/local/sbin
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib32
|
||||||
mkdir -p rootfs/usr/local/lib
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64
|
||||||
mkdir -p rootfs/usr/local/lib64
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib
|
||||||
mkdir -p rootfs/usr/local/etc
|
|
||||||
mkdir -p rootfs/usr/bin
|
|
||||||
mkdir -p rootfs/usr/sbin
|
|
||||||
mkdir -p rootfs/usr/lib
|
|
||||||
mkdir -p rootfs/usr/lib32
|
|
||||||
mkdir -p rootfs/dev
|
|
||||||
mkdir -p rootfs/sys
|
|
||||||
mkdir -p rootfs/tmp
|
|
||||||
mkdir -p rootfs/home
|
|
||||||
mkdir -p rootfs/root
|
|
||||||
#TODO: faire des lien vers usr/bin et usr/sbin
|
|
||||||
mkdir -p rootfs/proc
|
|
||||||
mkdir -p rootfs/run
|
|
||||||
|
|
||||||
npm i
|
#it doesn't work yet so we unset the vars
|
||||||
|
unset LD_LIBRARY_PATH
|
||||||
|
|
||||||
cd rootfs
|
echo $LD_LIBRARY_PATH
|
||||||
|
|
||||||
|
function makeroot {
|
||||||
|
mkdir -p ${1}/boot || exit 1
|
||||||
|
mkdir -p ${1}/chibrax || exit 1
|
||||||
|
mkdir -p ${1}/usr/local/bin || exit 1
|
||||||
|
mkdir -p ${1}/usr/local/sbin || exit 1
|
||||||
|
mkdir -p ${1}/usr/local/lib || exit 1
|
||||||
|
mkdir -p ${1}/usr/local/lib64 || exit 1
|
||||||
|
mkdir -p ${1}/usr/local/etc || exit 1
|
||||||
|
mkdir -p ${1}/usr/bin || exit 1
|
||||||
|
mkdir -p ${1}/usr/sbin || exit 1
|
||||||
|
mkdir -p ${1}/usr/lib || exit 1
|
||||||
|
mkdir -p ${1}/usr/lib32 || exit 1
|
||||||
|
mkdir -p ${1}/dev || exit 1
|
||||||
|
mkdir -p ${1}/sys || exit 1
|
||||||
|
mkdir -p ${1}/tmp || exit 1
|
||||||
|
mkdir -p ${1}/home || exit 1
|
||||||
|
mkdir -p ${1}/root || exit 1
|
||||||
|
mkdir -p ${1}/proc || exit 1
|
||||||
|
mkdir -p ${1}/run || exit 1
|
||||||
|
|
||||||
|
echo "creating ${1} links"
|
||||||
|
cd ${1}
|
||||||
ln -s usr/bin bin || exit 1
|
ln -s usr/bin bin || exit 1
|
||||||
ln -s usr/sbin sbin || exit 1
|
ln -s usr/sbin sbin || exit 1
|
||||||
ln -s usr/lib lib || exit 1
|
ln -s usr/lib lib || exit 1
|
||||||
ln -s usr/lib lib64 || exit 1
|
ln -s usr/lib lib64 || exit 1
|
||||||
cd -
|
cd -
|
||||||
|
cd ${1}/usr
|
||||||
|
ln -s lib lib64 || exit 1
|
||||||
|
cd -
|
||||||
|
}
|
||||||
|
|
||||||
|
# 2> /dev/null veut dire que l'on veut pas voire les erreurs
|
||||||
|
sudo umount rootfs/proc -R 2> /dev/null
|
||||||
|
sudo rm -rf rootfs/ 2> /dev/null
|
||||||
|
sudo rm -rf libfs/ 2> /dev/null
|
||||||
|
sudo rm root.iso 2> /dev/null
|
||||||
|
sudo rm chibrax.tar.gz 2> /dev/null
|
||||||
|
makeroot libfs || exit 1
|
||||||
|
makeroot rootfs || exit 1
|
||||||
|
|
||||||
cd rootfs/usr
|
cd rootfs/usr
|
||||||
ln -s lib lib64
|
ln -s lib lib64
|
||||||
|
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
|
echo "done"
|
||||||
|
|
||||||
echo "construction de la libc"
|
echo "construction de la libc"
|
||||||
chmod +x ./libc/build.sh
|
chmod +x ./libc/build.sh
|
||||||
cd libc && ./build.sh || exit 1 && cd -
|
cd libc && ./build.sh > /dev/null || exit 1 && cd -
|
||||||
echo "done"
|
echo "done"
|
||||||
|
|
||||||
echo "construction de gcc"
|
echo "Téléchargement de Bun"
|
||||||
chmod +x ./libgcc/build.sh
|
cd bun && ./build.sh && cd -
|
||||||
cd libgcc && ./build.sh || exit 1 && cd -
|
cp bun/bun-linux-x64/bun rootfs/usr/bin/bun
|
||||||
echo "done"
|
echo "done"
|
||||||
|
|
||||||
echo "construction de eudev"
|
bun/bun-linux-x64/bun install
|
||||||
chmod +x ./libudev/build.sh
|
|
||||||
cd libudev && ./build.sh || exit 1 && cd -
|
|
||||||
echo "done"
|
|
||||||
|
|
||||||
echo "construction de lvm2(libdemapper)"
|
|
||||||
chmod +x ./lvm2/build.sh
|
|
||||||
cd lvm2 && ./build.sh || exit 1 && cd -
|
|
||||||
echo "done"
|
|
||||||
|
|
||||||
echo "construction de liblzma"
|
|
||||||
chmod +x ./liblzma/build.sh
|
|
||||||
cd liblzma && ./build.sh || exit 1 && cd -
|
|
||||||
echo "done"
|
|
||||||
|
|
||||||
echo "construction de grub"
|
|
||||||
chmod +x ./grub/build.sh
|
|
||||||
cd grub && ./build.sh || exit 1 && cd -
|
|
||||||
echo "done"
|
|
||||||
|
|
||||||
echo "construction de Nodejs"
|
|
||||||
chmod +x ./nodejs/build.sh
|
|
||||||
cd nodejs && ./build.sh || exit 1 && cd -
|
|
||||||
echo "done"
|
|
||||||
|
|
||||||
echo "construction du loader"
|
echo "construction du loader"
|
||||||
chmod +x ./chibraxLoader/build.sh
|
chmod +x ./osLoader/build.sh
|
||||||
cd chibraxLoader && ./build.sh && cd -
|
cd osLoader && ./build.sh && cd -
|
||||||
sudo cp chibraxLoader/init rootfs/usr/bin/ || exit 1
|
cp osLoader/init rootfs/usr/sbin/ || exit 1
|
||||||
echo "done"
|
echo "done"
|
||||||
|
|
||||||
echo "construction du bypass de sh"
|
echo "construction du bypass de sh"
|
||||||
@@ -102,8 +105,16 @@ sudo mkdir -p rootfs/usr/lib/firmware || exit 1
|
|||||||
sudo cp linux-firmware/* rootfs/usr/lib/firmware/ -r || exit 1
|
sudo cp linux-firmware/* rootfs/usr/lib/firmware/ -r || exit 1
|
||||||
echo "done"
|
echo "done"
|
||||||
|
|
||||||
echo "rebuilding C++ hooks"
|
cp libfs/usr/lib/libc.so.6 rootfs/usr/lib/
|
||||||
./clibs.sh || exit 1
|
cp libfs/usr/lib/libdl.so.2 rootfs/usr/lib/
|
||||||
echo "done"
|
cp libfs/usr/lib/libm.so.6 rootfs/usr/lib/
|
||||||
|
cp libfs/usr/lib/libpthread.so.0 rootfs/usr/lib/
|
||||||
|
cp libfs/usr/lib64/ld-linux-x86-64.so.2 rootfs/usr/lib64/
|
||||||
|
|
||||||
sudo cp rootfs\ overrides/* rootfs/ -r || exit 1
|
sudo cp rootfs\ overrides/* rootfs/ -r || exit 1
|
||||||
|
|
||||||
|
unset LD_LIBRARY_PATH
|
||||||
|
|
||||||
|
sudo chown root rootfs -R
|
||||||
|
|
||||||
|
#`libtool --finish /usr/lib
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
bun-linux-x64
|
||||||
|
*.zip
|
||||||
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
# bun compilation is still very iffy so we use the precompiled binaries for now
|
||||||
|
|
||||||
|
|
||||||
|
VER=0.2.1
|
||||||
|
|
||||||
|
if [ ! -f bun-linux-x64-baseline$VER.zip ]
|
||||||
|
then
|
||||||
|
wget https://github.com/oven-sh/bun/releases/download/bun-v$VER/bun-linux-x64-baseline.zip
|
||||||
|
unzip bun-linux-x64-baseline.zip
|
||||||
|
mv bun-linux-x64-baseline.zip bun-linux-x64-baseline$VER.zip
|
||||||
|
mv bun-linux-x64-baseline bun-linux-x64
|
||||||
|
fi
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
rm -rf rootfs
|
rm -rf rootfs
|
||||||
|
rm -rf libfs
|
||||||
rm -rf build
|
rm -rf build
|
||||||
rm -f disk.img
|
rm -f disk.img
|
||||||
rm -f diskoffset
|
rm -f diskoffset
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
echo "building node-c hooks"
|
|
||||||
node node_modules/node-gyp/bin/node-gyp.js configure
|
|
||||||
node node_modules/node-gyp/bin/node-gyp.js build
|
|
||||||
|
|
||||||
|
|
||||||
echo " syscall"
|
|
||||||
cp build/Release/syscall.node rootfs\ overrides/core/syscall.node
|
|
||||||
echo " ioctl"
|
|
||||||
cp build/Release/ioctl.node rootfs\ overrides/core/ioctl.node
|
|
||||||
echo " mount"
|
|
||||||
cp build/Release/mount.node rootfs\ overrides/core/mount.node
|
|
||||||
echo " ip"
|
|
||||||
cp build/Release/ip.node rootfs\ overrides/core/ip.node
|
|
||||||
|
|
||||||
echo "done"
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
#include <sys/ioctl.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <node.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#define nodeparam v8::FunctionCallbackInfo<v8::Value>
|
|
||||||
|
|
||||||
namespace ioctlNode {
|
|
||||||
void nodeIoctl(const nodeparam& args) {
|
|
||||||
v8::Isolate* isolate = args.GetIsolate();
|
|
||||||
if (args.Length() < 2 || !args[0]->IsUint32() || !args[1]->IsUint32()) {
|
|
||||||
isolate->ThrowException(v8::Exception::TypeError(
|
|
||||||
v8::String::NewFromUtf8(isolate, "Argument 1& 2 must be a number").ToLocalChecked()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
u_int32_t fd = args[0].As<v8::Number>()->Value();
|
|
||||||
unsigned long request = args[1].As<v8::Number>()->Value();
|
|
||||||
int params[args.Length() - 2];
|
|
||||||
for(int i = 1 ; i < args.Length(); i++ ) {
|
|
||||||
if (!args[i]->IsNumber()) {
|
|
||||||
isolate->ThrowException(v8::Exception::TypeError(
|
|
||||||
v8::String::NewFromUtf8(isolate, "Argument must be a number").ToLocalChecked()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
params[i - 1] = args[i].As<v8::Number>()->Value();
|
|
||||||
}
|
|
||||||
|
|
||||||
args.GetReturnValue().Set(ioctl(fd, request, ¶ms));
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports) {
|
|
||||||
NODE_SET_METHOD(exports, "ioctl", nodeIoctl);
|
|
||||||
}
|
|
||||||
|
|
||||||
NODE_MODULE(ioctl_api, Initialize)
|
|
||||||
}
|
|
||||||
-73
@@ -1,73 +0,0 @@
|
|||||||
#include "nodeparams.hpp"
|
|
||||||
#include <iostream>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <net/if.h>
|
|
||||||
#include <net/route.h>
|
|
||||||
#include <linux/sockios.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <node.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
const int inet_sock_fd = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0);
|
|
||||||
|
|
||||||
namespace ipNode {
|
|
||||||
int setflags(const char* iface, short flags) {
|
|
||||||
struct ifreq ifr;
|
|
||||||
|
|
||||||
ifr.ifr_flags = flags;
|
|
||||||
strncpy(ifr.ifr_name, iface, IFNAMSIZ);
|
|
||||||
|
|
||||||
return ioctl(inet_sock_fd, SIOCSIFFLAGS, &ifr);
|
|
||||||
}
|
|
||||||
|
|
||||||
int getIfreq(struct ifreq *ifr ) {
|
|
||||||
return ioctl(inet_sock_fd, SIOCGIFFLAGS, ifr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void nodeGetFlags(const nodeparam& args) {
|
|
||||||
v8::Isolate* isolate = args.GetIsolate();
|
|
||||||
|
|
||||||
if (args.Length() < 1 || !args[0]->IsString()) {
|
|
||||||
isolate->ThrowException(v8::Exception::TypeError(
|
|
||||||
v8::String::NewFromUtf8(isolate, "Invalid arguments ip.getflags").ToLocalChecked()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string iface = argToString(args[0]);
|
|
||||||
|
|
||||||
struct ifreq ifr;
|
|
||||||
strncpy(ifr.ifr_name, iface.c_str(), IFNAMSIZ);
|
|
||||||
int err = getIfreq(&ifr);
|
|
||||||
|
|
||||||
if(err != 0) {
|
|
||||||
char errstr[36];
|
|
||||||
sprintf(errstr, "Error while getting flags %d", errno);
|
|
||||||
isolate->ThrowException(v8::Exception::TypeError(
|
|
||||||
v8::String::NewFromUtf8(isolate, errstr).ToLocalChecked()));
|
|
||||||
}
|
|
||||||
args.GetReturnValue().Set(ifr.ifr_flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
void nodeSetFlags(const nodeparam& args) {
|
|
||||||
v8::Isolate* isolate = args.GetIsolate();
|
|
||||||
|
|
||||||
if (args.Length() < 2 || !args[0]->IsString() || !args[1]->IsUint32()) {
|
|
||||||
isolate->ThrowException(v8::Exception::TypeError(
|
|
||||||
v8::String::NewFromUtf8(isolate, "Invalid arguments ip.srtFlags").ToLocalChecked()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
short flags = (short) argToInt(args[1]);
|
|
||||||
std::string path = argToString(args[0]);
|
|
||||||
|
|
||||||
args.GetReturnValue().Set(setflags(path.c_str(), flags));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports) {
|
|
||||||
NODE_SET_METHOD(exports, "setFlags", nodeSetFlags);
|
|
||||||
NODE_SET_METHOD(exports, "getFlags", nodeGetFlags);
|
|
||||||
}
|
|
||||||
|
|
||||||
NODE_MODULE(ip_api, Initialize)
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
#include <sys/mount.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <node.h>
|
|
||||||
|
|
||||||
namespace mountNode {
|
|
||||||
void nodemount(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|
||||||
v8::Isolate* isolate = args.GetIsolate();
|
|
||||||
|
|
||||||
if (!args[0]->IsString()) {
|
|
||||||
isolate->ThrowException(v8::Exception::TypeError(
|
|
||||||
v8::String::NewFromUtf8(isolate, "First argument must be a string pointing to a device").ToLocalChecked()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!args[1]->IsString()) {
|
|
||||||
isolate->ThrowException(v8::Exception::TypeError(
|
|
||||||
v8::String::NewFromUtf8(isolate, "Argument must be a string pointing to a folder").ToLocalChecked()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!args[2]->IsString()) {
|
|
||||||
isolate->ThrowException(v8::Exception::TypeError(
|
|
||||||
v8::String::NewFromUtf8(isolate, "Argument must be a filesystem name").ToLocalChecked()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!args[3]->IsNumber()) {
|
|
||||||
isolate->ThrowException(v8::Exception::TypeError(
|
|
||||||
v8::String::NewFromUtf8(isolate, "Argument must be a number made from the mount flags").ToLocalChecked()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!args[4]->IsString()) {
|
|
||||||
isolate->ThrowException(v8::Exception::TypeError(
|
|
||||||
v8::String::NewFromUtf8(isolate, "Argument must be a string").ToLocalChecked()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
v8::String::Utf8Value devpathV8(isolate, args[0]);
|
|
||||||
std::string devpath(*devpathV8);
|
|
||||||
|
|
||||||
v8::String::Utf8Value mountPointV8(isolate, args[1]);
|
|
||||||
std::string mountPoint(*mountPointV8);
|
|
||||||
|
|
||||||
v8::String::Utf8Value fsTypeV8(isolate, args[2]);
|
|
||||||
std::string fsType(*fsTypeV8);
|
|
||||||
|
|
||||||
unsigned long rwFlags = args[3].As<v8::Number>()->Value();
|
|
||||||
|
|
||||||
//comma separated parameters passed directly into the fs driver
|
|
||||||
v8::String::Utf8Value fsFlagsV8(isolate, args[4]);
|
|
||||||
std::string fsFlags(*fsFlagsV8);
|
|
||||||
|
|
||||||
const int returnValue = mount(devpath.c_str(), mountPoint.c_str(), fsType.c_str(), rwFlags, fsFlags.c_str());
|
|
||||||
args.GetReturnValue().Set(returnValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports) {
|
|
||||||
NODE_SET_METHOD(exports, "mount", nodemount);
|
|
||||||
}
|
|
||||||
|
|
||||||
NODE_MODULE(mount_api, Initialize)
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#include <string>
|
|
||||||
#include <v8.h>
|
|
||||||
|
|
||||||
#define nodeparam v8::FunctionCallbackInfo<v8::Value>
|
|
||||||
#define argToInt(arg) arg.As<v8::Number>()->Value()
|
|
||||||
#define argToString(arg) std::string(*v8::String::Utf8Value(isolate, arg))
|
|
||||||
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
#include <sys/syscall.h> /* Definition of SYS_* constants */
|
|
||||||
#include <sys/reboot.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <node.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#define returnjs(val) args.GetReturnValue().Set(val);
|
|
||||||
namespace syscallNode {
|
|
||||||
void freeList(std::list<std::string *> &list) {
|
|
||||||
std::list<std::string *>::iterator it = list.begin();
|
|
||||||
for(; it != list.end(); it++) {
|
|
||||||
delete *it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void nodeSyscall(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|
||||||
v8::Isolate* isolate = args.GetIsolate();
|
|
||||||
|
|
||||||
std::list<std::string *> memoryToClean;
|
|
||||||
|
|
||||||
//les registres rdi, rsi, rdx ...
|
|
||||||
long int registers[args.Length()];
|
|
||||||
|
|
||||||
for(int i=0; i < args.Length(); i++) {
|
|
||||||
if(args[i]->IsNumber()) {
|
|
||||||
registers[i] = args[i].As<v8::Number>()->Value();
|
|
||||||
} else if(args[i]->IsString()) {
|
|
||||||
v8::String::Utf8Value argv8(isolate, args[i]);
|
|
||||||
std::string *argStr = new std::string(*argv8);
|
|
||||||
//un pointer c'est un u_int32_t donc sa deverais passer
|
|
||||||
registers[i] = (long int)argStr->c_str();
|
|
||||||
memoryToClean.push_front(argStr);
|
|
||||||
} else {
|
|
||||||
freeList(memoryToClean);
|
|
||||||
//respond -1 is something went wrong
|
|
||||||
returnjs(-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
long int syscallReturnValue;
|
|
||||||
|
|
||||||
switch(memoryToClean.size()) {
|
|
||||||
case 1:
|
|
||||||
syscallReturnValue = syscall(registers[0]);
|
|
||||||
return;
|
|
||||||
case 2:
|
|
||||||
syscallReturnValue = syscall(registers[0], registers[1]);
|
|
||||||
return;
|
|
||||||
case 3:
|
|
||||||
syscallReturnValue = syscall(registers[0], registers[1], registers[2]);
|
|
||||||
return;
|
|
||||||
case 4:
|
|
||||||
syscallReturnValue = syscall(registers[0], registers[1], registers[2], registers[3]);
|
|
||||||
return;
|
|
||||||
case 5:
|
|
||||||
syscallReturnValue = syscall(registers[0], registers[1], registers[2], registers[3], registers[4]);
|
|
||||||
return;
|
|
||||||
|
|
||||||
default:
|
|
||||||
//unsuported length
|
|
||||||
returnjs(-2);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
freeList(memoryToClean);
|
|
||||||
if(syscallReturnValue == -1) {
|
|
||||||
returnjs(errno);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void nodeReboot(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|
||||||
v8::Isolate* isolate = args.GetIsolate();
|
|
||||||
if (!args[0]->IsNumber()) {
|
|
||||||
isolate->ThrowException(v8::Exception::TypeError(
|
|
||||||
v8::String::NewFromUtf8(isolate, "Argument must be a number").ToLocalChecked()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
long argsValue = args[0].As<v8::Number>()->Value();
|
|
||||||
reboot(argsValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports) {
|
|
||||||
NODE_SET_METHOD(exports, "reboot", nodeReboot);
|
|
||||||
NODE_SET_METHOD(exports, "syscall", nodeSyscall);
|
|
||||||
}
|
|
||||||
|
|
||||||
NODE_MODULE(syscall_api, Initialize)
|
|
||||||
}
|
|
||||||
+41
-42
@@ -5,73 +5,72 @@ then echo "Please run as root"
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d rootfs\ overrides/chibrax/node_modules ]
|
if [ ! -d rootfs\ overrides/core/node_modules ]
|
||||||
then
|
then
|
||||||
echo "please run npmi.sh"
|
echo "please run npmi.sh"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CHIBRAX_MOUNT_POINT="/tmp/chibraxMountPoint"
|
CHIBRAX_MOUNT_POINT="/tmp/core"
|
||||||
|
EFI_MOUNT_POINT="/tmp/efi"
|
||||||
|
|
||||||
rm -f disk.img
|
rm -f disk.img
|
||||||
|
|
||||||
|
while umount -R rootfs/proc
|
||||||
|
do
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
|
||||||
#create a 8Gb iso
|
#create a 8Gb iso
|
||||||
dd if=/dev/zero of=disk.img bs=1024k seek=$((1000 * 8)) count=0
|
dd if=/dev/zero of=disk.img bs=1024k seek=$((1000 * 8)) count=0
|
||||||
|
|
||||||
|
HEADER_SIZE=2048
|
||||||
|
EFI_SIZE=512
|
||||||
|
EFI_SECTOR_LIMIT=997376
|
||||||
|
ROOT_SECTOR_LIMIT=15382528
|
||||||
|
SECTOR_SIZE=512
|
||||||
|
HEADER_OFFSET=$(($HEADER_SIZE * $SECTOR_SIZE))
|
||||||
|
ROOT_OFFSET=$(( ($EFI_SECTOR_LIMIT + $HEADER_SIZE ) * $SECTOR_SIZE ))
|
||||||
|
|
||||||
#creating a msdos image for mbr boot
|
#creating a msdos image for mbr boot
|
||||||
parted disk.img mklabel msdos
|
parted disk.img mklabel gpt
|
||||||
parted disk.img mkpart primary ext4 0% 100%
|
echo "parted disk.img mkpart ext4 0% ${EFI_SIZE}M"
|
||||||
|
parted disk.img mkpart efi 0% ${EFI_SIZE}MB
|
||||||
|
parted disk.img mkpart root ${EFI_SIZE}MB 100%
|
||||||
|
|
||||||
|
##EFI
|
||||||
|
#parted disk.img name 1 root
|
||||||
START_SECTOR=$(file disk.img | cut -d',' -f 8 | cut -d' ' -f3)
|
START_SECTOR=$(file disk.img | cut -d',' -f 8 | cut -d' ' -f3)
|
||||||
echo "Start sector :" $START_SECTOR
|
echo "Start sector :" $START_SECTOR
|
||||||
OFFSET=$((512*$START_SECTOR))
|
|
||||||
|
|
||||||
echo $OFFSET > diskoffset
|
losetup --offset $HEADER_OFFSET -f disk.img
|
||||||
|
EFI_LOOP=$(losetup -a | grep -v deleted | grep disk.img | grep $HEADER_OFFSET | cut -d':' -f 1)
|
||||||
|
mkfs.fat -F 32 ${EFI_LOOP}
|
||||||
|
|
||||||
losetup --offset $OFFSET -f disk.img
|
echo "EFI LOOP: $EFI_LOOP"
|
||||||
LOOP=$(losetup -a | grep -v deleted | grep disk.img | cut -d':' -f 1)
|
|
||||||
|
|
||||||
losetup -f disk.img
|
mkdir -p $EFI_MOUNT_POINT
|
||||||
LOOP_ROOT=$(losetup -a | grep -v deleted | grep -v ${LOOP} | cut -d':' -f 1)
|
mount ${EFI_LOOP} $EFI_MOUNT_POINT
|
||||||
|
|
||||||
|
echo $ROOT_SECTOR_LIMIT
|
||||||
|
losetup --offset $ROOT_OFFSET -f disk.img --sizelimit $(($ROOT_SECTOR_LIMIT * 512))
|
||||||
|
ROOT_LOOP=$(losetup -a | grep -v deleted | grep disk.img | grep $ROOT_OFFSET | grep -v $EFI_LOOP | cut -d':' -f 1)
|
||||||
|
mkfs.ext4 ${ROOT_LOOP}
|
||||||
|
|
||||||
|
echo "ROOT LOOP: $ROOT_LOOP"
|
||||||
|
|
||||||
mkdir $CHIBRAX_MOUNT_POINT -p
|
mkdir $CHIBRAX_MOUNT_POINT -p
|
||||||
|
mount ${ROOT_LOOP} $CHIBRAX_MOUNT_POINT
|
||||||
mkfs.ext4 ${LOOP}
|
|
||||||
mount ${LOOP} $CHIBRAX_MOUNT_POINT
|
|
||||||
|
|
||||||
echo "rebuilding C++ hooks"
|
|
||||||
./clibs.sh
|
|
||||||
echo "done"
|
|
||||||
|
|
||||||
echo "coping rootfs"
|
echo "coping rootfs"
|
||||||
cp rootfs/* $CHIBRAX_MOUNT_POINT -r
|
cp rootfs/* $CHIBRAX_MOUNT_POINT -r
|
||||||
echo "done"
|
echo "done"
|
||||||
|
|
||||||
echo "installing grub"
|
cp kernel/src/arch/x86/boot/bzImage $EFI_MOUNT_POINT/bzImage.efi
|
||||||
mount --rbind /dev $CHIBRAX_MOUNT_POINT/dev
|
|
||||||
mount --make-rslave $CHIBRAX_MOUNT_POINT/dev
|
|
||||||
mount -t proc /proc $CHIBRAX_MOUNT_POINT/proc
|
|
||||||
mount --rbind /sys $CHIBRAX_MOUNT_POINT/sys
|
|
||||||
mount --make-rslave $CHIBRAX_MOUNT_POINT/sys
|
|
||||||
mount --rbind /tmp $CHIBRAX_MOUNT_POINT/tmp
|
|
||||||
|
|
||||||
chroot $CHIBRAX_MOUNT_POINT /sbin/ldconfig -p
|
|
||||||
chroot $CHIBRAX_MOUNT_POINT /usr/sbin/grub-install --target=i386-pc ${LOOP_ROOT} --modules=part_msdos
|
|
||||||
chroot $CHIBRAX_MOUNT_POINT /usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg
|
|
||||||
|
|
||||||
|
|
||||||
PARTUUID=$(lsblk $LOOP --fs | awk '{print $4}' | grep -v LABEL)
|
|
||||||
|
|
||||||
echo "menuentry 'Chibrax OS' {" >> $CHIBRAX_MOUNT_POINT/boot/grub/grub.cfg
|
|
||||||
echo " set root='hd0,msdos1'" >> $CHIBRAX_MOUNT_POINT/boot/grub/grub.cfg
|
|
||||||
echo " linux /boot/vmlinuz rootfstype=ext4 root=/dev/sda1 rw " >> $CHIBRAX_MOUNT_POINT/boot/grub/grub.cfg
|
|
||||||
echo "}" >> $CHIBRAX_MOUNT_POINT/boot/grub/grub.cfg
|
|
||||||
|
|
||||||
umount $CHIBRAX_MOUNT_POINT/dev -l
|
|
||||||
umount $CHIBRAX_MOUNT_POINT/proc -l
|
|
||||||
umount $CHIBRAX_MOUNT_POINT/sys -l
|
|
||||||
umount $CHIBRAX_MOUNT_POINT/tmp -l
|
|
||||||
umount $CHIBRAX_MOUNT_POINT
|
umount $CHIBRAX_MOUNT_POINT
|
||||||
losetup -d $LOOP_ROOT
|
umount $EFI_MOUNT_POINT
|
||||||
losetup -d $LOOP
|
losetup -d $EFI_LOOP
|
||||||
|
losetup -d $ROOT_LOOP
|
||||||
#built by root but used by any, usefull to run the vm without root privileges
|
#built by root but used by any, usefull to run the vm without root privileges
|
||||||
chmod 757 disk.img
|
chmod 757 disk.img
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
gcc fakesh.c -o executor
|
gcc fakesh.c -O3 -o executor
|
||||||
|
|
||||||
cp executor ../rootfs/bin/
|
cp executor ../rootfs/bin/
|
||||||
+1
-1
@@ -15,7 +15,7 @@ int main(int argc, char const *argv[])
|
|||||||
args[i-1] = (char *)argv[i];
|
args[i-1] = (char *)argv[i];
|
||||||
|
|
||||||
//args have to be null terminated
|
//args have to be null terminated
|
||||||
args[argc - 1] = NULL;
|
args[argc - 1] = (char *) NULL;
|
||||||
|
|
||||||
printf("starting %s\n", argv[1]);
|
printf("starting %s\n", argv[1]);
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
src
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
VER=2.06
|
|
||||||
|
|
||||||
if [ "$EUID" = 0 ]
|
|
||||||
then echo "Please don't run this as root"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ ! -d src ]
|
|
||||||
then
|
|
||||||
mkdir -p src
|
|
||||||
cd src
|
|
||||||
curl https://git.savannah.gnu.org/cgit/grub.git/snapshot/grub-$VER.tar.gz --output grub.tar.gz
|
|
||||||
tar xvf grub.tar.gz
|
|
||||||
rm grub.tar.gz
|
|
||||||
mv grub-$VER/* .
|
|
||||||
cd -
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd src
|
|
||||||
#no shure git.sv.gnu.org still exists but i had problems with my proxy anyway
|
|
||||||
sed -i "s/git\:\/\/git\.sv\.gnu\.org\/gnulib/https\:\/\/git.savannah.gnu.org\/git\/gnulib.git/g" ./bootstrap
|
|
||||||
|
|
||||||
./bootstrap
|
|
||||||
./configure --disable-werror --prefix=/usr
|
|
||||||
make -j$(nproc)
|
|
||||||
|
|
||||||
DESTDIR=$(pwd)/../../rootfs
|
|
||||||
|
|
||||||
sudo make install DESTDIR=$(realpath $DESTDIR)
|
|
||||||
cd -
|
|
||||||
|
|
||||||
Submodule
+1
Submodule kernel added at 59f83f98e7
-5353
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
|||||||
dist/
|
|
||||||
src/
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
|
|
||||||
if [ "$EUID" = 0 ]
|
|
||||||
then echo "Please don't run this as root"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d src ]
|
|
||||||
then
|
|
||||||
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.5.tar.xz
|
|
||||||
mkdir src
|
|
||||||
mv linux-5.15.5.tar.xz src/
|
|
||||||
cd src
|
|
||||||
tar xf linux-5.15.5.tar.xz
|
|
||||||
rm linux-5.15.5.tar.xz
|
|
||||||
mv linux-5.15.5/* .
|
|
||||||
rm -rf linux-5.15.5
|
|
||||||
|
|
||||||
cd -
|
|
||||||
|
|
||||||
fi
|
|
||||||
cd src
|
|
||||||
# make clean qui supprime le .config
|
|
||||||
#make mrproper
|
|
||||||
cp ../.config .config
|
|
||||||
make -j$(nproc) bzImage
|
|
||||||
make -j$(nproc) modules
|
|
||||||
sudo cp arch/x86_64/boot/bzImage ../../rootfs/boot/vmlinuz || exit 1
|
|
||||||
sudo cp System.map ../../rootfs/boot/System.map || exit 1
|
|
||||||
|
|
||||||
DESTDIR=$(pwd)/../../rootfs
|
|
||||||
sudo make modules_install INSTALL_MOD_PATH=$(realpath $DESTDIR) || exit 1
|
|
||||||
cd -
|
|
||||||
+4
-4
@@ -4,17 +4,17 @@ then echo "Please don't run this as root"
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git clone https://sourceware.org/git/glibc.git src
|
git clone https://sourceware.org/git/glibc.git src --depth=1 --single-branch --branch release/2.36/master
|
||||||
cd src
|
cd src
|
||||||
git checkout release/2.34/master
|
git restore .
|
||||||
git pull
|
git pull
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
mkdir src/build -p
|
mkdir src/build -p
|
||||||
cd src/build
|
cd src/build
|
||||||
pwd
|
pwd
|
||||||
../configure --sysconfdir=/etc -prefix=/usr --with-headers=/usr/include --with-bugurl=https://bugs.archlinux.org/ --enable-add-ons --enable-bind-now --enable-cet --enable-kernel=4.4 --enable-lock-elision --enable-multi-arch --enable-stack-protector=strong --enable-stackguard-randomization --enable-static-pie --enable-systemtap --disable-profile --disable-werror || exit 1
|
../configure --sysconfdir=/etc -prefix=/usr --with-headers=/usr/include --enable-add-ons --enable-bind-now --enable-cet --enable-lock-elision --enable-multi-arch --enable-stack-protector=strong --enable-stackguard-randomization --enable-static-pie --enable-systemtap --disable-profile --disable-werror || exit 1
|
||||||
make -j$(nproc) || exit 1
|
make -j$(nproc) || exit 1
|
||||||
DESTDIR=$(pwd)/../../../rootfs
|
DESTDIR=$(pwd)/../../../libfs
|
||||||
sudo make install DESTDIR=$(realpath $DESTDIR)
|
sudo make install DESTDIR=$(realpath $DESTDIR)
|
||||||
cd -
|
cd -
|
||||||
@@ -1 +0,0 @@
|
|||||||
src
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
VER=11.2.0
|
|
||||||
|
|
||||||
if [ ! -d src ]
|
|
||||||
then
|
|
||||||
mkdir src
|
|
||||||
cd src
|
|
||||||
curl https://ftp.gnu.org/gnu/gcc/gcc-$VER/gcc-$VER.tar.xz --output gcc.tar.xz -L
|
|
||||||
tar xvf gcc.tar.xz
|
|
||||||
mv gcc-$VER/* .
|
|
||||||
rm gcc.tar.xz gcc-$VER -rf
|
|
||||||
cd -
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd src
|
|
||||||
./configure --prefix=/usr
|
|
||||||
make -j$(nproc)
|
|
||||||
DESTDIR=$(pwd)/../../rootfs
|
|
||||||
sudo make install DESTDIR=$(realpath $DESTDIR)
|
|
||||||
cd -
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
src
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
if [ "$EUID" = 0 ]
|
|
||||||
then echo "Please don't run this as root"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
git clone https://github.com/kobolabs/liblzma src
|
|
||||||
cd src
|
|
||||||
git pull
|
|
||||||
./configure --prefix /usr
|
|
||||||
make -j$(nproc)
|
|
||||||
|
|
||||||
DESTDIR=$(pwd)/../../rootfs
|
|
||||||
sudo make install DESTDIR=$(realpath $DESTDIR)
|
|
||||||
|
|
||||||
cd -
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
src
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
|
|
||||||
VER=3.2.11-pre2
|
|
||||||
|
|
||||||
if [ ! -f src ]
|
|
||||||
then
|
|
||||||
mkdir src
|
|
||||||
cd src
|
|
||||||
curl https://github.com/eudev-project/eudev/releases/download/v$VER/eudev-$VER.tar.gz -L --output eudev.tar.gz
|
|
||||||
tar xvf eudev.tar.gz
|
|
||||||
mv eudev-$VER/* .
|
|
||||||
rm eudev.tar.gz
|
|
||||||
cd -
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd src
|
|
||||||
./configure --prefix=/usr --sysconfdir=/etc --enable-add-ons --enable-bind-now --enable-cet --enable-kernel=4.4 --enable-lock-elision --enable-stack-protector=strong --enable-stackguard-randomization --enable-static-pie --enable-systemtap --disable-profile --disable-werror
|
|
||||||
make -j$(nproc)
|
|
||||||
|
|
||||||
DESTDIR=$(pwd)/../../rootfs
|
|
||||||
|
|
||||||
sudo make install DESTDIR=$(realpath $DESTDIR)
|
|
||||||
cd -
|
|
||||||
Submodule
+1
Submodule linux-firmware added at 7304a0d522
@@ -1 +0,0 @@
|
|||||||
src
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
VER=4.1
|
|
||||||
|
|
||||||
git clone https://sourceware.org/git/lvm2.git src
|
|
||||||
|
|
||||||
cd src
|
|
||||||
git pull
|
|
||||||
./autogen.sh
|
|
||||||
./configure
|
|
||||||
make -j$(nproc)
|
|
||||||
DESTDIR=$(pwd)/../../rootfs
|
|
||||||
sudo make install DESTDIR=$(realpath $DESTDIR)
|
|
||||||
cd -
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
src
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [ "$EUID" = 0 ]
|
|
||||||
then echo "Please don't run this as root"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
VERSION=17.1.0
|
|
||||||
|
|
||||||
if [ ! -f src/node-$VERSION/Makefile ]
|
|
||||||
then
|
|
||||||
mkdir src -p
|
|
||||||
cd src
|
|
||||||
echo "clonning"
|
|
||||||
curl https://github.com/nodejs/node/archive/refs/tags/v$VERSION.zip -L --output $VERSION.zip || exit 1
|
|
||||||
unzip $VERSION.zip || exit 1
|
|
||||||
./patch.sh
|
|
||||||
cd -
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd src/node-$VERSION
|
|
||||||
./configure --prefix=/usr || exit 1
|
|
||||||
make -j$(nproc) || exit 1
|
|
||||||
cd -
|
|
||||||
|
|
||||||
sudo src/node-$VERSION/tools/install.py install $(pwd)/../rootfs || exit 1
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
patch -R src/node-17.1.0/lib/child_process.js patches/child_process_executor.diff
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
586,591d585
|
|
||||||
< } else if (typeof options.shell === 'string') {
|
|
||||||
< file = '/bin/executor';
|
|
||||||
< args = [ options.shell, '-c', command];
|
|
||||||
< } else if (process.platform === 'android') {
|
|
||||||
< file = '/system/bin/sh';
|
|
||||||
< args = ['-c', command];
|
|
||||||
593,594c587,593
|
|
||||||
< file = '/bin/executor';
|
|
||||||
< args = command.split(' ');
|
|
||||||
---
|
|
||||||
> if (typeof options.shell === 'string')
|
|
||||||
> file = options.shell;
|
|
||||||
> else if (process.platform === 'android')
|
|
||||||
> file = '/system/bin/sh';
|
|
||||||
> else
|
|
||||||
> file = '/bin/sh';
|
|
||||||
> args = ['-c', command];
|
|
||||||
@@ -4,4 +4,4 @@ then echo "Please don't run as root"
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
npm i
|
npm i
|
||||||
cd rootfs\ overrides/chibrax && npm i && cd -
|
cd rootfs\ overrides/core && npm i && cd -
|
||||||
+3
-1
@@ -4,4 +4,6 @@ then echo "Please don't run this as root"
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gcc osLoader.c -O3 -o init
|
CFLAGS=""
|
||||||
|
|
||||||
|
gcc osLoader.c -o init --static
|
||||||
|
|||||||
+30
-3
@@ -1,9 +1,36 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
//Chemin exacte de node (a changer aprés la creation d'un gestionnaire de packets)
|
//Chemin exacte de node (a changer aprés la creation d'un gestionnaire de packets)
|
||||||
#define node "/usr/local/bin/node"
|
#define BUN "/usr/bin/bun"
|
||||||
#define chibrax "/core/index.js"
|
#define INIT "/core/index.js"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
execl(node, node, chibrax);
|
printf("Booting \n");
|
||||||
|
|
||||||
|
if(access(INIT, F_OK) != 0) {
|
||||||
|
printf("/!\\ Core is missing \n");
|
||||||
|
sleep(INT_MAX);
|
||||||
|
} else {
|
||||||
|
printf("Core is present\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Mounting /proc:");
|
||||||
|
if(mount("dummy", "/proc", "proc", MS_NODEV | MS_RDONLY | MS_NOSUID | MS_RELATIME | MS_NOEXEC, NULL) == 0) {
|
||||||
|
printf(": Success\n");
|
||||||
|
} else {
|
||||||
|
printf(": Failure\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(access(BUN, F_OK) == 0) {
|
||||||
|
printf("Starting bun\n");
|
||||||
|
sleep(1);
|
||||||
|
execl(BUN, BUN, "run", INIT, NULL);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("JS binary not found\n");
|
||||||
|
sleep(INT_MAX);
|
||||||
|
}
|
||||||
|
sleep(5);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/jimp": "^0.2.28",
|
"@types/jimp": "^0.2.28",
|
||||||
"@types/node": "^17.0.14",
|
"bun-types": "^0.2.1"
|
||||||
"node-gyp": "^8.4.1"
|
},
|
||||||
}
|
"type": "module"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
### BEGIN /etc/grub.d/00_header ###
|
|
||||||
insmod part_gpt
|
|
||||||
insmod part_msdos
|
|
||||||
if [ -s $prefix/grubenv ]; then
|
|
||||||
load_env
|
|
||||||
fi
|
|
||||||
if [ "${next_entry}" ] ; then
|
|
||||||
set default="${next_entry}"
|
|
||||||
set next_entry=
|
|
||||||
save_env next_entry
|
|
||||||
set boot_once=true
|
|
||||||
else
|
|
||||||
set default="${saved_entry}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ x"${feature_menuentry_id}" = xy ]; then
|
|
||||||
menuentry_id_option="--id"
|
|
||||||
else
|
|
||||||
menuentry_id_option=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
export menuentry_id_option
|
|
||||||
|
|
||||||
if [ "${prev_saved_entry}" ]; then
|
|
||||||
set saved_entry="${prev_saved_entry}"
|
|
||||||
save_env saved_entry
|
|
||||||
set prev_saved_entry=
|
|
||||||
save_env prev_saved_entry
|
|
||||||
set boot_once=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
function savedefault {
|
|
||||||
if [ -z "${boot_once}" ]; then
|
|
||||||
saved_entry="${chosen}"
|
|
||||||
save_env saved_entry
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function load_video {
|
|
||||||
if [ x$feature_all_video_module = xy ]; then
|
|
||||||
insmod all_video
|
|
||||||
else
|
|
||||||
insmod efi_gop
|
|
||||||
insmod efi_uga
|
|
||||||
insmod ieee1275_fb
|
|
||||||
insmod vbe
|
|
||||||
insmod vga
|
|
||||||
insmod video_bochs
|
|
||||||
insmod video_cirrus
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ x$feature_default_font_path = xy ] ; then
|
|
||||||
font=unicode
|
|
||||||
else
|
|
||||||
insmod part_gpt
|
|
||||||
insmod ext2
|
|
||||||
search --no-floppy --fs-uuid --set=root c461e81d-f7a8-4d29-a874-f441afe07e45
|
|
||||||
font="/usr/share/grub/unicode.pf2"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if loadfont $font ; then
|
|
||||||
set gfxmode=auto
|
|
||||||
load_video
|
|
||||||
insmod gfxterm
|
|
||||||
set locale_dir=$prefix/locale
|
|
||||||
set lang=fr_FR
|
|
||||||
insmod gettext
|
|
||||||
fi
|
|
||||||
terminal_input console
|
|
||||||
terminal_output gfxterm
|
|
||||||
insmod part_gpt
|
|
||||||
insmod ext2
|
|
||||||
search --no-floppy --fs-uuid --set=root c461e81d-f7a8-4d29-a874-f441afe07e45
|
|
||||||
insmod gfxmenu
|
|
||||||
loadfont ($root)/usr/share/grub/themes/sleek/DejaVuSans-48.pf2
|
|
||||||
loadfont ($root)/usr/share/grub/themes/sleek/DejaVuSans-Regular-14.pf2
|
|
||||||
loadfont ($root)/usr/share/grub/themes/sleek/DejaVuSans-Regular-16.pf2
|
|
||||||
loadfont ($root)/usr/share/grub/themes/sleek/terminus-14.pf2
|
|
||||||
loadfont ($root)/usr/share/grub/themes/sleek/terminus-16.pf2
|
|
||||||
insmod png
|
|
||||||
set theme=($root)/usr/share/grub/themes/sleek/theme.txt
|
|
||||||
export theme
|
|
||||||
if [ x$feature_timeout_style = xy ] ; then
|
|
||||||
set timeout_style=menu
|
|
||||||
set timeout=1
|
|
||||||
# Fallback normal timeout code in case the timeout_style feature is
|
|
||||||
# unavailable.
|
|
||||||
else
|
|
||||||
set timeout=1
|
|
||||||
fi
|
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
const fs = require('fs')
|
import * as fs from 'fs'
|
||||||
const audiopath = '/dev/audio'
|
const audiopath = '/dev/audio'
|
||||||
|
|
||||||
module.exports = (path) => {
|
export default function play(path) {
|
||||||
if(fs.existsSync(path) && fs.existsSync(audiopath)) {
|
if(fs.existsSync(audiopath)) {
|
||||||
|
if(fs.existsSync(path)) {
|
||||||
const data = fs.readFileSync(path)
|
const data = fs.readFileSync(path)
|
||||||
fs.writeFileSync(audiopath, data)
|
fs.writeFileSync(audiopath, data)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
console.log('Kernel doesn\'t have snd_pcm_oss or snd_seq_oss or snd_mixer_oss')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//@ts-check
|
//@ts-check
|
||||||
/** @type {{ [key: number]: string | undefined }} */
|
/** @type {{ [key: number]: string | undefined }} */
|
||||||
module.exports = {
|
export default {
|
||||||
1: "EPERM", //Operation not permitted
|
1: "EPERM", //Operation not permitted
|
||||||
2: "ENOENT", //No such file or directory
|
2: "ENOENT", //No such file or directory
|
||||||
3: "ESRCH", //No such process
|
3: "ESRCH", //No such process
|
||||||
@@ -82,7 +82,7 @@ module.exports = {
|
|||||||
81: "ELIBSCN", //lib section in a.out corrupted
|
81: "ELIBSCN", //lib section in a.out corrupted
|
||||||
82: "ELIBMAX", //Attempting to link in too many shared libraries
|
82: "ELIBMAX", //Attempting to link in too many shared libraries
|
||||||
83: "ELIBEXEC", //Cannot exec a shared library directly
|
83: "ELIBEXEC", //Cannot exec a shared library directly
|
||||||
84: "EILSEQ", //Illegal byte sequence
|
84: "EILSEQ", //Illegal byte sequencerequire
|
||||||
85: "ERESTART", //Interrupted system call should be restarted
|
85: "ERESTART", //Interrupted system call should be restarted
|
||||||
86: "ESTRPIPE", //Streams pipe error
|
86: "ESTRPIPE", //Streams pipe error
|
||||||
87: "EUSERS", //Too many users
|
87: "EUSERS", //Too many users
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//@ts-check
|
//@ts-check
|
||||||
const fs = require('fs')
|
import * as fs from 'fs'
|
||||||
const jimp = require('jimp')
|
import * as jimp from 'jimp'
|
||||||
|
|
||||||
const screen = getScreenDimensions()
|
const screen = getScreenDimensions()
|
||||||
const buffer = Buffer.alloc(screen.width * screen.height * screen.byteDepth)
|
const buffer = Buffer.alloc(screen.width * screen.height * screen.byteDepth)
|
||||||
@@ -24,7 +24,7 @@ function getScreenDimensions() {
|
|||||||
/**
|
/**
|
||||||
* @param { Buffer } data
|
* @param { Buffer } data
|
||||||
*/
|
*/
|
||||||
function flip(data = buffer) {
|
export function flip(data = buffer) {
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync('/dev/fb0', data, { encoding: 'binary' })
|
fs.writeFileSync('/dev/fb0', data, { encoding: 'binary' })
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@@ -33,14 +33,14 @@ function flip(data = buffer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clear() {
|
export function clear() {
|
||||||
buffer.fill(0)
|
buffer.fill(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} filepath
|
* @param {string} filepath
|
||||||
*/
|
*/
|
||||||
function removeFromCache(filepath) {
|
export function removeFromCache(filepath) {
|
||||||
delete imageCache[filepath]
|
delete imageCache[filepath]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ function removeFromCache(filepath) {
|
|||||||
* @param {string} filepath
|
* @param {string} filepath
|
||||||
* @returns { Promise<import('@jimp/core').Bitmap> } BGRA buffer
|
* @returns { Promise<import('@jimp/core').Bitmap> } BGRA buffer
|
||||||
*/
|
*/
|
||||||
async function readImgFile(filepath) {
|
export async function readImgFile(filepath) {
|
||||||
const img = await jimp.read(filepath)
|
const img = await jimp.read(filepath)
|
||||||
const bitmap = img.bitmap
|
const bitmap = img.bitmap
|
||||||
bitmap.data = rgbaTObgra(bitmap.data)
|
bitmap.data = rgbaTObgra(bitmap.data)
|
||||||
@@ -60,7 +60,7 @@ async function readImgFile(filepath) {
|
|||||||
* @param { number } y
|
* @param { number } y
|
||||||
* @param { import('@jimp/core').Bitmap | Pencil } bitmap
|
* @param { import('@jimp/core').Bitmap | Pencil } bitmap
|
||||||
*/
|
*/
|
||||||
function drawBitmap(x, y, bitmap, handleTransparency = true) {
|
export function drawBitmap(x, y, bitmap, handleTransparency = true) {
|
||||||
for(let dy = 0; dy < bitmap.height; dy++) {
|
for(let dy = 0; dy < bitmap.height; dy++) {
|
||||||
let bitmapLineEnd = bitmap.width * screen.byteDepth * (dy + 1)
|
let bitmapLineEnd = bitmap.width * screen.byteDepth * (dy + 1)
|
||||||
let bitmapLineStart = bitmap.width * screen.byteDepth * dy
|
let bitmapLineStart = bitmap.width * screen.byteDepth * dy
|
||||||
@@ -123,7 +123,7 @@ function drawBitmap(x, y, bitmap, handleTransparency = true) {
|
|||||||
* @description this function work fine but will use caching. to clear the cache you can use removeFromCache(filepath) or you can keep the cache on the
|
* @description this function work fine but will use caching. to clear the cache you can use removeFromCache(filepath) or you can keep the cache on the
|
||||||
* client side and use readImgFile and drawBitmap methods instead
|
* client side and use readImgFile and drawBitmap methods instead
|
||||||
*/
|
*/
|
||||||
async function drawImgFile(x, y, filepath) {
|
export async function drawImgFile(x, y, filepath) {
|
||||||
//not caching would imply reading the image each time we want to write it to the screen even for small movement
|
//not caching would imply reading the image each time we want to write it to the screen even for small movement
|
||||||
let bitmap;
|
let bitmap;
|
||||||
if(!imageCache[filepath]) {
|
if(!imageCache[filepath]) {
|
||||||
@@ -153,7 +153,7 @@ function rgbaTObgra(buff) {
|
|||||||
* @param { string } color
|
* @param { string } color
|
||||||
* @returns { number[] }
|
* @returns { number[] }
|
||||||
*/
|
*/
|
||||||
function parseHexColor(color) {
|
export function parseHexColor(color) {
|
||||||
if(!color.startsWith('#') || color.length !== 7) {
|
if(!color.startsWith('#') || color.length !== 7) {
|
||||||
throw new Error('invalid hex color code')
|
throw new Error('invalid hex color code')
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@ function parseHexColor(color) {
|
|||||||
* @param { number } y
|
* @param { number } y
|
||||||
* @param { string | number[] } colorCode
|
* @param { string | number[] } colorCode
|
||||||
*/
|
*/
|
||||||
function setPixel(x, y, colorCode) {
|
export function setPixel(x, y, colorCode) {
|
||||||
if (screen.byteDepth !== 4) {
|
if (screen.byteDepth !== 4) {
|
||||||
throw new Error('Depth not supported yet')
|
throw new Error('Depth not supported yet')
|
||||||
}
|
}
|
||||||
@@ -179,5 +179,3 @@ function setPixel(x, y, colorCode) {
|
|||||||
}
|
}
|
||||||
buffer.set(colorCode, (x + y * screen.width) * screen.byteDepth)
|
buffer.set(colorCode, (x + y * screen.width) * screen.byteDepth)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { flip, clear, getScreenDimensions, drawImgFile, readImgFile, drawBitmap, parseHexColor, setPixel, removeFromCache }
|
|
||||||
@@ -1,23 +1,39 @@
|
|||||||
//@ts-check
|
//@ts-check
|
||||||
const { exec, fork } = require('child_process');
|
import { spawnSync, spawn } from 'bun'
|
||||||
/**
|
|
||||||
* @param {string} path
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
function hookTo(path) {
|
|
||||||
exec(`node ${path}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} path
|
* @param {string} path
|
||||||
*/
|
*/
|
||||||
async function fHook(path) {
|
export async function fHook(path) {
|
||||||
const child = fork(path)
|
return await spawnAndWait([ '/usr/bin/bun', 'run', path ])
|
||||||
return new Promise((res, rej) => {
|
}
|
||||||
child.on('exit', () => {
|
|
||||||
res()
|
/**
|
||||||
})
|
* @param { [string, ...string[]] } cmd
|
||||||
|
* @param { import('bun').SpawnOptions.OptionsObject } [option]
|
||||||
|
*/
|
||||||
|
export async function spawnAndWait(cmd, option) {
|
||||||
|
console.log('spawning ' + cmd.join(' '))
|
||||||
|
return spawnSync(cmd, {
|
||||||
|
...option,
|
||||||
|
env: {
|
||||||
|
PATH: "/bin:/sbin:/usr/bin:/usr/sbin",
|
||||||
|
...process.env,
|
||||||
|
...(option?.env || {})
|
||||||
|
},
|
||||||
|
|
||||||
|
stdout: "inherit",
|
||||||
|
stdin: "inherit",
|
||||||
|
stderr: "inherit"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { hookTo, fHook }
|
/**
|
||||||
|
* @param { string } path
|
||||||
|
* @param { string[] } [args]
|
||||||
|
* @param { import('bun').SpawnOptions.OptionsObject } [options]
|
||||||
|
*/
|
||||||
|
export async function startjs(path, args = [], options = {}) {
|
||||||
|
const SpawnArguments = args.map(arg => {return arg.includes(' ') ? `"${arg}"` : arg})
|
||||||
|
return spawnAndWait(['/usr/bin/bun', path, ...SpawnArguments ], options)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
|
|
||||||
//@ts-check
|
//@ts-check
|
||||||
|
import * as fs from 'fs'
|
||||||
|
import { init } from './initd.js'
|
||||||
|
import * as reboot from './reboot.js'
|
||||||
|
import { fHook } from './hook.js'
|
||||||
|
|
||||||
function panic() {
|
function panic() {
|
||||||
console.log("/!\\ INIT PANIK /!\\ LOSE CHIBRE")
|
console.log("/!\\ INIT PANIK /!\\ LOSE CHIBRE")
|
||||||
while(1) {}
|
while(1) {}
|
||||||
@@ -7,16 +11,16 @@ function panic() {
|
|||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
try {
|
try {
|
||||||
const initd = require('./initd.js')
|
|
||||||
const reboot = require('./reboot.js')
|
|
||||||
const { fHook } = require("./hook.js")
|
|
||||||
|
|
||||||
console.clear()
|
console.clear()
|
||||||
|
|
||||||
await initd()
|
await init()
|
||||||
|
|
||||||
//chainload into sheebr
|
//chainload into sheebr
|
||||||
|
if(fs.existsSync("/usr/bin/sheebr.js")) {
|
||||||
await fHook("/usr/bin/sheebr.js")
|
await fHook("/usr/bin/sheebr.js")
|
||||||
|
} else {
|
||||||
|
console.log('wrong shell path')
|
||||||
|
}
|
||||||
reboot.disableCtrlAltSupr()
|
reboot.disableCtrlAltSupr()
|
||||||
reboot.powerOff()
|
reboot.powerOff()
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
//@ts-check
|
//@ts-check
|
||||||
const fs = require('fs')
|
import * as fs from 'fs'
|
||||||
const path = require('path')
|
import * as path from 'path'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{ name: string, before: string[], after: string[], init(): undefined | Promise<undefined> }} InitScript
|
* @typedef {{ name: string, before: string[], after: string[], init(): undefined | Promise<undefined> }} InitScript
|
||||||
*/
|
*/
|
||||||
async function init() {
|
export async function init() {
|
||||||
|
|
||||||
const initdFiles = fs.readdirSync('/etc/init.d/')
|
const initdFiles = fs.readdirSync('/etc/init.d/')
|
||||||
const initdScripts = initdFiles.filter( (v) => v.endsWith('.js'))
|
const initdScripts = initdFiles.filter( (v) => v.endsWith('.js'))
|
||||||
@@ -78,6 +78,3 @@ function processBefores(scripts) {
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = init
|
|
||||||
@@ -5,23 +5,6 @@
|
|||||||
* @param {string} str
|
* @param {string} str
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async function input(str) {
|
export default async function input(str) {
|
||||||
console.log(str)
|
return await Bun.stdin.text()
|
||||||
process.stdin.resume();
|
|
||||||
process.stdin.setEncoding('utf8');
|
|
||||||
let line = "";
|
|
||||||
return new Promise((res, rej) => {
|
|
||||||
process.stdin.on('data', function(chunk) {
|
|
||||||
line += chunk
|
|
||||||
if (chunk.toString('utf-8').endsWith('\n')) {
|
|
||||||
process.stdin.pause()
|
|
||||||
res(line.substring(0, line.length -1))
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
process.stdin.on('error', function(err) {
|
|
||||||
rej(err)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = input
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
//@ts-check
|
|
||||||
//@ts-expect-error
|
|
||||||
const { ioctl } = require('./ioctl.node')
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = { ioctl }
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
//@ts-check
|
//@ts-check
|
||||||
|
|
||||||
//@ts-expect-error
|
|
||||||
const ip = require('./ip.node')
|
|
||||||
|
|
||||||
const flags = {
|
const flags = {
|
||||||
IFF_UP: 0x1, /* Interface is up. */
|
IFF_UP: 0x1, /* Interface is up. */
|
||||||
@@ -40,4 +38,15 @@ function getFlags(interface) {
|
|||||||
return ip.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,26 +1,34 @@
|
|||||||
//@ts-check
|
//@ts-check
|
||||||
//@ts-expect-error
|
import { dlopen, FFIType } from 'bun:ffi';
|
||||||
const { syscall } = require('./syscall.node')
|
import errno from './errno.js'
|
||||||
const errno = require('./errno')
|
import * as fs from 'fs'
|
||||||
const fs = require('fs')
|
import * as path from 'path'
|
||||||
const path = require('path')
|
|
||||||
|
|
||||||
|
|
||||||
|
const {
|
||||||
|
symbols: {
|
||||||
|
syscall,
|
||||||
|
},
|
||||||
|
} = dlopen('/usr/lib/libc.so.6', {
|
||||||
|
syscall: {
|
||||||
|
args: [ FFIType.int, FFIType.int, FFIType.cstring, FFIType.int ],
|
||||||
|
returns: FFIType.int,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// TBD
|
// TBD
|
||||||
const SYSCALL_INIT_MODULE = 105
|
const SYSCALL_INIT_MODULE = 105
|
||||||
const SYSCALL_FINIT_MODULE = 273
|
const SYSCALL_FINIT_MODULE = 273
|
||||||
|
|
||||||
const doProcExists = () => fs.existsSync('/proc')
|
export const doProcExists = () => fs.existsSync('/proc')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {string} path
|
* @param {string} path
|
||||||
* @param {string} params
|
* @param {string} params
|
||||||
* @param {number} flags
|
* @param {number} flags
|
||||||
* @deprecated un tested dangerous
|
* @deprecated untested very dangerous
|
||||||
*/
|
*/
|
||||||
function finit_module(path, params = "", flags = 0) {
|
export function finit_module(path, params = "", flags = 0) {
|
||||||
const fileDescriptor = fs.openSync(path, 'r')
|
const fileDescriptor = fs.openSync(path, 'r')
|
||||||
const result = syscall(SYSCALL_FINIT_MODULE, fileDescriptor, params, flags)
|
const result = syscall(SYSCALL_FINIT_MODULE, fileDescriptor, params, flags)
|
||||||
if(result > 0) {
|
if(result > 0) {
|
||||||
@@ -34,8 +42,8 @@ function finit_module(path, params = "", flags = 0) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function uname() {
|
export function uname() {
|
||||||
if(!doProcExists) {
|
if(!doProcExists()) {
|
||||||
throw "Proc don't exists exception"
|
throw "Proc don't exists exception"
|
||||||
}
|
}
|
||||||
const linuxVersionString = fs.readFileSync('/proc/version').toString()
|
const linuxVersionString = fs.readFileSync('/proc/version').toString()
|
||||||
@@ -44,8 +52,9 @@ function uname() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} modulename
|
* @param {string} modulename
|
||||||
|
* @deprecated untested very dangerous
|
||||||
*/
|
*/
|
||||||
function modprobe(modulename) {
|
export function modprobe(modulename) {
|
||||||
const name = uname()
|
const name = uname()
|
||||||
if(fs.existsSync(path.join('/lib/modules', name, 'kernel', modulename))) {
|
if(fs.existsSync(path.join('/lib/modules', name, 'kernel', modulename))) {
|
||||||
finit_module(path.join('/lib/modules', name, 'kernel', modulename))
|
finit_module(path.join('/lib/modules', name, 'kernel', modulename))
|
||||||
@@ -55,11 +64,9 @@ function modprobe(modulename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function lsmod() {
|
export function lsmod() {
|
||||||
if(!doProcExists) {
|
if(!doProcExists()) {
|
||||||
throw "Proc don't exists exception"
|
throw "Proc don't exists exception"
|
||||||
}
|
}
|
||||||
return fs.readFileSync('/proc/modules').toString('utf-8').split('\n')
|
return fs.readFileSync('/proc/modules').toString('utf-8').split('\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { modprobe, uname, finit_module, doProcExists, lsmod, syscall }
|
|
||||||
@@ -1,18 +1,11 @@
|
|||||||
//@ts-check
|
//@ts-check
|
||||||
const fs =require('fs')
|
import * as fs from 'fs'
|
||||||
/**
|
import { dlopen, FFIType } from 'bun:ffi'
|
||||||
* @type {{ mount: (device_path: string, mount_point: string, fs: string, flags: number, fsparams: string ) => number }}
|
import { filesystems } from './suportedFilesystems'
|
||||||
*///@ts-expect-error
|
|
||||||
const nodemount = require("./mount.node")
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
const cmount = nodemount.mount
|
|
||||||
|
|
||||||
|
|
||||||
/* These are the fs-independent mount-flags: up to 16 flags are
|
/* These are the fs-independent mount-flags: up to 16 flags are
|
||||||
supported */
|
supported */
|
||||||
const flags = {
|
export const flags = {
|
||||||
MS_RDONLY: 1, /* Mount read-only. */
|
MS_RDONLY: 1, /* Mount read-only. */
|
||||||
MS_NOSUID: 2, /* Ignore suid and sgid bits. */
|
MS_NOSUID: 2, /* Ignore suid and sgid bits. */
|
||||||
MS_NODEV: 4, /* Disallow access to device special files. */
|
MS_NODEV: 4, /* Disallow access to device special files. */
|
||||||
@@ -41,6 +34,19 @@ const flags = {
|
|||||||
MS_NOUSER: 1 << 31
|
MS_NOUSER: 1 << 31
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const {
|
||||||
|
symbols: {
|
||||||
|
mount,
|
||||||
|
},
|
||||||
|
} = dlopen('/usr/lib/libc.so.6', {
|
||||||
|
mount: {
|
||||||
|
args: [ FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.u64, FFIType.cstring ],
|
||||||
|
returns: FFIType.int,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} devicePath
|
* @param {string} devicePath
|
||||||
* @param {string} mountPoint
|
* @param {string} mountPoint
|
||||||
@@ -49,20 +55,13 @@ const flags = {
|
|||||||
* @param {string} fsparams
|
* @param {string} fsparams
|
||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
function mount(devicePath, mountPoint, fstype, flags, fsparams) {
|
export function JSmount(devicePath, mountPoint, fstype, flags, fsparams) {
|
||||||
const supportedFilesystems = require('./suportedFilesystems')
|
const filesystem = filesystems.find( v => v.name === fstype)
|
||||||
|
|
||||||
const filesystem = supportedFilesystems.find( v => v.name === fstype)
|
|
||||||
if(! filesystem) {
|
if(! filesystem) {
|
||||||
throw "Invalid filesystem"
|
throw "Invalid filesystem"
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! fs.existsSync(devicePath) && filesystem.hasdev)
|
if(! fs.existsSync(devicePath) && filesystem.hasdev)
|
||||||
throw "Device don't exist"
|
throw "Device don't exist"
|
||||||
return cmount(devicePath, mountPoint, fstype, flags, fsparams)
|
return mount(Buffer.from(devicePath), Buffer.from(mountPoint), Buffer.from(fstype), flags, Buffer.from(fsparams))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = { mount, cmount, flags }
|
|
||||||
@@ -1,7 +1,4 @@
|
|||||||
{
|
{
|
||||||
"devDependencies": {
|
|
||||||
"@types/node": "^16.11.21"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"jimp": "^0.16.1"
|
"jimp": "^0.16.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
//@ts-check
|
//@ts-check
|
||||||
|
import { dlopen, FFIType } from 'bun:ffi';
|
||||||
|
|
||||||
/* Perform a hard reset now. */
|
/* Perform a hard reset now. */
|
||||||
const RB_AUTOBOOT = 0x01234567
|
const RB_AUTOBOOT = 0x01234567
|
||||||
|
|
||||||
@@ -20,37 +22,40 @@ const RB_SW_SUSPEND = 0xd000fce2
|
|||||||
/* Reboot system into new kernel. */ //no idea how to use that but hey
|
/* Reboot system into new kernel. */ //no idea how to use that but hey
|
||||||
const RB_KEXEC = 0x45584543
|
const RB_KEXEC = 0x45584543
|
||||||
|
|
||||||
/**
|
|
||||||
@type {{
|
|
||||||
reboot: (rebootid: number) => void //https://unix.superglobalmegacorp.com/Net2/newsrc/sys/syscall.h.html
|
|
||||||
syscall: (syscallid: number) => void
|
|
||||||
}}
|
|
||||||
*///@ts-expect-error
|
|
||||||
const syscalls = require('./syscall.node')
|
|
||||||
|
|
||||||
function disableCtrlAltSupr() {
|
const {
|
||||||
syscalls.reboot(RB_DISABLE_CAD)
|
symbols: {
|
||||||
|
reboot,
|
||||||
|
},
|
||||||
|
} = dlopen('/usr/lib/libc.so.6', {
|
||||||
|
reboot: {
|
||||||
|
args: [ FFIType.int ],
|
||||||
|
returns: FFIType.int,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export function disableCtrlAltSupr() {
|
||||||
|
reboot(RB_DISABLE_CAD)
|
||||||
}
|
}
|
||||||
|
|
||||||
function enableCtrlAltSupr() {
|
export function enableCtrlAltSupr() {
|
||||||
syscalls.reboot(RB_ENABLE_CAD)
|
reboot(RB_ENABLE_CAD)
|
||||||
}
|
}
|
||||||
|
|
||||||
function halt() {
|
export function halt() {
|
||||||
syscalls.reboot(RB_HALT_SYSTEM)
|
reboot(RB_HALT_SYSTEM)
|
||||||
}
|
}
|
||||||
|
|
||||||
function reboot() {
|
export function classicReboot() {
|
||||||
syscalls.reboot(RB_AUTOBOOT)
|
reboot(RB_AUTOBOOT)
|
||||||
}
|
}
|
||||||
|
|
||||||
function powerOff() {
|
export function powerOff() {
|
||||||
syscalls.reboot(RB_POWER_OFF)
|
reboot(RB_POWER_OFF)
|
||||||
}
|
}
|
||||||
|
|
||||||
function suspend() {
|
export function suspend() {
|
||||||
syscalls.reboot(RB_SW_SUSPEND)
|
reboot(RB_SW_SUSPEND)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = { disableCtrlAltSupr, enableCtrlAltSupr, halt, reboot, powerOff, suspend }
|
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
async function mSleep(ms) {
|
export async function mSleep(ms) {
|
||||||
return new Promise(resolve => setTimeout(resolve, ms))
|
return new Promise(resolve => setTimeout(resolve, ms))
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sleep(s) {
|
export async function sleep(s) {
|
||||||
return mSleep(s * 1000)
|
return mSleep(s * 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { mSleep, sleep }
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
//@ts-check
|
|
||||||
//@ts-expect-error
|
|
||||||
const csocket = require('./socket.node')
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param { number } domain
|
|
||||||
* @param { number } type
|
|
||||||
* @param { number } protocol
|
|
||||||
* @return { number }
|
|
||||||
*/
|
|
||||||
function socket(domain, type, protocol) {
|
|
||||||
return csocket.socket(domain, type, protocol)
|
|
||||||
}
|
|
||||||
|
|
||||||
const socketTypes = {
|
|
||||||
SOCK_DGRAM : 1, /* Connectionless, unreliable datagrams of fixed maximum length. */
|
|
||||||
SOCK_STREAM : 2, /* Sequenced, reliable, connection-based byte streams. */
|
|
||||||
SOCK_RAW : 3, /* Raw protocol interface. */
|
|
||||||
SOCK_RDM : 4, /* Reliably-delivered messages. */
|
|
||||||
SOCK_SEQPACKET : 5, /* Sequenced, reliable, connection-based, datagrams of fixed maximum length. */
|
|
||||||
SOCK_DCCP : 6, /* Datagram Congestion Control Protocol. */
|
|
||||||
SOCK_PACKET : 10, /* Linux specific way of getting packets at the dev level. For writing rarp and other similar things on the user level. */
|
|
||||||
|
|
||||||
SOCK_CLOEXEC : 0o2000000, /* Atomically set close-on-exec flag for the new descriptor(s). */
|
|
||||||
SOCK_NONBLOCK : 0o0000200 /* Atomically mark descriptor(s) as non-blocking. */
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { socketTypes, socket }
|
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
//@ts-check
|
//@ts-check
|
||||||
const fs = require('fs')
|
import * as fs from 'fs'
|
||||||
|
|
||||||
const systems = fs.readFileSync('/proc/filesystems', { encoding: 'utf-8' }).split('\n')
|
const systems = fs.readFileSync('/proc/filesystems', { encoding: 'utf-8' }).split('\n')
|
||||||
|
|
||||||
const filesystems = systems.map(s => ({ hasdev: !s.includes('nodev'), name: s.includes('nodev') ? s.split('nodev')[1].trim() : s.trim() }))
|
export const filesystems = systems.map(s => ({ hasdev: !s.includes('nodev'), name: s.includes('nodev') ? s.split('nodev')[1].trim() : s.trim() }))
|
||||||
|
Object.freeze(filesystems)
|
||||||
module.exports = filesystems
|
|
||||||
Object.freeze(module.exports)
|
|
||||||
|
|||||||
@@ -1,26 +1,20 @@
|
|||||||
//@ts-check
|
//@ts-check
|
||||||
const { cmount, mount, flags } = require('../../core/mount.js')
|
import { JSmount, flags } from '../../core/mount.js'
|
||||||
|
|
||||||
async function init() {
|
export async function init() {
|
||||||
cmount("dummy", "/proc", "proc",
|
/*cmount("dummy", "/proc", "proc",
|
||||||
flags.MS_NODEV | flags.MS_RDONLY | flags.MS_NOSUID | flags.MS_RELATIME | flags.MS_NOEXEC
|
flags.MS_NODEV | flags.MS_RDONLY | flags.MS_NOSUID | flags.MS_RELATIME | flags.MS_NOEXEC
|
||||||
, "")
|
, "")*/
|
||||||
|
|
||||||
mount("dummy", "/sys", "sysfs", flags.MS_NODEV | flags.MS_NOSUID | flags.MS_RELATIME | flags.MS_NOEXEC, "")
|
JSmount("dummy", "/sys", "sysfs", flags.MS_NODEV | flags.MS_NOSUID | flags.MS_RELATIME | flags.MS_NOEXEC, "")
|
||||||
mount("dummy", "/tmp", "tmpfs", flags.MS_NODEV, "")
|
JSmount("dummy", "/tmp", "tmpfs", flags.MS_NODEV, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type { string[] }
|
* @type { string[] }
|
||||||
*/
|
*/
|
||||||
const after = [] // list of init script to load before
|
export const after = [] // list of init script to load before
|
||||||
/**
|
/**
|
||||||
* @type { string[] }
|
* @type { string[] }
|
||||||
*/
|
*/
|
||||||
const before = []
|
export const before = []
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
init,
|
|
||||||
after,
|
|
||||||
before
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const ip = require('../../core/ip')
|
const ip = require('../../core/ip.js.bak')
|
||||||
//async is optional but recomended for optimisation (optimisations are yet to be implemented)
|
//async is optional but recomended for optimisation (optimisations are yet to be implemented)
|
||||||
async function init() {
|
async function init() {
|
||||||
ip.setFlags('lo', ip.flags.IFF_UP | ip.flags.IFF_LOOPBACK | ip.flags.IFF_RUNNING)
|
ip.setFlags('lo', ip.flags.IFF_UP | ip.flags.IFF_LOOPBACK | ip.flags.IFF_RUNNING)
|
||||||
@@ -1,33 +1,32 @@
|
|||||||
//async is optional but recomended for optimisation (optimisations are yet to be implemented)
|
//async is optional but recomended for optimisation (optimisations are yet to be implemented)
|
||||||
async function init() {
|
export async function init() {
|
||||||
//code to execute
|
//code to execute
|
||||||
console.log(`
|
console.log(`
|
||||||
_______ _________ ______ _______ _______
|
_ _ _ _ _ _ _ _ _
|
||||||
( ____ \\|\\ /|\\__ __/( ___ \\ ( ____ )( ___ )|\\ /|
|
/\\ \\ / /\\ / /\\ /\\ \\ / /\\ /\\ \\ / /\\ /_/\\ /\\ \\
|
||||||
| ( \\/| ) ( | ) ( | ( ) )| ( )|| ( ) |( \\ / )
|
/ \\ \\ / / / / / / \\ \\ \\ / / \\ / \\ \\ / / \\ \\ \\ \\ \\ \\_\\
|
||||||
| | | (___) | | | | (__/ / | (____)|| (___) | \\ (_) /
|
/ /\\ \\ \\ / /_/ / / / /\\ \\_\\ / / /\\ \\ / /\\ \\ \\ / / /\\ \\ \\ \\ \\__/ / /
|
||||||
| | | ___ | | | | __ ( | __)| ___ | ) _ (
|
/ / /\\ \\ \\ / /\\ \\__/ / / / /\\/_/ / / /\\ \\ \\ / / /\\ \\_\\ / / /\\ \\ \\ \\ \\__ \\/_/
|
||||||
| | | ( ) | | | | ( \\ \\ | (\\ ( | ( ) | / ( ) \\
|
/ / / \\ \\_\\ / /\\ \\___\\/ / / / / / / /\\ \\_\\ \\ / / /_/ / / / / / \\ \\ \\ \\/_/\\__/\\
|
||||||
| (____/\\| ) ( |___) (___| )___) )| ) \\ \\__| ) ( |( / \\ )
|
/ / / \\/_/ / / /\\/___/ / / / / / / /\\ \\ \\___\\ / / /__\\/ / / / /___/ /\\ \\ _/\\/__\\ \\
|
||||||
(_______/|/ \\|\\_______/|/ \\___/ |/ \\__/|/ \\||/ \\|
|
/ / / / / / / / / / / / / / / \\ \\ \\__/ / / /_____/ / / /_____/ /\\ \\ / _/_/\\ \\ \\
|
||||||
|
/ / /________ / / / / / /___/ / /__ / / /____\\_\\ \\ / / /\\ \\ \\ / /_________/\\ \\ \\ / / / \\ \\ \\
|
||||||
_______ _______
|
/ / /_________\\/ / / / / //\\__\\/_/___\\/ / /__________\\/ / / \\ \\ \\/ / /_ __\\ \\_\\/ / / /_/ /
|
||||||
( ___ )( ____ \\
|
\\/____________/\\/_/ \\/_/ \\/_________/\\/_____________/\\/_/ \\_\\/\\_\\___\\ /____/_/\\/_/ \\_\\/
|
||||||
| ( ) || ( \\/
|
_ _ _
|
||||||
| | | || (_____
|
/\\ \\ / /\\ /\\ \\
|
||||||
| | | |(_____ )
|
/ \\ \\ / / \\ / \\ \\
|
||||||
| | | | ) |
|
/ /\\ \\ \\ / / /\\ \\__ / /\\ \\ \\
|
||||||
| (___) |/\\____) |
|
/ / /\\ \\ \\ / / /\\ \\___\\\\/_/\\ \\ \\
|
||||||
(_______)\\_______)
|
/ / / \\ \\_\\ \\ \\ \\ \\/___/ / / /
|
||||||
|
/ / / / / / \\ \\ \\ / / /
|
||||||
|
/ / / / / /_ \\ \\ \\ / / / _
|
||||||
|
/ / /___/ / //_/\\__/ / / / / /_/\\_\\
|
||||||
|
/ / /____\\/ / \\ \\/___/ / / /_____/ /
|
||||||
|
\\/_________/ \\_____\\/ \\________/
|
||||||
|
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const after = [] // list of init script to load before
|
export const after = [] // list of init script to load before
|
||||||
const before = []
|
export const before = []
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
init,
|
|
||||||
after,
|
|
||||||
before
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,14 +1,8 @@
|
|||||||
const audio = require('../../core/audio')
|
import audio from '../../core/audio'
|
||||||
|
|
||||||
async function init() {
|
export async function init() {
|
||||||
audio('/chibrax/sheeebr.wav')
|
audio('/core/sheeebr.wav')
|
||||||
}
|
}
|
||||||
|
|
||||||
const after = [ "filesystem.js" ] // list of init script to load before
|
export const after = [ "filesystem.js" ] // list of init script to load before
|
||||||
const before = []
|
export const before = []
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
init,
|
|
||||||
after,
|
|
||||||
before
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const fs = require('fs');
|
import * as fs from 'fs'
|
||||||
|
|
||||||
if(process.argv.length >= 3){
|
if(process.argv.length >= 3){
|
||||||
try{
|
try{
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
//@ts-check
|
//@ts-check
|
||||||
const graphics = require('../../core/graphics')
|
import * as graphics from '../../core/graphics'
|
||||||
const shapes = require('../lib/shapes')
|
import * as shapes from '../lib/shapes'
|
||||||
const path = require('path')
|
|
||||||
|
|
||||||
graphics.clear()
|
graphics.clear()
|
||||||
drawChibrax()
|
drawChibrax()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//@ts-check
|
//@ts-check
|
||||||
const ip = require('../../core/ip')
|
const ip = require('../../core/ip.js.bak')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const { exit } = require('process')
|
const { exit } = require('process')
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
//@ts-check
|
//@ts-check
|
||||||
const ip = require('../../core/ip')
|
const ip = require('../../core/ip.js.bak')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const { exit } = require('process')
|
const { exit } = require('process')
|
||||||
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
const fs = require('fs')
|
|
||||||
|
|
||||||
|
|
||||||
let paths = []
|
|
||||||
let options = []
|
|
||||||
|
|
||||||
for(arg of process.argv.slice(3)){
|
|
||||||
if(arg.startsWith('--')){
|
|
||||||
options.push(arg)
|
|
||||||
}
|
|
||||||
else if(arg.startsWith('-')){
|
|
||||||
for(let option of arg.slice(1)){
|
|
||||||
options.push('-' + option);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
paths.push(arg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(paths.length == 0){
|
|
||||||
paths = ['.'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
try{
|
|
||||||
|
|
||||||
listFiles(paths[0], options)
|
|
||||||
}
|
|
||||||
catch(e){
|
|
||||||
switch(e.code){
|
|
||||||
case "ENOENT":
|
|
||||||
console.error(`path "${paths[0]}" does not exist`);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
console.error(`ls: ${e.code}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function listFiles(path, options){
|
|
||||||
const files = ['.', '..'].concat(fs.readdirSync(paths[0]))
|
|
||||||
const nonHiddenFiles = files.filter(file => file[0] != '.')
|
|
||||||
colorList = JSON.parse(process.env.ls_color)
|
|
||||||
if(options.includes('-l')){
|
|
||||||
console.log(`total ${options.includes('-a') ? files.length : nonHiddenFiles.length}`)
|
|
||||||
for(let file of options.includes('-a') ? files : nonHiddenFiles){
|
|
||||||
|
|
||||||
stats = fs.lstatSync(`${path}/${file}`);
|
|
||||||
mode = stats.mode
|
|
||||||
result = ""
|
|
||||||
let color = []
|
|
||||||
let defaultColor = "\x1b[0m"
|
|
||||||
let fileType = "-"
|
|
||||||
if(stats.isFile()){
|
|
||||||
fileType = "-";
|
|
||||||
if(stats.mode & 00100){ //owner can execute
|
|
||||||
color = colorList.ex ? `\x1b[${colorList.ex[0]}m\x1b[${colorList.ex[1]}m` : "\x1b[0m"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (stats.isDirectory()) {
|
|
||||||
fileType = "d";
|
|
||||||
color = colorList.di ? `\x1b[${colorList.di[0]}m\x1b[${colorList.di[1]}m` : "\x1b[0m"
|
|
||||||
}
|
|
||||||
else if (stats.isSymbolicLink()){
|
|
||||||
fileType = "l"
|
|
||||||
color = colorList.ln ? `\x1b[${colorList.ln[0]}m\x1b[${colorList.ln[1]}m` : "\x1b[0m"
|
|
||||||
}
|
|
||||||
result += fileType;
|
|
||||||
permissions = "xwr"
|
|
||||||
for(let i=8;i>=0;i--){
|
|
||||||
result += parseInt(Math.pow(2,i).toString(2)) & mode ? permissions[i%3] : '-'
|
|
||||||
}
|
|
||||||
if(01000 & mode){ // check sticky bit
|
|
||||||
color = "\x1b[40m\x1b[92m\x1b[7m"
|
|
||||||
}
|
|
||||||
let date = new Date(stats.mtimeMs*1000).toDateString().split(' ');
|
|
||||||
result += ` ${usernameFromUID(stats.uid)}\t${groupnameFromGID(stats.gid)}\t${stats.size}\t${date[2]} ${date[1]}. ${options.includes('--color') ? color : ""}${file}${defaultColor}`
|
|
||||||
console.log(result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
result = ""
|
|
||||||
const defaultColor = "\x1b[0m";
|
|
||||||
if(options.includes('--color')){
|
|
||||||
for(let file of options.includes('-a') ? files : nonHiddenFiles){
|
|
||||||
stats = fs.lstatSync(`${path}/${file}`);
|
|
||||||
let color = defaultColor
|
|
||||||
if(stats.isDirectory()){
|
|
||||||
color = colorList.di ? `\x1b[${colorList.di[1]}m\x1b[${colorList.di[0]}m` : defaultColor
|
|
||||||
}
|
|
||||||
else if (stats.isSymbolicLink()){
|
|
||||||
color = colorList.ln ? `\x1b[${colorList.ln[1]}m\x1b[${colorList.ln[0]}m` : defaultColor
|
|
||||||
}
|
|
||||||
if(01000 & stats.mode){ // check sticky bit
|
|
||||||
color = "\x1b[40m\x1b[92m\x1b[7m"
|
|
||||||
}
|
|
||||||
result += color + file + defaultColor + " ";
|
|
||||||
}
|
|
||||||
console.log(result)
|
|
||||||
}else{
|
|
||||||
console.log(options.includes('-a') ? files.join(' ') : nonHiddenFiles.join(' '))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function usernameFromUID(uid){
|
|
||||||
const passwd = fs.readFileSync("/etc/passwd", {encoding: 'utf-8'}).split('\n');
|
|
||||||
for(let line of passwd){
|
|
||||||
let lineSplited = line.split(':')
|
|
||||||
if(lineSplited[2] == uid){
|
|
||||||
return lineSplited[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return uid
|
|
||||||
}
|
|
||||||
|
|
||||||
function groupnameFromGID(uid){
|
|
||||||
const passwd = fs.readFileSync("/etc/passwd", {encoding: 'utf-8'}).split('\n');
|
|
||||||
for(let line of passwd){
|
|
||||||
let lineSplited = line.split(':')
|
|
||||||
if(lineSplited[3] == uid){
|
|
||||||
return lineSplited[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return uid
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
'strict'
|
||||||
|
import { file } from 'bun'
|
||||||
|
import * as fs from 'fs'
|
||||||
|
import * as path from 'path'
|
||||||
|
|
||||||
|
|
||||||
|
let paths: string[] = []
|
||||||
|
let options = []
|
||||||
|
|
||||||
|
const defaultColors = {
|
||||||
|
di: [1, 34],
|
||||||
|
ln: [1, 36],
|
||||||
|
ex: [1, 32]
|
||||||
|
}
|
||||||
|
|
||||||
|
for(const arg of process.argv.slice(3)){
|
||||||
|
if(arg.startsWith('--')){
|
||||||
|
options.push(arg)
|
||||||
|
}
|
||||||
|
else if(arg.startsWith('-')){
|
||||||
|
for(let option of arg.slice(1)){
|
||||||
|
options.push('-' + option);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
paths.push(arg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(paths.length == 0){
|
||||||
|
paths = [ process.cwd() ];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
listFiles(paths[0], options)
|
||||||
|
}
|
||||||
|
catch(e){
|
||||||
|
switch(e.code){
|
||||||
|
case 'ENOENT':
|
||||||
|
console.error(`path '${paths[0]}' does not exist`);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.error(`ls: ${e}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function listFiles(directory: string, options: string[]){
|
||||||
|
if(!fs.existsSync(directory)) {
|
||||||
|
console.error('Path not found')
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let files = ['.', '..', ...fs.readdirSync(paths[0])]
|
||||||
|
|
||||||
|
if(!options.includes('-a')) {
|
||||||
|
files = files.filter(file => !file.startsWith('.') || file === '.' || file === '..')
|
||||||
|
}
|
||||||
|
|
||||||
|
let colorList: typeof defaultColors
|
||||||
|
|
||||||
|
if(process.env.ls_color) {
|
||||||
|
colorList = { ...defaultColors, ...JSON.parse(process.env.ls_color)}
|
||||||
|
} else {
|
||||||
|
colorList = defaultColors
|
||||||
|
}
|
||||||
|
|
||||||
|
if(options.includes('-l')){
|
||||||
|
console.log(`total ${file.length}`)
|
||||||
|
for(let file of files){
|
||||||
|
let result = ''
|
||||||
|
const stats = fs.lstatSync(path.join(directory, file));
|
||||||
|
let color = ''
|
||||||
|
let defaultColor = '\x1b[0m'
|
||||||
|
let fileType = '?'
|
||||||
|
if(stats.isFile()){
|
||||||
|
fileType = '-';
|
||||||
|
if(stats.mode & 0o100){ //owner can execute
|
||||||
|
color = colorList.ex ? `\x1b[${colorList.ex[0]}m\x1b[${colorList.ex[1]}m` : '\x1b[0m'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (stats.isDirectory()) {
|
||||||
|
fileType = 'd';
|
||||||
|
color = colorList.di ? `\x1b[${colorList.di[0]}m\x1b[${colorList.di[1]}m` : '\x1b[0m'
|
||||||
|
}
|
||||||
|
else if (stats.isSymbolicLink()){
|
||||||
|
fileType = 'l'
|
||||||
|
color = colorList.ln ? `\x1b[${colorList.ln[0]}m\x1b[${colorList.ln[1]}m` : '\x1b[0m'
|
||||||
|
}
|
||||||
|
result += fileType;
|
||||||
|
const permissions = 'xwr'
|
||||||
|
for(let i=8;i>=0;i--){
|
||||||
|
result += parseInt(Math.pow(2,i).toString(2)) & stats.mode ? permissions[i%3] : '-'
|
||||||
|
}
|
||||||
|
if(0o1000 & stats.mode){ // check sticky bit
|
||||||
|
color = '\x1b[40m\x1b[92m\x1b[7m'
|
||||||
|
}
|
||||||
|
const date = stats.mtime.toDateString().split(' ');
|
||||||
|
result += ` ${usernameFromUID(stats.uid)}\t${groupnameFromGID(stats.gid)}\t${stats.size}\t${date[2]} ${date[1]}. ${options.includes('--color') ? color : ''}${file}${defaultColor}`
|
||||||
|
console.log(result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
const defaultColor = '\x1b[0m';
|
||||||
|
if(options.includes('--color')){
|
||||||
|
let result = ''
|
||||||
|
for(let file of files){
|
||||||
|
const stats = fs.lstatSync(path.join(directory, file));
|
||||||
|
let color = defaultColor
|
||||||
|
if(0o1000 & stats.mode){ // check sticky bit
|
||||||
|
color = '\x1b[40m\x1b[92m\x1b[7m'
|
||||||
|
} else if(stats.isDirectory()){
|
||||||
|
color = colorList.di ? `\x1b[${colorList.di[1]}m\x1b[${colorList.di[0]}m` : defaultColor
|
||||||
|
} else if (stats.isSymbolicLink()){
|
||||||
|
color = colorList.ln ? `\x1b[${colorList.ln[1]}m\x1b[${colorList.ln[0]}m` : defaultColor
|
||||||
|
}
|
||||||
|
|
||||||
|
result += color + file + ' ' + defaultColor;
|
||||||
|
}
|
||||||
|
console.log(result)
|
||||||
|
}else{
|
||||||
|
console.log(files.join(' '))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function usernameFromUID(uid: string | number){
|
||||||
|
if(uid == 0) return 'root'
|
||||||
|
if(uid != 0) return 'unknown user'
|
||||||
|
//TODO: add support for multiple users to the os
|
||||||
|
return uid
|
||||||
|
}
|
||||||
|
|
||||||
|
function groupnameFromGID(uid: string | number){
|
||||||
|
if(uid == 0) return 'root'
|
||||||
|
if(uid != 0) return 'unknown group'
|
||||||
|
//TODO: add support for multiple groups to the os
|
||||||
|
return uid
|
||||||
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
const { lsmod } = require('/chibrax/kernel.js')
|
import { lsmod } from '../../core/kernel'
|
||||||
|
|
||||||
console.log(lsmod())
|
console.log(lsmod())
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
const fs = require('fs')
|
import * as fs from 'fs'
|
||||||
|
|
||||||
if(process.argv.length >= 3){
|
if(process.argv.length >= 3){
|
||||||
fs.mkdir(process.argv[3], { recursive: true }, (err) => {
|
fs.mkdir(process.argv[3], { recursive: true }, (err) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//@ts-check
|
//@ts-check
|
||||||
const { finit_module, uname } = require('../../core/kernel.js')
|
import { finit_module, uname } from '../../core/kernel.js'
|
||||||
const fs = require('fs')
|
import * as fs from 'fs'
|
||||||
const path = require('path')
|
import * as path from 'path'
|
||||||
|
|
||||||
const name = uname()
|
const name = uname()
|
||||||
const modulePath = path.join('/lib/modules', name, 'kernel')
|
const modulePath = path.join('/lib/modules', name, 'kernel')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const fs = require('fs')
|
import * as fs from 'fs'
|
||||||
|
|
||||||
if(process.argv.length >= 3){
|
if(process.argv.length >= 3){
|
||||||
let filesToRemove = process.argv.slice(3).filter((arg) => !arg.startsWith('-'));
|
let filesToRemove = process.argv.slice(3).filter((arg) => !arg.startsWith('-'));
|
||||||
|
|||||||
@@ -1,31 +1,11 @@
|
|||||||
//@ts-check
|
//@ts-check
|
||||||
const { Lexer } = require('../lib/sheebr/lexer')
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
import { startjs } from '../../core/hook'
|
||||||
|
import Lexer from '../lib/sheebr/lexer'
|
||||||
|
import * as fs from 'fs'
|
||||||
|
import environment from '../lib/sheebr/environment'
|
||||||
|
import aliases from '../lib/sheebr/aliases'
|
||||||
|
import * as path from 'path'
|
||||||
|
|
||||||
let current_dir = process.cwd()
|
let current_dir = process.cwd()
|
||||||
|
|
||||||
@@ -33,9 +13,13 @@ start()
|
|||||||
|
|
||||||
async function start(){
|
async function start(){
|
||||||
while(true){
|
while(true){
|
||||||
const input = await getline("sheebr> ");
|
const input = prompt("sheebr> ");
|
||||||
if(input === "exit") break;
|
if(input === "exit") break;
|
||||||
if(!input) continue;
|
if(!input) {
|
||||||
|
//work around missing line break
|
||||||
|
console.log()
|
||||||
|
continue
|
||||||
|
}
|
||||||
else await evaluate(input);
|
else await evaluate(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,21 +66,30 @@ async function evaluate(input){
|
|||||||
* @param {string[]} args
|
* @param {string[]} args
|
||||||
*/
|
*/
|
||||||
async function evaluateProgram(args){
|
async function evaluateProgram(args){
|
||||||
|
|
||||||
let found = false;
|
let found = false;
|
||||||
for(let path of environment.path.split(':')){
|
for(const envPath of environment.path.split(':')){
|
||||||
let tobreak = false;
|
let tobreak = false;
|
||||||
const files = fs.readdirSync(path);
|
if(!fs.existsSync(envPath)) continue
|
||||||
if(files.includes(`${args[0]}.js`)){
|
|
||||||
|
const jsPath = path.join(envPath, `${args[0]}.js`)
|
||||||
|
const tsPath = path.join(envPath, `${args[0]}.ts`)
|
||||||
|
|
||||||
|
console.log(jsPath, tsPath, envPath)
|
||||||
|
|
||||||
|
if(fs.existsSync(jsPath) || fs.existsSync(tsPath) ){
|
||||||
found = true;
|
found = true;
|
||||||
|
console.log('found it: ' + path + args[0])
|
||||||
try {
|
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 = fs.existsSync(jsPath) ? jsPath : tsPath
|
||||||
tobreak = true;
|
const options = {cwd: current_dir, env: environment, shell: true}
|
||||||
|
console.log(args)
|
||||||
|
await startjs(cmd, args, options)
|
||||||
|
console.log('\x1b[0m')
|
||||||
|
tobreak = true
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log("Program crashed")
|
console.log("Program crashed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tobreak) break;
|
if(tobreak) break;
|
||||||
}
|
}
|
||||||
if(!found){
|
if(!found){
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
const fs = require('fs')
|
import * as fs from 'fs'
|
||||||
|
|
||||||
if(process.argv.length >= 3){
|
if(process.argv.length >= 3){
|
||||||
try{
|
try{
|
||||||
fs.openSync(process.argv[3], 'w');
|
fs.openSync(process.argv[3], 'w');
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const fs = require('fs');
|
import * as fs from 'fs'
|
||||||
const { resolve } = require('path');
|
import { resolve } from 'path';
|
||||||
|
|
||||||
if(process.argv.length >= 3){
|
if(process.argv.length >= 3){
|
||||||
// console.log(process.env.path)
|
// console.log(process.env.path)
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
let os = require('os')
|
import { userInfo } from 'os'
|
||||||
console.log(os.userInfo().username);
|
|
||||||
|
console.log(userInfo().username);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* DICKPICK is a image drawing library
|
* DICKPICK is a image drawing library
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const graphics = require('../../core/graphics')
|
import * as graphics from '../../core/graphics'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param { number } x
|
* @param { number } x
|
||||||
@@ -12,7 +12,7 @@ const graphics = require('../../core/graphics')
|
|||||||
* @param { number } dy length on the y axis
|
* @param { number } dy length on the y axis
|
||||||
* @param { string } color
|
* @param { string } color
|
||||||
*/
|
*/
|
||||||
function drawRect(x, y, dx, dy, color) {
|
export function drawRect(x, y, dx, dy, color) {
|
||||||
const bitmap = {
|
const bitmap = {
|
||||||
data: Buffer.alloc(dx*dy*4, Buffer.from(graphics.parseHexColor(color))),
|
data: Buffer.alloc(dx*dy*4, Buffer.from(graphics.parseHexColor(color))),
|
||||||
width: dx,
|
width: dx,
|
||||||
@@ -28,7 +28,7 @@ function drawRect(x, y, dx, dy, color) {
|
|||||||
* @param { number[] } color
|
* @param { number[] } color
|
||||||
* @returns { Pencil }
|
* @returns { Pencil }
|
||||||
*/
|
*/
|
||||||
function pencilFromBitmap(Bitmap, color) {
|
export function pencilFromBitmap(Bitmap, color) {
|
||||||
return { ...Bitmap, color }
|
return { ...Bitmap, color }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ function pencilFromBitmap(Bitmap, color) {
|
|||||||
* @param { number } height
|
* @param { number } height
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function createBitmap(width, height) {
|
export function createBitmap(width, height) {
|
||||||
const data = Buffer.alloc(width * height * 4, Buffer.from([0, 0, 0, 0]));
|
const data = Buffer.alloc(width * height * 4, Buffer.from([0, 0, 0, 0]));
|
||||||
return { width, height, data }
|
return { width, height, data }
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ function createBitmap(width, height) {
|
|||||||
* @param { number } x
|
* @param { number } x
|
||||||
* @param { number } y
|
* @param { number } y
|
||||||
*/
|
*/
|
||||||
function setPixel(pencil, x, y) {
|
export function setPixel(pencil, x, y) {
|
||||||
pencil.data.set(pencil.color, y*pencil.width*4 + x*4)
|
pencil.data.set(pencil.color, y*pencil.width*4 + x*4)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ function setPixel(pencil, x, y) {
|
|||||||
* @param { number } yc
|
* @param { number } yc
|
||||||
* @param { Pencil } pencil
|
* @param { Pencil } pencil
|
||||||
*/
|
*/
|
||||||
function symetrie8Axes(xc, yc, x, y, pencil) {
|
export function symetrie8Axes(xc, yc, x, y, pencil) {
|
||||||
setPixel(pencil, x+xc, y+yc)
|
setPixel(pencil, x+xc, y+yc)
|
||||||
setPixel(pencil, x+xc,-y+yc)
|
setPixel(pencil, x+xc,-y+yc)
|
||||||
setPixel(pencil, -x+xc,-y+yc)
|
setPixel(pencil, -x+xc,-y+yc)
|
||||||
@@ -78,7 +78,7 @@ function symetrie8Axes(xc, yc, x, y, pencil) {
|
|||||||
* @param { number } yc
|
* @param { number } yc
|
||||||
* @param { number } r
|
* @param { number } r
|
||||||
*/
|
*/
|
||||||
function drawCircle(pencil, xc, yc, r) {
|
export function drawCircle(pencil, xc, yc, r) {
|
||||||
let x = 0
|
let x = 0
|
||||||
let y = r
|
let y = r
|
||||||
let d = 3 - (2 * r);
|
let d = 3 - (2 * r);
|
||||||
@@ -96,6 +96,3 @@ function drawCircle(pencil, xc, yc, r) {
|
|||||||
symetrie8Axes(xc, yc, x, y, pencil);
|
symetrie8Axes(xc, yc, x, y, pencil);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = { drawRect, setPixel, pencilFromBitmap, createBitmap, drawCircle }
|
|
||||||
@@ -2,8 +2,6 @@
|
|||||||
/**
|
/**
|
||||||
* @type {{ [key: string]: string[] }}
|
* @type {{ [key: string]: string[] }}
|
||||||
*/
|
*/
|
||||||
const aliases = {
|
export default {
|
||||||
ls: ["ls", "--color"]
|
ls: ["ls", "--color"]
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = aliases
|
|
||||||
@@ -9,7 +9,6 @@ let environment = {
|
|||||||
ln: [1, 36],
|
ln: [1, 36],
|
||||||
ex: [1, 32]
|
ex: [1, 32]
|
||||||
}),
|
}),
|
||||||
node: "/usr/local/bin/node"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = environment
|
export default environment
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
//@ts-check
|
//@ts-check
|
||||||
const { isAlpha } = require('./utils')
|
|
||||||
|
|
||||||
|
export default class Lexer{
|
||||||
class Lexer{
|
|
||||||
/**
|
/**
|
||||||
* @param { string } source
|
* @param { string } source
|
||||||
*/
|
*/
|
||||||
@@ -55,8 +53,3 @@ class Lexer{
|
|||||||
// this.tokens.push(Token(tokenType, value))
|
// this.tokens.push(Token(tokenType, value))
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
Lexer
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,6 +8,12 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
import * as crypto from 'crypto'
|
||||||
|
import { tmpdir } from 'os';
|
||||||
|
import * as fs from 'fs'
|
||||||
|
import * as childProc from 'child_process'
|
||||||
|
import * as pathUtil from 'path'
|
||||||
|
|
||||||
var
|
var
|
||||||
IS_WIN = process.platform === 'win32',
|
IS_WIN = process.platform === 'win32',
|
||||||
|
|
||||||
@@ -15,10 +21,7 @@ var
|
|||||||
ALGORITHM_HASH = 'sha256',
|
ALGORITHM_HASH = 'sha256',
|
||||||
DEFAULT_ERR_MSG = 'The current environment doesn\'t support interactive reading from TTY.',
|
DEFAULT_ERR_MSG = 'The current environment doesn\'t support interactive reading from TTY.',
|
||||||
|
|
||||||
fs = require('fs'),
|
|
||||||
TTY = process.binding('tty_wrap').TTY,
|
TTY = process.binding('tty_wrap').TTY,
|
||||||
childProc = require('child_process'),
|
|
||||||
pathUtil = require('path'),
|
|
||||||
|
|
||||||
defaultOptions = {
|
defaultOptions = {
|
||||||
/* eslint-disable key-spacing */
|
/* eslint-disable key-spacing */
|
||||||
@@ -91,7 +94,7 @@ function _execFileSync(options, execOptions) {
|
|||||||
function getTempfile(name) {
|
function getTempfile(name) {
|
||||||
var suffix = '',
|
var suffix = '',
|
||||||
filepath, fd;
|
filepath, fd;
|
||||||
tempdir = tempdir || require('os').tmpdir();
|
tempdir = tempdir || tmpdir();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
filepath = pathUtil.join(tempdir, name + suffix);
|
filepath = pathUtil.join(tempdir, name + suffix);
|
||||||
@@ -116,7 +119,6 @@ function _execFileSync(options, execOptions) {
|
|||||||
pathStderr = getTempfile('readline-sync.stderr'),
|
pathStderr = getTempfile('readline-sync.stderr'),
|
||||||
pathExit = getTempfile('readline-sync.exit'),
|
pathExit = getTempfile('readline-sync.exit'),
|
||||||
pathDone = getTempfile('readline-sync.done'),
|
pathDone = getTempfile('readline-sync.done'),
|
||||||
crypto = require('crypto'),
|
|
||||||
hostArgs, shellPath, shellArgs, exitCode, extMessage, shasum, decipher, password;
|
hostArgs, shellPath, shellArgs, exitCode, extMessage, shasum, decipher, password;
|
||||||
|
|
||||||
shasum = crypto.createHash(ALGORITHM_HASH);
|
shasum = crypto.createHash(ALGORITHM_HASH);
|
||||||
|
|||||||
@@ -1,41 +1,9 @@
|
|||||||
//@ts-check
|
//@ts-check
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} str
|
|
||||||
* @returns { Promise<string> }
|
|
||||||
*/
|
|
||||||
async function getline(str) {
|
|
||||||
process.stdout.write(str)
|
|
||||||
process.stdin.resume()
|
|
||||||
process.stdin.setEncoding('utf8')
|
|
||||||
let line = ""
|
|
||||||
return new Promise((res, rej) => {
|
|
||||||
process.stdin.on('data', function(chunk) {
|
|
||||||
|
|
||||||
line += chunk
|
|
||||||
if (chunk.toString('utf-8').endsWith('\n')) {
|
|
||||||
process.stdin.pause()
|
|
||||||
res(line.substring(0, line.length -1))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
process.stdin.on('error', function(err) {
|
|
||||||
rej(err)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param { string } str
|
* @param { string } str
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function isAlpha(str){
|
export function isAlpha(str){
|
||||||
return /^[a-zA-Z]*$/.test(str)
|
return /^[a-zA-Z]*$/.test(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
isAlpha, getline
|
|
||||||
|
|
||||||
}
|
|
||||||
+12
-1
@@ -1,3 +1,9 @@
|
|||||||
|
if [ ! -f ovmf_vars.fd ]
|
||||||
|
then
|
||||||
|
cp /usr/share/edk2-ovmf/x64/OVMF_VARS.fd ovmf_vars.fd
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo "Attention sur linux le son est a zero par default dans le paneau de config"
|
echo "Attention sur linux le son est a zero par default dans le paneau de config"
|
||||||
qemu-system-x86_64\
|
qemu-system-x86_64\
|
||||||
-boot menu=on\
|
-boot menu=on\
|
||||||
@@ -11,4 +17,9 @@ qemu-system-x86_64\
|
|||||||
-k fr\
|
-k fr\
|
||||||
-vga qxl\
|
-vga qxl\
|
||||||
-audiodev pa,id=hda,out.mixing-engine=on \
|
-audiodev pa,id=hda,out.mixing-engine=on \
|
||||||
-device intel-hda -device hda-output,audiodev=hda
|
-device intel-hda -device hda-output,audiodev=hda \
|
||||||
|
-kernel './kernel/src/arch/x86/boot/bzImage' \
|
||||||
|
-drive if=pflash,format=raw,readonly=on,file=/usr/share/edk2-ovmf/x64/OVMF_CODE.fd \
|
||||||
|
-drive if=pflash,format=raw,file=ovmf_vars.fd \
|
||||||
|
-append 'console=ttyS0 root=/dev/sda2 rw' $* \
|
||||||
|
-nographic #TODO: enable efi graphics
|
||||||
|
|||||||
+5
-4
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"include": ["./definitions.d.ts", "./rootfs overrides/**/*"],
|
"include": ["./definitions.d.ts", "./rootfs overrides/**/*", "node_modules/**/*"],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"module": "esnext",
|
||||||
// Tells TypeScript to read JS files, as
|
// Tells TypeScript to read JS files, as
|
||||||
// normally they are ignored as source files
|
// normally they are ignored as source files
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
@@ -8,9 +9,9 @@
|
|||||||
"declaration": true,
|
"declaration": true,
|
||||||
"emitDeclarationOnly": false,
|
"emitDeclarationOnly": false,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"lib": [ "ES2016" ],
|
"lib": [ "ESNext" ],
|
||||||
"target": "es2016",
|
"target": "ESNext",
|
||||||
"moduleResolution":"Node",
|
"moduleResolution":"Classic",
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
src
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
VER=2.37.2
|
|
||||||
|
|
||||||
if [ ! -d src ]
|
|
||||||
then
|
|
||||||
mkdir src -p
|
|
||||||
cd src
|
|
||||||
curl -L https://github.com/util-linux/util-linux/archive/refs/tags/v$VER.tar.gz --output v$VER.tar.gz || exit 1
|
|
||||||
tar xvf v$VER.tar.gz || exit 1
|
|
||||||
mv util-linux-$VER/* . || exit 1
|
|
||||||
rm util-linux-$VER -rf
|
|
||||||
rm v$VER.tar.gz
|
|
||||||
cd -
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd src
|
|
||||||
|
|
||||||
|
|
||||||
./autogen.sh || exit 1
|
|
||||||
./configure || exit 1
|
|
||||||
make -j$(nproc)|| exit 1
|
|
||||||
DESTDIR=$(pwd)/../../rootfs
|
|
||||||
sudo make install DESTDIR=$(realpath $DESTDIR)
|
|
||||||
cd -
|
|
||||||
Reference in New Issue
Block a user