summaryrefslogtreecommitdiff
path: root/src/query.sh
blob: 06970057430d3b6ba6d61c06ae639b5a1d5464d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

search () {
    find ${PACKAGES_DIR} -type f | sed "s,${PACKAGES_DIR}/,," | grep$(echo $@ | sed "s/ /\\|/g")
}

files () {
    for package in $@; do
        local file="${INSTALLED_DIR}/$package/files"
        [ -f $file ] && cat $file || >&2 printf "${RED}Package ${LIGHT_RED}$package${RED} is not installed"
    done
}

file () {
    for file in $@; do
        [ ! -f ${SYSROOT}$file ] && file=$(realpath $file)
        for list in ${INSTALLED_DIR}/*/files; do
            package=$(dirname $list | xargs basename)
            grep -q $file $list &&
                printf "${LIGHT_BLUE}%s${BLUE} belongs to ${LIGHT_BLUE}%s${RESET}\n" $file $package
        done
    done
}