hd.setup 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/perl
  2. #
  3. # Copyright (C) 1994 Carl Streeter <streeter@cae.wisc.edu>
  4. #
  5. # this script is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as
  7. # published by the Free Software Foundation; either version 2,
  8. # or (at your option) any later version.
  9. #
  10. # this script is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public
  16. # License along with this script; if not, write to the Free Software
  17. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. print "Is the partition to install from mounted? [Y] ";
  19. $ans = <STDIN>;
  20. if ($ans =~ /^[Nn]/) {
  21. do {
  22. do {
  23. print "Which device should I mount? /dev/";
  24. $drive = <STDIN>;
  25. chop $drive;
  26. $drive =~ tr/[A-Z]/[a-z]/;
  27. } while (! -b "/dev/$drive");
  28. $mpoint = "/mnt";
  29. do {
  30. print "Where should I mount it? (Please use full path) [$mpoint] ";
  31. $newmp = <STDIN>;
  32. chop $newmp;
  33. $mpoint = $newmp if ($newmp !~ /^$/);
  34. } while (($mpoint !~ ?^/?) || (! -d $mpoint));
  35. print "These filesystems are available:";
  36. open(FILESYS, "</proc/filesystems");
  37. $systems = " ";
  38. while (<FILESYS>) {
  39. next if /^nodev/;
  40. chop;
  41. /(\w+)/;
  42. $systems .= "$1 ";
  43. }
  44. print "$systems\n";
  45. do {
  46. print "What filesystem is the partition to mount? [ext2] ";
  47. $filesys = <STDIN>;
  48. chop $filesys;
  49. $filesys = "ext2" if ($filesys =~ /^$/);
  50. $filesys =~ tr/[A-Z]/[a-z]/;
  51. } while ($systems !~ /\s$filesys\s/);
  52. do {
  53. print "Any other options for mount? ";
  54. print "(eg. '-o ro' for cdrom, must start with '-') [] ";
  55. $opts = <STDIN>;
  56. chop $opts;
  57. } while ($opts !~ /^$/ && $opts !~ /^\-/);
  58. $command = "/bin/mount -t $filesys $opts /dev/$drive $mpoint";
  59. print "I will now run \"$command\"\n";
  60. # system("$command");
  61. } while ($?);
  62. } # I never knew how hard I could make it to mount a drive.
  63. # Assumedly, the drive is now mounted
  64. open (STATUS, ">/var/lib/dpkg/methods/hd/hd.status") || die "Can't open hd.status";
  65. do {
  66. print "What is the full path to the 'available' file?\n";
  67. print "This file is found as Packages on the ftp site and CDROM";
  68. print "Use 'none' if you don't have one.";
  69. $avail = <STDIN>;
  70. chop $avail;
  71. } while (! -f $avail || $avail !~ ?^/? || $avail !~ /none/);
  72. do{
  73. print "What is the full path to the base directory ";
  74. print "containing the .deb packages?\n";
  75. $debpath = <STDIN>;
  76. chop $debpath;
  77. } while(! -d $debpath || $debpath !~ ?^/?);
  78. print STATUS "AVAIL: $avail\n";
  79. print STATUS "DEBDIR: $debpath\n";
  80. close (STATUS);
  81. exit (0);