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
|
|
|
|
2014-02-03 12:18:52 +00:00
|
|
|
if test "$(uname -m)" != "$arch"; then
|
2013-09-25 09:20:05 +00:00
|
|
|
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
|
2014-02-05 12:45:38 +00:00
|
|
|
if [ "$i" = "$d" ]; then
|
2013-09-24 15:43:30 +00:00
|
|
|
# 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
|
2014-02-03 12:18:52 +00:00
|
|
|
if test "$(echo $line | cut -d' ' -f1)" != "$pkg"; then
|
2013-09-23 18:36:54 +00:00
|
|
|
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() {
|
2014-02-05 14:08:52 +00:00
|
|
|
build_pkg_deps $(basename $1) && ./build $1
|
2013-09-24 15:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Build stage0 packages
|
2014-02-05 12:43:01 +00:00
|
|
|
for pkg in pkgs/*; do
|
2014-02-05 14:08:52 +00:00
|
|
|
build_pkg $pkg
|
2013-09-06 08:31:51 +00:00
|
|
|
done
|