install 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 <https://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") or 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. die "internal error - no package" if length($package) == 0;
  59. die "internal error - no filename" if not @filename;
  60. die "internal error - mismatch >@filename< >@msdosfilename<"
  61. if @filename && @msdosfilename &&
  62. @filename != @msdosfilename;
  63. @invoke=(); $|=1;
  64. for ($i=0; $i<=$#filename; $i++) {
  65. $ppart= $i+1;
  66. print "Looking for part $ppart of $package ... ";
  67. if (-f "$binaryprefix$filename[$i]") {
  68. $print= $filename[$i];
  69. $invoke= "$binaryprefix$filename[$i]";
  70. } elsif (-f "$binaryprefix$msdosfilename[$i]") {
  71. $print= $msdosfilename[$i];
  72. $invoke= "$binaryprefix$msdosfilename[$i]";
  73. } else {
  74. $base= $filename[$i]; $base =~ s,.*/,,;
  75. $msdosbase= $msdosfilename[$i]; $msdosbase =~ s,.*/,,;
  76. $c = open(X, "-|"));
  77. if (not defined $c) {
  78. die "failed to fork for find: $!\n";
  79. }
  80. if (!$c) {
  81. exec("find", "-L",
  82. length($binaryprefix) ?
  83. $binaryprefix : ".",
  84. "-name",$base,"-o","-name",$msdosbase);
  85. die "failed to exec find: $!\n";
  86. }
  87. while (chop($invoke= <X>)) { last if -f $invoke; }
  88. $print= $invoke;
  89. if (substr($print,0,length($binaryprefix)+1) eq
  90. "$binaryprefix/") {
  91. $print= substr($print,length($binaryprefix));
  92. }
  93. }
  94. if (!length($invoke)) {
  95. warn "
  96. Oh dear, I need to install or upgrade $package, but I don'\''t see
  97. the appropriate file(s) anywhere. I'\''m expecting version $version or
  98. later, as that is listed in the Packages file.
  99. Perhaps you downloaded it with an unexpected name, or something.
  100. In any case, you must find the file(s) and then either place it with
  101. the correct filename(s) (as listed in the Packages file or in
  102. $vardir/available) and rerun the installation, or upgrade the
  103. package by using '\''dpkg --install --auto-deconfigure'\'' by hand.
  104. ";
  105. exit(1);
  106. }
  107. print "$print\n";
  108. push(@invoke,$invoke);
  109. }
  110. print "Running dpkg -iB for $package ...\n";
  111. exec("dpkg","--admindir",$vardir,"-iB","--",@invoke);
  112. die "failed to exec dpkg: $!\n";
  113. ' -- "$p_mountpoint$p_main_binary" "$predep"
  114. done
  115. for f in main ctb nf nus lcl
  116. do
  117. eval 'this_binary=$p_'$f'_binary'
  118. if [ -z "$this_binary" ]; then continue; fi
  119. echo Running dpkg --admindir $vardir -iGROEB "$p_mountpoint$this_binary"
  120. dpkg --admindir $vardir -iGROEB "$p_mountpoint$this_binary"
  121. done
  122. echo -n 'Installation OK. Hit RETURN. '
  123. read response
  124. xit=0