install 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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", length($binaryprefix)
  66. ? $binaryprefix : ".","-follow",
  67. "-name",$base,"-o","-name",$msdosbase);
  68. die "failed to exec find: $!\n";
  69. }
  70. while (chop($invoke= <X>)) { last if -f $invoke; }
  71. $print= $invoke;
  72. if (substr($print,0,length($binaryprefix)+1) eq
  73. "$binaryprefix/") {
  74. $print= substr($print,length($binaryprefix));
  75. }
  76. }
  77. if (!length($invoke)) {
  78. print STDERR "
  79. Oh dear, I need to install or upgrade $package, but I don'\''t see
  80. the appropriate file(s) anywhere. I'\''m expecting version $version or
  81. later, as that is listed in the Packages file.
  82. Perhaps you downloaded it with an unexpected name, or something.
  83. In any case, you must find the file(s) and then either place it with
  84. the correct filename(s) (as listed in the Packages file or in
  85. $vardir/available) and rerun the installation, or upgrade the
  86. package by using `dpkg --install --auto-deconfigure'\'' by hand.
  87. ";
  88. exit(1);
  89. }
  90. print "$print\n";
  91. push(@invoke,$invoke);
  92. }
  93. print "Running dpkg -iB for $package ...\n";
  94. exec("dpkg","--admindir",$vardir,"-iB","--",@invoke);
  95. die "failed to exec dpkg: $!\n";
  96. ' -- "$p_mountpoint$p_main_binary" "$predep"
  97. done
  98. for f in main ctb nf nus lcl
  99. do
  100. eval 'this_binary=$p_'$f'_binary'
  101. if [ -z "$this_binary" ]; then continue; fi
  102. echo Running dpkg --admindir $vardir -iGROEB "$p_mountpoint$this_binary"
  103. dpkg --admindir $vardir -iGROEB "$p_mountpoint$this_binary"
  104. done
  105. echo -n 'Installation OK. Hit RETURN. '
  106. read response
  107. xit=0