public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: James Le Cuirot <chewi@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: Re: [gentoo-dev] [PATCH] ffmpeg-compat.eclass: new eclass
Date: Sun, 09 Mar 2025 10:17:42 +0000	[thread overview]
Message-ID: <c09fcf4abf10e46d979cdea89566cf0b24124cd5.camel@gentoo.org> (raw)
In-Reply-To: <20250309033514.576-1-ionen@gentoo.org>

[-- Attachment #1: Type: text/plain, Size: 4505 bytes --]

On Sat, 2025-03-08 at 22:34 -0500, Ionen Wolkens wrote:
> Sending this to dev ML in advance given it's simple and "probably"
> won't need to change the code further.
> 
> If interested in the whole deal, see the PR instead:
> https://github.com/gentoo/gentoo/pull/40942
> 
> --- (actual commit message below)
> 
> Both the slotting method and eclass are meant to be as simple
> as possible, and isolated so that it does not really need to
> work with everything given non-slotted ffmpeg stays.
> 
> Did not want turn ffmpeg into a permanent slotting model with
> a FFMPEG_SLOT use_expand, eselect, or such potentially turning
> it into a special Gentoo-only thing that often need hacks.
> 
> Essentially just a way for broken packages to gain time without
> blocking everyone's ffmpeg updates.
> 
> Signed-off-by: Ionen Wolkens <ionen@gentoo.org>
> ---
>  eclass/ffmpeg-compat.eclass | 69 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 69 insertions(+)
>  create mode 100644 eclass/ffmpeg-compat.eclass
> 
> diff --git a/eclass/ffmpeg-compat.eclass b/eclass/ffmpeg-compat.eclass
> new file mode 100644
> index 000000000000..2d675ab4cc66
> --- /dev/null
> +++ b/eclass/ffmpeg-compat.eclass
> @@ -0,0 +1,69 @@
> +# Copyright 2025 Gentoo Authors
> +# Distributed under the terms of the GNU General Public License v2
> +
> +# @ECLASS: ffmpeg-compat.eclass
> +# @MAINTAINER:
> +# Ionen Wolkens <ionen@gentoo.org>
> +# @AUTHOR:
> +# Ionen Wolkens <ionen@gentoo.org>
> +# @SUPPORTED_EAPIS: 8
> +# @BLURB: Helper functions to link with slotted ffmpeg-compat libraries
> +# @DESCRIPTION:
> +# To use this, run ``ffmpeg_compat_setup <slot>`` before packages use
> +# pkg-config, depend on media-video/ffmpeg-compat:<slot>=, and ensure
> +# usage of both pkg-config --cflags and --libs (which adds -Wl,-rpath
> +# to find libraries at runtime).
> +#
> +# This eclass is intended as a quick-to-setup alternative to setting
> +# an upper bound on ffmpeg for packages broken with the latest version,
> +# and thus allow users to upgrade their normal ffmpeg.
> +#
> +# This should still be a temporary measure, and it is recommended to
> +# keep migration bugs open rather than consider this eclass as being
> +# the "fix".
> +#
> +# Unlike LLVM_SLOT-style, this does not have USE to select the slot
> +# and should instead pick only the highest one usable until package
> +# is fixed and can use non-slotted ffmpeg again.
> +#
> +# Do *not* use both like ``|| ( <ffmpeg-<ver> ffmpeg-compat:<slot> )``,
> +# the package manager cannot know which version it linked against
> +# without USE flags.  Unfortunately means a period where users may
> +# have two identical versions in stable before the newest major version
> +# is stabilized, but idea is to not mangle normal ffmpeg with slotting
> +# logic and make this an isolated temporary deal.
> +
> +case ${EAPI} in
> +	8) ;;
> +	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
> +esac
> +
> +if [[ -z ${_FFMPEG_COMPAT_ECLASS} ]]; then
> +_FFMPEG_COMPAT_ECLASS=1
> +
> +# @FUNCTION: ffmpeg_compat_get_prefix
> +# @USAGE: <slot>
> +# @DESCRIPTION:
> +# Return prefix of the installed ffmpeg-compat:<slot>.  Binaries like
> +# ffmpeg will be found under <prefix>/bin if needed.
> +ffmpeg_compat_get_prefix() {
> +	(( ${#} == 1 )) || die "Usage: ${FUNCNAME} <slot>"
> +
> +	echo "${EPREFIX}/usr/lib/ffmpeg${1}"
> +}
> +
> +# @FUNCTION: ffmpeg_compat_setup
> +# @USAGE: <slot>
> +# @DESCRIPTION:
> +# Add ESYSROOT's ffmpeg-compat:<slot> to PKG_CONFIG_PATH for the
> +# current ABI.  Can be called multiple times for multilib.
> +ffmpeg_compat_setup() {
> +	(( ${#} == 1 )) || die "Usage: ${FUNCNAME} <slot>"
> +
> +	local path=${SYSROOT}$(ffmpeg_compat_get_prefix "${1}")
> +	[[ ${PKG_CONFIG_PATH} =~ (.*)"${path}"/[^/]+/pkgconfig:(.*) ]] &&
> +		PKG_CONFIG_PATH=${BASH_REMATCH[1]}${BASH_REMATCH[2]}
> +	export PKG_CONFIG_PATH=${path}/$(get_libdir)/pkgconfig:${PKG_CONFIG_PATH}
> +}
> +
> +fi

I like this approach. We've generally been quite good at dragging upstreams to
the latest, so it would be a shame to go fully slotted.

The regex check seems like overkill to me, but perhaps I've missed something.

This currently won't work when cross-compiling as cross-pkg-config currently
unsets PKG_CONFIG_PATH, but I have been thinking about changing that. That was
done to tame non-Gentoo environments, but no one else uses crossdev in
reality.


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 858 bytes --]

  reply	other threads:[~2025-03-09 10:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-09  3:34 [gentoo-dev] [PATCH] ffmpeg-compat.eclass: new eclass Ionen Wolkens
2025-03-09 10:17 ` James Le Cuirot [this message]
2025-03-09 10:27   ` Ionen Wolkens
2025-03-09 10:33     ` James Le Cuirot
2025-03-09 15:22       ` Ionen Wolkens
2025-03-09 16:45 ` Eli Schwartz
2025-03-09 18:47   ` Ionen Wolkens
2025-03-09 19:34 ` Ionen Wolkens
2025-03-11  4:37   ` [gentoo-dev] " Duncan
2025-03-11  5:14     ` Ionen Wolkens

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c09fcf4abf10e46d979cdea89566cf0b24124cd5.camel@gentoo.org \
    --to=chewi@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox