Skip to content

Commit

Permalink
fix searching for lrm drivers matching linux-image-virtual
Browse files Browse the repository at this point in the history
(LP: #2085962)

Signed-off-by: Kuba Pawlak <[email protected]>
  • Loading branch information
ktpawlak committed Dec 2, 2024
1 parent 67fa72f commit 68f773f
Show file tree
Hide file tree
Showing 2 changed files with 227 additions and 2 deletions.
7 changes: 5 additions & 2 deletions UbuntuDrivers/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -1651,8 +1651,11 @@ def get_linux_modules_metapackage(apt_cache, candidate):
if dep.parent_pkg.name.startswith('linux-modules-nvidia-')]

pick = ''
modules_candidate = 'linux-modules-nvidia-%s-%s' % (candidate_flavour,
get_linux_image(apt_cache).replace('linux-image-', ''))
candidate_suffix = get_linux_image(apt_cache).replace('linux-image-', '')
if candidate_suffix == "virtual":
candidate_suffix = "generic"
modules_candidate = 'linux-modules-nvidia-%s-%s' % (candidate_flavour, candidate_suffix)

for dep in reverse_deps:
if dep == modules_candidate:
pick = dep
Expand Down
222 changes: 222 additions & 0 deletions tests/test_ubuntu_drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3984,6 +3984,228 @@ def test_system_open_driver_packages_chroot5(self):
# Get the linux-modules-nvidia module for the kernel
self.assertEqual(modules_package, 'linux-modules-nvidia-550-server-open-generic-hwe-20.04')

def test_system_virtual_driver_packages_chroot(self):
'''system_gpgpu_driver_packages() handles linux-image-virtual'''

chroot = aptdaemon.test.Chroot()
try:
chroot.setup()
chroot.add_test_repository()
archive = gen_fakearchive()
# older applicable driver which is not the recommended one
archive.create_deb('nvidia-driver-550', dependencies={'Depends': 'xorg-video-abi-4'},
extra_tags={'Modaliases': 'nv(pci:v000010DEd000010C3sv*sd*bc03sc*i*)',
'Support': 'PB'})

archive.create_deb('nvidia-driver-550-open', dependencies={'Depends': 'xorg-video-abi-4'},
extra_tags={'Modaliases': 'nv(pci:v000010DEd000010C3sv*sd*bc03sc*i*)',
'Support': 'PB'})

archive.create_deb('nvidia-driver-550-server', dependencies={'Depends': 'xorg-video-abi-4'},
extra_tags={'Modaliases': 'nv(pci:v000010DEd000010C3sv*sd*bc03sc*i*)',
'Support': 'PB'})

archive.create_deb('nvidia-driver-550-server-open', dependencies={'Depends': 'xorg-video-abi-4'},
extra_tags={'Modaliases': 'nv(pci:v000010DEd000010C3sv*sd*bc03sc*i*)',
'Support': 'PB'})

archive.create_deb('nvidia-driver-560', dependencies={'Depends': 'xorg-video-abi-4'},
extra_tags={'Modaliases': 'nv(pci:v000010DEd000010C3sv*sd*bc03sc*i*)',
'Support': 'NFB'})

archive.create_deb('nvidia-driver-560-open', dependencies={'Depends': 'xorg-video-abi-4'},
extra_tags={'Modaliases': 'nv(pci:v000010DEd000010C3sv*sd*bc03sc*i*)',
'Support': 'NFB'})

archive.create_deb('nvidia-driver-560-server', dependencies={'Depends': 'xorg-video-abi-4'},
extra_tags={'Modaliases': 'nv(pci:v000010DEd000010C3sv*sd*bc03sc*i*)',
'Support': 'NFB'})

archive.create_deb('nvidia-driver-560-server-open', dependencies={'Depends': 'xorg-video-abi-4'},
extra_tags={'Modaliases': 'nv(pci:v000010DEd000010C3sv*sd*bc03sc*i*)',
'Support': 'NFB'})
# driver package which supports multiple ABIs
archive.create_deb('nvidia-headless-no-dkms-550',
dependencies={'Depends': 'xorg-video-abi-3 | xorg-video-abi-4'},
extra_tags={})

