4 2

[alpine-devel] apk and libraries that optionally replace others

Oliver Smith
Details
Message ID
<5ad90a46-8c78-ebdd-e022-a94fe7937805@bitmessage.ch>
Sender timestamp
1526417820
DKIM signature
missing
Download raw message
Hey folks,

in Alpine based postmarketOS we have hit the following use case quite a
few times by now, and we're wondering how to solve it properly:
Packaging "testlib-b" as a _optional_ replacement for "testlib-a".

Both "testlib-a" and "testlib-b" provide the same soname, which means
abuild will automatically make both binary packages provide
"so:libtestlib.so.1".

Now there is a "testapp" package, which has "testlib-a" in makedepends
and links against "libtestlib.so.1". Therefore abuild puts
"so:libtestlib.so.1" in the depends of "testapp". What we would like to
achieve is, that whenever installing "testapp", it pulls in "testlib-a".
But when "testlib-b" is already installed, it uses "testlib-b" instead
of "testlib-a".

I have tried various combinations with "provides" and
"provider_priority", and I couldn't get it working. The only way it
would work was if "testapp" explicitly depended on "testlib-a", but that
won't fulfill our use case: if the library in question is "libdrm", then
we would need to change a lot of Alpine's aports to explicitly depend on
libdrm instead of implicitly to make it work.

If someone is interested, I can provide apk's output of what I've tried
so far. The aports I have used for testing are here [1].

To make this less abstract, one example where we would actually use
this, is "libdrm-grate", which adds out of tree tegra drivers to
"libdrm" [2].

Here are my questions:
* Am I missing something, or does this not work with apk?
* Would Alpine be interested in a patch that adds this functionality,
  and if so, how would everyone like to have it integrated?

Thanks for reading,
Oliver

[1]: https://github.com/ollieparanoid/apk-conflicts-example
[2]:
https://github.com/postmarketOS/pmbootstrap/issues/1380#issuecomment-385183609



---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
William Pitcock
Details
Message ID
<CA+T2pCGeMe+LgApEwUju6NL8FCSAPxY7bPCKDHw5Pj3FXZvqCA@mail.gmail.com>
In-Reply-To
<5ad90a46-8c78-ebdd-e022-a94fe7937805@bitmessage.ch> (view parent)
Sender timestamp
1526443725
DKIM signature
missing
Download raw message
Hello,

On Tue, May 15, 2018 at 3:57 PM, Oliver Smith
<ollieparanoid@bitmessage.ch> wrote:
> Hey folks,
>
> in Alpine based postmarketOS we have hit the following use case quite a
> few times by now, and we're wondering how to solve it properly:
> Packaging "testlib-b" as a _optional_ replacement for "testlib-a".
>
> Both "testlib-a" and "testlib-b" provide the same soname, which means
> abuild will automatically make both binary packages provide
> "so:libtestlib.so.1".

By default this means that both packages will provide
so:libtestlib.so.1 with provider_priority 0.  When provider_priority
is 0, it means to skip automatically resolving the provider.  Provider
selection is based on a combination of priority and overall "cost" of
choosing that provider.  apk will prefer the highest priority provider
with the lowest cost (dependency chain length) that can yield a
satiable solution.

> Now there is a "testapp" package, which has "testlib-a" in makedepends
> and links against "libtestlib.so.1". Therefore abuild puts
> "so:libtestlib.so.1" in the depends of "testapp". What we would like to
> achieve is, that whenever installing "testapp", it pulls in "testlib-a".
> But when "testlib-b" is already installed, it uses "testlib-b" instead
> of "testlib-a".

testlib-b (libdrm) should have provider_priority 1, testlib-a
(libdrm-grate) should have provider_priority greater than 1.  The
provides field itself should be left alone.  The key is to set a
priority on both providers, otherwise APK will treat it as a collision
and behave as you describe.

> I have tried various combinations with "provides" and
> "provider_priority", and I couldn't get it working. The only way it
> would work was if "testapp" explicitly depended on "testlib-a", but that
> won't fulfill our use case: if the library in question is "libdrm", then
> we would need to change a lot of Alpine's aports to explicitly depend on
> libdrm instead of implicitly to make it work.
>
> If someone is interested, I can provide apk's output of what I've tried
> so far. The aports I have used for testing are here [1].
>
> To make this less abstract, one example where we would actually use
> this, is "libdrm-grate", which adds out of tree tegra drivers to
> "libdrm" [2].
>
> Here are my questions:
> * Am I missing something, or does this not work with apk?
> * Would Alpine be interested in a patch that adds this functionality,
>   and if so, how would everyone like to have it integrated?
>
> Thanks for reading,
> Oliver
>
> [1]: https://github.com/ollieparanoid/apk-conflicts-example
> [2]:
> https://github.com/postmarketOS/pmbootstrap/issues/1380#issuecomment-385183609

William


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
William Pitcock
Details
Message ID
<CA+T2pCEdamivZ8J1JL7L2p8abgboP6MBdyDjMbdcOs53c2=nxg@mail.gmail.com>
In-Reply-To
<CA+T2pCGeMe+LgApEwUju6NL8FCSAPxY7bPCKDHw5Pj3FXZvqCA@mail.gmail.com> (view parent)
Sender timestamp
1526443982
DKIM signature
missing
Download raw message
Hello,

