summaryrefslogtreecommitdiff
path: root/dselect/methods/disk/install
blob: 605359920a0628c8f4ab8e4bd443bd9ccca1878d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/sh

set -e
vardir="$1"
method=$2
option=$3

cd "$vardir/methods/disk"

. ./shvar.$option

xit=1
trap '
	if [ -n "$umount" ]
	then
		umount "$umount" >/dev/null 2>&1
	fi
	exit $xit
' 0

if [ -n "$p_blockdev" ]
then
	umount="$p_mountpoint"
	mount -rt "$p_fstype" -o nosuid,nodev "$p_blockdev" "$p_mountpoint"
fi

if [ -n "$p_nfs" ]
then
	umount="$p_mountpoint"
	mount -rt nfs "$p_nfs" -o nosuid,nodev "$p_mountpoint"
fi

predep="$vardir/predep-package"
while true
do
	set +e
	dpkg --admindir "$vardir" --predep-package >"$predep"
	rc=$?
	set -e
	if test $rc = 1; then break; fi
	test $rc = 0

	perl -e '
		($binaryprefix,$predep) = @ARGV;
		$binaryprefix =~ s,/*$,/, if length($binaryprefix);
		open(P,"< $predep") || die "cannot open $predep: $!\n";
		while (<P>) {
			s/\s*\n$//;
			$package= $_ if s/^Package: //i;
			@filename= split(/ /,$_) if s/^Filename: //i;
			@msdosfilename= split(/ /,$_) if s/^MSDOS-Filename: //i;
		}
		length($package) || die "internal error - no package";
		@filename || die "internal error - no filename";
		@filename==@msdosfilename || !@filename || !@msdosfilename ||
			die "internal error - mismatch >@filename< >@msdosfilename<";
		@invoke=(); $|=1;
		for ($i=0; $i<=$#filename; $i++) {
			$ppart= $i+1;
			print "Looking for part $ppart of $package ... ";
			if (-f "$binaryprefix$filename[$i]") {
				$print= $filename[$i];
				$invoke= "$binaryprefix$filename[$i]";
			} elsif (-f "$binaryprefix$msdosfilename[$i]") {
				$print= $msdosfilename[$i];
				$invoke= "$binaryprefix$msdosfilename[$i]";
			} else {
				$base= $filename[$i]; $base =~ s,.*/,,;
				$msdosbase= $msdosfilename[$i]; $msdosbase =~ s,.*/,,;
				defined($c= open(X,"-|")) ||
					die "failed to fork for find: $!\n";
				if (!$c) {
					exec("find", "-L",
					     length($binaryprefix) ?
					     $binaryprefix : ".",
					     "-name",$base,"-o","-name",$msdosbase);
					die "failed to exec find: $!\n";
				}
				while (chop($invoke= <X>)) { last if -f $invoke; }
				$print= $invoke;
				if (substr($print,0,length($binaryprefix)+1) eq
				    "$binaryprefix/") {
					$print= substr($print,length($binaryprefix));
				}
			}
			if (!length($invoke)) {
				print STDERR "

Oh dear, I need to install or upgrade $package, but I don'\''t see
the appropriate file(s) anywhere.  I'\''m expecting version $version or
later, as that is listed in the Packages file.

Perhaps you downloaded it with an unexpected name, or something.
In any case, you must find the file(s) and then either place it with
the correct filename(s) (as listed in the Packages file or in
$vardir/available) and rerun the installation, or upgrade the
package by using '\''dpkg --install --auto-deconfigure'\'' by hand.

";
				exit(1);
			}
			print "$print\n";
			push(@invoke,$invoke);
		}
		print "Running dpkg -iB for $package ...\n";
		exec("dpkg","--admindir",$vardir,"-iB","--",@invoke);
		die "failed to exec dpkg: $!\n";
	' -- "$p_mountpoint$p_main_binary" "$predep"
done

for f in main ctb nf nus lcl
do
	eval 'this_binary=$p_'$f'_binary'
	if [ -z "$this_binary" ]; then continue; fi
	echo Running dpkg --admindir $vardir -iGROEB "$p_mountpoint$this_binary"
	dpkg --admindir $vardir -iGROEB "$p_mountpoint$this_binary"
done

echo -n 'Installation OK.  Hit RETURN.  '
read response

xit=0