Skip to content

Commit 996f6de

Browse files
committed
MiOSv0.2.0 - Final Sync of Root Overlay Logic
1 parent fb8b12c commit 996f6de

1 file changed

Lines changed: 39 additions & 28 deletions

File tree

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,47 @@
1-
#!/usr/bin/zsh
1+
#!/bin/bash
22
set -e
33

4-
echo "Applying MiOS FHS Symlink Overlay..."
5-
6-
# Define the source (the repo mount)
74
REPO_ROOT="/mios"
5+
SYSTEM_ROOT="/"
6+
7+
echo "🔄 Initializing MiOS COMPLETE System Root Overlay..."
88

9-
# 1. Symlink .git to root
10-
if [ -d "${REPO_ROOT}/.git" ]; then
11-
echo " Symlinking /.git -> ${REPO_ROOT}/.git"
12-
ln -sf "${REPO_ROOT}/.git" /.git
13-
fi
9+
# 1. Mandatory Git Identity (The System Root IS the Git Repository)
10+
echo " [ROOT] Mapping /.git -> ${REPO_ROOT}/.git"
11+
ln -sf "${REPO_ROOT}/.git" "${SYSTEM_ROOT}.git"
1412

15-
# 2. Soft-merge FHS directories from the repository into the container root
16-
# This makes the repository "act" as the system root.
17-
for dir in etc usr var srv home; do
18-
if [ -d "${REPO_ROOT}/$dir" ]; then
19-
echo " Merging ${REPO_ROOT}/$dir -> /$dir"
20-
mkdir -p "/$dir"
21-
# Use find to get all top-level items and symlink them
22-
find "${REPO_ROOT}/$dir" -maxdepth 1 -mindepth 1 | while read item; do
23-
target="/$dir/$(basename "$item")"
24-
# We use ln -sf. This will replace existing symlinks but skip
25-
# real files/directories that already exist in the base image
26-
# to prevent system breakage (like /etc/passwd).
27-
if [ -e "$target" ] && [ ! -L "$target" ]; then
28-
echo " Skipping existing real path: $target"
29-
else
30-
ln -sf "$item" "$target" 2>/dev/null || true
31-
fi
32-
done
13+
# 2. Aggressive Global Merge
14+
# We include ALL files and directories from the repo root
15+
shopt -s dotglob
16+
for item in "${REPO_ROOT}"/*; do
17+
[ -e "$item" ] || continue
18+
name=$(basename "$item")
19+
20+
# Avoid self-recursion and sensitive container mounts
21+
case "$name" in
22+
.devcontainer|vscode|workspaces|proc|sys|dev|run|tmp|boot|mnt|root)
23+
continue
24+
;;
25+
esac
26+
27+
target="${SYSTEM_ROOT}${name}"
28+
29+
if [ -d "$item" ]; then
30+
# For FHS-standard directories, we merge the contents
31+
if [[ "$name" =~ ^(usr|etc|var|srv|home|v1|bin|lib|lib64|sbin)$ ]]; then
32+
echo " [MERGE] /$name"
33+
mkdir -p "$target"
34+
cp -as "${item}/"* "$target/" 2>/dev/null || true
35+
else
36+
# For project-specific directories (automation, tools, etc.), link them directly
37+
echo " [LINK] /$name"
38+
ln -sfn "$item" "$target"
39+
fi
40+
else
41+
# For all root-level files (Justfile, Containerfile, VERSION, etc.)
42+
echo " [FILE] /$name"
43+
ln -sf "$item" "$target"
3344
fi
3445
done
3546

36-
echo " MiOS Root Overlay Active"
47+
echo " MiOS System Root Overlay: FULLY MERGED"

0 commit comments

Comments
 (0)