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

function PKG_DATA_() {
    echo "${PKG_BASE}/data/$1"
}

export -f PKG_DATA_

function PKG_WORK_() {
    echo "${PKG_BASE}/work/${PKG_ARCH}/${PKG_CFTARG}/$1"
}

export -f PKG_WORK_

function PKG_MORE_() {
    echo "${PKG_BASE}/more/${PKG_ARCH}/${PKG_CFTARG}/$1"
}

function PKG_DEST_() {
    echo "${PKG_BASE}/dest/${PKG_ARCH}/${PKG_CFTARG}/$1"
}

export -f PKG_DEST_

function pkg_ {
    case "${1:0:1}" in
        (/) echo "${PKG_DEST}$1";;
        (@) echo "${PKG_MORE}${1:1}";;
        (%) echo "${PKG_DATA}${1:1}";;
        (*) echo -"$1" | sed -e 's/^.//';;
    esac
}

export -f pkg_

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

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

    ${FAKEROOT} "${argv[@]}"
}

export -f pkg: