-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into users_mandatory_step
- Loading branch information
Showing
69 changed files
with
21,402 additions
and
57,845 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#! /usr/bin/env ruby | ||
|
||
# This script removes not needed multimedia drivers (sound cards, TV cards,...). | ||
# | ||
# By default the script runs in safe mode and only lists the drivers to delete, | ||
# use the "--delete" argument to really delete the drivers. | ||
|
||
require "find" | ||
require "shellwords" | ||
|
||
# class holding the kernel driver data | ||
class Driver | ||
# the driver name, full file path, dependencies | ||
attr_reader :name, :path, :deps | ||
|
||
def initialize(name, path, deps) | ||
@name = name | ||
@path = path | ||
@deps = deps | ||
end | ||
|
||
# load the kernel driver data from the given path recursively | ||
def self.find(dir) | ||
drivers = [] | ||
puts "Scanning kernel modules in #{dir}..." | ||
|
||
return drivers unless File.directory?(dir) | ||
|
||
Find.find(dir) do |path| | ||
if File.file?(path) && path.end_with?(".ko", ".ko.xz", ".ko.zst") | ||
name = File.basename(path).sub(/\.ko(\.xz|\.zst|)\z/, "") | ||
deps = `/usr/sbin/modinfo -F depends #{path.shellescape}`.chomp.split(",") | ||
drivers << Driver.new(name, path, deps) | ||
end | ||
end | ||
|
||
return drivers | ||
end | ||
end | ||
|
||
# delete the kernel drivers in these subdirectories, but keep the drivers used by | ||
# dependencies from other drivers | ||
delete = [ | ||
"kernel/sound", | ||
"kernel/drivers/media", | ||
"kernel/drivers/staging/media" | ||
] | ||
|
||
# in the Live ISO there should be just one kernel installed | ||
dir = Dir["/lib/modules/*"].first | ||
|
||
# drivers to delete | ||
delete_drivers = [] | ||
|
||
# scan the drivers in the delete subdirectories | ||
delete.each do |d| | ||
delete_drivers += Driver.find(File.join(dir, d)) | ||
end | ||
|
||
all_drivers = Driver.find(dir) | ||
|
||
# remove the possibly deleted drivers | ||
all_drivers.reject!{|a| delete_drivers.any?{|d| d.name == a.name}} | ||
|
||
puts "Skipping dependent drivers:" | ||
|
||
# iteratively find the dependant drivers (dependencies of dependencies...) | ||
loop do | ||
referenced = delete_drivers.select do |dd| | ||
all_drivers.any?{|ad| ad.deps.include?(dd.name)} | ||
end | ||
|
||
# no more new dependencies, end of the dependency chain reached | ||
break if referenced.empty? | ||
|
||
puts referenced.map(&:path).sort.join("\n") | ||
|
||
# move the referenced drivers from the "delete" list to the "keep" list | ||
all_drivers += referenced | ||
delete_drivers.reject!{|a| referenced.any?{|d| d.name == a.name}} | ||
end | ||
|
||
puts "Drivers to delete:" | ||
delete = ARGV[0] == "--delete" | ||
|
||
delete_drivers.each do |d| | ||
if (delete) | ||
puts "Deleting #{d.path}" | ||
File.delete(d.path) | ||
else | ||
puts d.path | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
------------------------------------------------------------------- | ||
Thu Nov 28 08:58:21 UTC 2024 - Ladislav Slezák <[email protected]> | ||
|
||
- Less aggressive kernel driver cleanup, keep the multimedia | ||
drivers which are needed as dependencies of other drivers | ||
(usually graphic card drivers) (gh#agama-project/agama#1665) | ||
|
||
------------------------------------------------------------------- | ||
Wed Nov 13 12:20:23 UTC 2024 - Lubos Kocman <[email protected]> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.