list-rdeps: use a cache file for installability checks
Ximin Luo
4 years ago
17 | 17 | aptitude versions --disable-columns -F '%p %t' --group-by=none "~rnative $1" | grep "$ARCHIVE" |
18 | 18 | } |
19 | 19 | |
20 | inst_cache=$(mktemp) | |
21 | # https://stackoverflow.com/a/14812383 inside "trap" avoids running handler twice | |
22 | trap 'excode=$?; rm -rf "'"$inst_cache"'"; trap - EXIT' EXIT HUP INT QUIT PIPE TERM | |
23 | ||
20 | 24 | installability() { |
21 | if apt -t "$ARCHIVE" -s install "$1=$2" 2>/dev/null >/dev/null; then | |
22 | echo " " | |
25 | local r=$(grep -F "$1=$2" "$inst_cache" | cut -f2) | |
26 | if [ -n "$r" ]; then | |
27 | echo "$r" | |
23 | 28 | else |
24 | echo "X" | |
29 | if apt -t "$ARCHIVE" -s install "$1=$2" 2>/dev/null >/dev/null; then | |
30 | r=" " | |
31 | else | |
32 | r="X" | |
33 | fi | |
34 | printf "%s=%s\t%s\n" "$1" "$2" "$r" >> "$inst_cache" | |
35 | echo "$r" | |
25 | 36 | fi |
26 | 37 | } |
27 | 38 |