smoke_test_release.sh 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #!/usr/bin/env bash
  2. # Checks a release tarball on the running distribution: unpacks it, resolves the engine and the web helper with
  3. # `ldd -r` (portable tarballs through their launcher's --check-libraries) and runs `linux-wallpaperengine --help`.
  4. # A missing library or symbol version fails, and so does an unresolved symbol in our own libraries. Unresolved
  5. # functions in bundled third-party libraries are only listed, they bind lazily.
  6. #
  7. # Usage:
  8. # tools/smoke_test_release.sh [--install-deps] <tarball>
  9. #
  10. # --install-deps first installs what a desktop system has anyway (GTK 3, NSS, Mesa, libva, PipeWire, CUPS, ALSA,
  11. # GnuTLS, libgcrypt) for bare CI containers, and for a non-portable tarball whatever provides the libraries still
  12. # missing, looked up by soname (LIBNODE_PKG names a built package for Arch's AUR-only libnode). Run as root then.
  13. # Knows Debian/Ubuntu, Fedora, Arch and openSUSE.
  14. set -euo pipefail
  15. install_deps=0
  16. if [ "${1:-}" = --install-deps ]; then
  17. install_deps=1
  18. shift
  19. fi
  20. tarball="$(realpath "$1")"
  21. install_desktop_runtime() {
  22. . /etc/os-release
  23. case " $ID ${ID_LIKE:-} " in
  24. *" debian "* | *" ubuntu "*)
  25. export DEBIAN_FRONTEND=noninteractive
  26. apt-get update -qq
  27. # Ubuntu 24.04 and Debian 13 renamed some for the 64 bit time_t transition
  28. local pkgs=() p
  29. for p in libgtk-3-0 libnss3 libasound2 libcups2 libpipewire-0.3-0 libgl1 libegl1 libgbm1 libvulkan1 \
  30. libva2 libva-drm2 libva-x11-2 libva-wayland2 libxkbcommon0 libwayland-egl1 libxxf86vm1 liblz4-1 libgnutls30 libgcrypt20; do
  31. if apt-cache show "${p}t64" >/dev/null 2>&1; then pkgs+=("${p}t64"); else pkgs+=("$p"); fi
  32. done
  33. apt-get install -y -qq --no-install-recommends "${pkgs[@]}" >/dev/null
  34. ;;
  35. *" fedora "*)
  36. dnf -y -q install gtk3 nss alsa-lib cups-libs pipewire-libs mesa-libGL mesa-libEGL mesa-libgbm \
  37. vulkan-loader libva libxkbcommon libwayland-egl libXxf86vm lz4-libs gnutls libgcrypt binutils findutils >/dev/null
  38. ;;
  39. *" arch "*)
  40. pacman -Syu --noconfirm --needed gtk3 nss alsa-lib libcups libpipewire mesa vulkan-icd-loader libva \
  41. libxkbcommon libxxf86vm lz4 gnutls libgcrypt binutils findutils >/dev/null
  42. ;;
  43. *" suse "* | *" opensuse "*)
  44. zypper -n -q install libgtk-3-0 mozilla-nss libasound2 libcups2 libpipewire-0_3-0 Mesa-libGL1 \
  45. Mesa-libEGL1 libgbm1 libvulkan1 libva2 libva-drm2 libva-x11-2 libva-wayland2 libxkbcommon0 \
  46. libwayland-egl1 libXxf86vm1 liblz4-1 libgnutls30 libgcrypt20 binutils findutils gzip tar >/dev/null
  47. ;;
  48. *)
  49. echo "don't know how to install packages on $PRETTY_NAME" >&2
  50. exit 1
  51. ;;
  52. esac
  53. }
  54. # packages providing the given sonames, through each package manager's file index
  55. install_sonames() {
  56. . /etc/os-release
  57. local pkgs=() so pkg
  58. case " $ID ${ID_LIKE:-} " in
  59. *" debian "* | *" ubuntu "*)
  60. apt-get install -y -qq --no-install-recommends apt-file >/dev/null
  61. apt-file update >/dev/null
  62. for so in "$@"; do
  63. pkg="$(apt-file search -x "/${so//./\\.}\$" | cut -d: -f1 | grep -v -- '-dbg' | head -1 || true)"
  64. if [ -n "$pkg" ]; then pkgs+=("$pkg"); else echo " no package provides $so" >&2; fi
  65. done
  66. if [ "${#pkgs[@]}" -gt 0 ]; then
  67. apt-get install -y -qq --no-install-recommends "${pkgs[@]}" >/dev/null
  68. fi
  69. ;;
  70. *" fedora "*)
  71. dnf -y -q install "${@/%/()(64bit)}" >/dev/null
  72. ;;
  73. *" arch "*)
  74. if [[ " $* " == *" libnode.so."* ]] && [ -n "${LIBNODE_PKG:-}" ]; then
  75. pacman -U --noconfirm "$LIBNODE_PKG" >/dev/null
  76. fi
  77. pacman -Fy >/dev/null
  78. for so in "$@"; do
  79. [[ "$so" == libnode.so.* ]] && continue
  80. pkg="$(pacman -Fq "/usr/lib/$so" | head -1 | cut -d/ -f2 || true)"
  81. if [ -n "$pkg" ]; then pkgs+=("$pkg"); else echo " no package provides $so" >&2; fi
  82. done
  83. if [ "${#pkgs[@]}" -gt 0 ]; then
  84. pacman -S --noconfirm --needed "${pkgs[@]}" >/dev/null
  85. fi
  86. ;;
  87. *" suse "* | *" opensuse "*)
  88. zypper -n -q install "${@/%/()(64bit)}" >/dev/null
  89. ;;
  90. esac
  91. }
  92. [ "$install_deps" = 1 ] && install_desktop_runtime
  93. work="$(mktemp -d)"
  94. trap 'rm -rf "$work"' EXIT
  95. tar -xzf "$tarball" -C "$work"
  96. dir=("$work"/*/)
  97. dir="${dir[0]%/}"
  98. . /etc/os-release
  99. echo "== $(basename "$tarball") on $PRETTY_NAME, $(ldd --version | head -1)"
  100. failed=0
  101. check_libraries() {
  102. if [ -e "$dir/linux-wallpaperengine.bin" ]; then
  103. # the launcher puts the fallback copies the system lacks on the path, like when it starts the engine
  104. "$dir/linux-wallpaperengine" --check-libraries 2>&1 || true
  105. else
  106. ldd -r "$dir/linux-wallpaperengine" "$dir/linux-wallpaperengine-web-helper" 2>&1 || true
  107. fi
  108. }
  109. out="$(check_libraries)"
  110. if [ "$install_deps" = 1 ] && [ ! -e "$dir/linux-wallpaperengine.bin" ]; then
  111. mapfile -t sonames < <(awk '/=> not found/ { print $1 }' <<<"$out" | sort -u)
  112. if [ "${#sonames[@]}" -gt 0 ]; then
  113. echo "-- installing what provides ${sonames[*]}"
  114. install_sonames "${sonames[@]}"
  115. out="$(check_libraries)"
  116. fi
  117. fi
  118. missing="$(grep -E 'not found' <<<"$out" | sort -u || true)"
  119. ours="$(grep -E 'undefined symbol: .*/(linux-wallpaperengine[^/]*|liblinux-wallpaperengine-lib\.so)\)' <<<"$out" || true)"
  120. lazy="$(grep -E 'undefined symbol' <<<"$out" | grep -vE '/(linux-wallpaperengine[^/]*|liblinux-wallpaperengine-lib\.so)\)' |
  121. sed -E 's/^\s*undefined symbol: (\S+).*\/([^/)]+)\)$/\2: \1/' | sort -u || true)"
  122. if [ -n "$missing$ours" ]; then
  123. echo "-- missing"
  124. printf '%s\n' "$missing" "$ours" | sed -e '/^$/d' -e 's/^/ /' | head -30
  125. failed=1
  126. fi
  127. if [ -n "$lazy" ]; then
  128. echo "-- unresolved functions in bundled libraries (only fail when called):"
  129. sed 's/^/ /' <<<"$lazy" | head -30
  130. fi
  131. fallback="$(grep -oE 'lib/fallback/[^/]+' <<<"$out" | sort -u | sed 's|lib/fallback/||' | paste -sd' ' || true)"
  132. [ -n "$fallback" ] && echo "-- uses the bundled fallback for: $fallback"
  133. if ! help="$(cd / && "$dir/linux-wallpaperengine" --help 2>&1)"; then
  134. echo "-- linux-wallpaperengine --help failed:"
  135. sed 's/^/ /' <<<"$help" | tail -20
  136. failed=1
  137. elif ! grep -q -- '--screen-root' <<<"$help"; then
  138. echo "-- linux-wallpaperengine --help printed something unexpected:"
  139. sed 's/^/ /' <<<"$help" | head -20
  140. failed=1
  141. fi
  142. if [ "$failed" = 0 ]; then
  143. echo "OK"
  144. else
  145. echo "FAILED"
  146. fi
  147. exit "$failed"