Sharing a script between two "Multi-Arch: foreign" packages

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Sharing a script between two "Multi-Arch: foreign" packages

Jens Reyer-3
Hi all,

is there a way for two different, arch-specific packages (from the same
source package) to share an identical file (script)?


This works for "Multi-Arch: same" packages:

$ dpkg -S /usr/share/doc/libwine/changelog.Debian.gz
libwine:i386, libwine:amd64: /usr/share/doc/libwine/changelog.Debian.gz


But if I try [1] the same for two different packages I end up with only
one package being the owner:

$ dpkg -S /usr/lib/wine/wineserver
wine32:i386: /usr/lib/wine/wineserver


Instead of [fictious output following]:

$ dpkg -S /usr/lib/wine/wineserver
wine32:i386, wine64:amd64: /usr/lib/wine/wineserver



Background:

See #932201.

In src:wine we have two M-A: foreign packages:
 pkg:wine64 (built on some 64-bit architectures)
 pkg:wine32 (built on some 32-bit architectures)

Both build and install a "wineserver" binary, which we install as
/usr/lib/wine/wineserver32 or wineserver64.  We call that binary from a
script [2] /usr/lib/wine/wineserver which currently is in pkg:wine
(arch:all), which is only "recommended" [3] by pkg:wine32 or pkg:wine64.

Since the wineserver{32|64} file is not found by the Wine code, these
filenames are broken without our wineserver script.  So I'd like to move
that script to pkg:wine32 and pkg:wine64.


Thanks and greets
jre


[1] I get both wine32 and wine64 to install with these breaks/replaces:

Package: wine32
Architecture: any-i386 any-powerpc armel armhf
Multi-Arch: foreign
Breaks:
 wine64VERSION (<< ${binary:Version})
Replaces:
 wine64VERSION

Package: wine64
Architecture: amd64 arm64
Multi-Arch: foreign
Breaks:
 wine32VERSION (<< ${binary:Version})
Replaces:
 wine32VERSION

... but then the "shared" wineserver script is only owned by one
package.  Without this unversioned "replaces" dpkg refuses to overwrite
the (identical) script

[2] There are also unrelated reasons for having this script.  Otherwise
I'd dpkg-divert the 32-bit wineserver in favor of the 64-bit one, which
would perfectly match the way Wine works (Wine uses the 32-bit
wineserver only for pure 32-bit installations, but the 64-bit server for
mixed and 64-bit installations).
I could dpkg-divert the script, but that looks like a workaround, not a
solution, to me.


[3] pkg:wine already "depends" on pkg:wine32|wine64, so to avoid a
circular dependency I can't also "depend" the other way round.
The only solution here would be to make a separate arch:all
pkg:wineserver which only has the wineserver script, and let pkg:wine32
and pkg:wine64 "depend" on that.  While this would be a clean solution,
it seems to be excessive to ship only one small wrapper script in a
separate package.

Thanks and greets
jre

Reply | Threaded
Open this post in threaded view
|

Re: Sharing a script between two "Multi-Arch: foreign" packages

wookey-4
On 2019-08-06 16:45 +0200, Jens Reyer wrote:
> Hi all,
>
> is there a way for two different, arch-specific packages (from the same
> source package) to share an identical file (script)?

Only if those two arch-specific packages have the same name -
i.e. they are the 'same' package from dpkg's point of view, just
arch-specific variants of it.

> This works for "Multi-Arch: same" packages:
> $ dpkg -S /usr/share/doc/libwine/changelog.Debian.gz
> libwine:i386, libwine:amd64: /usr/share/doc/libwine/changelog.Debian.gz
>
>
> $ dpkg -S /usr/lib/wine/wineserver
> wine32:i386, wine64:amd64: /usr/lib/wine/wineserver

If I understand correctly you want 'wine32' and 'wine64' (different
packages) to share a file.
 
dpkg has special magic to notice that files in multiarch:same packages
which are in fact identical may be installed over each other without
complaining about clashes, and mark tham as being owned by all the
install arch variants, and not remove them until the last version of
the package is removed.

Otherwise a file is always owned by exactly one package.

So if you could arrange to just have a 'wine' binary that was 32 or 64
as required then you could make this work as you want. Otherwise you
need both those packages to depend on another wine-startup or whatever
that contains the shared file.

(I think - I admit I haven't fully groked the wine package layout)

Wookey
--
Principal hats:  Linaro, Debian, Wookware, ARM
http://wookware.org/

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Sharing a script between two "Multi-Arch: foreign" packages

Sven Joachim
In reply to this post by Jens Reyer-3
On 2019-08-06 16:45 +0200, Jens Reyer wrote:

> Hi all,
>
> is there a way for two different, arch-specific packages (from the same
> source package) to share an identical file (script)?

Yes, provided one of these two packages diverts the other one's file,
see dpkg-divert(1).  This is usually done if the files are different,
but it should work for your case as well.

,----
| $ dpkg -S /usr/bin/perldoc
| diversion by perl-doc from: /usr/bin/perldoc
| diversion by perl-doc to: /usr/bin/perldoc.stub
| perl-doc, perl: /usr/bin/perldoc
`----

Cheers,
       Sven

Reply | Threaded
Open this post in threaded view
|

Re: Sharing a script between two "Multi-Arch: foreign" packages

Jens Reyer-3
In reply to this post by wookey-4
Hi Wookey and Sven,

thanks for your answers!  They helped to stop looking for a non-existing
solution, but find a (nearly) clean one:

(ab)use libwine (M-A:same) for the wineserver wrapper script.


On 06.08.19 17:03, Wookey wrote:

> On 2019-08-06 16:45 +0200, Jens Reyer wrote:
>> Hi all,
>>
>> is there a way for two different, arch-specific packages (from the same
>> source package) to share an identical file (script)?
>
> Only if those two arch-specific packages have the same name -
> i.e. they are the 'same' package from dpkg's point of view, just
> arch-specific variants of it.
>
>> This works for "Multi-Arch: same" packages:
>> $ dpkg -S /usr/share/doc/libwine/changelog.Debian.gz
>> libwine:i386, libwine:amd64: /usr/share/doc/libwine/changelog.Debian.gz
>>
>>
>> $ dpkg -S /usr/lib/wine/wineserver
>> wine32:i386, wine64:amd64: /usr/lib/wine/wineserver
>
> If I understand correctly you want 'wine32' and 'wine64' (different
> packages) to share a file.

Yes.


> dpkg has special magic to notice that files in multiarch:same packages
> which are in fact identical may be installed over each other without
> complaining about clashes, and mark tham as being owned by all the
> install arch variants, and not remove them until the last version of
> the package is removed.
>
> Otherwise a file is always owned by exactly one package.
>
> So if you could arrange to just have a 'wine' binary that was 32 or 64
> as required then you could make this work as you want. Otherwise you
> need both those packages to depend on another wine-startup or whatever
> that contains the shared file.

Instead of adding this new package "wineserver", I'm (ab)using libwine
now (which is "M-A: same" and depended on by wine32 and wine64 which
have the binary).

The only drawback is that libwine now ships a wrapper script for
binaries, which are in packages that libwine doesn't depend on.  I don't
expect this to be an issue in practice, but still added a clear error
message for that case.


> (I think - I admit I haven't fully groked the wine package layout)

Yeah, we're special ;)
I'd be happy to explain this in more depth, just tell me.

Greets and thanks again
jre