Dpkg::Vendor::Debian: Set -Wno-error on qa=-bug-implicit-func
[dpkg.git] / dselect / methods / file / install.sh
blobf5e3dae3c79ba5b8df5276c6e548711ca3078cb7
1 #!/bin/sh
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.
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.
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/>.
16 set -e
17 vardir="$1"
18 method=$2
19 option=$3
21 cd "$vardir/methods/file"
23 . ./shvar.$option
25 xit=1
26 trap '
27 exit $xit
28 ' 0
30 predep="$vardir/predep-package"
31 while true; do
32 set +e
33 dpkg --admindir "$vardir" --predep-package >"$predep"
34 rc=$?
35 set -e
36 if test $rc = 1; then
37 break
39 test $rc = 0
41 perl -e '
42 ($binaryprefix,$predep) = @ARGV;
43 $binaryprefix =~ s,/*$,/, if length($binaryprefix);
44 open(P, "< $predep") or die "cannot open $predep: $!\n";
45 while (<P>) {
46 s/\s*\n$//;
47 $package = $_ if s/^Package: //i;
48 @filename = split(/ /,$_) if s/^Filename: //i;
49 @msdosfilename = split(/ /,$_) if s/^MSDOS-Filename: //i;
51 die "internal error - no package" if length($package) == 0;
52 die "internal error - no filename" if not @filename;
53 die "internal error - mismatch >@filename< >@msdosfilename<"
54 if @filename && @msdosfilename &&
55 @filename != @msdosfilename;
56 @invoke = (); $| = 1;
57 for ($i = 0; $i <= $#filename; $i++) {
58 $ppart = $i+1;
59 print "Looking for part $ppart of $package ... ";
60 if (-f "$binaryprefix$filename[$i]") {
61 $print = $filename[$i];
62 $invoke = "$binaryprefix$filename[$i]";
63 } elsif (-f "$binaryprefix$msdosfilename[$i]") {
64 $print = $msdosfilename[$i];
65 $invoke = "$binaryprefix$msdosfilename[$i]";
66 } else {
67 $base = $filename[$i]; $base =~ s,.*/,,;
68 $msdosbase = $msdosfilename[$i]; $msdosbase =~ s,.*/,,;
69 $c = open(X, "-|"));
70 if (not defined $c) {
71 die "failed to fork for find: $!\n";
73 if (!$c) {
74 exec("find", "-L",
75 length($binaryprefix) ?
76 $binaryprefix : ".",
77 "-name",$base,"-o","-name",$msdosbase);
78 die "failed to exec find: $!\n";
80 while (chop($invoke = <X>)) { last if -f $invoke; }
81 $print = $invoke;
82 if (substr($print,0,length($binaryprefix)+1) eq
83 "$binaryprefix/") {
84 $print = substr($print,length($binaryprefix));
87 if (!length($invoke)) {
88 warn "
90 Cannot find the appropriate file(s) anywhere needed to install or upgrade
91 package $package. Expecting version $version or later, as listed in the
92 Packages file.
94 Perhaps the package was downloaded with an unexpected name? In any case,
95 you must find the file(s) and then either place it with the correct
96 filename(s) (as listed in the Packages file or in $vardir/available)
97 and rerun the installation, or upgrade the package by using
98 \"dpkg --install --auto-deconfigure" by hand.
101 exit(1);
103 print "$print\n";
104 push(@invoke,$invoke);
106 print "Running dpkg -iB for $package ...\n";
107 exec("dpkg","--admindir",$vardir,"-iB","--",@invoke);
108 die "failed to exec dpkg: $!\n";
109 ' -- "$p_mountpoint$p_main_binary" "$predep"
110 done
112 for f in main ctb nf lcl; do
113 eval 'this_binary=$p_'$f'_binary'
114 if [ -z "$this_binary" ]; then
115 continue
117 echo Running dpkg --admindir $vardir -iGROEB "$p_mountpoint$this_binary"
118 dpkg --admindir $vardir -iGROEB "$p_mountpoint$this_binary"
119 done
121 echo -n 'Installation OK. Hit RETURN. '
122 read response
124 xit=0