summaryrefslogtreecommitdiff
path: root/Ports/build_all.sh
blob: c569fd116164022935e3f094a49514e1db8d6a65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash

clean=false
verbose=false

case "$1" in
    clean)
        clean=true
        ;;
    verbose)
        verbose=true
        ;;
    *)
        ;;
esac

case "$2" in
    clean)
        clean=true
        ;;
    verbose)
        verbose=true
        ;;
    *)
        ;;
esac

some_failed=false
built_ports=""

for file in *; do
    if [ -d $file ]; then
        pushd $file > /dev/null
            port=$(basename $file)
            port_built=0
            for built_port in $built_ports; do
                if [ "$built_port" = "$port" ]; then
                    port_built=1
                    break
                fi
            done
            if [ $port_built -eq 1 ]; then
                echo "Built $port."
                popd > /dev/null
                continue
            fi
            if ! [ -f package.sh ]; then
                echo "ERROR: Skipping $port because its package.sh script is missing."
                popd > /dev/null
                continue
            fi
            built_ports="$built_ports $port $(./package.sh showproperty depends) "

            if [ "$clean" == true ]; then
                if [ "$verbose" == true ]; then
                    ./package.sh clean_all
                else
                    ./package.sh clean_all > /dev/null 2>&1
                fi
            fi
            if [ "$verbose" == true ]; then
                if ./package.sh; then
                    echo "Built ${port}."
                else
                    echo "ERROR: Build of ${port} was not successful!"
                    some_failed=true
                fi
            else
                if ./package.sh > /dev/null 2>&1; then
                    echo "Built ${port}."
                else
                    echo "ERROR: Build of ${port} was not successful!"
                    some_failed=true
                fi
            fi
        popd > /dev/null
    fi
done

if [ "$some_failed" == false ]; then
    exit 0
else
    exit 1
fi