agama/live/root/tmp/fw_cleanup.rb
Ladislav Slezák d4f44b8a8e
Add Live ISO sources to Git (#1160)
## Problem

The Live ISO sources are not maintained at GitHub, that makes the
development complicated:

- Cannot track the changes easily, working with history in OBS is
limited and more complicated than with Git
- Changing files in tarballs is difficult, you have to unpack it, modify
a file and then manually compress back with correct parameters
- Building the Live ISO locally is not trivial

## Solution

- Move the sources into the `/live` subdirectory
- Add GitHub action for automatic submission from `master` to the
[systemsmanagement:Agama:Staging](https://build.opensuse.org/project/show/systemsmanagement:Agama:Staging)
OBS project
- Allow running the ISO build locally via `make build`

## Changes

The individual files were not touched, I just copied them from the
current OBS project. I only moved the `fw_cleanup.rb` script to the
`/tmp` directory as the script is temporary and it is deleted at the end
of the ISO build.

- All Kiwi tarballs were unpacked to Git
- Simple `make` builds the sources to the `dist` subdirectory and builds
the tarballs
- The ISO can be built locally using `make build`
- Updated/extended the documentation in README.md (There are two
README.md files, the main in `/live` which documents the details and the
`/live/src/README.md` which is copied to OBS. Mostl importantly it says
"do not touch this in OBS, use GitHub".)

## Testing

- Tested manually
- The autosubmission works (see the [GitHub action
log](https://github.com/lslezak/agama/actions/runs/8780447151/job/24090382501))
- The built ISO works (tested in my [agama-live
branch](https://build.opensuse.org/package/show/home:lslezak:branches:systemsmanagement:Agama:Staging/agama-live)
project)
- Local build works as well

---------

Co-authored-by: Imobach González Sosa <igonzalezsosa@suse.com>
2024-04-23 10:03:43 +02:00

43 lines
1.1 KiB
Ruby
Executable file

#! /usr/bin/env ruby
# This script removes unused firmware files (not referenced by any kernel
# driver) from the system. By default the script runs in safe mode and only
# lists the unused firmware file, use the "--delete" argument to delete the
# found files.
require "find"
require "shellwords"
fw_dir = "/lib/firmware/"
dir = Dir["/lib/modules/*"].first
puts "Scanning kernel modules in #{dir}..."
# list of referenced firmware names from the kernel modules
fw = []
Find.find(dir) do |path|
if File.file?(path) && path.end_with?(".ko", ".ko.xz", ".ko.zst")
fw += `/usr/sbin/modinfo -F firmware #{path.shellescape}`.split("\n")
end
end
unused_size = 0
Find.find(fw_dir) do |fw_path|
next unless File.file?(fw_path)
fw_name = fw_path.delete_prefix(fw_dir).delete_suffix(".xz").delete_suffix(".zstd")
if !fw.include?(fw_name)
unused_size += File.size(fw_path)
if (ARGV[0] == "--delete")
puts "Deleting firmware file #{fw_path}"
File.delete(fw_path)
else
puts "Found unused firmware #{fw_path}"
end
end
end
puts "Unused firmware size: #{unused_size} (#{unused_size/1024/1024} MiB)"