mirror of
https://github.com/outbackdingo/scratchpkg.git
synced 2026-03-22 05:44:57 +00:00
61 lines
1.1 KiB
Bash
Executable File
61 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
INDEX_DIR="/var/lib/scratchpkg/index"
|
|
CONF_FILE="/etc/scratchpkg.conf"
|
|
|
|
source "$CONF_FILE"
|
|
source "/usr/share/scratchpkg/color"
|
|
source "/usr/share/scratchpkg/message"
|
|
|
|
if [ ! "$1" ]; then
|
|
msgerr "Please specify package name to list its dependencies order."
|
|
exit 1
|
|
fi
|
|
|
|
calc_dep() {
|
|
|
|
# check currently process package for loop
|
|
if [ ${#CHECK[@]} -gt 0 ]; then
|
|
if [[ "$(echo ${CHECK[@]} | tr " " "\n" | grep -x $1)" == "$1" ]]; then
|
|
msgerr "loop dependency found: $1"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# add package to currently process
|
|
CHECK+=($1)
|
|
|
|
# check dependencies
|
|
for i in $(scratch -d "$1" --no-color | awk '{print $2}'); do
|
|
if [[ $(echo ${DEP[@]} | tr " " "\n" | grep -w $i) = "" ]]; then
|
|
calc_dep $i
|
|
fi
|
|
done
|
|
|
|
# add dependency to list checked dep
|
|
DEP+=($1)
|
|
|
|
# delete process package array
|
|
for i in "${!CHECK[@]}"; do
|
|
if [[ ${CHECK[i]} = "$1" ]]; then
|
|
unset 'CHECK[i]'
|
|
fi
|
|
done
|
|
|
|
}
|
|
|
|
CHECK=()
|
|
DEP=()
|
|
|
|
calc_dep $1
|
|
|
|
for deps in ${DEP[@]}; do
|
|
if [ -e $INDEX_DIR/$deps/.pkginfo ]; then
|
|
echo -e "$deps ${color_green}[installed]${color_reset}"
|
|
else
|
|
echo $deps
|
|
fi
|
|
done
|
|
|
|
exit 0
|