Nvidia GL libs access broken on Ubuntu 18.04

I’ve updated the PR with more elaborate detection. Nvidia drivers package in xenial (actually all versions before bionic) have both /usr/lib/<arch-triplet>, but the libraries are under /usr/lib/nvidia. Then in bionic, all libraries are under /usr/lib/<arch-triplet>.

The way things work now:

  • during configure time, pass --with-host-arch-triplet=x86_64-gnu-linux (optionally --with-host-arch-32bit-triplet=i386-gnu-linux) - this is picked up automatically in debian/rules and autogen.sh
  • use a well known nvidia library as a canary, in this case it’s libnvidia-glcore.so.<driver-major>.<driver-minor>, eg. libnvidia-glcore.so.390.42 in my system, 390.42 is the driver package version
  • at runtime
    • grab the current driver version by poking /sys (we had this code before)
    • check if /usr/lib/<arch-triplet>/libnvidia-glcore.so.%d.%d exists, if so symlink all the files like we do in biarch case
      • additionally check if /usr/lib/<arch-32bit-triplet>/libnvidia-glcore... exists, if so also symlink it at the proper location
    • when symlinking prefix path is preserved, eg.
      /usr/lib/<arch-triplet>/libnvidia-tls.so..  -> /var/lib/snapd/lib/gl/<arch-triplet>/libnvidia-tls.so..`
      /usr/lib/<arch-triplet>/tls/libnvidia-tls.so..  -> /var/lib/snapd/lib/gl/<arch-triplet>/tls/libnvidia-tls.so..
      
    • if the canary lib does not exist, falls back to bind mounting /usr/lib/nvidia-<driver-major> as we did before
  • apparmor profile was updated to allow snap-confine do create the prefix path as needed
  • opengl interface was updated to allow access to /var/lib/snapd/lib/gl/<arch-triplet>/tlslibnvidia-tls.so.., as this was causing unexplained segfaults that were debugged in the other nvidia thread already

Ohmygiraffe works with nvidia and confinement now.