2013-09-06 08:31:51 +00:00
|
|
|
#!/bin/sh
|
2013-09-24 15:43:30 +00:00
|
|
|
#
|
|
|
|
# This is the stage0 script, it prepares a basic usable system
|
|
|
|
# in $root.
|
2013-09-06 08:31:51 +00:00
|
|
|
|
2013-09-17 14:26:52 +00:00
|
|
|
. ./prepare-env
|
2013-09-06 08:31:51 +00:00
|
|
|
|
2013-09-25 09:20:05 +00:00
|
|
|
if [ $(uname -m) != $arch ]; then
|
|
|
|
echo You need an $arch host to build morpheus 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2013-09-26 19:41:09 +00:00
|
|
|
rm -rf root morpheus.log
|
2013-09-25 09:20:05 +00:00
|
|
|
. ./prepare-root
|
2013-09-26 19:38:43 +00:00
|
|
|
mkdir -p src
|
2013-09-06 08:31:51 +00:00
|
|
|
|
2013-09-25 16:06:02 +00:00
|
|
|
# Fetch and install our musl cross-compiler
|
2013-09-26 19:38:43 +00:00
|
|
|
./build cross-scripts/crossmusl
|
2013-09-17 10:37:13 +00:00
|
|
|
|
2013-09-24 11:27:46 +00:00
|
|
|
installed_deps=
|
2013-09-24 15:43:30 +00:00
|
|
|
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
|
2013-09-23 18:36:54 +00:00
|
|
|
while read line; do
|
|
|
|
if [ $(echo $line | cut -d' ' -f1) != $pkg ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
deps=$(echo $line | cut -d' ' -f2-)
|
2013-09-25 13:12:49 +00:00
|
|
|
build_pkg_dep "$pkg" "$deps"
|
2013-09-24 15:43:30 +00:00
|
|
|
break
|
2013-09-23 18:36:54 +00:00
|
|
|
done < DEPS
|
2013-09-24 15:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
build_pkg() {
|
|
|
|
build_pkg_deps $1 && ./build pkgs/$1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Build stage0 packages
|
|
|
|
pkglist=$(ls pkgs)
|
|
|
|
for pkg in $pkglist; do
|
|
|
|
build_pkg $pkg
|
2013-09-06 08:31:51 +00:00
|
|
|
done
|