#!/usr/bin/perl -w # original script by Jacob Meuser # You are free to use this as you please # This code comes with ABSOLUTELY NO WARRANTY # USE AT YOUR OWN RISK # To use: Get patch-2.2.15pre14-ppscsi1.gz from ftp://people.redhat.com/twaugh/parport/. # Gunzip the patch. (gunzip patch-2.2.15pre14-ppscsi1.gz) # Become root. (su root) # Put the patch in /usr/src. (cp patch-2.2.15pre14-ppscsi1 /usr/src/) # Run this script. (./patch_ppscsi.pl) # This was wdeveloped under perl-5.6.0 on a i686 running Debian linux # NOTE: This script will fail if you don't have "linux" in the name of your source tree use strict; print qq (\nppSCSI patch program\n\n); chdir "/usr/src"; if (-d "linux") { if (!(-l "linux")) { print qq (It is recomended that your linux kernel source be in a directory other than "linux", and that a symlink named "linux" points to your source\n); my $yorn = "q"; while (($yorn ne "y") and ($yorn ne "n")) { print qq (\nWould you like me to do this? [yn] ); $yorn = ; chomp $yorn; } if ($yorn eq "y") { print qq (What would you like "linux" to be renamed as? ); my $new_name = ; chomp $new_name; rename "linux", "$new_name"; symlink "$new_name", "linux"; } } } opendir (SRCDIR, ".") or die "Could not open /usr/src: $!\n"; my @linux = grep (/linux/, readdir SRCDIR); closedir SRCDIR; print qq (Num\tDirectory\n); print qq (--------------------\n); my @linux_dirs; my $count = 0; foreach (@linux) { next if (-l); if (-d) { push @linux_dirs, $_; print qq ($count\t$_\n); $count++; } } my $high = $count - 1; die "\nCould not find linux source tree, sorry!\n"if ($high < 0); my $tree = -1; while (($tree < 0) or ($tree > $high)) { print qq (\nWhat number corresponds to the linux source tree to patch? [0-$high] ); $tree = ; chomp $tree; } my $new = $linux_dirs[$tree]; if (-l "linux") { my $link = readlink "linux"; if ($link ne "$new") { print qq (The "linux" symlink does not appear to point at $new. It needs to.\n); print qq (Changing symlink.\n); unlink "linux"; symlink "$new", "linux"; } } else { print qq (You need a symlink.\n); symlink "$new", "linux"; print qq (Made symlink\n); } my $patch_file = "patch-2.2.15pre14-ppscsi1"; open (PATCH, "$patch_file") or die "Could not open $patch_file: $!\n"; my @lines = ; close (PATCH); my $new_patch = "ppSCSI_patch_ppscsi"; open (NEWPATCH, ">$new_patch") or die "Could not could not open $new_patch for writing: $!\n"; foreach (@lines) { s/linux-2.2.15pre14/$new/; print NEWPATCH; } print qq (Beginning patch ... \n); system ("patch -p0 < $new_patch"); print qq (Done!\n); exit (0);