mirror of
https://git.proxmox.com/git/pve-firmware
synced 2025-04-29 04:06:16 +00:00
assemble: actively cleanup unreferenced FW files
we use the linux-firmware.git copy script instead of our logic to copy and generate links for FW files. While its allows for a more complete result with less maintenance required it also results in copying over to much (i.e., FW our kernels do not know off). So cleanup actively at the end - its not pretty but gets the job done. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
fbfa5f47ce
commit
c3fe809a7f
1
Makefile
1
Makefile
@ -25,6 +25,7 @@ fwdata: linux-firmware.git/WHENCE dvb-firmware.git/README fw.list
|
||||
mkdir -p fwdata.tmp/lib/firmware
|
||||
cd linux-firmware.git; ./copy-firmware.sh -v ../fwdata.tmp/lib/firmware/
|
||||
./assemble-firmware.pl fw.list fwdata.tmp/lib/firmware
|
||||
find fwdata.tmp/lib/firmware -empty -type d -delete
|
||||
install -d fwdata.tmp/usr/share/doc/pve-firmware
|
||||
cp linux-firmware.git/WHENCE fwdata.tmp/usr/share/doc/pve-firmware/README
|
||||
install -d fwdata.tmp/usr/share/doc/pve-firmware/licenses
|
||||
|
@ -301,6 +301,7 @@ sub copy_fw {
|
||||
}
|
||||
|
||||
my $fwdone = {};
|
||||
my $fwbase_name = {};
|
||||
|
||||
my $error = 0;
|
||||
|
||||
@ -309,6 +310,9 @@ while(defined(my $line = <$fd>)) {
|
||||
chomp $line;
|
||||
my ($fw, $mod) = split(/\s+/, $line, 2);
|
||||
|
||||
my $fw_name = basename($fw);
|
||||
$fwbase_name->{$fw_name} = 1;
|
||||
|
||||
next if $mod =~ m|^kernel/sound|;
|
||||
next if $mod =~ m|^kernel/drivers/isdn|;
|
||||
|
||||
@ -400,4 +404,41 @@ while(defined(my $line = <$fd>)) {
|
||||
}
|
||||
close($fd);
|
||||
|
||||
exit($error);
|
||||
exit($error) if $error;
|
||||
|
||||
my $target_fw_string = `find '$target' -type f -o -type l`;
|
||||
chomp $target_fw_string;
|
||||
exit(-1) if !$target_fw_string;
|
||||
|
||||
my $all_fw_files = [ split("\n", $target_fw_string) ];
|
||||
|
||||
my ($keep, $delete) = (0, 0);
|
||||
|
||||
my $link_target = {};
|
||||
for my $f (@$all_fw_files) {
|
||||
next if ! -l $f;
|
||||
my $link = basename($f);
|
||||
my $file = readlink($f);
|
||||
my $target = basename($file);
|
||||
$link_target->{$target} = 1 if $fwbase_name->{$link};
|
||||
$link_target->{$file} = 1 if $fwbase_name->{$link};
|
||||
}
|
||||
|
||||
for my $f (@$all_fw_files) {
|
||||
my $name = basename($f);
|
||||
|
||||
if ($fwbase_name->{$name}) {
|
||||
$keep++;
|
||||
} elsif ($link_target->{$name}) {
|
||||
#print "skip link target '$f'\n";
|
||||
$keep++;
|
||||
} else {
|
||||
print "delete unreferenced $f\n";
|
||||
unlink $f or warn "ERROR deleting '$f' - $!\n";
|
||||
$delete++;
|
||||
}
|
||||
}
|
||||
|
||||
print "cleanup end result: keep: $keep, delete: $delete\n";
|
||||
|
||||
exit(0);
|
||||
|
Loading…
Reference in New Issue
Block a user