summaryrefslogtreecommitdiff
path: root/src/build.sh
blob: b94b8d32d8f0c784614c0b9339b9ba6b9fff8719 (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
#!/bin/bash

ERROR="\033[0;31m"
INFO="\033[0;34m"
PASS="\033[0;32m"
NEUTRAL="\033[0;33m"
RESET="\033[0m"

source prepare_environment.sh

build_all () {
    for line in $(perl build_order.pm); do
        name=$(echo $line | cut -d"+" -f1)
        buildfile=$(find $XIB_BUILDFILES -wholename "*/$name.xibuild" | head -1)
        
        if [ -f "$buildfile" ]; then
            printf $INFO
            printf "Building$NEUTRAL %s$INFO:\n$RESET" $name 
            ./build_package.sh $buildfile || return 1

            # Install the package if it is needed for other builds
            if echo $line | grep -q '+'; then
                printf "$INFO\tInstalling..." 
                exported_pkg=$(find $XIB_EXPORT -wholename "*/$name.xipkg" | head -1 | xargs realpath)
                if [ -f $exported_pkg ]; then
                    tar -h --no-overwrite-dir -xf $exported_pkg -C $XIB_CHROOT
                fi

                printf "$PASS installed to chroot!\n"
            fi

            printf $RESET
            printf "Finished building %s!\n" $name
        else
            printf "$ERROR$name does not exist\n"
        fi

        # configure shadow here
        if [ "$name" = "shadow" ];
            xichroot "$XIB_CHROOT" /usr/sbin/pwconv
            xichroot "$XIB_CHROOT" /usr/sbin/grpconv
            xichroot "$XIB_CHROOT" "mkdir -p /etc/default"
            xichroot "$XIB_CHROOT" "useradd -D --gid 999"
        fi
    done

}

if build_all; then 
    printf "$PASSBuilt all packages!"
else
    printf "$ERROR Something went wrong!$NEUTRAL Press enter to view recent log"
    read;

    f=$(ls -1 --sort time $XIB_EXPORT/repo/*/*.log | head -1 | xargs realpath)
    less $f
fi