| 1 |
#!/usr/bin/env bash |
| 2 |
# |
| 3 |
# This file is part of the LibreOffice project. |
| 4 |
# |
| 5 |
# This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
# |
| 9 |
|
| 10 |
# verify that ELF NEEDED entries are known-good so hopefully builds run on |
| 11 |
# lots of different GNU/Linux distributions |
| 12 |
|
| 13 |
set -euo pipefail |
| 14 |
|
| 15 |
PARA=1 |
| 16 |
check_path="${INSTDIR:-.}" |
| 17 |
|
| 18 |
help() |
| 19 |
{ |
| 20 |
cat << "EOF" |
| 21 |
-d <dir> directory to check |
| 22 |
-p run unbound parallel checks |
| 23 |
-h help |
| 24 |
EOF |
| 25 |
[ -z "${1:-}" ] && exit 0 |
| 26 |
} |
| 27 |
|
| 28 |
die() |
| 29 |
{ |
| 30 |
echo "$1" |
| 31 |
echo |
| 32 |
help 1 |
| 33 |
exit 1 |
| 34 |
} |
| 35 |
|
| 36 |
while [ "${1:-}" != "" ]; do |
| 37 |
parm=${1%%=*} |
| 38 |
arg=${1#*=} |
| 39 |
has_arg= |
| 40 |
if [ "${1}" != "${parm?}" ] ; then |
| 41 |
has_arg=1 |
| 42 |
else |
| 43 |
arg="" |
| 44 |
fi |
| 45 |
|
| 46 |
case "${parm}" in |
| 47 |
--dir|-d) |
| 48 |
if [ "$has_arg" ] ; then |
| 49 |
check_path="$arg" |
| 50 |
else |
| 51 |
shift |
| 52 |
check_path="$1" |
| 53 |
fi |
| 54 |
if [ ! -d "$check_path" ]; then |
| 55 |
die "Invalid directory '$check_path'" |
| 56 |
fi |
| 57 |
;; |
| 58 |
-h) |
| 59 |
help |
| 60 |
;; |
| 61 |
-p) |
| 62 |
# this sounds counter intuitive but the idea |
| 63 |
# is to possibly support -p <n> |
| 64 |
# in the meantime: 0 = nolimit and -p 1 would mean |
| 65 |
# the current default: serialize |
| 66 |
PARA=0 |
| 67 |
;; |
| 68 |
-*) |
| 69 |
die "Invalid option $1" |
| 70 |
;; |
| 71 |
*) |
| 72 |
if [ "$DO_NEW" = 1 ] ; then |
| 73 |
REPO="$1" |
| 74 |
else |
| 75 |
die "Invalid argument $1" |
| 76 |
fi |
| 77 |
;; |
| 78 |
esac |
| 79 |
shift |
| 80 |
done |
| 81 |
|
| 82 |
|
| 83 |
files=$(find "${check_path}/program" "${check_path}/sdk/bin" -type f) |
| 84 |
# all RPATHs should point to ${INSTDIR}/program so that's the files they find |
| 85 |
programfiles=$(echo ${files} | grep -o '/program/[^/]* ' | xargs -n 1 basename) |
| 86 |
|
| 87 |
# allowlists should contain only system libraries that have a good reputation |
| 88 |
# of maintaining ABI stability |
| 89 |
# allow extending the allowlist using the environment variable to be able to work |
| 90 |
# on the installer stuff without the need for a baseline setup |
| 91 |
globalallowlist="ld-linux-x86-64.so.2 ld-linux-aarch64.so.1 ld-linux.so.2 libc.so.6 libm.so.6 libdl.so.2 libpthread.so.0 librt.so.1 libutil.so.1 libnsl.so.1 libcrypt.so.2 libgcc_s.so.1 libstdc++.so.6 libz.so.1 libfontconfig.so.1 libfreetype.so.6 libxml2.so.2 libxslt.so.1 libexslt.so.0 libnspr4.so libnss3.so libnssutil3.so libplc4.so libplds4.so libsmime3.so libssl3.so ${LO_ELFCHECK_ALLOWLIST-}" |
| 92 |
x11allowlist="libX11.so.6 libX11-xcb.so.1 libXext.so.6 libSM.so.6 libICE.so.6 libXinerama.so.1 libXrender.so.1 libXrandr.so.2 libcairo.so.2" |
| 93 |
openglallowlist="libGL.so.1" |
| 94 |
gobjectallowlist="libgobject-2.0.so.0 libglib-2.0.so.0" |
| 95 |
gdbusallowlist="libdbus-glib-1.so.2 libdbus-1.so.3 libgmodule-2.0.so.0 libgthread-2.0.so.0 ${gobjectallowlist}" |
| 96 |
gioallowlist="libgio-2.0.so.0 ${gdbusallowlist}" |
| 97 |
gstreamerallowlist="libgsttag-1.0.so.0 libgstaudio-1.0.so.0 libgstpbutils-1.0.so.0 libgstvideo-1.0.so.0 libgstbase-1.0.so.0 libgstreamer-1.0.so.0 ${gobjectallowlist}" |
| 98 |
gtk3allowlist="libgtk-3.so.0 libgdk-3.so.0 libcairo-gobject.so.2 libpangocairo-1.0.so.0 libfribidi.so.0 libatk-1.0.so.0 libcairo.so.2 libpangoft2-1.0.so.0 libpango-1.0.so.0 libfontconfig.so.1 libfreetype.so.6 libgdk_pixbuf-2.0.so.0 libharfbuzz.so.0 ${gioallowlist}" |
| 99 |
gtk4allowlist="libgtk-4.so.1 libcairo-gobject.so.2 libpangocairo-1.0.so.0 libatk-1.0.so.0 libcairo.so.2 libpango-1.0.so.0 libgdk_pixbuf-2.0.so.0 libharfbuzz.so.0 libgraphene-1.0.so.0 ${gioallowlist}" |
| 100 |
qt5allowlist="libQt5Core.so.5 libQt5Gui.so.5 libQt5Network.so.5 libQt5Widgets.so.5 libQt5X11Extras.so.5 libcairo.so.2 libxcb.so.1 libxcb-icccm.so.4 ${gobjectallowlist}" |
| 101 |
qt6allowlist="libQt6Core.so.6 libQt6Gui.so.6 libQt6Multimedia.so.6 libQt6MultimediaWidgets.so.6 libQt6Network.so.6 libQt6Widgets.so.6 libcairo.so.2 libxcb.so.1" |
| 102 |
kf5allowlist="libKF5ConfigCore.so.5 libKF5CoreAddons.so.5 libKF5I18n.so.5 libKF5KIOCore.so.5 libKF5KIOFileWidgets.so.5 libKF5KIOWidgets.so.5 libKF5WindowSystem.so.5" |
| 103 |
kf6allowlist="libKF6ConfigCore.so.6 libKF6CoreAddons.so.6 libKF6I18n.so.6 libKF6KIOCore.so.6 libKF6KIOFileWidgets.so.6 libKF6KIOWidgets.so.6 libKF6WindowSystem.so.6" |
| 104 |
avahiallowlist="libavahi-common.so.3 libavahi-client.so.3 ${gdbusallowlist}" |
| 105 |
kerberosallowlist="libgssapi_krb5.so.2 libcom_err.so.2 libkrb5.so.3" |
| 106 |
dconfallowlist="libdconf.so.1 libgio-2.0.so.0 ${gobjectallowlist}" |
| 107 |
|
| 108 |
check_one_file() |
| 109 |
{ |
| 110 |
local file="$1" |
| 111 |
|
| 112 |
skip=0 |
| 113 |
allowlist="${globalallowlist}" |
| 114 |
case "${file}" in |
| 115 |
*/sdk/docs/*) |
| 116 |
# skip the majority of files, no ELF binaries here |
| 117 |
skip=1 |
| 118 |
;; |
| 119 |
*/_uuid.cpython-*.so) |
| 120 |
allowlist="${allowlist} libuuid.so.1" |
| 121 |
;; |
| 122 |
*/libcairo-lo.so.2) |
| 123 |
allowlist="${allowlist} ${x11allowlist} libxcb-shm.so.0 libxcb.so.1 libxcb-render.so.0" |
| 124 |
;; |
| 125 |
*/libcairocanvaslo.so) |
| 126 |
allowlist="${allowlist} libcairo.so.2" |
| 127 |
;; |
| 128 |
*/libucpgio1lo.so|*/liblosessioninstalllo.so|*/libevoablo.so) |
| 129 |
allowlist="${allowlist} ${gioallowlist}" |
| 130 |
;; |
| 131 |
*/libavmediagst.so) |
| 132 |
allowlist="${allowlist} ${gstreamerallowlist}" |
| 133 |
;; |
| 134 |
*/libavmediagtk.so) |
| 135 |
allowlist="${allowlist} ${gtk4allowlist}" |
| 136 |
;; |
| 137 |
*/libavmediaqt6.so) |
| 138 |
allowlist="${allowlist} ${qt6allowlist}" |
| 139 |
;; |
| 140 |
*/libvclplug_kf5lo.so|*/libkf5be1lo.so) |
| 141 |
if [ "$ENABLE_KF5" = TRUE ]; then |
| 142 |
allowlist="${allowlist} ${qt5allowlist} ${kf5allowlist}" |
| 143 |
fi |
| 144 |
;; |
| 145 |
*/libvclplug_kf6lo.so) |
| 146 |
if [ "$ENABLE_KF6" = TRUE ]; then |
| 147 |
allowlist="${allowlist} ${qt6allowlist} ${kf6allowlist}" |
| 148 |
fi |
| 149 |
;; |
| 150 |
*/libvclplug_gtk3lo.so|*/updater) |
| 151 |
allowlist="${allowlist} ${x11allowlist} ${gtk3allowlist}" |
| 152 |
;; |
| 153 |
*/libvclplug_gtk4lo.so) |
| 154 |
allowlist="${allowlist} ${x11allowlist} ${gtk4allowlist}" |
| 155 |
;; |
| 156 |
*/libvclplug_qt5lo.so) |
| 157 |
if [ "$ENABLE_QT5" = TRUE ]; then |
| 158 |
allowlist="${allowlist} ${qt5allowlist}" |
| 159 |
fi |
| 160 |
;; |
| 161 |
*/libvclplug_qt6lo.so) |
| 162 |
if [ "$ENABLE_QT6" = TRUE ]; then |
| 163 |
allowlist="${allowlist} ${qt6allowlist}" |
| 164 |
fi |
| 165 |
;; |
| 166 |
*/libvclplug_gtk3_kde5lo.so) |
| 167 |
if [ "$ENABLE_GTK3_KDE5" = TRUE ]; then |
| 168 |
allowlist="${allowlist} ${x11allowlist} ${gtk3allowlist} ${qt5allowlist} ${kf5allowlist}" |
| 169 |
fi |
| 170 |
;; |
| 171 |
*/lo_kde5filepicker) |
| 172 |
if [ "$ENABLE_GTK3_KDE5" = TRUE ]; then |
| 173 |
allowlist="${allowlist} ${x11allowlist} ${gtk3allowlist} ${qt5allowlist} \ |
| 174 |
${kf5allowlist}" |
| 175 |
fi |
| 176 |
;; |
| 177 |
*/oosplash|*/gengal.bin) |
| 178 |
allowlist="${allowlist} ${x11allowlist}" |
| 179 |
;; |
| 180 |
*/libvclplug_genlo.so|*/libchart2lo.so|*/libavmediaogl.so|*/libOGLTranslo.so|*/liboglcanvaslo.so) |
| 181 |
allowlist="${allowlist} ${x11allowlist} ${openglallowlist}" |
| 182 |
;; |
| 183 |
*/libvcllo.so) |
| 184 |
allowlist="${allowlist} ${x11allowlist} ${openglallowlist} ${gioallowlist} libcups.so.2" |
| 185 |
;; |
| 186 |
*/libsofficeapp.so) |
| 187 |
allowlist="${allowlist} ${x11allowlist} ${openglallowlist} ${gioallowlist} libcups.so.2" |
| 188 |
;; |
| 189 |
*/liblibreofficekitgtk.so) |
| 190 |
allowlist="${allowlist} ${gtk3allowlist}" |
| 191 |
;; |
| 192 |
*/libsdlo.so) |
| 193 |
allowlist="${allowlist} ${avahiallowlist}" |
| 194 |
;; |
| 195 |
*/libskialo.so) |
| 196 |
allowlist="${allowlist} ${openglallowlist} ${x11allowlist}" |
| 197 |
;; |
| 198 |
*/libofficebean.so) |
| 199 |
allowlist="${allowlist} libjawt.so" |
| 200 |
;; |
| 201 |
*/libcurl.so.4) |
| 202 |
if [ "$WITH_GSSAPI" = TRUE ]; then |
| 203 |
allowlist="${allowlist} ${kerberosallowlist}" |
| 204 |
fi |
| 205 |
;; |
| 206 |
*/libpostgresql-sdbc-impllo.so) |
| 207 |
if [ "$WITH_GSSAPI" = TRUE ]; then |
| 208 |
allowlist="${allowlist} ${kerberosallowlist}" |
| 209 |
fi |
| 210 |
;; |
| 211 |
*/libmysqlclo.so) |
| 212 |
if [ "$WITH_GSSAPI" = TRUE ]; then |
| 213 |
allowlist="${allowlist} ${kerberosallowlist}" |
| 214 |
fi |
| 215 |
;; |
| 216 |
*/libconfigmgrlo.so) |
| 217 |
if [ "$ENABLE_DCONF" = TRUE ]; then |
| 218 |
allowlist="${allowlist} ${dconfallowlist}" |
| 219 |
fi |
| 220 |
;; |
| 221 |
*/libmergedlo.so) |
| 222 |
allowlist="${allowlist} ${x11allowlist} ${openglallowlist} ${gioallowlist} ${kerberosallowlist} ${dconfallowlist} libcups.so.2 libcairo.so.2" |
| 223 |
;; |
| 224 |
esac |
| 225 |
if test "${skip}" = 0 && readelf -d "${file}" &> /dev/null ; then |
| 226 |
rpath=$(readelf -d "${file}" | grep '(\(RPATH\|RUNPATH\))' || true) |
| 227 |
neededs=$(readelf -d "${file}" | grep '(NEEDED)' | sed -e 's/.*\[\(.*\)\]$/\1/') |
| 228 |
neededsinternal= |
| 229 |
for needed in ${neededs} |
| 230 |
do |
| 231 |
if ! echo ${allowlist} | grep -q -w "${needed}" ; then |
| 232 |
neededsinternal="${neededsinternal} ${needed}" |
| 233 |
if ! echo ${programfiles} | grep -q -w "${needed}" ; then |
| 234 |
echo "${file}" has suspicious NEEDED: "${needed}" |
| 235 |
status=1 |
| 236 |
fi |
| 237 |
fi |
| 238 |
done |
| 239 |
if test -z "${rpath}" ; then |
| 240 |
case "${file}" in |
| 241 |
*/python-core-*/lib/lib-dynload/*) |
| 242 |
# python modules don't have RPATH |
| 243 |
;; |
| 244 |
*/share/extensions/*) |
| 245 |
# extension libraries don't have RPATH |
| 246 |
;; |
| 247 |
*) |
| 248 |
# no NEEDED from instdir, no RPATH needed |
| 249 |
if test -n "${neededsinternal}" ; then |
| 250 |
echo "${file}" has no RPATH |
| 251 |
status=1 |
| 252 |
fi |
| 253 |
;; |
| 254 |
esac |
| 255 |
else |
| 256 |
case "$file" in |
| 257 |
*/sdk/bin/*) |
| 258 |
if echo "${rpath}" | grep -q -v '\[\$ORIGIN/../../program\]$' ; then |
| 259 |
echo "${file}" has unexpected RPATH "${rpath}" |
| 260 |
status=1 |
| 261 |
fi |
| 262 |
;; |
| 263 |
*) |
| 264 |
if echo "${rpath}" | grep -q -v '\[\$ORIGIN\]$' ; then |
| 265 |
echo "${file}" has unexpected RPATH "${rpath}" |
| 266 |
status=1 |
| 267 |
fi |
| 268 |
;; |
| 269 |
esac |
| 270 |
fi |
| 271 |
fi |
| 272 |
} |
| 273 |
status=0 |
| 274 |
|
| 275 |
if [ "$PARA" = "1" ] ; then |
| 276 |
for file in ${files} |
| 277 |
do |
| 278 |
check_one_file $file |
| 279 |
done |
| 280 |
else |
| 281 |
rm -f check_elf.out |
| 282 |
for file in ${files} |
| 283 |
do |
| 284 |
( |
| 285 |
check_one_file $file |
| 286 |
)>> check_elf.out & |
| 287 |
done |
| 288 |
|
| 289 |
wait |
| 290 |
|
| 291 |
if [ -s check_elf.out ] ; then |
| 292 |
cat check_elf.out |
| 293 |
status=1 |
| 294 |
fi |
| 295 |
rm check_elf.out |
| 296 |
fi |
| 297 |
exit ${status} |
| 298 |
|