Comment 0 for bug 1853977

Hello,

When installing `nvidia-340` there is an error is the postinst script:

philippe@pv-desktop:~$ sudo apt install --reinstall nvidia-340
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 to upgrade, 0 to newly install, 1 reinstalled, 0 to remove and 7 not to upgrade.
Need to get 0 B/51.9 MB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 309892 files and directories currently installed.)
Preparing to unpack .../nvidia-340_340.107-0ubuntu0.18.04.4_amd64.deb ...
Stopping nvidia-persistenced
nvidia-persistenced: no process found
Done.
Removing all DKMS Modules
Done.
Stopping previous nvidia-persistenced
nvidia-persistenced: no process found
Done.
diversion of /usr/lib/x86_64-linux-gnu/libGL.so.1 to /usr/lib/x86_64-linux-gnu/libGL.so.1.distrib by nvidia-340
diversion of /usr/lib/i386-linux-gnu/libGL.so.1 to /usr/lib/i386-linux-gnu/libGL.so.1.distrib by nvidia-340
diversion of /usr/lib/x86_64-linux-gnu/libGL.so to /usr/lib/x86_64-linux-gnu/libGL.so.distrib by nvidia-340
diversion of /usr/lib/i386-linux-gnu/libGL.so to /usr/lib/i386-linux-gnu/libGL.so.distrib by nvidia-340
diversion of /usr/lib/x86_64-linux-gnu/libEGL.so.1 to /usr/lib/x86_64-linux-gnu/libEGL.so.1.distrib by nvidia-340
diversion of /usr/lib/i386-linux-gnu/libEGL.so.1 to /usr/lib/i386-linux-gnu/libEGL.so.1.distrib by nvidia-340
diversion of /usr/lib/x86_64-linux-gnu/libEGL.so to /usr/lib/x86_64-linux-gnu/libEGL.so.distrib by nvidia-340
diversion of /usr/lib/i386-linux-gnu/libEGL.so to /usr/lib/i386-linux-gnu/libEGL.so.distrib by nvidia-340
diversion of /usr/lib/x86_64-linux-gnu/libGLESv2.so to /usr/lib/x86_64-linux-gnu/libGLESv2.so.distrib by nvidia-340
diversion of /usr/lib/i386-linux-gnu/libGLESv2.so to /usr/lib/i386-linux-gnu/libGLESv2.so.distrib by nvidia-340
diversion of /usr/lib/x86_64-linux-gnu/libGLESv2.so.2 to /usr/lib/x86_64-linux-gnu/libGLESv2.so.2.distrib by nvidia-340
diversion of /usr/lib/i386-linux-gnu/libGLESv2.so.2 to /usr/lib/i386-linux-gnu/libGLESv2.so.2.distrib by nvidia-340
diversion of /usr/lib/x86_64-linux-gnu/libGLESv1_CM.so to /usr/lib/x86_64-linux-gnu/libGLESv1_CM.so.distrib by nvidia-340
diversion of /usr/lib/i386-linux-gnu/libGLESv1_CM.so to /usr/lib/i386-linux-gnu/libGLESv1_CM.so.distrib by nvidia-340
diversion of /usr/lib/x86_64-linux-gnu/libGLESv1_CM.so.1 to /usr/lib/x86_64-linux-gnu/libGLESv1_CM.so.1.distrib by nvidia-340
diversion of /usr/lib/i386-linux-gnu/libGLESv1_CM.so.1 to /usr/lib/i386-linux-gnu/libGLESv1_CM.so.1.distrib by nvidia-340
Unpacking nvidia-340 (340.107-0ubuntu0.18.04.4) over (340.107-0ubuntu0.18.04.4) ...
Setting up nvidia-340 (340.107-0ubuntu0.18.04.4) ...
dpkg: error: version '-' has bad syntax: revision number is empty
dpkg: error: version '-' has bad syntax: revision number is empty
update-initramfs: deferring update (trigger activated)
INFO:Enable nvidia-340
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/lenovo_thinkpad
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/dell_latitude
Loading new nvidia-340-340.107 DKMS files...
Building for 4.15.0-70-generic
Building for architecture x86_64
Building initial module for 4.15.0-70-generic
Done.

The comment at https://askubuntu.com/questions/969352/uninstalling-and-then-reinstalling-nvidia-384-kills-colord tells us that /var/lib/dpkg/info/nvidia-340.postinst has a typo: replace $KERNELS with $CURRENT_KERNEL `dpkg-reconfigure nvidia-384` works as expected.