1
0
mirror of git://git.2f30.org/morpheus.git synced 2024-06-16 14:08:34 +00:00
morpheus/stage0
2013-09-26 20:41:09 +01:00

61 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
#
# This is the stage0 script, it prepares a basic usable system
# in $root.
. ./prepare-env
if [ $(uname -m) != $arch ]; then
echo You need an $arch host to build morpheus 1>&2
exit 1
fi
rm -rf root morpheus.log
. ./prepare-root
mkdir -p src
# Fetch and install our musl cross-compiler
./build cross-scripts/crossmusl
installed_deps=
build_pkg_dep() {
pkg=$1; deps=$2
# Build dependencies for package in order
for d in $deps; do
install=1
for i in $installed_deps; do
if [ $i == $d ]; then
# If already installed, then skip it
install=0
break
fi
done
if [ $install -eq 1 ]; then
./build cross-scripts/$d
installed_deps="$installed_deps $d"
fi
done
}
build_pkg_deps() {
pkg=$1
while read line; do
if [ $(echo $line | cut -d' ' -f1) != $pkg ]; then
continue
fi
deps=$(echo $line | cut -d' ' -f2-)
build_pkg_dep "$pkg" "$deps"
break
done < DEPS
}
build_pkg() {
build_pkg_deps $1 && ./build pkgs/$1
}
# Build stage0 packages
pkglist=$(ls pkgs)
for pkg in $pkglist; do
build_pkg $pkg
done