Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,20 @@ run/

# Ignore datagen cache.
/common/src/main/generated/resources/.cache/

/fabric/run
/fabric/runs
/forge/run
/forge/runs
/neoforge/run
/neoforge/runs
/common/run
/common/runs
/quilt/run
/quilt/runs
/bootimage/logs
/logs
*.log.gz
*.log
*.ext2
/bootimage/src/fs/.idea/
15 changes: 15 additions & 0 deletions .run/Run Boot Imager.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Boot Imager" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="dev.ultreon.bootimager.BootImager" />
<module name="devices-mod.bootimage.main" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="dev.ultreon.bootimager.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
42 changes: 42 additions & 0 deletions bootimage/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
plugins {
id 'java'
}

group = 'dev.ultreon.mods'
version = '0.9.0'

repositories {
mavenCentral()
}

sourceSets {
fs {
resources {
srcDirs = ['src/fs']
}
java {
srcDirs.clear()
srcDirs = ['src/main/java']
}
}
}

processFsResources {
exclude ".idea"
exclude ".gradle"
exclude "build"
exclude "out"
exclude "**/__pycache__"
exclude "**/*.pyc"
}

dependencies {
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'

implementation 'com.github.Nuix:jnode-fs:v1.0.1'
}

test {
useJUnitPlatform()
}
7 changes: 7 additions & 0 deletions bootimage/src/fs/bin/echo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from libstd import main


@main
def prog_main(args: list[str]) -> int:
print(" ".join(args))
return 0
Empty file added bootimage/src/fs/bin/shell.py
Empty file.
80 changes: 80 additions & 0 deletions bootimage/src/fs/boot/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import os

def create_dir(path, mode):
if not os.path.exists(path):
os.makedirs(path, exist_ok=True)


# noinspection PyProtectedMember,PyUnresolvedReferences
def boot():
import sys
create_dir("/bin", 0o755)
create_dir("/sys", 0o755)
create_dir("/sys/dev", 0o755)
create_dir("/sys/proc", 0o755)
create_dir("/sys/sys", 0o755)

create_dir("/dev/pts", 0o755)
create_dir("/dev/serial", 0o755)
create_dir("/dev/usb", 0o755)
create_dir("/dev/virtual", 0o755)

create_dir("/usr/bin", 0o755)
create_dir("/usr/lib", 0o755)
create_dir("/usr/sbin", 0o755)
create_dir("/usr/share", 0o755)
create_dir("/usr/local", 0o755)
create_dir("/usr/local/bin", 0o755)
create_dir("/usr/local/lib", 0o755)

create_dir("/var", 0o755)
create_dir("/var/log", 0o755)
create_dir("/var/lib", 0o755)
create_dir("/var/lock", 0o755)
create_dir("/var/run", 0o755)
create_dir("/var/tmp", 0o755)

create_dir("/etc", 0o755)
create_dir("/media", 0o755)
create_dir("/tmp", 0o755)
create_dir("/opt", 0o755)
create_dir("/home", 0o755)
create_dir("/home/setup", 0o755)
create_dir("/root", 0o755)
create_dir("/run", 0o755)
create_dir("/sbin", 0o755)

sys.path.append("/usr/bin")
sys.path.append("/usr/lib")
sys.path.append("/bin")
sys.path.append("/lib")
sys.path.append("/usr/local/bin")
sys.path.append("/usr/local/lib")
sys.path.append("/sbin")
sys.path.append("/usr/sbin")
sys.path.append("/usr/local/sbin")
sys.path.append("/var/lib")

if "/lib" not in sys.path:
raise Exception("Failed to add /lib to sys.path")

import os
if not os.path.exists("/lib/libsystem.py"):
raise Exception("Failed to find /lib/libsystem.py")

import importlib

importlib.invalidate_caches()
libsystem = importlib.import_module("libsystem")

# noinspection PyUnresolvedReferences
try:
libsystem._bootinit(bios)
except Exception as e:
print(e)

while True:
pass


boot()
Empty file.
1 change: 1 addition & 0 deletions bootimage/src/fs/lib/libstd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def main(self):
Loading
Loading