summaryrefslogtreecommitdiff
path: root/xi_profile.sh
blob: 78bd6f41fd8cf2c8e0e0120070f5e70d7a2f86a9 (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
#!/bin/sh

export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin:/tools/sbin
export LIBRARY_PATH=/lib:/usr/lib/:/tools/lib:/tools/lib64

export CC="clang"
export CXX="clang++"
export LD="clang"

export JOBS=$(grep "processor" /proc/cpuinfo | wc -l)
export HOME=/root

export MAKEFLAGS="-j$JOBS"
export XORG_PREFIX="/usr"

export XORG_CONFIG="--prefix=/usr --sysconfdir=/etc --localstatedir=/var --disable-static"
export RUST_TARGET="x86_64-unknown-linux-musl"

apply_patches () {
    for p in *.patch; do
        echo "Applying $p"
        patch -Np1 -i $p
    done
}

PKG_NAME=$1
cd $2
export BUILD_ROOT=$(realpath $2)

builds="$(ls *.xibuild | grep -v "$PKG_NAME.xibuild")"

for xibuild in $PKG_NAME.xibuild $(ls *.xibuild | grep -v "$PKG_NAME.xibuild"); do 
        SUBPKG_NAME=$(basename $xibuild .xibuild)
        mkdir -p ./xipkg/$SUBPKG_NAME
        export PKG_DEST=$(realpath ./xipkg/$SUBPKG_NAME)
        echo "to install to $PKG_DEST"

        echo "============$PKG_NAME============="

        #  read only the static variables fromt the primary
        . ./$PKG_NAME.xibuild
        unset -f prepare
        unset -f build
        unset -f check
        unset -f package

        . ./$xibuild

        
        for t in prepare build check package; do
            type $t >/dev/null && {
                echo "==========================$t stage=========================="
                $t || exit 1
            }
        done

        printf "checking for postinstall... "
        if command -v postinstall > /dev/null; then 
            echo "adding postinstall"
            POST_DIR=$PKG_DEST/var/lib/xipkg/postinstall
            mkdir -p $POST_DIR
            cat ./$PKG_NAME.xibuild > $POST_DIR/$PKG_NAME.sh
            echo >> $POST_DIR/$PKG_NAME.sh
            echo "postinstall" >> $POST_DIR/$PKG_NAME.sh
        else
            echo "no postinstall"
        fi
done