]> git.mdlowis.com Git - proto/aardvark-linux.git/commitdiff
Added curses and sandy as well as code for an init daemon master
authorMike Lowis <mike.lowis@gentex.com>
Mon, 4 Apr 2016 15:30:51 +0000 (11:30 -0400)
committerMike Lowis <mike.lowis@gentex.com>
Mon, 4 Apr 2016 15:30:51 +0000 (11:30 -0400)
build.sh
clean.sh
config.sh
etc/rc.init [new file with mode: 0755]
etc/rc.shutdown [new file with mode: 0755]
init.c [new file with mode: 0644]

index c243263dce73e09e458f671a09aee811a05cd55d..12d613df288389a9dff65d04f50d39ee453b525c 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -16,6 +16,7 @@ fetch(){
     if [ ! -d "$3" ]; then
         mkdir -p "$AL_SOURCES"
         if [ ! -f "$AL_SOURCES/$1" ]; then
+            echo fetching "$2/$1"
             echo curl -L --retry 5 "$2/$1" > "$AL_SOURCES/$1"
             curl -L --retry 5 "$2/$1" > "$AL_SOURCES/$1"
         fi
@@ -63,7 +64,7 @@ cp bin/* "$AL_ROOT/bin/"
 fetch musl-1.1.12.tar.gz http://www.musl-libc.org/releases/ "$AL_ROOT/src/musl"
 if [ ! -f "$AL_ROOT/lib/libc.a" ]; then
     cd "$AL_ROOT/src/musl"
-    ./configure --prefix="$AL_ROOT"
+    ./configure --prefix="$AL_ROOT" --disable-shared
     make $MAKEFLAGS install
     make clean
     cd $AL
@@ -86,6 +87,7 @@ if [ ! -f "$AL_ROOT/bin/cc" ]; then
     make install
     cp cc/cc/cc "$AL_ROOT/bin"
     chmod 755 "$AL_ROOT/bin/cc"
+    make clean
     cd $AL
 fi
 
@@ -99,6 +101,20 @@ if [ ! -f "$AL_ROOT/bin/as" ]; then
         --disable-shared
     make $MAKEFLAGS
     make install
+    make clean
+    cd $AL
+fi
+
+# Install byacc
+fetch byacc.tar.gz http://invisible-island.net/datafiles/release/ "$AL_ROOT/src/byacc"
+if [ ! -f "$AL_ROOT/bin/yacc" ]; then
+    cd "$AL_ROOT/src/byacc/"
+    ./configure \
+        --prefix="$AL_ROOT"      \
+        --exec-prefix="$AL_ROOT"
+    make $MAKEFLAGS
+    make install
+    make clean
     cd $AL
 fi
 
@@ -106,29 +122,31 @@ fi
 # Install the Base Packages
 ###############################################################################
 # Install sbase
-gitclone http://git.suckless.org/sbase "$AL_SOURCES/sbase"
+gitclone http://git.suckless.org/sbase "$AL_ROOT/src/sbase"
 if [ ! -f "$AL_ROOT/bin/ls" ]; then
-    cd "$AL_SOURCES/sbase"
+    cd "$AL_ROOT/src/sbase"
     git checkout .
-    git apply ../../patches/sbase.diff
+    #git apply ../../../patches/sbase.diff
     make $MAKEFLAGS CC="$CC" LD="$LD" LDFLAGS="$LDFLAGS"
     make $MAKEFLAGS PREFIX=$AL_ROOT install
+    make clean
     cd $AL
 fi
 
 # Install ubase
-gitclone http://git.suckless.org/ubase "$AL_SOURCES/ubase"
+gitclone http://git.suckless.org/ubase "$AL_ROOT/src/ubase"
 if [ ! -f "$AL_ROOT/bin/clear" ]; then
-    cd "$AL_SOURCES/ubase"
+    cd "$AL_ROOT/src/ubase"
     make $MAKEFLAGS CC="$CC" LD="$LD" LDFLAGS="$LDFLAGS"
     make $MAKEFLAGS PREFIX=$AL_ROOT install
+    make clean
     cd $AL
 fi
 
 # Install mksh
-fetch mksh-R52b.tgz https://www.mirbsd.org/MirOS/dist/mir/mksh/ "$AL_SOURCES/mksh"
+fetch mksh-R52b.tgz https://www.mirbsd.org/MirOS/dist/mir/mksh/ "$AL_ROOT/src/mksh"
 if [ ! -f "$AL_ROOT/bin/mksh" ]; then
-    cd "$AL_SOURCES/mksh"
+    cd "$AL_ROOT/src/mksh"
     chmod +x Build.sh
     ./Build.sh
     mkdir -p "$AL_ROOT/etc/" "$AL_ROOT/share/doc/mksh/examples"
@@ -140,9 +158,9 @@ if [ ! -f "$AL_ROOT/bin/mksh" ]; then
 fi
 
 # Install shadow
-fetch shadow-4.2.1.tar.xz http://pkg-shadow.alioth.debian.org/releases/ "$AL_SOURCES/shadow"
+fetch shadow-4.2.1.tar.xz http://pkg-shadow.alioth.debian.org/releases/ "$AL_ROOT/src/shadow"
 if [ ! -f "$AL_ROOT/bin/groups" ]; then
-    cd "$AL_SOURCES/shadow"
+    cd "$AL_ROOT/src/shadow"
     ./configure             \
         LDFLAGS="--static"  \
         --prefix="$AL_ROOT" \
@@ -151,15 +169,36 @@ if [ ! -f "$AL_ROOT/bin/groups" ]; then
         --sysconfdir="$AL_ROOT/etc"   \
         --with-group-name-max-length=32
     make $MAKEFLAGS install
+    make clean
     sed -i 's/yes/no/; s/bash/sh/' "$AL_ROOT/etc/default/useradd"
     cd $AL
 fi
 
 # Install Iana-Etc files
-fetch iana-etc-2.30.tar.bz2 http://anduin.linuxfromscratch.org/sources/LFS/lfs-packages/conglomeration/iana-etc/ "$AL_SOURCES/iana-etc"
+fetch iana-etc-2.30.tar.bz2 http://anduin.linuxfromscratch.org/sources/LFS/lfs-packages/conglomeration/iana-etc/ "$AL_ROOT/src/iana-etc"
 if [ ! -f "$AL_ROOT/etc/services" ]; then
-    cd "$AL_SOURCES/iana-etc"
+    cd "$AL_ROOT/src/iana-etc"
     make PREFIX="$AL_ROOT" install
+    make clean
+    cd $AL
+fi
+
+# Install curses
+gitclone https://github.com/sabotage-linux/netbsd-curses.git "$AL_ROOT/src/curses"
+if [ ! -f "$AL_ROOT/lib/libcurses.a" ]; then
+    cd "$AL_ROOT/src/curses/"
+    make $MAKE_FLAGS LDFLAGS=-static PREFIX=$AL_ROOT all-static install-static
+    make clean
+    cd $AL
+fi
+
+# Install sandy
+gitclone http://git.suckless.org/sandy "$AL_ROOT/src/sandy"
+if [ ! -f "$AL_ROOT/bin/sandy" ]; then
+    cd "$AL_ROOT/src/sandy/"
+    make $MAKE_FLAGS CC=$CC LD=$LD INCS="-I. -I$AL_ROOT/include" LIBS="-L$AL_ROOT/lib -lncurses -lterminfo"
+    make PREFIX=$AL_ROOT install
+    make clean
     cd $AL
 fi
 
@@ -169,9 +208,9 @@ fi
 # These packages should be replaced with non-gnu versions when possible
 
 # Install GNU awk
-fetch gawk-4.1.3.tar.xz http://ftp.gnu.org/gnu/gawk/ "$AL_SOURCES/gawk"
+fetch gawk-4.1.3.tar.xz http://ftp.gnu.org/gnu/gawk/ "$AL_ROOT/src/gawk"
 if [ ! -f "$AL_ROOT/bin/gawk" ]; then
-    cd "$AL_SOURCES/gawk"
+    cd "$AL_ROOT/src/gawk"
     ./configure              \
         LDFLAGS="--static"   \
         --prefix="$AL_ROOT"  \
@@ -180,60 +219,33 @@ if [ ! -f "$AL_ROOT/bin/gawk" ]; then
         --disable-nls        \
         --without-readline
     make $MAKEFLAGS gawk
-    cp "$AL_SOURCES/gawk/gawk" "$AL_ROOT/bin/gawk"
+    cp "$AL_ROOT/src/gawk/gawk" "$AL_ROOT/bin/gawk"
     ln -sfv gawk "$AL_ROOT/bin/awk"
+    make clean || true # gawks makefile is busted :(
     cd $AL
 fi
 
 # Install GNU diffutils
-fetch diffutils-3.3.tar.xz http://ftp.gnu.org/gnu/diffutils/ "$AL_SOURCES/diffutils"
+fetch diffutils-3.3.tar.xz http://ftp.gnu.org/gnu/diffutils/ "$AL_ROOT/src/diffutils"
 if [ ! -f "$AL_ROOT/bin/diff" ]; then
-    cd "$AL_SOURCES/diffutils"
+    cd "$AL_ROOT/src/diffutils"
     ./configure \
         --prefix="$AL_ROOT"
     make $MAKEFLAGS install
+    make clean
     cd $AL
 fi
 
 # Install GNU make
-fetch make-4.1.tar.gz http://ftp.gnu.org/gnu/make/ "$AL_SOURCES/make"
+fetch make-4.1.tar.gz http://ftp.gnu.org/gnu/make/ "$AL_ROOT/src/make"
 if [ ! -f "$AL_ROOT/bin/make" ]; then
-    cd "$AL_SOURCES/make"
+    cd "$AL_ROOT/src/make"
     ./configure              \
         LDFLAGS="--static"   \
         --prefix="$AL_ROOT"  \
         --without-guile
     make $MAKEFLAGS install
+    make clean
     cd $AL
 fi
 
-###############################################################################
-# Finalize the Chroot
-###############################################################################
-#rm -r "$AL_TOOLS"
-#symlink "$AL_TGT-addr2line"  "$AL_TOOLS/bin/addr2line"
-#symlink "$AL_TGT-ar"         "$AL_TOOLS/bin/ar"
-#symlink "$AL_TGT-as"         "$AL_TOOLS/bin/as"
-#symlink "$AL_TGT-c++"        "$AL_TOOLS/bin/c++"
-#symlink "$AL_TGT-c++filt"    "$AL_TOOLS/bin/c++filt"
-#symlink "$AL_TGT-cpp"        "$AL_TOOLS/bin/cpp"
-#symlink "$AL_TGT-elfedit"    "$AL_TOOLS/bin/elfedit"
-#symlink "$AL_TGT-g++"        "$AL_TOOLS/bin/g++"
-#symlink "$AL_TGT-gcc"        "$AL_TOOLS/bin/gcc"
-#symlink "$AL_TGT-gcc-5.3.0"  "$AL_TOOLS/bin/gcc-5.3.0"
-#symlink "$AL_TGT-gcc-ar"     "$AL_TOOLS/bin/gcc-ar"
-#symlink "$AL_TGT-gcc-nm"     "$AL_TOOLS/bin/gcc-nm"
-#symlink "$AL_TGT-gcc-ranlib" "$AL_TOOLS/bin/gcc-ranlib"
-#symlink "$AL_TGT-gcov"       "$AL_TOOLS/bin/gcov"
-#symlink "$AL_TGT-gcov-tool"  "$AL_TOOLS/bin/gcov-tool"
-#symlink "$AL_TGT-gprof"      "$AL_TOOLS/bin/gprof"
-#symlink "$AL_TGT-ld"         "$AL_TOOLS/bin/ld"
-#symlink "$AL_TGT-ld.bfd"     "$AL_TOOLS/bin/ld.bfd"
-#symlink "$AL_TGT-nm"         "$AL_TOOLS/bin/nm"
-#symlink "$AL_TGT-objcopy"    "$AL_TOOLS/bin/objcopy"
-#symlink "$AL_TGT-objdump"    "$AL_TOOLS/bin/objdump"
-#symlink "$AL_TGT-ranlib"     "$AL_TOOLS/bin/ranlib"
-#symlink "$AL_TGT-readelf"    "$AL_TOOLS/bin/readelf"
-#symlink "$AL_TGT-size"       "$AL_TOOLS/bin/size"
-#symlink "$AL_TGT-strings"    "$AL_TOOLS/bin/strings"
-#symlink "$AL_TGT-strip"      "$AL_TOOLS/bin/strip"
index cc9f15dcf1dc9b0bb7885a49db097e05d0e1fcfa..51e434134c4c2c0b349d66b509a3d7d6b24f7d8c 100755 (executable)
--- a/clean.sh
+++ b/clean.sh
@@ -1,10 +1,8 @@
 #!/bin/sh
 . ./config.sh
-echo rm "$AL_ROOT/sbin"
-rm "$AL_ROOT/sbin"
-echo rm "$AL_ROOT/usr"
-rm "$AL_ROOT/usr"
 echo rm -r "$AL_SOURCES"
 rm -rf "$AL_SOURCES"
 echo rm -r "$AL_ROOT"
 rm -rf "$AL_ROOT"
+echo rm -r "$AL_TOOLS"
+rm -rf "$AL_TOOLS"
index d5383a00e62dd6c9f728860aa206be9af825e483..70a65df065fd3c70dddb85218177745f3ff0d716 100644 (file)
--- a/config.sh
+++ b/config.sh
@@ -13,7 +13,7 @@ export LANGUAGE=$LC_ALL
 export AL_ROOT=$AL/root
 
 # Variable pointing to the toolchain directory
-export AL_TOOLS=$AL_ROOT/tools
+export AL_TOOLS=$AL/tools
 
 # Variable pointing to the tarballs directory
 export AL_TARBALLS=$AL/tarballs
@@ -25,7 +25,7 @@ export AL_SOURCES=$AL/sources
 export AL_TGT=$(uname -m)-linux-musl
 
 # Options to use for every invocation of make
-export MAKEFLAGS="-j8"
+export MAKEFLAGS="-j4"
 
 ###############################################################################
 # Build Environment Settings
diff --git a/etc/rc.init b/etc/rc.init
new file mode 100755 (executable)
index 0000000..2b76184
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+mount -t devtmpfs devtmpfs /dev
+mount -t sysfs sysfs /sys
+mount -t procfs  procfs /proc
+dmesg -n 1
+/bin/getty /dev/tty1 &
+/bin/getty /dev/tty2 &
+/bin/getty /dev/tty3 &
diff --git a/etc/rc.shutdown b/etc/rc.shutdown
new file mode 100755 (executable)
index 0000000..1a24852
--- /dev/null
@@ -0,0 +1 @@
+#!/bin/sh
diff --git a/init.c b/init.c
new file mode 100644 (file)
index 0000000..2d83e84
--- /dev/null
+++ b/init.c
@@ -0,0 +1,42 @@
+/**
+  @brief
+  @author Michael D. Lowis
+  @license BSD 2-clause License
+*/
+#include <signal.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+static sigset_t set;
+static char* const rcinitcmd[]     = { "/etc/rc.init", 0 };
+static char* const rcrebootcmd[]   = { "/etc/rc.shutdown", "reboot", 0 };
+static char* const rcpoweroffcmd[] = { "/etc/rc.shutdown", "poweroff", 0 };
+
+static void spawn(char *const argv[]) {
+    if (0 == fork()) {
+        sigprocmask(SIG_UNBLOCK, &set, NULL);
+        setsid();
+        execvp(argv[0], argv);
+        _exit(1);
+    }
+}
+
+int main(void) {
+    if (getpid() != 1) return 1;
+    chdir("/");
+    sigfillset(&set);
+    sigprocmask(SIG_BLOCK, &set, NULL);
+    spawn(rcinitcmd);
+    while (1) {
+        int sig;
+        sigwait(&set, &sig);
+        switch (sig) {
+            case SIGUSR1: spawn(rcpoweroffcmd); break;
+            case SIGINT:  spawn(rcrebootcmd);   break;
+            case SIGCHLD:
+                while (waitpid(-1, NULL, WNOHANG) > 0);
+                break;
+        }
+    }
+    return 0;
+}