Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .github/script/check_no_copyleft_libs.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
#!/usr/bin/env bash
# Fail if a Linux package ships, links or depends on a library FLM dropped for
# licensing reasons: FFmpeg and the GPL codecs distro FFmpeg pulls in (x264,
# x265, xvid, libdvdnav/libdvdread), FFTW and GNU readline.
# x265, xvid, libdvdnav/libdvdread), FFTW and GNU readline. Also fail if it
# bundles an (L)GPL system library: the ones distro FFmpeg and libcurl pulled
# into the HRX tarball, glibc pieces and the GCC runtime. Packages may link
# those, but they come from the host.
#
# Usage: check_no_copyleft_libs.sh <package.tar.gz | package.deb>...
set -euo pipefail

# Shared-library file names (bundled files and ELF NEEDED entries).
lib_re='^lib(av(codec|format|util|filter|device)|sw(scale|resample)|postproc|x264|x265|xvidcore|dvdnav|dvdread|fftw3[a-z_]*|readline)[.]so'
# Shared-library file names that must not be bundled (linking is fine).
bundle_re='^lib(codec2|gme|gdk_pixbuf-2[.]0|(glib|gio|gobject|gmodule|gthread)-2[.]0|fribidi|idn2|tasn1|unistring|gmp|gnutls|keyutils|mp3lame|bluray|datrie|numa|rsvg-2|rtmp|soxr|ssh|thai|udfread|mpg123|nettle|hogweed|pgm-5[.]3|pango(cairo|ft2)?-1[.]0|shine|twolame|blkid|mount|zvbi|mvec|resolv|stdc[+][+]|gcc_s|gomp|atomic)[.]so'
# Debian binary package names (.deb Depends).
pkg_re='^(libav(codec|format|util|filter|device)|libsw(scale|resample)|libpostproc|libx26[45]|libxvidcore|libdvd(nav|read)|libfftw3|libreadline)'

Expand All @@ -32,13 +37,17 @@ for pkg in "$@"; do
echo "::error::$pkg bundles a library listed above"
status=1
fi
if find "$tmp" \( -type f -o -type l \) -printf '%f\n' | grep -E "$bundle_re"; then
echo "::error::$pkg bundles an (L)GPL system library listed above; it must come from the host"
status=1
fi
while IFS= read -r -d '' f; do
if readelf -d "$f" 2>/dev/null | sed -n 's/.*(NEEDED).*\[\(.*\)\]/\1/p' | grep -E "$lib_re"; then
echo "::error::${f#"$tmp"/} in $pkg links a library listed above"
status=1
fi
done < <(find "$tmp" -type f -print0)
rm -rf "$tmp"
[ "$status" -eq 0 ] && echo "$pkg: no FFmpeg, GPL codec, FFTW or readline libraries"
[ "$status" -eq 0 ] && echo "$pkg: no FFmpeg, GPL codec, FFTW or readline libraries, no bundled (L)GPL system libraries"
done
exit "$status"
Loading
Loading