disk.install 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #!/bin/sh
  2. set -e
  3. vardir="$1"
  4. method=$2
  5. option=$3
  6. cd "$vardir/methods/disk"
  7. . ./shvar.$option
  8. xit=1
  9. trap '
  10. if [ -n "$umount" ]
  11. then
  12. umount "$umount" >/dev/null 2>&1
  13. fi
  14. exit $xit
  15. ' 0
  16. if [ -n "$p_blockdev" ]
  17. then
  18. umount="$p_mountpoint"
  19. mount -rt "$p_fstype" -o nosuid,nodev "$p_blockdev" "$p_mountpoint"
  20. fi
  21. if [ -n "$p_nfs" ]
  22. then
  23. umount="$p_mountpoint"
  24. mount -rt nfs "$p_nfs" -o nosuid,nodev "$p_mountpoint"
  25. fi
  26. case "$p_mountpoint" in
  27. */ ) binaryprefix="$p_mountpoint" ;;
  28. '' ) binaryprefix="" ;;
  29. * ) binaryprefix="$p_mountpoint/" ;;
  30. esac
  31. predep="$vardir/predep-package"
  32. while true
  33. do
  34. set +e
  35. dpkg --predep-package >"$predep"
  36. rc=$?
  37. set -e
  38. if test $rc = 1; then break; fi
  39. test $rc = 0
  40. perl -e '
  41. ($binaryprefix,$predep) = @ARGV;
  42. $binaryprefix =~ s,/*$,/, if length($binaryprefix);
  43. open(P,"< $predep") || die "cannot open $predep: $!\n";
  44. while (<P>) {
  45. s/\s*\n$//;
  46. $package= $_ if s/^Package: //i;
  47. @filename= split(/ /,$_) if s/^Filename: //i;
  48. @msdosfilename= split(/ /,$_) if s/^MSDOS-Filename: //i;
  49. }
  50. length($package) || die "internal error - no package";
  51. @filename || die "internal error - no filename";
  52. @filename==@msdosfilename || !@filename || !@msdosfilename ||
  53. die "internal error - mismatch >@filename< >@msdosfilename<";
  54. @invoke=(); $|=1;
  55. for ($i=0; $i<=$#filename; $i++) {
  56. $ppart= $i+1;
  57. print "Looking for part $ppart of $package ... ";
  58. if (-f "$binaryprefix$filename[$i]") {
  59. $print= $filename[$i];
  60. $invoke= "$binaryprefix$filename[$i]";
  61. } elsif (-f "$binaryprefix$msdosfilename[$i]") {
  62. $print= $msdosfilename[$i];
  63. $invoke= "$binaryprefix$msdosfilename[$i]";
  64. } else {
  65. $base= $filename[$i]; $base =~ s,.*/,,;
  66. $msdosbase= $msdosfilename[$i]; $msdosbase =~ s,.*/,,;
  67. defined($c= open(X,"-|")) ||
  68. die "failed to fork for find: $!\n";
  69. if (!$c) {
  70. exec("find", length($binaryprefix)
  71. ? $binaryprefix : ".","-follow",
  72. "-name",$base,"-o","-name",$msdosbase);
  73. die "failed to exec find: $!\n";
  74. }
  75. while (chop($invoke= <X>)) { last if -f $invoke; }
  76. $print= $invoke;
  77. if (substr($print,0,length($binaryprefix)+1) eq
  78. "$binaryprefix/") {
  79. $print= substr($print,length($binaryprefix));
  80. }
  81. }
  82. if (!length($invoke)) {
  83. print STDERR "
  84. Oh dear, I need to install or upgrade $package, but I don'\''t see
  85. the appropriate file(s) anywhere. I'\''m expecting version $version or
  86. later, as that is listed in the Packages file.
  87. Perhaps you downloaded it with an unexpected name, or something.
  88. In any case, you must find the file(s) and then either place it with
  89. the correct filename(s) (as listed in the Packages file or in
  90. /var/lib/dpkg/available) and rerun the installation, or upgrade the
  91. package by using `dpkg --install --auto-deconfigure'\'' by hand.
  92. ";
  93. exit(1);
  94. }
  95. print "$print\n";
  96. push(@invoke,$invoke);
  97. }
  98. print "Running dpkg -iB for $package ...\n";
  99. exec("dpkg","-iB","--",@invoke);
  100. die "failed to exec dpkg: $!\n";
  101. ' -- "$binaryprefix$p_main_binary" "$predep"
  102. done
  103. for f in main ctb nf lcl
  104. do
  105. eval 'this_binary=$p_'$f'_binary'
  106. if [ -z "$this_binary" ]; then continue; fi
  107. echo Running dpkg -iGROEB "$binaryprefix$this_binary"
  108. dpkg -iGROEB "$binaryprefix$this_binary"
  109. done
  110. echo -n 'Installation OK. Hit RETURN. '
  111. read response
  112. xit=0