summaryrefslogtreecommitdiff
path: root/v4l/scripts
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2007-08-23 22:07:31 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-08-23 22:07:31 -0300
commitc36e2573dade4145df824183887237dabfcde9f9 (patch)
tree502536406d070835ded5ac98c7a4f7fbf4468811 /v4l/scripts
parentc3220ca3a955b5791845c822fabf476e987445ab (diff)
downloadmediapointer-dvb-s2-c36e2573dade4145df824183887237dabfcde9f9.tar.gz
mediapointer-dvb-s2-c36e2573dade4145df824183887237dabfcde9f9.tar.bz2
Add capability to remove obsolete drivers with make rmmod
From: Mauro Carvalho Chehab <mchehab@infradead.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'v4l/scripts')
-rwxr-xr-xv4l/scripts/make_makefile.pl54
-rwxr-xr-xv4l/scripts/rmmod.pl44
2 files changed, 97 insertions, 1 deletions
diff --git a/v4l/scripts/make_makefile.pl b/v4l/scripts/make_makefile.pl
index 8a31c025c..709546fca 100755
--- a/v4l/scripts/make_makefile.pl
+++ b/v4l/scripts/make_makefile.pl
@@ -124,6 +124,53 @@ sub open_makefile($) {
close $in;
}
+my $obsolete;
+sub getobsolete()
+{
+ open OBSOLETE, "<obsolete.txt";
+ while (<OBSOLETE>) {
+ if (m/^\s*\#/) {
+ next;
+ }
+ s/\s*\#.*$//;
+ s/\n$//;
+
+ my $idir=$_;
+
+ if (!$idir) {
+ next;
+ }
+ my $file=$_;
+
+ $idir=~ s|(^.*)/[^/]+|\1|;
+ $file=~ s|^.*/||;
+ $file.=".ko";
+
+ $obsolete{$idir}{$file} = 1;
+ }
+
+ close OBSOLETE;
+}
+
+sub removeobsolete()
+{
+ while ( my ($dir, $files) = each(%obsolete) ) {
+ print OUT "\t\@echo -e \"\\nRemoving obsolete files at \$(KDIR26)/$dir:\"\n";
+ print OUT "\t\@files='", join(' ', keys %$files), "'; ";
+
+ print OUT "for i in \$\$files;do if [ -e \$(DESTDIR)\$(KDIR26)/$dir/\$\$i ]; then ";
+ print OUT "echo -n \"\$\$i \";";
+ print OUT " rm \$(DESTDIR)\$(KDIR26)/$dir/\$\$i; fi; done; ";
+
+ print OUT "for i in \$\$files;do if [ -e \$(DESTDIR)\$(KDIR26)/$dir/\$\$i.gz ]; then ";
+ print OUT "echo -n \"\$\$i.gz \";";
+ print OUT " rm \$(DESTDIR)\$(KDIR26)/$dir/\$\$i.gz; fi; done; echo;\n\n";
+ }
+}
+
+
+getobsolete();
+
open OUT, '>Makefile.media' or die 'Unable to write Makefile.media';
open_makefile('../linux/drivers/media/Makefile');
@@ -131,6 +178,9 @@ open_makefile('../linux/drivers/media/Makefile');
print OUT "media-install::\n";
print OUT "\t\@echo \"Stripping debug info from files\"\n";
print OUT "\t\@strip --strip-debug \$(inst-m)\n\n";
+
+removeobsolete();
+
print OUT "\t\@echo \"Installing kernel modules under \$(DESTDIR)\$(KDIR26)/:\"\n";
while (my ($dir, $files) = each %instdir) {
@@ -150,8 +200,10 @@ print OUT "\t/sbin/depmod -a \$(KERNELRELEASE) \$(if \$(DESTDIR),-b \$(DESTDIR))
# Creating Remove rule
print OUT "media-rminstall::\n";
-print OUT "\t\@echo -e \"\\nRemoving old \$(DEST) files\\n\"\n";
+removeobsolete();
+
+print OUT "\t\@echo -e \"\\nRemoving old \$(DEST) files\\n\"\n";
while ( my ($dir, $files) = each(%instdir) ) {
print OUT "\t\@echo -e \"\\nRemoving old \$(KDIR26)/$dir files:\"\n";
print OUT "\t\@files='", join(' ', keys %$files), "'; ";
diff --git a/v4l/scripts/rmmod.pl b/v4l/scripts/rmmod.pl
index d190a9edf..48bc7ac1f 100755
--- a/v4l/scripts/rmmod.pl
+++ b/v4l/scripts/rmmod.pl
@@ -27,6 +27,25 @@ my %debug = ( "tuner" => "tuner_debug=1",
"dvb-usb-dibusb-common" => "debug=0x03",
);
+my @obsolete;
+sub getobsolete()
+{
+ open OBSOLETE, "<obsolete.txt";
+ while (<OBSOLETE>) {
+ if (m/^\s*\#/) {
+ next;
+ }
+ s/\s*\#.*$//;
+ s/\n$//;
+ s|^.*/||;
+ if (!$_) {
+ next;
+ }
+ push @obsolete,$_;
+ }
+
+ close OBSOLETE;
+}
sub findprog($)
{
@@ -155,6 +174,7 @@ sub insmod ($)
sub rmmod ()
{
+ getobsolete();
my $rmmod = findprog('rmmod');
while (my $key=pop @modlist) {
my $dep=$key;
@@ -166,6 +186,25 @@ sub rmmod ()
}
}
+sub rm_obsolete ()
+{
+ getobsolete();
+ my @obsolete2;
+
+ my $rmmod = findprog('rmmod');
+ while (my $key=pop @obsolete) {
+ my $dep=$key;
+ $dep=~s/[\-]/_/g;
+ if (exists ($loaded{$dep})) {
+ print "$rmmod $dep\n";
+ if (system "$rmmod $dep\n") {
+ push @obsolete2,$key;
+ }
+ }
+ }
+ @obsolete=@obsolete2;
+}
+
sub prepare_cmd()
{
find(\&parse_dir, ".");
@@ -185,6 +224,11 @@ if ($mode eq "load") {
prepare_cmd;
parse_loaded;
rmmod;
+ if (length(@obsolete)) {
+ rm_obsolete;
+ rmmod;
+ rm_obsolete;
+ }
} elsif ($mode eq "reload") {
prepare_cmd;
parse_loaded;