install 3.8 KB

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