File: ALTERNATIVES

package info (click to toggle)
cruft-ng 0.9.78
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,904 kB
  • sloc: cpp: 1,748; sh: 816; python: 262; makefile: 97; ansic: 82; perl: 75
file content (33 lines) | stat: -rwxr-xr-x 865 bytes parent folder | download
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
#!/bin/sh
set -e

ALTDIR="/etc/alternatives"

update-alternatives --root "$CRUFT_ROOT" --get-selections | while read -r alternative _y _z
do
    update-alternatives --root "$CRUFT_ROOT" --query "$alternative" 2>/dev/null | while read -r line
    do
        case "$line" in
            Name:*|Slaves:*|Status:*|Best:*)
                ;;
            Link:*)
                link="${line#* }"
                ;;
            Value:*)
                test -e "${line#* }" && printf "%s\n%s\n" "$ALTDIR/$alternative" "$link" || true
                ;;
            '')
                break
                ;;
            *)
                alt="$ALTDIR/${line% *}"
                test -e "$alt" && echo "$alt" || true

                target="${line#* }"
                test -e "$target" && echo "$target" || true
                ;;
        esac
    done
done

exit 0