CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
Fixed some issues with getBuildOrder script (duplicates, nonexistent ports, ...)
[devtools.git] / getBuildOrder.sh
CommitLineData
258775a1
JB
1#!/bin/bash
2
3getDeps() {
4 local pkg="$1"
ae841da3 5 local deps="$(grep "^# Depends on:" $pkg/Pkgfile 2>/dev/null| cut -d':' -f2-)"
258775a1
JB
6 echo "${deps# *}"
7}
8
9getRecursiveDeps() {
10 local pkg="$1"
11 local deps="$(getDeps $pkg)"
12 if [ -z "$deps" ]; then
13 case $pkg in
ae841da3 14 # toolchain ports must be in order
f637bdc0 15 libgmp|libmpfr|libmpc|binutils|glibc|zlib|gcc)
258775a1
JB
16 ;;
17 *)
18 if [ ! "$(echo $BUILD_ORDER | grep " ${pkg}")" ]; then
19 BUILD_ORDER="$BUILD_ORDER $pkg"
20 fi
21 ;;
22 esac
23 else
24 for d in ${deps[@]}; do
25 getRecursiveDeps "$d"
26 done
ae841da3
JB
27
28 if [ ! "$(echo $BUILD_ORDER | grep " ${pkg}")" ]; then
29 BUILD_ORDER="$BUILD_ORDER $pkg"
30 fi
258775a1
JB
31 fi
32}
33
34# global var to store all final deps order
f637bdc0 35BUILD_ORDER="libgmp libmpfr libmpc binutils glibc zlib gcc"
258775a1 36
ae841da3
JB
37for i in $(find . -type f -name 'Pkgfile' -exec dirname {} \;); do
38 PKG="$(basename $i)"
39 case $PKG in
40 # toolchain ports must be in order
f637bdc0 41 libgmp|libmpfr|libmpc|binutils|glibc|zlib|gcc) continue ;;
258775a1 42 esac
ae841da3 43 getRecursiveDeps "$PKG"
258775a1
JB
44done
45
ae841da3 46echo $BUILD_ORDER | tr ' ' '\n'
258775a1
JB
47echo
48
49# End fo file