CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
cca2c9e97ac19c9aab81d7d73507ec8bc669e470
[devtools.git] / getBuildOrder.sh
1 #!/bin/bash
2
3 getDeps() {
4 local pkg="$1"
5 local deps="$(grep "^# Depends on:" $pkg/Pkgfile | cut -d':' -f2-)"
6 echo "${deps# *}"
7 }
8
9 getRecursiveDeps() {
10 local pkg="$1"
11 local deps="$(getDeps $pkg)"
12 if [ -z "$deps" ]; then
13 case $pkg in
14 libgmp|libmpfr|binutils|glibc|gcc)
15 # discard these ports
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
27 BUILD_ORDER="$BUILD_ORDER $pkg"
28 fi
29 }
30
31 # global var to store all final deps order
32 BUILD_ORDER="libgmp libmpfr binutils glibc gcc"
33
34 for f in *; do
35 [ ! -d "$f" ] && continue
36 case $f in
37 libgmp|libmpfr|binutils|glibc|gcc) continue ;;
38 esac
39 getRecursiveDeps "$f"
40 done
41
42 echo $BUILD_ORDER
43 echo
44
45 # End fo file