summaryrefslogtreecommitdiff
path: root/helper.sh
blob: 939fde011bb7dee55ae600aac99360211990b138 (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
#!/bin/bash

export PKG_ROOT=$(arm-apple-darwin-gcc -dumpspecs | grep '%{isysroot' | sed -e 's/.*%{isysroot\*:\([^}]*\)}.*/\1/; s/;:/\n/g' | sed -e 's/^-syslibroot //' | tail -n 1)

export PKG_WORK=${PKG_BASE}/work/${PKG_NAME}
export PKG_DEST=${PKG_BASE}/dest/${PKG_NAME}
export PKG_STAT=${PKG_BASE}/stat/${PKG_NAME}
export PKG_DATA=$(echo "${PKG_BASE}"/data/"${PKG_NAME}"?(_))
export PKG_VRSN=$(cat "${PKG_DATA}/_metadata/version")

if [[ ! -e ${PKG_DATA} ]]; then
    echo "unknown package: ${PKG_NAME}" 1>&2
    exit 1
fi

PKG_DEPS=("${PKG_DATA}"/_metadata/*.dep)

function pkg_ {
    if [[ ${1:0:1} = / ]]; then
        echo "${PKG_DEST}$1"
    else
        echo $1
    fi
}

function pkg: {
    declare -a argv
    declare argc=$#

    for ((i=0; $i != $argc; ++i)); do
        argv[$i]=$(pkg_ $1)
        shift
    done

    "${argv[@]}"
}