openmamba-release/install-virtual.lua

45 lines
1.3 KiB
Lua
Raw Permalink Normal View History

2015-02-15 15:36:26 +01:00
-- This script will perform custom selections when a virtual package
-- is required
--
-- Author: Silvan Calarco <silvan.calarco@mambasoft.it> Copyright (c) 2005-2009
--
-- Allow someone to disable this without removing the script.
if confget("APT::Get::install-virtual/b", "true") == "false" then
return
end
selectnames = { "kernel-mamba-wireless", "kernel-mamba-sound-backport" }
knames = { "mamba" }
-- get kernel package name for running kernel (kernel-smp, kernel, etc)
function get_kerneltype()
return string.gsub(posix.uname("%r"), "[%d.]*(.*)", "%1")
end
-- get kernel package prefix name
function get_kernelname()
return "kernel";
end
kernel_suffix = get_kerneltype()
kernel_prefix = get_kernelname()
for i, pkg in pairs(packagenames) do
-- select correct kernel package
-- the choiche is for the shortest match so for instance if kernel_suffix is mamba
-- the mamba package is preferred over mamba-64GB
if (string.find(pkg,kernel_prefix.."-") == 1) then
if not (kernel_suffix == "") and (string.find(pkg,kernel_suffix)) then
if (not selected) then
selected=pkgfind(pkg)
else
if (string.len(pkg) < string.len(tostring(selected))) then
selected=pkgfind(pkg)
end
end
end
end
end
return