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