From 6d752da1ba8bdad2a4bd023cfc0afdb2abea76b4 Mon Sep 17 00:00:00 2001 From: Suleyman Farajli Date: Mon, 2 Jun 2025 22:51:56 +0400 Subject: dep.sh: check library files also --- dep.sh | 94 ++++++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 54 insertions(+), 40 deletions(-) diff --git a/dep.sh b/dep.sh index 333a45e..bb886e5 100755 --- a/dep.sh +++ b/dep.sh @@ -3,55 +3,69 @@ # Format for entries `program,alternative_program:output_message` # `alternative_program` and `message` are optional check() { - for entry in "$@"; do - program_part=${entry%%:*} - program1=${program_part%%,*} - alt_program=${program_part#*,} - - msg=${entry#*:} - [ "${msg}" = "${entry}" ] && msg="${program1} is missing" - - if ! command -v "${program1}" > /dev/null 2>&1 && ! command -v "${alt_program}" > /dev/null 2>&1; then - echo "$msg" >&2 - fi - done + retval=0 + [ "$1" = "-l" ] && { ISLIB=1; shift;} || ISLIB=0 + for entry in "${@}"; do + fail=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}" || fail=1 + elif ! command -v "${program}" > /dev/null 2>&1 && + ! command -v "${alt_program}" > /dev/null 2>&1; then + fail=1 + fi + + [ "${fail}" -eq 1 ] && { echo "$msg" >&2; retval=1; } + done + return "${retval}" } # Programs check \ - git \ - lf \ - fzf \ - mpv \ - picom \ - qutebrowser \ - zathura \ - vim,nvim \ - sxiv,nsxiv \ - zsh,bash \ - dunst \ - scrot \ - startx:"xorg-xinit is missing" + git \ + lf \ + fzf \ + mpv \ + picom \ + qutebrowser \ + zathura \ + vim,nvim \ + sxiv,nsxiv \ + zsh,bash \ + dunst \ + scrot \ + startx:"xorg-xinit is missing" # TODO: check for xorg-server # Script dependencies check \ - brightnessctl \ - pactl:"pulseaudio is missing" \ - xinput \ - xset \ - xwallpaper \ - xgamma + brightnessctl \ + pactl:"pulseaudio is missing" \ + xinput \ + xset \ + xwallpaper \ + xgamma # Build dependencies check \ - pkg-config \ - curl \ - tar \ - make \ - cc:"c compiler is missing" \ - ld:"linker is missing" - -if ! command -v ld -L/usr/X11R6/lib -lX11 -lXinerama -lfontconfig -lXft > /dev/null 2>&1;then - echo "Xorg library files missing" >&2 + curl \ + tar \ + make \ + cc:"c compiler is missing" \ + ld:"linker is missing" + +# Libraries +if check pkg-config; then + check -l \ + xinerama \ + xft \ + x11 +else + echo "Warning: Skipping library check since 'pkg-config' is missing" >&2 fi -- cgit v1.2.3