-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-oblivion-rootfs.sh
More file actions
executable file
·112 lines (91 loc) · 2.8 KB
/
Copy pathcreate-oblivion-rootfs.sh
File metadata and controls
executable file
·112 lines (91 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# Script to create minimal root filesystem for OblivionOS
set -e
ROOTFS_DIR="oblivion-rootfs"
MIRROR="http://deb.debian.org/debian"
echo "📁 Creating minimal OblivionOS root filesystem..."
# Clean up
rm -rf "$ROOTFS_DIR"
# Create minimal Debian system
echo "📦 Bootstrapping minimal Debian..."
debootstrap --variant=minbase --include=busybox,libc6,libgcc-s1,libstdc++6,zlib1g,ca-certificates \
--foreign trixie "$ROOTFS_DIR" "$MIRROR"
# Complete the bootstrap
echo "🔧 Completing bootstrap..."
chroot "$ROOTFS_DIR" /bin/sh -c "
/debootstrap/debootstrap --second-stage
apt-get clean
rm -rf /var/lib/apt/lists/*
"
# Configure basic system
echo "⚙️ Configuring system..."
cat > "$ROOTFS_DIR"/etc/hostname << EOF
oblivion-os
EOF
cat > "$ROOTFS_DIR"/etc/fstab << EOF
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
devpts /dev/pts devpts defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
EOF
cat > "$ROOTFS_DIR"/etc/passwd << EOF
root:x:0:0:root:/root:/bin/sh
oblivion:x:1000:1000:oblivion:/home/oblivion:/bin/sh
EOF
cat > "$ROOTFS_DIR"/etc/group << EOF
root:x:0:
oblivion:x:1000:
EOF
# Create init script
cat > "$ROOTFS_DIR"/init << 'EOF'
#!/bin/sh
echo "OblivionOS Starting..."
echo "Mounting filesystems..."
# Mount filesystems
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t devpts devpts /dev/pts
echo "Filesystems mounted."
echo "Setting up environment..."
# Basic setup
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
export HOME=/root
# Create runtime directories
mkdir -p /var/log /var/run /tmp
# Start OblivionOS
echo "Launching OblivionOS..."
exec /usr/local/bin/oblivion-session
EOF
chmod +x "$ROOTFS_DIR"/init
# Install essential libraries for Rust
echo "📚 Installing Rust dependencies..."
chroot "$ROOTFS_DIR" /bin/sh -c "
apt-get update
apt-get install -y --no-install-recommends \
libgcc-s1 \
libstdc++6 \
zlib1g \
ca-certificates
apt-get clean
"
# Install kernel headers from the submodule
echo "🌱 Installing kernel headers from submodule..."
if [ -d "./kernel" ]; then
mkdir -p "$ROOTFS_DIR/usr/src/linux-headers"
cp -r ./kernel/include "$ROOTFS_DIR/usr/src/linux-headers/" 2>/dev/null || true
cp ./kernel/.config "$ROOTFS_DIR/usr/src/linux-headers/.config" 2>/dev/null || true
cp ./kernel/Makefile "$ROOTFS_DIR/usr/src/linux-headers/Makefile" 2>/dev/null || true
echo "Kernel headers installed from submodule at /usr/src/linux-headers"
else
echo "Warning: kernel submodule not found, installing generic headers"
chroot "$ROOTFS_DIR" /bin/sh -c "
apt-get update
apt-get install -y --no-install-recommends linux-headers-amd64
apt-get clean
"
fi
# Create directories
mkdir -p "$ROOTFS_DIR"/usr/local/bin
mkdir -p "$ROOTFS_DIR"/home/oblivion
mkdir -p "$ROOTFS_DIR"/var/log
echo "✅ Root filesystem created in $ROOTFS_DIR"