feat(image): switching root
This commit is contained in:
parent
6899203860
commit
e196cf729c
5 changed files with 135 additions and 45 deletions
rootfs
|
@ -10,21 +10,12 @@ find . -type d -exec chmod 755 {} \;
|
|||
### create directories
|
||||
ln -sf ../usr/lib/systemd/systemd init
|
||||
|
||||
# set default target to basic
|
||||
mkdir usr/lib/systemd/system/basic.target.wants
|
||||
ln -sf basic.target usr/lib/systemd/system/default.target
|
||||
|
||||
# enable dbus broker
|
||||
ln -sf ../dbus-broker.service usr/lib/systemd/system/basic.target.wants/dbus-broker.service
|
||||
ln -sf ../dbus.socket usr/lib/systemd/system/sockets.target.wants/dbus.socket
|
||||
mkdir sysroot
|
||||
|
||||
### Create needed files
|
||||
echo patos > ./etc/hostname
|
||||
cat <<EOF > ./etc/os-release
|
||||
NAME="PatOS"
|
||||
PRETTY_NAME="PatOS Platform"
|
||||
ID=patos
|
||||
EOF
|
||||
|
||||
ln -sf /etc/os-release ./etc/initrd-release
|
||||
|
||||
cat <<EOF > ./etc/passwd
|
||||
root::0:0:root:/root:/bin/sh
|
||||
|
@ -36,6 +27,10 @@ http:x:33:33:http:/srv/http:/usr/bin/nologin
|
|||
uuidd:x:68:68:uuidd:/:/usr/bin/nologin
|
||||
messagebus:x:81:81:messagebus:/:/usr/bin/nologin
|
||||
nobody:x:99:99:nobody:/:/usr/bin/nologin
|
||||
systemd-coredump:x:151:992::/var/empty:/usr/bin/nologin
|
||||
systemd-network:x:152:152::/var/empty:/usr/bin/nologin
|
||||
systemd-resolve:x:153:153::/var/empty:/usr/bin/nologin
|
||||
systemd-timesync:x:154:154::/var/empty:/usr/bin/nologin
|
||||
EOF
|
||||
chmod 644 ./etc/passwd
|
||||
|
||||
|
@ -65,6 +60,12 @@ games:x:50:
|
|||
lock:x:54:
|
||||
uuidd:x:68:
|
||||
messagebus:x:81:
|
||||
systemd-journal:x:62:
|
||||
systemd-network:x:152:
|
||||
systemd-resolve:x:153:
|
||||
systemd-timesync:x:154:
|
||||
systemd-oom:x:991:
|
||||
systemd-coredump:x:992:
|
||||
network:x:90:
|
||||
video:x:91:
|
||||
audio:x:92:
|
||||
|
@ -78,31 +79,6 @@ nobody:x:99:
|
|||
EOF
|
||||
chmod 644 ./etc/group
|
||||
|
||||
# FIXME: remove this later (just to get a shell in the initramfs)
|
||||
cat <<EOF > usr/lib/systemd/system/demo.service
|
||||
[Unit]
|
||||
Description=Debug Shell (/bin/sulogin)
|
||||
Conflicts=shutdown.target
|
||||
Before=shutdown.target
|
||||
|
||||
[Service]
|
||||
Environment=HOME=/root
|
||||
WorkingDirectory=/root
|
||||
ExecStart=/bin/sulogin
|
||||
Type=idle
|
||||
StandardInput=tty-force
|
||||
StandardOutput=inherit
|
||||
StandardError=inherit
|
||||
KillMode=process
|
||||
IgnoreSIGPIPE=no
|
||||
SendSIGHUP=yes
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
||||
EOF
|
||||
ln -sf ../demo.service usr/lib/systemd/system/basic.target.wants/demo.service
|
||||
|
||||
# gen initrd
|
||||
find . -print0 | cpio --null --owner=root:root -o --format=newc | xz -9 --check=crc32 > ../initrd.xz
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
set -ex -o pipefail
|
||||
|
||||
mkdir -p $out
|
||||
mkdir -p $out/etc $out/dev $out/proc $out/sys $out/tmp $out/root
|
||||
mkdir -p $out/etc $out/dev $out/proc $out/sys $out/tmp $out/root $out/run $out/boot
|
||||
ln -sf ../usr/bin $out/bin
|
||||
ln -sf ../usr/bin $out/sbin
|
||||
ln -sf ../usr/lib $out/lib
|
||||
|
@ -18,6 +18,15 @@ rm -f $out/usr/lib/systemd/system/sysinit.target.wants/systemd-firstboot.service
|
|||
# remove vconsole setup
|
||||
rm -f $out/usr/lib/udev/rules.d/90-vconsole.rules
|
||||
|
||||
cat <<EOF > $out/etc/os-release
|
||||
NAME="PatOS"
|
||||
PRETTY_NAME="PatOS 0.0.1 (pre-alpha)"
|
||||
ID=patos
|
||||
VERSION="0.0.1 (pre-alpha)"
|
||||
VERSION_CODENAME=pre-alpha
|
||||
VERSION_ID="0.0.1"
|
||||
EOF
|
||||
|
||||
### install PatOS glibc
|
||||
cp -P $glibcPatos/lib/*.so* $out/usr/lib/
|
||||
|
||||
|
@ -51,4 +60,3 @@ patchelf --remove-rpath $out/usr/lib/ld-linux-x86-64.so.2
|
|||
# strip binaries
|
||||
find $out -type f -executable -exec strip {} \;
|
||||
find $out -type d -exec chmod 755 {} \;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue