openSUSE / obs-build

OBS build script, can be used with OBS or stand alone
GNU General Public License v2.0
130 stars 181 forks source link

[mkbaselibs] baselibs.conf `-regex` Directive not functional #1010

Closed e4t closed 1 month ago

e4t commented 1 month ago

(This issue was discussed in bsc#1223967 - for more details check there) mkbaselibs allows to remove libraries from the list of libraries to handle using the -regex expression - of course, it requires that this library has been added prior. This feature is not well documented - at least it is not documented here, therefore it may be rarely used, nontheless the mkbaselibs code shows that it exists. It is useful to remove the default library path (/usr/lib(64)?/) which gets added automatically. Thus expressions like:

 liblapack3
   -/usr/lib(64)?/liblapack.so.3
   requires "update-alternatives"
   postin "ln -sf /etc/alternatives/liblapack.so.3_<targettype> /usr/%_lib/liblapack.so.3"
   postin "/usr/sbin/update-alternatives --force --install /usr/%_lib/liblapack.so.3 liblapack.so.3_<targettype> /usr/%_lib/lapack/liblapack.so.3  50"
   postun "/usr/sbin/update-alternatives --remove liblapack.so.3_<targettype> /usr/%_lib/lapack/liblapack.so.3"

are expected to work. However, the (non-exisitent) default library path /usr/lib64/liblapack.so.3 is still considered - which leads to the error message:

...
> [  221s] + mkdir -p /home/abuild/rpmbuild/BUILDROOT/lapack-3.12.0-94.1.x86_64/usr/lib64/glibc-hwcaps/x86-64-v3
> [  221s] + mv .cfiles/usr/lib64/liblapack.so.3 /home/abuild/rpmbuild/BUILDROOT/lapack-3.12.0-94.1.x86_64/usr/lib64/glibc-hwcaps/x86-64-v3/liblapack.so.3
> [  221s] mv: cannot stat '.cfiles/usr/lib64/liblapack.so.3': No such file or directory
> [  221s] error: Bad exit status from /var/tmp/rpm-tmp.Aiq5Zt (%install)
...

This is because /usr/lib64/liblapack.so.3 is removed from the %files hash, however, not from the %moves hash. I believe, the following change to /usr/lib/build/mkbaselibs would remedy this problem:

      } elsif (substr($r, 0, 1) eq '-') {
        delete $files{$_} for grep {/$rr/} keys %files;
+       delete $moves{$_} for grep {/$rr/} keys %moves;
      } elsif (substr($r, 0, 1) eq '"') {
e4t commented 1 month ago

Example use case can be found in home:eeich:lapack_tst/lapack in OBS.

mlschroe commented 1 month ago

Yes, I think this is correct.

mlschroe commented 1 month ago

(Actually I fixed it a bit different, see the linked commit)

e4t commented 1 month ago

@mlschroe: Thank you!