[v3] gstreamer1.0-plugins-bad/ugly: use the GPL-2.0-or-later only when it is in use

Message ID 20220307001527.197791-1-quaresma.jose@gmail.com
State Accepted, archived
Commit 25ea8753e2d1dc4e1aa01b4800da532ca1aecec7
Headers show
Series [v3] gstreamer1.0-plugins-bad/ugly: use the GPL-2.0-or-later only when it is in use | expand

Commit Message

Jose Quaresma March 7, 2022, 12:15 a.m. UTC
Since all gstreamer modules uses LGPLv2.1 with exceptions
for some plugins in bad and ugly modules that has GPLv2+.

For the GPLv2+ this patch set the licence only for each plugin
that is affected by this licence. The commercial LICENSE_FLAGS
is enabled if any of the previous plugins is builded.

CC: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Jose Quaresma <quaresma.jose@gmail.com>
---
 .../gstreamer1.0-plugins-bad_1.20.0.bb        |  5 +--
 .../gstreamer1.0-plugins-license.inc          | 36 +++++++++++++++++++
 .../gstreamer1.0-plugins-ugly_1.20.0.bb       |  6 ++--
 3 files changed, 42 insertions(+), 5 deletions(-)
 create mode 100644 meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-license.inc

Patch

diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.20.0.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.20.0.bb
index 44532222fa..17799040ef 100644
--- a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.20.0.bb
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.20.0.bb
@@ -1,4 +1,5 @@ 
 require gstreamer1.0-plugins-common.inc
+require gstreamer1.0-plugins-license.inc
 
 DESCRIPTION = "'Bad' GStreamer plugins and helper libraries "
 HOMEPAGE = "https://gstreamer.freedesktop.org/"
@@ -92,8 +93,8 @@  PACKAGECONFIG[webrtcdsp]       = "-Dwebrtcdsp=enabled,-Dwebrtcdsp=disabled,webrt
 PACKAGECONFIG[zbar]            = "-Dzbar=enabled,-Dzbar=disabled,zbar"
 PACKAGECONFIG[x11]             = "-Dx11=enabled,-Dx11=disabled,libxcb libxkbcommon"
 
-# GPL - only built if gpl option is also enabled!
-PACKAGECONFIG[gpl]             = "-Dgpl=enabled,-Dgpl=disabled"
+GSTREAMER_GPL = "${@bb.utils.filter('PACKAGECONFIG', 'faad resindvd x265', d)}"
+
 PACKAGECONFIG[faad]            = "-Dfaad=enabled,-Dfaad=disabled,faad2"
 PACKAGECONFIG[resindvd]        = "-Dresindvd=enabled,-Dresindvd=disabled,libdvdread libdvdnav"
 PACKAGECONFIG[x265]            = "-Dx265=enabled,-Dx265=disabled,x265"
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-license.inc b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-license.inc
new file mode 100644
index 0000000000..d7a39066cc
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-license.inc
@@ -0,0 +1,36 @@ 
+# This .inc file contains functionality for automatically setting
+# the common license of all plugins so we can overwride some of them
+#
+# This is mainly used by the gstreamer1.0-plugins-* plugin set recipes,
+# but can be used in any recipe that produces GStreamer plugins.
+
+PACKAGESPLITFUNCS:append = " set_gstreamer_common_license "
+
+def get_gpl_plugins_name(d):
+    gpl_plugins_name = []
+    pn = d.getVar('PN')
+    for plugin in d.getVar('GSTREAMER_GPL'):
+        gpl_plugins_name.append(pn + '-' + plugin)
+    return gpl_plugins_name
+
+python set_gstreamer_common_license () {
+    import oe.utils
+    license = 'LGPL-2.1-or-later'
+    gpl_plugins_name = get_gpl_plugins_name(d)
+    for pkg in oe.utils.packages_filter_out_system(d):
+        if pkg not in gpl_plugins_name:
+            d.setVar('LICENSE:' + pkg, license)
+        else:
+            gpl_plugins_name.remove(pkg)
+}
+
+def gpl_oemeson(d):
+    gpl = '-Dgpl=disabled'
+    for gpl_plugins_name in get_gpl_plugins_name(d):
+        gpl = '-Dgpl=enabled'
+        d.setVar('LICENSE:' + gpl_plugins_name, 'GPL-2.0-or-later')
+        d.setVar('LICENSE_FLAGS:' + gpl_plugins_name, 'commercial')
+
+    return gpl
+
+EXTRA_OEMESON += "${@gpl_oemeson(d)}"
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-ugly_1.20.0.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-ugly_1.20.0.bb
index 9b6f80aa89..8e2fadfb02 100644
--- a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-ugly_1.20.0.bb
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-ugly_1.20.0.bb
@@ -1,4 +1,5 @@ 
 require gstreamer1.0-plugins-common.inc
+require gstreamer1.0-plugins-license.inc
 
 DESCRIPTION = "'Ugly GStreamer plugins"
 HOMEPAGE = "https://gstreamer.freedesktop.org/"
@@ -8,7 +9,6 @@  LIC_FILES_CHKSUM = "file://COPYING;md5=a6f89e2100d9b6cdffcea4f398e37343 \
                     file://tests/check/elements/xingmux.c;beginline=1;endline=21;md5=4c771b8af188724855cb99cadd390068"
 
 LICENSE = "LGPL-2.1-or-later & GPL-2.0-or-later"
-LICENSE_FLAGS = "commercial"
 
 SRC_URI = " \
             https://gstreamer.freedesktop.org/src/gst-plugins-ugly/gst-plugins-ugly-${PV}.tar.xz \
@@ -29,8 +29,8 @@  PACKAGECONFIG ??= " \
 PACKAGECONFIG[amrnb]    = "-Damrnb=enabled,-Damrnb=disabled,opencore-amr"
 PACKAGECONFIG[amrwb]    = "-Damrwbdec=enabled,-Damrwbdec=disabled,opencore-amr"
 
-# GPL - only built if gpl option is also enabled!
-PACKAGECONFIG[gpl]      = "-Dgpl=enabled,-Dgpl=disabled"
+GSTREAMER_GPL = "${@bb.utils.filter('PACKAGECONFIG', 'cdio a52dec dvdread mpeg2dec x264', d)}"
+
 PACKAGECONFIG[cdio]     = "-Dcdio=enabled,-Dcdio=disabled,libcdio"
 PACKAGECONFIG[a52dec]   = "-Da52dec=enabled,-Da52dec=disabled,liba52"
 PACKAGECONFIG[dvdread]  = "-Ddvdread=enabled,-Ddvdread=disabled,libdvdread"