aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2018-04-11 21:36:25 -0400
committerMitch Riedstra <mitch@riedstra.us>2018-04-11 21:36:25 -0400
commit2eecfae10050c1a4fcfacd1caa756d6d115afb1b (patch)
treedfcc61c9db9f32507bdc2084d42022fe34b2b0e5
downloadmin-2eecfae10050c1a4fcfacd1caa756d6d115afb1b.tar.gz
min-2eecfae10050c1a4fcfacd1caa756d6d115afb1b.tar.xz
Initial
-rw-r--r--.gitignore3
-rw-r--r--.vars5
-rw-r--r--inc15
-rw-r--r--readme.md34
-rw-r--r--scripts/build.sh6
-rw-r--r--scripts/destroy.sh3
-rw-r--r--scripts/get_sources.sh7
-rw-r--r--scripts/mksh.sh13
-rw-r--r--scripts/musl.sh9
-rw-r--r--scripts/sbase.sh14
-rw-r--r--scripts/ubase.sh15
-rw-r--r--sources.lst3
12 files changed, 127 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0c8216f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+build
+pfx
+distfiles
diff --git a/.vars b/.vars
new file mode 100644
index 0000000..2cab6b4
--- /dev/null
+++ b/.vars
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+set -x
+
+. ./inc
diff --git a/inc b/inc
new file mode 100644
index 0000000..5a22994
--- /dev/null
+++ b/inc
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+base_dir="$(pwd)"
+# So we can source this and use it in the shell
+export prefix="$(pwd)/pfx"
+dist_dir="$(pwd)/distfiles"
+build_dir="$(pwd)/build"
+
+if ! [ -d $build_dir ] ; then mkdir $build_dir; fi
+if ! [ -d $prefix ] ; then mkdir $prefix; fi
+
+# Reset our PATH
+. /etc/profile
+
+PATH="$prefix/usr/local/musl/bin:$prefix/usr/sbin:$prefix/usr/bin:$prefix/bin:$prefix/sbin:${PATH}"
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..803d9ba
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,34 @@
+# *MIN*imum system
+
+A small set of scripts to build an absolutely minimalist system using
+the `musl` `libc`, `mksh`, the "one true awk", and other tools.
+
+I'm purposely trying to avoid large or complex projects such as Busybox.
+Not that they don't have their place, or that there's anything wrong with
+them, but IMO they take the fun out of it because they have absolutely
+everything you need. The Linux Kernel will be the glaring exception here.
+
+Currently it's just building a minimal set of tools into `pfx/` eventually
+the scripts will encompass building a virtual machine image with a boot
+loader and all the bells and whistles. ( if I get around to it ha ha )
+
+## Will your system include a compiler?
+
+Probably not, but I've thought about this one, it'd be cool to make it
+"self-hosting" in a sense.
+
+## What Linux distribution are you building this on?
+
+Gentoo at the moment, it should work on any Linux distribution.
+
+## Why?
+
+I want to learn more about how operating systems are built and doing something
+that someone else has already laid out for you ( such as the LFS project ) is
+just too tedious and boring for me, I'd rather do something different.
+
+
+## The process so far:
+
+Run `scripts/get_sources.sh` and then `scripts/build.sh` It's rather important
+to run them from the `min` directory so the paths and imports will be correct.
diff --git a/scripts/build.sh b/scripts/build.sh
new file mode 100644
index 0000000..c96f1cb
--- /dev/null
+++ b/scripts/build.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+shell="/bin/sh"
+$shell scripts/musl.sh
+$shell scripts/mksh.sh
+$shell scripts/sbase.sh
+$shell scripts/ubase.sh
diff --git a/scripts/destroy.sh b/scripts/destroy.sh
new file mode 100644
index 0000000..91b4d94
--- /dev/null
+++ b/scripts/destroy.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+set -x
+rm -rf build pfx
diff --git a/scripts/get_sources.sh b/scripts/get_sources.sh
new file mode 100644
index 0000000..946c288
--- /dev/null
+++ b/scripts/get_sources.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+set -e
+set -x
+cd ${dist_dir}
+wget -i sources.lst
+git clone git://git.suckless.org/sbase
+git clone git://git.suckless.org/ubase
diff --git a/scripts/mksh.sh b/scripts/mksh.sh
new file mode 100644
index 0000000..e4dcd59
--- /dev/null
+++ b/scripts/mksh.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+. ./.vars
+VERSION="R56c"
+cd $build_dir
+tar xfzv ${dist_dir}/mksh-$VERSION.tgz
+cd mksh
+export LDFLAGS="-static"
+export CC="musl-gcc"
+sh ./Build.sh
+install -d $prefix/bin
+install -m 555 mksh $prefix/bin/sh
+ln $prefix/bin/sh $prefix/bin/ksh
+ln $prefix/bin/sh $prefix/bin/mksh
diff --git a/scripts/musl.sh b/scripts/musl.sh
new file mode 100644
index 0000000..2ad8b0e
--- /dev/null
+++ b/scripts/musl.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+. ./.vars
+VERSION="1.1.19"
+cd $build_dir
+tar xzvf ${dist_dir}/musl-$VERSION.tar.gz
+cd musl-$VERSION
+./configure --prefix=$prefix/usr/local/musl --enable-static
+make -j$(nproc)
+make install
diff --git a/scripts/sbase.sh b/scripts/sbase.sh
new file mode 100644
index 0000000..ec5b7d2
--- /dev/null
+++ b/scripts/sbase.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+. ./.vars
+export DESTDIR=$prefix
+git clone --depth=1 ${dist_dir}/sbase ${build_dir}/sbase
+cd $build_dir/sbase
+cp config.mk config.mk.bak
+sed \
+ -e's@^PREFIX = .*$@PREFIX = /@' \
+ -e's@^MANPREFIX = .*$@MANPREFIX = /usr/share/man@' \
+ -e's/^CC.*$/CC = musl-gcc/' \
+ -e'/^LDFLAGS/ s/$/ -static/' \
+ < config.mk.bak > config.mk
+make
+make install
diff --git a/scripts/ubase.sh b/scripts/ubase.sh
new file mode 100644
index 0000000..36bc064
--- /dev/null
+++ b/scripts/ubase.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+. ./.vars
+export DESTDIR=$prefix
+git clone ${dist_dir}/ubase ${build_dir}/ubase
+cd ${build_dir}/ubase
+cp config.mk config.mk.bak
+sed \
+ -e's@^PREFIX = .*$@PREFIX = /@' \
+ -e's@^MANPREFIX = .*$@MANPREFIX = /usr/share/man@' \
+ -e's/^CC.*$/CC = musl-gcc/' \
+ -e'/^LDFLAGS/ s/$/ -static/' \
+ < config.mk.bak > config.mk
+rm config.mk.bak
+make
+make install
diff --git a/sources.lst b/sources.lst
new file mode 100644
index 0000000..cd541d2
--- /dev/null
+++ b/sources.lst
@@ -0,0 +1,3 @@
+https://www.musl-libc.org/releases/musl-1.1.19.tar.gz
+http://www.mirbsd.org/MirOS/dist/mir/mksh/mksh-R56c.tgz
+http://www.cs.princeton.edu/~bwk/btl.mirror/awk.tar.gz