commit be80e06d2a1473c73273e3594bab6b23d8819f7e
parent c1ed3900b31878695aa5839c3fb0b5b4cf88f8e0
Author: sin <sin@2f30.org>
Date: Fri, 6 Sep 2013 09:31:51 +0100
Make the build system a bit more sane
Diffstat:
13 files changed, 208 insertions(+), 172 deletions(-)
diff --git a/build b/build
@@ -1,44 +1,9 @@
#!/bin/sh
-# Export important variables for the build scripts
-top=$(pwd)
-root=$top/root
-mirror=http://dl.2f30.org/morpheus-pkgs
-export top root mirror
-
-# Create directory hierarchy
-rm -rf $root src
-mkdir -p $root/{bin,boot,dev,etc,svc,home,root,var,share,devel}
-mkdir -p $root/share/man
-mkdir -p $root/devel/{include,lib,src}
-mkdir -p $root/var/run
-mkdir -p $root/dev/shm
-mkdir -p $root/{sys,proc}
-pushd $root/
-ln -s /bin sbin
-popd
-mkdir -p src
-mkdir -p kernel
-
-export pkg=musl
-. cross-scripts/$pkg
-
-PATH=$top/cross/bin:$PATH
-export PATH
-
-# Fetch packages
-pkglist=$(ls pkgs)
-for pkg in $pkglist; do
- export pkg
- . pkgs/$pkg
-done
-
-# Fetch kernel
-wget -c http://dl.2f30.org/morpheus-pkgs/bzImage -O kernel/bzImage
-wget -c http://dl.2f30.org/morpheus-pkgs/bzImage-config -O kernel/bzImage-config
-
-pushd $root
-find . | cpio --quiet -H newc -o | gzip -9 -n > ../rootfs.img
-popd
-
-echo OK!
+. $1
+(
+ fetch
+ unpack
+ build
+ install
+)
diff --git a/cross-scripts/musl b/cross-scripts/musl
@@ -1,16 +0,0 @@
-url=http://dl.2f30.org/morpheus-pkgs/musl-0.9.13.tar.gz
-echo $url
-
-# Fetch musl
-wget -c $url -O src/musl-0.9.13.tar.gz
-
-# Unpack musl
-pushd src
-[ -d musl-0.9.13 ] || tar xzf musl-0.9.13.tar.gz
-popd
-
-# Build musl
-pushd src/musl-0.9.13
-./configure --prefix=$top/cross
-make -j2 && make install
-popd
diff --git a/cross-scripts/musl-0.9.13 b/cross-scripts/musl-0.9.13
@@ -0,0 +1,24 @@
+url=http://dl.2f30.org/morpheus-pkgs/musl-0.9.13.tar.gz
+
+fetch() {
+ wget -c $url -O src/musl-0.9.13.tar.gz
+}
+
+unpack() {
+ pushd src
+ [ -d musl-0.9.13 ] || tar xzf musl-0.9.13.tar.gz
+ popd
+}
+
+build() {
+ pushd src/musl-0.9.13
+ ./configure --prefix=$top/cross --syslibdir=$top/cross/lib
+ make -j2
+ popd
+}
+
+install() {
+ pushd src/musl-0.9.13
+ make install
+ popd
+}
diff --git a/pkgbuild b/pkgbuild
@@ -23,6 +23,4 @@ ln -s /bin sbin
popd
mkdir -p src
-pkg=$1
-export $pkg
-. pkgs/$pkg
+./build pkgs/"$1"
diff --git a/pkgs/busybox b/pkgs/busybox
@@ -1,21 +1,25 @@
-url=$mirror/$pkg
+url=$mirror/busybox
# Fetch package
-wget -c $url -O src/$pkg
+fetch() {
+ wget -c $url -O src/busybox
+}
-# Install package
-pushd src/
-chmod +x $pkg
-cp $pkg $root/bin
-pushd $root/bin
-ln -s busybox ifconfig
-ln -s busybox nc
-ln -s busybox getty
-ln -s busybox login
-ln -s busybox find
-ln -s busybox du
-ln -s busybox ping
-ln -s busybox wget
-ln -s busybox vi
-popd
-popd
+install() {
+ # Install package
+ pushd src/
+ chmod +x busybox
+ cp busybox $root/bin
+ pushd $root/bin
+ ln -s busybox ifconfig
+ ln -s busybox nc
+ ln -s busybox getty
+ ln -s busybox login
+ ln -s busybox find
+ ln -s busybox du
+ ln -s busybox ping
+ ln -s busybox wget
+ ln -s busybox vi
+ popd
+ popd
+}
diff --git a/pkgs/fs b/pkgs/fs
@@ -1,13 +1,16 @@
-file=$pkg.tar.gz
-url=$mirror/$file
+url=$mirror/fs.tar.gz
-# Fetch package
-wget -c $url -O src/$file
+fetch() {
+ # Fetch package
+ wget -c $url -O src/fs.tar.gz
+}
-# Unpack package
-pushd src
-[ -d $pkg ] || tar xzf $file
-popd
+unpack() {
+ pushd src
+ [ -d fs ] || tar xzf fs.tar.gz
+ popd
+}
-# Install package
-cp -r src/$pkg/* $root/
+install() {
+ cp -r src/fs/* $root/
+}
diff --git a/pkgs/mksh-R47 b/pkgs/mksh-R47
@@ -1,21 +1,24 @@
-file=$pkg.tar.gz
-url=$mirror/$file
+url=$mirror/mksh-R47.tar.gz
-# Fetch package
-wget -c $url -O src/$file
+fetch() {
+ wget -c $url -O src/mksh-R47.tar.gz
+}
-# Unpack package
-pushd src
-[ -d mksh ] || tar xzf $file
-popd
+unpack() {
+ pushd src
+ [ -d mksh ] || tar xzf mksh-R47.tar.gz
+ popd
+}
-# Build package
-pushd src/mksh
-CC=musl-gcc LDFLAGS+=-static sh Build.sh
-popd
+build() {
+ pushd src/mksh
+ CC=musl-gcc LDFLAGS+=-static sh Build.sh
+ popd
+}
-# Install package
-cp src/mksh/mksh $root/bin
-pushd $root/bin
-ln -s /bin/mksh sh
-popd
+install() {
+ cp src/mksh/mksh $root/bin
+ pushd $root/bin
+ ln -s /bin/mksh sh
+ popd
+}
diff --git a/pkgs/sbase b/pkgs/sbase
@@ -1,15 +1,18 @@
-url=git://git.2f30.org/$pkg
+url=git://git.2f30.org/sbase
-# Fetch package
-git clone $url src/$pkg
+fetch() {
+ git clone $url src/sbase
+}
-# Build package
-pushd src/$pkg
-make clean
-make CC=musl-gcc LDFLAGS=-static
-popd
+build() {
+ pushd src/sbase
+ make clean
+ make CC=musl-gcc LDFLAGS=-static
+ popd
+}
-# Install package
-pushd src/$pkg
-make PREFIX=$root install
-popd
+install() {
+ pushd src/sbase
+ make PREFIX=$root install
+ popd
+}
diff --git a/pkgs/sdhcp b/pkgs/sdhcp
@@ -1,19 +1,22 @@
-file=$pkg.tar.gz
-url=$mirror/$file
+url=$mirror/sdhcp.tar.gz
-# Fetch package
-wget -c $url -O src/$file
+fetch() {
+ wget -c $url -O src/sdhcp.tar.gz
+}
-# Unpack package
-pushd src
-[ -d $pkg ] || tar xzf $file
-popd
+unpack() {
+ pushd src
+ [ -d sdhcp ] || tar xzf sdhcp.tar.gz
+ popd
+}
-# Build package
-pushd src/$pkg
-make clean
-make CC=musl-gcc LDFLAGS=-static
-popd
+build() {
+ pushd src/sdhcp
+ make clean
+ make CC=musl-gcc LDFLAGS=-static
+ popd
+}
-# Install package
-cp src/$pkg/sdhcp $root/bin
+install() {
+ cp src/sdhcp/sdhcp $root/bin
+}
diff --git a/pkgs/sic b/pkgs/sic
@@ -1,19 +1,22 @@
-file=$pkg.tar.gz
-url=$mirror/$file
+url=$mirror/sic.tar.gz
-# Fetch package
-wget -c $url -O src/$file
+fetch() {
+ wget -c $url -O src/sic.tar.gz
+}
-# Unpack package
-pushd src
-[ -d $pkg ] || tar xzf $file
-popd
+unpack() {
+ pushd src
+ [ -d sic ] || tar xzf sic.tar.gz
+ popd
+}
-# Build package
-pushd src/$pkg
-make clean
-make CC=musl-gcc LDFLAGS=-static
-popd
+build() {
+ pushd src/sic
+ make clean
+ make CC=musl-gcc LDFLAGS=-static
+ popd
+}
-# Install package
-cp src/$pkg/sic $root/bin
+install() {
+ cp src/sic/sic $root/bin
+}
diff --git a/pkgs/smdev b/pkgs/smdev
@@ -1,15 +1,18 @@
-url=git://git.2f30.org/$pkg
+url=git://git.2f30.org/smdev
-# Fetch package
-git clone $url src/$pkg
+fetch() {
+ git clone $url src/smdev
+}
-# Build package
-pushd src/$pkg
-make clean
-make CC=musl-gcc LDFLAGS=-static
-popd
+build() {
+ pushd src/smdev
+ make clean
+ make CC=musl-gcc LDFLAGS=-static
+ popd
+}
-# Install package
-pushd src/$pkg
-make PREFIX=$root install
-popd
+install() {
+ pushd src/smdev
+ make PREFIX=$root install
+ popd
+}
diff --git a/pkgs/ubase b/pkgs/ubase
@@ -1,15 +1,18 @@
-url=git://git.2f30.org/$pkg
+url=git://git.2f30.org/ubase
-# Fetch package
-git clone $url src/$pkg
+fetch() {
+ git clone $url src/ubase
+}
-# Build package
-pushd src/$pkg
-make clean
-make CC=musl-gcc LDFLAGS=-static
-popd
+build() {
+ pushd src/ubase
+ make clean
+ make CC=musl-gcc LDFLAGS=-static
+ popd
+}
-# Install package
-pushd src/$pkg
-make PREFIX=$root install
-popd
+install() {
+ pushd src/ubase
+ make PREFIX=$root install
+ popd
+}
diff --git a/stage0 b/stage0
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+# Export important variables for the build scripts
+top=$(pwd)
+root=$top/root
+mirror=http://dl.2f30.org/morpheus-pkgs
+export top root mirror
+
+# Create directory hierarchy
+rm -rf $root src
+mkdir -p $root/{bin,boot,dev,etc,svc,home,root,var,share,devel,sys,proc}
+mkdir -p $root/dev/shm
+mkdir -p $root/devel/{include,lib,src}
+mkdir -p $root/share/man
+pushd $root/
+ln -s /bin sbin
+popd
+mkdir -p src
+mkdir -p kernel
+
+./build cross-scripts/musl-0.9.13
+
+PATH=$top/cross/bin:$PATH
+export PATH
+
+# Build stage0 packages
+pkglist=$(ls pkgs)
+for pkg in $pkglist; do
+ ./build pkgs/$pkg
+done
+
+# Fetch kernel
+wget -c http://dl.2f30.org/morpheus-pkgs/bzImage -O kernel/bzImage
+wget -c http://dl.2f30.org/morpheus-pkgs/bzImage-config -O kernel/bzImage-config
+
+pushd $root
+find . | cpio --quiet -H newc -o | gzip -9 -n > ../rootfs.img
+popd
+
+echo OK!