aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2020-08-19 19:22:18 +0200
committerMateja <mail@matejamaric.com>2020-08-19 19:22:18 +0200
commit6333ae0782327d99d9bdde4ca9565e819038591f (patch)
tree2f0355c833b606da8a95b1ceee11cec1c361599b
downloaddistro-6333ae0782327d99d9bdde4ca9565e819038591f.tar.gz
distro-6333ae0782327d99d9bdde4ca9565e819038591f.zip
first commit
-rw-r--r--.gitignore3
-rw-r--r--README.md8
-rwxr-xr-xcreate133
3 files changed, 144 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4e4f96d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+ml.iso
+ml-src
+plain.html
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..387bd0a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,8 @@
+#Required packages
+- build-essentials
+- musl
+- kernel-headers-musl
+- grub
+- libisoburn(xorriso)
+- cpio
+- wget
diff --git a/create b/create
new file mode 100755
index 0000000..fd1f6b9
--- /dev/null
+++ b/create
@@ -0,0 +1,133 @@
+#!/bin/bash
+echo "Make sure you have build-essentials, musl, kernel-headers-musl, grub, libisoburn(xorriso), cpio and wget installed!"
+
+KERNEL_VERSION=5.8.2
+KERNEL_DIRECTORY=linux-$KERNEL_VERSION
+KERNEL_ARCHIVE=$KERNEL_DIRECTORY.tar.xz
+KERNEL_URL=https://www.kernel.org/pub/linux/kernel/v5.x/$KERNEL_ARCHIVE
+
+BUSYBOX_VERSION=1.32.0
+BUSYBOX_DIRECTORY=busybox-$BUSYBOX_VERSION
+BUSYBOX_ARCHIVE=$BUSYBOX_DIRECTORY.tar.bz2
+BUSYBOX_URL=https://busybox.net/downloads/$BUSYBOX_ARCHIVE
+
+[[ ! -d ml-src ]] && mkdir ml-src
+cd ml-src
+
+#DOWNLOAD SOURCE
+#works bad man
+[[ ! -f $KERNEL_ARCHIVE ]] && wget $KERNEL_URL
+[[ ! -f $BUSYBOX_ARCHIVE ]] && wget $BUSYBOX_URL
+
+[[ ! -d $KERNEL_DIRECTORY ]] && tar xf $KERNEL_ARCHIVE
+[[ ! -d $BUSYBOX_DIRECTORY ]] && tar xf $BUSYBOX_ARCHIVE
+
+#COMPILING
+cd $KERNEL_DIRECTORY
+[[ ! -f .config ]] && make defconfig
+#Set OS name
+sed -i "s/CONFIG_DEFAULT_HOSTNAME=\"(none)\"/CONFIG_DEFAULT_HOSTNAME=\"MatejaOS\"/" .config
+make -j`nproc`
+cp ./arch/x86/boot/bzImage ../vmlinux
+cd ..
+
+cd $BUSYBOX_DIRECTORY
+[[ ! -f .config ]] && make defconfig
+#BusyBox static linking
+sed -i "s/# CONFIG_STATIC is not set/CONFIG_STATIC=y/" .config
+sed -i "s/gcc/musl-gcc/" Makefile
+make -j`nproc`
+cp busybox ..
+cd ..
+
+#INITRAMFS
+[[ ! -d initramfs-root ]] && mkdir initramfs-root
+cd initramfs-root
+
+#Filesystem Hierarchy Standard
+mkdir -p ./{bin,boot,dev,etc/{opt,sgml,X11,xml},home,lib,media,mnt,opt,sbin,srv,tmp,usr/{bin,include,lib,local,sbin,share,src},proc,root,run,sys,var/{cache,lib,lock,log,mail,opt,run,spool/mail,tmp}}
+
+#Basic Initramfs Directory Structure
+#mkdir --parents ./{bin,dev,etc,lib,lib64,mnt/root,proc,root,sbin,sys}
+
+#Link tools to busybox
+cd bin
+cp ../../busybox .
+for i in `./busybox --list`
+do
+ ln -s busybox $i
+done
+cd ..
+
+#initramfs init script
+cat > ./init << EOF
+#!/bin/sh
+
+mount -t proc proc /proc
+mount -t sysfs sysfs /sys
+
+#Disable kernel messages
+echo 0 > /proc/sys/kernel/printk
+
+#Dynamic devices
+mdev -s
+
+echo 1 > /proc/sys/kernel/sysrq
+
+echo "Welcome to MatejaOS!"
+
+echo "You can turn off the system using SysRq."
+echo "echo s > /proc/sysrq-trigger"
+echo "echo o > /proc/sysrq-trigger"
+
+while true
+do
+ #Job control for BusyBox shell
+ setsid cttyhack sh
+ sleep 1
+done
+
+##FOR FUTURE USE (SWITCH ROOT TO HARD DRIVE)
+#mkdir /mnt/root
+#rescue_shell() {
+# echo "Something went wrong. Dropping to a shell."
+# exec sh
+#}
+#cmdline() {
+# local value
+# value=" $(cat /proc/cmdline) "
+# value="${value##* ${1}=}"
+# value="${value%% *}"
+# [ "${value}" != "" ] && echo "${value}"
+#}
+## Mount the root filesystem.
+#mount -o ro $(findfs $(cmdline root)) /mnt/root || rescue_shell
+## Clean up.
+#umount /proc
+#umount /sys
+## Switch to hard drive
+#exec switch_root /mnt/root /sbin/init
+EOF
+chmod +x init
+
+#create initramfs
+find . | cpio --create --format=newc > ../initramfs
+
+cd ..
+
+#CREATE ISO
+mkdir -p iso-dir/boot/grub
+cp vmlinux initramfs iso-dir/boot/
+cat > iso-dir/boot/grub/grub.cfg << EOF
+set timeout=3
+set default=0
+menuentry 'MatejaOS' {
+ linux /boot/vmlinux
+ initrd /boot/initramfs
+}
+EOF
+grub-mkrescue -o ../ml.iso iso-dir
+
+echo "Finished!"
+echo "You can boot the iso file with command:"
+echo "qemu-system-x86_64 -m 512 -cdrom ml.iso -boot d"