initial commit

Signed-off-by: Aleksey Selihov <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-05-22 02:40:32 +03:00
commit bba5c8a39a
109 files changed
+14085

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
# VoidLibC executable format (.vle)
# Registered with systemd-binfmt.service (reads /etc/binfmt.d/*.conf on boot).
#
# File extensions used by VoidLibC:
# .vle executable (run via voidloader, triggered by this binfmt rule)
# .vls shared library (loaded via voidlib_load / dlopen, not executed directly)
# .vla static archive (linked at build time via voidlink, not executed directly)
#
# Format: :name:type:offset:magic:mask:interpreter:flags
# M = magic-based detection (not extension-based)
# offset 0, magic = "VLC\0" (4 bytes: 0x56 0x4C 0x43 0x00)
# voidloader verifies the Executable flag in the container header;
# shared libraries and static archives are rejected.
:vlc:M:0:VLC\x00::/usr/local/bin/voidloader:
+101
View File
@@ -0,0 +1,101 @@
#!/usr/bin/env bash
# VoidLibC Linux installer.
# Installs voidlink + voidloader, then registers the .vle binfmt_misc entry.
# Must be run as root (or with sudo).
set -euo pipefail
INSTALL_BIN="${INSTALL_BIN:-/usr/local/bin}"
BINFMT_CONF_DIR="${BINFMT_CONF_DIR:-/etc/binfmt.d}"
MAGIC_DIR="${MAGIC_DIR:-/usr/share/file/magic}"
BINFMT_PROC="/proc/sys/fs/binfmt_misc"
BINFMT_ENTRY_NAME="vlc"
# --- Resolve build artifacts ---
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR="${BUILD_DIR:-${SCRIPT_DIR}/../../build}"
VOIDLOADER="${BUILD_DIR}/voidloader/voidloader"
VOIDLINK="${BUILD_DIR}/voidlink/voidlink"
if [[ ! -f "$VOIDLOADER" ]]; then
echo "error: voidloader not found at $VOIDLOADER" >&2
echo " Set BUILD_DIR to your cmake build directory." >&2
exit 1
fi
if [[ ! -f "$VOIDLINK" ]]; then
echo "error: voidlink not found at $VOIDLINK" >&2
echo " Set BUILD_DIR to your cmake build directory." >&2
exit 1
fi
# --- Install binaries ---
echo "Installing voidlink → ${INSTALL_BIN}/voidlink"
install -Dm755 "$VOIDLINK" "${INSTALL_BIN}/voidlink"
echo "Installing voidloader → ${INSTALL_BIN}/voidloader"
install -Dm755 "$VOIDLOADER" "${INSTALL_BIN}/voidloader"
# --- Register binfmt_misc ---
# 1. Persistent (systemd-binfmt.service reads /etc/binfmt.d on boot).
if [[ -d "$BINFMT_CONF_DIR" ]]; then
echo "Installing binfmt.d config → ${BINFMT_CONF_DIR}/vlc.conf"
install -Dm644 "${SCRIPT_DIR}/binfmt.d/vlc.conf" \
"${BINFMT_CONF_DIR}/vlc.conf"
# Substitute actual interpreter path in case it differs from the default.
sed -i "s|/usr/local/bin/voidloader|${INSTALL_BIN}/voidloader|g" \
"${BINFMT_CONF_DIR}/vlc.conf"
fi
# 2. Immediate (without needing a reboot or systemctl restart).
if [[ -d "$BINFMT_PROC" ]]; then
# Remove stale entry if present (ignore errors if not registered yet).
if [[ -f "${BINFMT_PROC}/${BINFMT_ENTRY_NAME}" ]]; then
echo "Removing stale binfmt_misc entry '${BINFMT_ENTRY_NAME}'"
echo -1 > "${BINFMT_PROC}/${BINFMT_ENTRY_NAME}" 2>/dev/null || true
fi
echo "Registering binfmt_misc entry '${BINFMT_ENTRY_NAME}'"
# Magic: V=0x56 L=0x4C C=0x43 \0=0x00 — null escaped as \x00.
printf ':vlc:M:0:VLC\x00::%s:\n' "${INSTALL_BIN}/voidloader" \
> "${BINFMT_PROC}/register"
echo " binfmt_misc: .vlc files will now execute via voidloader"
else
echo "warning: ${BINFMT_PROC} not mounted; binfmt_misc not active." >&2
echo " Run: mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc" >&2
echo " Then re-run this installer, or reboot after installing the binfmt.d config." >&2
fi
# --- Install file(1) magic database entry ---
if [[ -d "$MAGIC_DIR" ]]; then
echo "Installing file(1) magic definition → ${MAGIC_DIR}/vlc"
install -Dm644 "${SCRIPT_DIR}/magic/vlc.magic" "${MAGIC_DIR}/vlc"
# Recompile the system magic database so `file` picks it up.
# file -C -m DIR reads all magic sources from DIR and writes magic.mgc
# into the current working directory. We need to cd to the parent so
# the compiled database lands next to the magic/ directory where file(1)
# expects it.
if command -v file &>/dev/null; then
MAGIC_PARENT="$(dirname "$MAGIC_DIR")"
MAGIC_BASE="$(basename "$MAGIC_DIR")"
echo "Recompiling magic database in ${MAGIC_PARENT}..."
if ( cd "$MAGIC_PARENT" && file -C -m "$MAGIC_BASE" ) 2>/dev/null; then
echo " file(1) now recognizes VoidLibC files"
else
echo " warning: magic database recompile failed" >&2
echo " Try manually: cd ${MAGIC_PARENT} && sudo file -C -m ${MAGIC_BASE}" >&2
fi
fi
else
echo "warning: ${MAGIC_DIR} not found; file(1) magic not installed." >&2
echo " Install file(1) and re-run, or copy tools/vlc.magic manually." >&2
echo " System-wide: sudo cp tools/vlc.magic ${MAGIC_DIR}/vlc" >&2
echo " cd $(dirname '${MAGIC_DIR}') && sudo file -C -m $(basename '${MAGIC_DIR}')" >&2
fi
echo ""
echo "VoidLibC installed successfully."
echo " voidlink: ${INSTALL_BIN}/voidlink"
echo " voidloader: ${INSTALL_BIN}/voidloader"
echo ""
echo "Test: chmod +x hello.vle && ./hello.vle"
echo " voidlink dump hello.vls"
+29
View File
@@ -0,0 +1,29 @@
# magic(5) entry for VoidLibC container files.
#
# File extensions:
# .vle executable (bit 2 = Executable)
# .vls shared library (default when neither executable nor static)
# .vla static archive (bit 4 = StaticLibrary)
#
# Offset layout (FileHeader, packed, LE):
# 0 u32 magic = 0x00434C56
# 4 u16 version_major
# 6 u16 version_minor
# 8 u32 flags (bit 0=HasDebug, bit 1=HasCppExports, bit 2=Executable,
# bit 3=HasDynamicImports, bit 4=StaticLibrary)
# 12 u16 arch (1 = x86_64)
#
# Quick test: file -m vlc.magic <file>
# System-wide: sudo cp vlc.magic /usr/share/file/magic/vlc
# cd /usr/share/file && sudo file -C -m magic
0 lelong 0x00434C56 VoidLibC container
>4 leshort x \b v%d
>6 leshort x \b.%d
>12 leshort 1 \b, x86_64
>8 lelong &0x04 \b, executable
>8 lelong ^0x04 \b, shared library
>8 lelong &0x10 \b, static archive
>8 lelong &0x08 \b, dynamically linked
>8 lelong ^0x08 \b, statically linked
>8 lelong &0x01 \b, with debug
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# Register the .vlc binfmt_misc entry for an already-installed voidloader.
# Use this after a source build instead of running the full installer.
# Requires root (or write access to /proc/sys/fs/binfmt_misc/register).
#
# Usage: sudo ./register_binfmt.sh [/path/to/voidloader]
set -euo pipefail
VOIDLOADER="${1:-/usr/local/bin/voidloader}"
BINFMT_PROC="/proc/sys/fs/binfmt_misc"
BINFMT_ENTRY_NAME="vlc"
if [[ ! -x "$VOIDLOADER" ]]; then
echo "error: voidloader not found or not executable: $VOIDLOADER" >&2
echo " Build it first (cmake --build build) or pass its path as an argument." >&2
exit 1
fi
if [[ ! -d "$BINFMT_PROC" ]]; then
echo "error: ${BINFMT_PROC} not found — is binfmt_misc mounted?" >&2
echo " Try: sudo mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc" >&2
exit 1
fi
# Remove stale entry (ignore if not registered).
if [[ -f "${BINFMT_PROC}/${BINFMT_ENTRY_NAME}" ]]; then
echo "Removing stale binfmt_misc entry '${BINFMT_ENTRY_NAME}'"
echo -1 > "${BINFMT_PROC}/${BINFMT_ENTRY_NAME}"
fi
# Register: magic is V=0x56 L=0x4C C=0x43 \0=0x00.
printf ':vlc:M:0:VLC\x00::%s:\n' "$VOIDLOADER" > "${BINFMT_PROC}/register"
echo "Registered: .vlc files → ${VOIDLOADER}"
echo " Note: this registration is lost on reboot."
echo " For persistence: copy installer/linux/binfmt.d/vlc.conf to /etc/binfmt.d/"
echo " and run: sudo systemctl restart systemd-binfmt"
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# VoidLibC Linux uninstaller.
# Reverses install.sh: removes binaries and deregisters binfmt_misc.
# Must be run as root (or with sudo).
set -euo pipefail
INSTALL_BIN="${INSTALL_BIN:-/usr/local/bin}"
BINFMT_CONF_DIR="${BINFMT_CONF_DIR:-/etc/binfmt.d}"
MAGIC_DIR="${MAGIC_DIR:-/usr/share/file/magic}"
BINFMT_PROC="/proc/sys/fs/binfmt_misc"
BINFMT_ENTRY_NAME="vlc"
# --- Deregister binfmt_misc ---
if [[ -f "${BINFMT_PROC}/${BINFMT_ENTRY_NAME}" ]]; then
echo "Deregistering binfmt_misc entry '${BINFMT_ENTRY_NAME}'"
echo -1 > "${BINFMT_PROC}/${BINFMT_ENTRY_NAME}"
else
echo "(binfmt_misc entry '${BINFMT_ENTRY_NAME}' not active — skipping)"
fi
# --- Remove binfmt.d config ---
if [[ -f "${BINFMT_CONF_DIR}/vlc.conf" ]]; then
echo "Removing ${BINFMT_CONF_DIR}/vlc.conf"
rm -f "${BINFMT_CONF_DIR}/vlc.conf"
fi
# --- Remove binaries ---
for f in "${INSTALL_BIN}/voidlink" "${INSTALL_BIN}/voidloader"; do
if [[ -f "$f" ]]; then
echo "Removing $f"
rm -f "$f"
fi
done
# --- Remove file(1) magic entry ---
if [[ -f "${MAGIC_DIR}/vlc" ]]; then
echo "Removing ${MAGIC_DIR}/vlc"
rm -f "${MAGIC_DIR}/vlc"
if command -v file &>/dev/null; then
echo "Recompiling magic database..."
file -C -m "$MAGIC_DIR" 2>/dev/null || true
fi
fi
echo ""
echo "VoidLibC uninstalled."
+58
View File
@@ -0,0 +1,58 @@
#!/usr/bin/env bash
# VoidLibC macOS installer.
# Installs voidlink + voidloader to INSTALL_BIN (default: /usr/local/bin).
# Does not require root if INSTALL_BIN is user-writable (e.g. Homebrew prefix).
#
# .vle files are not auto-executed via binfmt_misc on macOS; invoke via:
# voidloader file.vle [args...]
# or register a file association via Finder/Launch Services separately.
set -euo pipefail
INSTALL_BIN="${INSTALL_BIN:-/usr/local/bin}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Release package layout: binaries live in ../bin/ relative to installer/.
# Development layout: binaries live in BUILD_DIR (set via env or default).
if [[ -f "${SCRIPT_DIR}/../bin/voidlink" ]]; then
VOIDLINK="${SCRIPT_DIR}/../bin/voidlink"
VOIDLOADER="${SCRIPT_DIR}/../bin/voidloader"
else
BUILD_DIR="${BUILD_DIR:-${SCRIPT_DIR}/../../build}"
VOIDLINK="${BUILD_DIR}/voidlink/voidlink"
VOIDLOADER="${BUILD_DIR}/voidloader/voidloader"
fi
for f in "$VOIDLINK" "$VOIDLOADER"; do
if [[ ! -f "$f" ]]; then
echo "error: $(basename "$f") not found at $f" >&2
echo " If running from a release package, make sure you extracted" >&2
echo " the archive before running this script." >&2
echo " For development builds, set BUILD_DIR to your cmake directory." >&2
exit 1
fi
done
mkdir -p "${INSTALL_BIN}"
echo "Installing voidlink → ${INSTALL_BIN}/voidlink"
install -m755 "$VOIDLINK" "${INSTALL_BIN}/voidlink"
echo "Installing voidloader → ${INSTALL_BIN}/voidloader"
install -m755 "$VOIDLOADER" "${INSTALL_BIN}/voidloader"
# Verify the binaries are in PATH.
if ! command -v voidlink &>/dev/null || ! command -v voidloader &>/dev/null; then
echo ""
echo "note: ${INSTALL_BIN} is not in your PATH."
echo " Add the following to your shell profile:"
echo " export PATH=\"${INSTALL_BIN}:\$PATH\""
fi
echo ""
echo "VoidLibC installed successfully."
echo " voidlink: ${INSTALL_BIN}/voidlink"
echo " voidloader: ${INSTALL_BIN}/voidloader"
echo ""
echo "Run .vle files: voidloader hello.vle"
echo "Inspect .vls: voidlink dump hello.vls"
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# VoidLibC macOS uninstaller. Reverses install.sh.
set -euo pipefail
INSTALL_BIN="${INSTALL_BIN:-/usr/local/bin}"
for f in "${INSTALL_BIN}/voidlink" "${INSTALL_BIN}/voidloader"; do
if [[ -f "$f" ]]; then
echo "Removing $f"
rm -f "$f"
else
echo "(not found: $f — skipping)"
fi
done
echo ""
echo "VoidLibC uninstalled."
+87
View File
@@ -0,0 +1,87 @@
# VoidLibC Windows installer (PowerShell).
# Copies voidlink.exe + voidloader.exe to %LOCALAPPDATA%\VoidLibC\bin and
# optionally registers .vle files to open with voidloader via the registry.
#
# Usage from a release package (recommended):
# powershell -ExecutionPolicy Bypass -File installer\install.ps1
#
# Usage from a dev build:
# powershell -ExecutionPolicy Bypass -File installer\windows\install.ps1 -BuildDir .\build
#
# Optional parameters:
# -BuildDir path cmake build directory (ignored when running from a release package)
# -InstallDir path Install directory (default: %LOCALAPPDATA%\VoidLibC\bin)
# -RegisterVle Register .vle file association (default: $true)
param(
[string]$BuildDir = "",
[string]$InstallDir = "$env:LOCALAPPDATA\VoidLibC\bin",
[bool]$RegisterVle = $true
)
$ErrorActionPreference = "Stop"
# Release package layout: binaries live in ..\bin\ relative to installer\.
# Development layout: binaries live in BuildDir\voidlink\ etc.
$PackageBin = Join-Path $PSScriptRoot ".." "bin"
if (Test-Path (Join-Path $PackageBin "voidlink.exe")) {
$VoidLink = Join-Path $PackageBin "voidlink.exe"
$VoidLoader = Join-Path $PackageBin "voidloader.exe"
} else {
if (-not $BuildDir) { $BuildDir = Join-Path $PSScriptRoot ".." ".." "build" }
$VoidLink = Join-Path $BuildDir "voidlink" "voidlink.exe"
$VoidLoader = Join-Path $BuildDir "voidloader" "voidloader.exe"
}
foreach ($f in @($VoidLink, $VoidLoader)) {
if (-not (Test-Path $f)) {
Write-Error (
"Not found: $f`n" +
"If running from a release package, ensure you extracted the archive first.`n" +
"For dev builds, pass -BuildDir to your cmake build directory."
)
exit 1
}
}
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
Write-Host "Installing voidlink.exe -> $InstallDir"
Copy-Item -Force $VoidLink (Join-Path $InstallDir "voidlink.exe")
Write-Host "Installing voidloader.exe -> $InstallDir"
Copy-Item -Force $VoidLoader (Join-Path $InstallDir "voidloader.exe")
# Add to user PATH if not already present.
$userPath = [Environment]::GetEnvironmentVariable("PATH", "User") ?? ""
if ($userPath -notlike "*$InstallDir*") {
[Environment]::SetEnvironmentVariable(
"PATH", "$InstallDir;$userPath", "User")
Write-Host "Added $InstallDir to user PATH."
Write-Host "(Restart your terminal or log off/on for PATH to take effect.)"
}
# Register .vle file association in HKCU (no admin required).
if ($RegisterVle) {
$vloaderPath = Join-Path $InstallDir "voidloader.exe"
# ProgID
$progId = "VoidLibC.VLE.1"
New-Item -Force -Path "HKCU:\Software\Classes\$progId" |
Set-ItemProperty -Name "(Default)" -Value "VoidLibC Executable"
New-Item -Force -Path "HKCU:\Software\Classes\$progId\shell\open\command" |
Set-ItemProperty -Name "(Default)" -Value "`"$vloaderPath`" `"%1`" %*"
# .vle extension
New-Item -Force -Path "HKCU:\Software\Classes\.vle" |
Set-ItemProperty -Name "(Default)" -Value $progId
Write-Host "Registered .vle -> voidloader.exe via HKCU\Software\Classes"
}
Write-Host ""
Write-Host "VoidLibC installed successfully."
Write-Host " voidlink: $(Join-Path $InstallDir 'voidlink.exe')"
Write-Host " voidloader: $(Join-Path $InstallDir 'voidloader.exe')"
Write-Host ""
Write-Host "Run .vle files: double-click in Explorer, or: voidloader hello.vle"
Write-Host "Inspect .vls: voidlink dump hello.vls"
+37
View File
@@ -0,0 +1,37 @@
# VoidLibC Windows uninstaller. Reverses install.ps1.
param(
[string]$InstallDir = "$env:LOCALAPPDATA\VoidLibC\bin"
)
$ErrorActionPreference = "Stop"
foreach ($exe in @("voidlink.exe", "voidloader.exe")) {
$f = Join-Path $InstallDir $exe
if (Test-Path $f) {
Write-Host "Removing $f"
Remove-Item -Force $f
} else {
Write-Host "(not found: $f — skipping)"
}
}
# Remove .vle file association.
foreach ($key in @("HKCU:\Software\Classes\.vle",
"HKCU:\Software\Classes\VoidLibC.VLE.1")) {
if (Test-Path $key) {
Write-Host "Removing registry key $key"
Remove-Item -Recurse -Force $key
}
}
# Remove from user PATH.
$userPath = [Environment]::GetEnvironmentVariable("PATH", "User") ?? ""
$newPath = ($userPath -split ";" | Where-Object { $_ -ne $InstallDir }) -join ";"
if ($newPath -ne $userPath) {
[Environment]::SetEnvironmentVariable("PATH", $newPath, "User")
Write-Host "Removed $InstallDir from user PATH."
}
Write-Host ""
Write-Host "VoidLibC uninstalled."