Commit | Line | Data |
---|---|---|
258775a1 JB |
1 | #!/bin/bash |
2 | ||
3 | getDeps() { | |
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 | ||
9 | getRecursiveDeps() { | |
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 | ||
6adbbcf4 | 34 | ALT_START=0 |
258775a1 | 35 | |
6adbbcf4 JB |
36 | # check for passed arguments |
37 | if [ $# -ne 0 ]; then | |
38 | # use package as starting point | |
39 | ALT_START=1 | |
40 | START_PKG=$1 | |
41 | BUILD_ORDER="" | |
42 | else | |
43 | # global var to store all final deps order | |
44 | BUILD_ORDER="libgmp libmpfr libmpc binutils glibc zlib gcc" | |
45 | fi | |
46 | ||
47 | for i in $(find . -type f -name 'Pkgfile' -exec dirname {} \; | sort); do | |
ae841da3 JB |
48 | PKG="$(basename $i)" |
49 | case $PKG in | |
50 | # toolchain ports must be in order | |
f637bdc0 | 51 | libgmp|libmpfr|libmpc|binutils|glibc|zlib|gcc) continue ;; |
258775a1 | 52 | esac |
ae841da3 | 53 | getRecursiveDeps "$PKG" |
258775a1 JB |
54 | done |
55 | ||
6adbbcf4 JB |
56 | if [ $ALT_START -eq 0 ]; then |
57 | echo $BUILD_ORDER | tr ' ' '\n' | |
58 | else | |
59 | echo $BUILD_ORDER | sed "s|.* $START_PKG|$START_PKG|" | tr ' ' '\n' | |
60 | fi | |
258775a1 JB |
61 | echo |
62 | ||
63 | # End fo file |