install 3.2 KB

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