On Tue, May 15, 2018 at 11:08 PM, William Pitcock
<nenolod@dereferenced.org> wrote:
> Hello,
>
> On Tue, May 15, 2018 at 3:57 PM, Oliver Smith
> <ollieparanoid@bitmessage.ch> wrote:
>> Hey folks,
>>
>> in Alpine based postmarketOS we have hit the following use case quite a
>> few times by now, and we're wondering how to solve it properly:
>> Packaging "testlib-b" as a _optional_ replacement for "testlib-a".
>>
>> Both "testlib-a" and "testlib-b" provide the same soname, which means
>> abuild will automatically make both binary packages provide
>> "so:libtestlib.so.1".
>
> By default this means that both packages will provide
> so:libtestlib.so.1 with provider_priority 0.  When provider_priority
> is 0, it means to skip automatically resolving the provider.  Provider
> selection is based on a combination of priority and overall "cost" of
> choosing that provider.  apk will prefer the highest priority provider
> with the lowest cost (dependency chain length) that can yield a
> satiable solution.
>
>> Now there is a "testapp" package, which has "testlib-a" in makedepends
>> and links against "libtestlib.so.1". Therefore abuild puts
>> "so:libtestlib.so.1" in the depends of "testapp". What we would like to
>> achieve is, that whenever installing "testapp", it pulls in "testlib-a".
>> But when "testlib-b" is already installed, it uses "testlib-b" instead
>> of "testlib-a".
>
> testlib-b (libdrm) should have provider_priority 1, testlib-a
> (libdrm-grate) should have provider_priority greater than 1.  The
> provides field itself should be left alone.  The key is to set a
> priority on both providers, otherwise APK will treat it as a collision
> and behave as you describe.

For what it's worth, I am open to adding provider_priority=1 to
libdrm.  But it's not my package, so I prefer to hear from ncopa who
maintains it first.  Otherwise, you will need to rebuild the package.

William


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
William Pitcock
Details
Message ID
<CA+T2pCF5JomJy_5hNQKQq+McYe29vCOuQvYM3jtjbyOWYpJy8g@mail.gmail.com>
In-Reply-To
<171bdb07-0c96-7184-e412-99e322c60385@bitmessage.ch> (view parent)
Sender timestamp
1526505126
DKIM signature
missing
Download raw message
Hello,

On Wed, May 16, 2018 at 3:55 PM, Oliver Smith
<ollieparanoid@bitmessage.ch> wrote:
> Thanks for the quick and detailed reply! With the solution you have
> described, one can reliably make one package always get installed
> instead of the other one. I have tried it and it works.
>
> But our use case is slightly different: not all devices need
> libdrm-tegra, so we would like all non-tegra devices to depend on the
> regular libdrm package. (If we add a higher provider_priority to
> libdrm-tegra, then *all* devices will use libdrm-tegra.)

Set the higher priority on libdrm instead.  It is just the inverse use
case, so use the same technique but backwards.

William


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
Oliver Smith
Details
Message ID
<171bdb07-0c96-7184-e412-99e322c60385@bitmessage.ch>
In-Reply-To
<CA+T2pCEdamivZ8J1JL7L2p8abgboP6MBdyDjMbdcOs53c2=nxg@mail.gmail.com> (view parent)
Sender timestamp
1526504100
DKIM signature
missing
Download raw message
Thanks for the quick and detailed reply! With the solution you have
described, one can reliably make one package always get installed
instead of the other one. I have tried it and it works.

But our use case is slightly different: not all devices need
libdrm-tegra, so we would like all non-tegra devices to depend on the
regular libdrm package. (If we add a higher provider_priority to
libdrm-tegra, then *all* devices will use libdrm-tegra.)

Can this be done with apk as well?

Thanks,
Oliver

William Pitcock:
> Hello,
>
> On Tue, May 15, 2018 at 11:08 PM, William Pitcock
> <nenolod@dereferenced.org> wrote:
>> Hello,
>>
>> On Tue, May 15, 2018 at 3:57 PM, Oliver Smith
>> <ollieparanoid@bitmessage.ch> wrote:
>>> Hey folks,
>>>
>>> in Alpine based postmarketOS we have hit the following use case quite a
>>> few times by now, and we're wondering how to solve it properly:
>>> Packaging "testlib-b" as a _optional_ replacement for "testlib-a".
>>>
>>> Both "testlib-a" and "testlib-b" provide the same soname, which means
>>> abuild will automatically make both binary packages provide
>>> "so:libtestlib.so.1".
>>
>> By default this means that both packages will provide
>> so:libtestlib.so.1 with provider_priority 0.  When provider_priority
>> is 0, it means to skip automatically resolving the provider.  Provider
>> selection is based on a combination of priority and overall "cost" of
>> choosing that provider.  apk will prefer the highest priority provider
>> with the lowest cost (dependency chain length) that can yield a
>> satiable solution.
>>
>>> Now there is a "testapp" package, which has "testlib-a" in makedepends
>>> and links against "libtestlib.so.1". Therefore abuild puts
>>> "so:libtestlib.so.1" in the depends of "testapp". What we would like to
>>> achieve is, that whenever installing "testapp", it pulls in "testlib-a".
>>> But when "testlib-b" is already installed, it uses "testlib-b" instead
>>> of "testlib-a".
>>
>> testlib-b (libdrm) should have provider_priority 1, testlib-a
>> (libdrm-grate) should have provider_priority greater than 1.  The
>> provides field itself should be left alone.  The key is to set a
>> priority on both providers, otherwise APK will treat it as a collision
>> and behave as you describe.
>
> For what it's worth, I am open to adding provider_priority=1 to
> libdrm.  But it's not my package, so I prefer to hear from ncopa who
> maintains it first.  Otherwise, you will need to rebuild the package.
>
> William



---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---