summaryrefslogtreecommitdiffstats
path: root/update-ldetect-lst
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2005-08-24 13:12:46 +0000
committerPascal Rigaux <pixel@mandriva.com>2005-08-24 13:12:46 +0000
commit5ce71ac605a2a9ef6bc3a49d024f6ea9618817e5 (patch)
tree7cd214d4fd775b053934a39a30ef5cd000a3d67c /update-ldetect-lst
parentfdb0c46768a0bd9dcebbe9ab1d68292400369033 (diff)
downloadldetect-lst-5ce71ac605a2a9ef6bc3a49d024f6ea9618817e5.tar
ldetect-lst-5ce71ac605a2a9ef6bc3a49d024f6ea9618817e5.tar.gz
ldetect-lst-5ce71ac605a2a9ef6bc3a49d024f6ea9618817e5.tar.bz2
ldetect-lst-5ce71ac605a2a9ef6bc3a49d024f6ea9618817e5.tar.xz
ldetect-lst-5ce71ac605a2a9ef6bc3a49d024f6ea9618817e5.zip
- handle compressed .lst
- compress the result - use a hard link when possible to win even more room
Diffstat (limited to 'update-ldetect-lst')
-rw-r--r--update-ldetect-lst19
1 files changed, 13 insertions, 6 deletions
diff --git a/update-ldetect-lst b/update-ldetect-lst
index 008b8afc..beabe069 100644
--- a/update-ldetect-lst
+++ b/update-ldetect-lst
@@ -3,17 +3,24 @@
my $dir = '/usr/share/ldetect-lst';
my @files = qw(pcitable usbtable isatable pcmciatable dmitable);
-unlink "$dir/$_" foreach @files;
+unlink("$dir/$_", "$dir/$_.gz") foreach @files;
$ARGV[0] eq '--clean' and exit 0;
foreach (@files) {
my $d = "$dir/$_.d";
-d $d or next;
- my @l = sort glob("$d/*.lst") or next;
- open(my $OUT, " > $dir/$_");
- foreach (@l) {
- open(my $IN, $_) or next;
- print $OUT $_ foreach <$IN>;
+ my @l = sort glob("$d/*.lst");
+ my @l_gz = sort glob("$d/*.lst.gz");
+ @l || @l_gz or next;
+ if (@l == 0 && @l_gz == 1) {
+ link $l_gz[0], "$dir/$_.gz";
+ } else {
+ open(my $OUT, "| gzip -9 > $dir/$_.gz");
+ push @l, map { "gzip -dc $_ |" } @l_gz;
+ foreach (@l) {
+ open(my $IN, $_) or next;
+ print $OUT $_ foreach <$IN>;
+ }
}
}