archive.create_deb('nvidia-headless-no-dkms-550-open',
dependencies={'Depends': 'xorg-video-abi-3 | xorg-video-abi-4'},
extra_tags={})

archive.create_deb('nvidia-headless-no-dkms-550-server',
dependencies={'Depends': 'xorg-video-abi-3 | xorg-video-abi-4'},
extra_tags={})

archive.create_deb('nvidia-headless-no-dkms-550-server-open',
dependencies={'Depends': 'xorg-video-abi-3 | xorg-video-abi-4'},
extra_tags={})

archive.create_deb('nvidia-dkms-550',
dependencies={'Depends': 'xorg-video-abi-3 | xorg-video-abi-4'},
extra_tags={})

archive.create_deb('nvidia-dkms-550-open',
dependencies={'Depends': 'xorg-video-abi-3 | xorg-video-abi-4'},
extra_tags={})

archive.create_deb('nvidia-dkms-550-server',
dependencies={'Depends': 'xorg-video-abi-3 | xorg-video-abi-4'},
extra_tags={})

archive.create_deb('nvidia-dkms-550-server-open',
dependencies={'Depends': 'xorg-video-abi-3 | xorg-video-abi-4'},
extra_tags={})

archive.create_deb('nvidia-headless-no-dkms-560',
dependencies={'Depends': 'xorg-video-abi-3 | xorg-video-abi-4'},
extra_tags={})

archive.create_deb('nvidia-headless-no-dkms-560-open',
dependencies={'Depends': 'xorg-video-abi-3 | xorg-video-abi-4'},
extra_tags={})

archive.create_deb('nvidia-headless-no-dkms-560-server',
dependencies={'Depends': 'xorg-video-abi-3 | xorg-video-abi-4'},
extra_tags={})

archive.create_deb('nvidia-headless-no-dkms-560-server-open',
dependencies={'Depends': 'xorg-video-abi-3 | xorg-video-abi-4'},
extra_tags={})

archive.create_deb('nvidia-dkms-560',
dependencies={'Depends': 'xorg-video-abi-3 | xorg-video-abi-4'},
extra_tags={})

archive.create_deb('nvidia-dkms-560-open',
dependencies={'Depends': 'xorg-video-abi-3 | xorg-video-abi-4'},
extra_tags={})

archive.create_deb('nvidia-dkms-560-server',
dependencies={'Depends': 'xorg-video-abi-3 | xorg-video-abi-4'},
extra_tags={})

archive.create_deb('nvidia-dkms-560-server-open',
dependencies={'Depends': 'xorg-video-abi-3 | xorg-video-abi-4'},
extra_tags={})

# Linux nvidia modules
archive.create_deb('linux-modules-nvidia-560-generic',
dependencies={'Depends': 'linux-modules-nvidia-560-5.4.0-25-generic'},
extra_tags={})

archive.create_deb('linux-modules-nvidia-560-5.4.0-25-generic',
dependencies={'Depends': 'linux-image-5.4.0-25-generic'},
extra_tags={})

archive.create_deb('linux-modules-nvidia-560-server-5.4.0-25-generic',
dependencies={'Depends': 'linux-image-5.4.0-25-generic'},
extra_tags={})

archive.create_deb('linux-modules-nvidia-560-server-open-5.4.0-25-generic',
dependencies={'Depends': 'linux-image-5.4.0-25-generic'},
extra_tags={})

archive.create_deb('linux-modules-nvidia-550-generic',
dependencies={'Depends': 'linux-modules-nvidia-560-5.4.0-25-generic'},
extra_tags={})

archive.create_deb('linux-modules-nvidia-550-5.4.0-25-generic',
dependencies={'Depends': 'linux-image-5.4.0-25-generic'},
extra_tags={})

archive.create_deb('linux-modules-nvidia-550-server-5.4.0-25-generic',
dependencies={'Depends': 'linux-image-5.4.0-25-generic'},
extra_tags={})

