scripts

misc scripts and tools
git clone git://git.2f30.org/scripts.git
Log | Files | Refs

commit 69eead12fc2cb4249648db9afc34b064c9053dbf
parent 61ca4bc96c6ce409a1f0ae42e1acea78dc6f355c
Author: sin <sin@2f30.org>
Date:   Wed Aug 14 12:48:59 +0100

Add suckless-initramfs

Diffstat:
suckless-initramfs | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+), 0 deletions(-)
diff --git a/suckless-initramfs b/suckless-initramfs @@ -0,0 +1,71 @@ +#!/bin/sh -x + +# Fetch sbase + ubase + mksh +mkdir build +cd build +git clone git://git.2f30.org/sbase +git clone git://git.2f30.org/ubase +wget -O mksh-R47.tgz -c https://www.mirbsd.org/MirOS/dist/mir/mksh/mksh-R47.tgz + +# Build statically linked sbase + ubase +cd sbase +make clean +make LDFLAGS+=-static +cd - +cd ubase +make clean +make LDFLAGS+=-static +cd - + +# Build statically linked mksh +tar xzf mksh-R47.tgz +cd mksh +LDFLAGS+=-static CPPFLAGS+=-DMKSH_NOPWNAM sh Build.sh +cd - + +# Create dir hierarchy +rm -rf initramfs +mkdir -p initramfs/{bin,etc,dev,proc,root,sys} +cd initramfs +ln -s /bin sbin +cd - + +# Install sbase + ubase + mksh +for i in $(find sbase/ -not -iwholename "*.git*" -perm 755); do + cp "$i" initramfs/bin +done +for i in $(find ubase/ -not -iwholename "*.git*" -perm 755); do + cp "$i" initramfs/bin +done +cp mksh/mksh initramfs/bin/ksh + +# Create symlink for /bin/sh -> ksh +cd initramfs/bin +ln -s /bin/ksh sh +cd - + +# Our init script +cat << EOF > initramfs/init +#!/bin/sh + +export PATH=/sbin:/bin + +mount -t sysfs sysfs /sys +mount -t proc proc /proc +mknod /dev/null c 1 3 +mknod /dev/zero c 1 5 +mknod /dev/tty c 5 0 +mkdir /dev/pts +mount -t devpts devpts /dev/pts + +while :; do + sh +done +EOF + +chmod +x initramfs/init + +cd initramfs +find . | cpio --quiet -H newc -o | gzip -9 -n > ../initramfs.img +rm -rf initramfs +echo Done