summaryrefslogtreecommitdiff
path: root/dep.sh
blob: dc5f1bd053696243799856d15d1a763a8b01294d (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh

# Check if programs are installed on the system.
# Format for entries `program,alternative_program:output_message`,
# `alternative_program` and `message` are optional.
check() {
    fail=0
    [ "${1}" = "-l" ] && { ISLIB=1; shift;} || ISLIB=0
    for entry in "${@}"; do
        missing=0
        program_part=${entry%%:*}
        program=${program_part%%,*}
        alt_program=${program_part#*,}
        msg=${entry#*:}

        [ "${msg}" = "${entry}" ] && msg="${program} is missing"

        if [ "${ISLIB}" -eq 1 ]; then
            pkg-config --exists "${program}" || missing=1
        elif ! command -v "${program}" > /dev/null 2>&1 &&
                ! command -v "${alt_program}" > /dev/null 2>&1; then
        missing=1
        fi

        [ "${missing}" -eq 1 ] && { echo "$msg" >&2; fail=1; }
    done
    return "${fail}"
}

retval=0

# Optional Dependencies, skip QEMU and lualatex check
[ "${1}" = "--optional" ] && check \
	cmus                                    \
	latex,pdflatex:"Latex is missing"       \
	mutt,neomutt                            \
	pandoc                                  \
	shellcheck                              \
	trans:"Translate shell is missing"      \
        abook                                   \
        acpi                                    \
        cmus                                    \
        dash                                    \
        docker                                  \
        ffmpeg                                  \
        less                                    \
        pass                                    \
        python3                                 \
        rsync                                   \
        sudo                                    \
        tldr,"A tldr implementation is missing" \
        unclutter,"unclutter-xfixes is missing" \
        xclip                                   \
        yt-dlp


# Programs
check \
    Xorg                           \
    dunst                          \
    fzf                            \
    git                            \
    lf                             \
    mpv                            \
    picom                          \
    qutebrowser                    \
    scrot                          \
    setxkbmap                      \
    startx:"xorg-xinit is missing" \
    sxiv,nsxiv                     \
    vim,nvim                       \
    zathura                        \
    zsh,bash

# Script dependencies
check \
    brightnessctl                 \
    pactl:"pulseaudio is missing" \
    xgamma                        \
    xinput                        \
    xset                          \
    xwallpaper

# Build dependencies
check \
    cc:"c compiler is missing"  \
    curl                        \
    ld:"linker is missing"      \
    make                        \
    tar || retval=1

# Libraries
if check pkg-config; then
    check -l \
        x11:"libX11 is missing"  \
        xft:"libXft is missing " \
        xinerama:"libXinerama is missing" || retval=1
else
    echo "Warning: Skipping library check since 'pkg-config' is missing" >&2
    retval=1
fi

exit "${retval}"