X-Git-Url: http://gitweb/?a=blobdiff_plain;f=getBuildOrder.sh;h=8cf3d1c0467595dd4ec7058fb0871048689edf9e;hb=HEAD;hp=86af3fdbdd811d51a7de9de1550c593a1c9e3254;hpb=f637bdc02619b5786d81ad9d0b46e92ece9f4b35;p=devtools.git diff --git a/getBuildOrder.sh b/getBuildOrder.sh index 86af3fd..8cf3d1c 100755 --- a/getBuildOrder.sh +++ b/getBuildOrder.sh @@ -2,7 +2,7 @@ getDeps() { local pkg="$1" - local deps="$(grep "^# Depends on:" $pkg/Pkgfile | cut -d':' -f2-)" + local deps="$(grep "^# Depends on:" $pkg/Pkgfile 2>/dev/null| cut -d':' -f2-)" echo "${deps# *}" } @@ -11,8 +11,8 @@ getRecursiveDeps() { local deps="$(getDeps $pkg)" if [ -z "$deps" ]; then case $pkg in + # toolchain ports must be in order libgmp|libmpfr|libmpc|binutils|glibc|zlib|gcc) - # discard these ports ;; *) if [ ! "$(echo $BUILD_ORDER | grep " ${pkg}")" ]; then @@ -24,22 +24,39 @@ getRecursiveDeps() { for d in ${deps[@]}; do getRecursiveDeps "$d" done - BUILD_ORDER="$BUILD_ORDER $pkg" + + if [ ! "$(echo $BUILD_ORDER | grep " ${pkg}")" ]; then + BUILD_ORDER="$BUILD_ORDER $pkg" + fi fi } -# global var to store all final deps order -BUILD_ORDER="libgmp libmpfr libmpc binutils glibc zlib gcc" +ALT_START=0 + +# check for passed arguments +if [ $# -ne 0 ]; then + # use package as starting point + ALT_START=1 + START_PKG=$1 + BUILD_ORDER="" +else + # global var to store all final deps order + BUILD_ORDER="libgmp libmpfr libmpc binutils glibc zlib gcc" +fi -for f in *; do - [ ! -d "$f" ] && continue - case $f in +for i in $(find . -type f -name 'Pkgfile' -exec dirname {} \; | sort); do + PKG="$(basename $i)" + case $PKG in + # toolchain ports must be in order libgmp|libmpfr|libmpc|binutils|glibc|zlib|gcc) continue ;; esac - getRecursiveDeps "$f" + getRecursiveDeps "$PKG" done -echo $BUILD_ORDER -echo +if [ $ALT_START -eq 0 ]; then + echo $BUILD_ORDER | tr ' ' '\n' +else + echo $BUILD_ORDER | sed "s|.* $START_PKG|$START_PKG|" | tr ' ' '\n' +fi # End fo file