--- /dev/null
+#!/bin/bash
+
+[ ! -f getBuildOrder.sh ] && exit 1
+
+for port in $(sh getBuildOrder.sh); do
+ [ ! -f "${port}/Pkgfile" ] && exit 1
+ . $port/Pkgfile
+ [ -f "$port/${name}#${version}-${release}.pkg.tar.gz" ] && continue
+ cd $port || exit 1
+ ( fakeroot pkgmk-cross -d 2>&1 | tee pkgmk.log ) || exit 1
+ ( sudo pkgadd-cross $(find . -type f -name '*.pkg.tar.gz') || sudo pkgadd-cross -f $(find . -type f -name '*.pkg.tar.gz') ) || exit 1
+ cd - || exit 1
+done
+
+# End fo file
--- /dev/null
+#!/bin/bash
+
+getDeps() {
+ local pkg="$1"
+ local deps="$(grep "^# Depends on:" $pkg/Pkgfile | cut -d':' -f2-)"
+ echo "${deps# *}"
+}
+
+getRecursiveDeps() {
+ local pkg="$1"
+ local deps="$(getDeps $pkg)"
+ if [ -z "$deps" ]; then
+ case $pkg in
+ libgmp|libmpfr|binutils|glibc|gcc)
+ # discard these ports
+ ;;
+ *)
+ if [ ! "$(echo $BUILD_ORDER | grep " ${pkg}")" ]; then
+ BUILD_ORDER="$BUILD_ORDER $pkg"
+ fi
+ ;;
+ esac
+ else
+ for d in ${deps[@]}; do
+ getRecursiveDeps "$d"
+ done
+ BUILD_ORDER="$BUILD_ORDER $pkg"
+ fi
+}
+
+# global var to store all final deps order
+BUILD_ORDER="libgmp libmpfr binutils glibc gcc"
+
+for f in *; do
+ [ ! -d "$f" ] && continue
+ case $f in
+ libgmp|libmpfr|binutils|glibc|gcc) continue ;;
+ esac
+ getRecursiveDeps "$f"
+done
+
+echo $BUILD_ORDER
+echo
+
+# End fo file