archive.create_deb('linux-modules-nvidia-550-server-open-5.4.0-25-generic',
dependencies={'Depends': 'linux-image-5.4.0-25-generic'},
extra_tags={})

# Linux nvidia modules hwe-20.04 flavours
archive.create_deb('linux-modules-nvidia-550-generic',
dependencies={'Depends': 'linux-modules-nvidia-550-5.4.0-25-generic'},
extra_tags={})

archive.create_deb('linux-modules-nvidia-550-server-generic',
dependencies={'Depends': 'linux-modules-nvidia-550-server-5.4.0-25-generic'},
extra_tags={})

archive.create_deb('linux-modules-nvidia-550-server-open-generic',
dependencies={'Depends': 'linux-modules-nvidia-550-server-open-5.4.0-25-generic'},
extra_tags={})

archive.create_deb('linux-modules-nvidia-560-generic',
dependencies={'Depends': 'linux-modules-nvidia-560-5.4.0-25-generic'},
extra_tags={})

archive.create_deb('linux-modules-nvidia-560-server-generic',
dependencies={'Depends': 'linux-modules-nvidia-560-server-5.4.0-25-generic'},
extra_tags={})

archive.create_deb('linux-modules-nvidia-560-server-open-generic',
dependencies={'Depends': 'linux-modules-nvidia-560-server-open-5.4.0-25-generic'},
extra_tags={})

# Image packages
archive.create_deb('linux-image-5.4.0-25-generic',
extra_tags={'Source': 'linux-signed'})

archive.create_deb('linux-image-5.3.0-29-generic',
extra_tags={'Source': 'linux-signed'})

archive.create_deb('linux-image-5.4.0-24-generic',
extra_tags={'Source': 'linux-signed'})

archive.create_deb('linux-headers-5.4.0-24-generic',
extra_tags={'Source': 'linux-signed'})

archive.create_deb('linux-headers-5.4.0-25-generic',
extra_tags={'Source': 'linux-signed'})

archive.create_deb('linux-image-virtual',
dependencies={'Depends': 'linux-image-5.4.0-25-generic, '
'linux-headers-5.4.0-25-generic'},
extra_tags={'Source': 'linux-meta'})

archive.create_deb('linux-headers-virtual',
dependencies={'Depends': 'linux-headers-5.4.0-25-generic'},
extra_tags={})

chroot.add_repository(archive.path, True, False)
apt_pkg.init_config()
dpkg_status = os.path.abspath(os.path.join(chroot.path, "var", "lib", "dpkg", "status"))
apt_pkg.config.set("Dir::State::status", dpkg_status)
apt_pkg.init_system()
cache = apt_pkg.Cache(None)
depcache = apt_pkg.DepCache(cache)

# Install kernel packages
for pkg in ('linux-image-5.4.0-25-generic',
'linux-image-5.4.0-24-generic',
'linux-image-5.3.0-29-generic',
'linux-headers-5.4.0-24-generic',
'linux-headers-5.4.0-25-generic',
'linux-headers-virtual',
'linux-image-virtual'):
package = cache.__getitem__(pkg)
depcache.mark_install(package)

res = UbuntuDrivers.detect.system_gpgpu_driver_packages(cache,
sys_path=self.umockdev.get_sys_dir())
packages = UbuntuDrivers.detect.auto_install_filter(res, 'nvidia')

modules_package = UbuntuDrivers.detect.get_linux_modules_metapackage(cache,
'nvidia-driver-550-server')
finally:
chroot.remove()

self.assertTrue('nvidia-driver-550-server' in res)

self.assertEqual(set(packages), set(['nvidia-driver-550-server']))
# Get the linux-modules-nvidia module for the kernel
self.assertEqual(modules_package, 'linux-modules-nvidia-550-server-generic')

def test_system_device_specific_metapackages_chroot1(self):
'''system_device_specific_metapackages() for test package repository'''

Expand Down

0 comments on commit 68f773f

Please sign in to comment.