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


list () {
    find ${PACKAGES_DIR} -type f | sed "s,${PACKAGES_DIR}/,," 
}

list_installed () {
    ls -1 ${INSTALLED_DIR}
}

search () {
    if [ $# = 0 ]; then
        list
    else
        list | grep $(echo $@ | sed "s/ /\\|/g")
    fi
}

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\n"
    done
}

file_info () {
    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
}