Commit | Line | Data |
---|---|---|
1479465f GJ |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright © 1995-1998 Ian Jackson <ijackson@chiark.greenend.org.uk> | |
4 | # Copyright © 1998 Heiko Schlittermann <hs@schlittermann.de> | |
5 | # | |
6 | # This is free software; you can redistribute it and/or modify | |
7 | # it under the terms of the GNU General Public License as published by | |
8 | # the Free Software Foundation; either version 2 of the License, or | |
9 | # (at your option) any later version. | |
10 | # | |
11 | # This program is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. | |
15 | # | |
16 | # You should have received a copy of the GNU General Public License | |
17 | # along with this program. If not, see <https://www.gnu.org/licenses/>. | |
18 | ||
19 | set -e | |
20 | vardir="$1" | |
21 | method=$2 | |
22 | option=$3 | |
23 | iarch=`dpkg --print-architecture` | |
24 | ||
25 | cd "$vardir/methods/$method" | |
26 | ||
27 | . ./shvar.$option | |
28 | ||
29 | #debug() { echo "DEBUG: $@"; } | |
30 | debug() { true; } | |
31 | ismulti() { debug $1 $2; test -e "$1/.disk/info" || test -e "$1$2/.disk/info"; } | |
32 | ||
33 | packages=0 | |
34 | for f in main ctb nf nonus nonusctb nonusnf lcl | |
35 | do | |
36 | eval 'this_packages=$p_'$f'_packages' | |
37 | ||
38 | if [ -n "$this_packages" ] | |
39 | then | |
40 | packages=1 | |
41 | fi | |
42 | done | |
43 | ||
44 | if [ $packages eq 0 ] | |
45 | then | |
46 | echo ' | |
47 | No Packages files available, cannot update available packages list. | |
48 | Hit RETURN to continue. ' | |
49 | read response | |
50 | exit 0 | |
51 | fi | |
52 | ||
53 | xit=1 | |
54 | trap ' | |
55 | rm -f packages-{main,ctb,nf,nonus,nonusctb,nonusnf,lcl} | |
56 | if [ -n "$umount" ] | |
57 | then | |
58 | umount "$umount" >/dev/null 2>&1 | |
59 | fi | |
60 | exit $xit | |
61 | ' 0 | |
62 | ||
63 | if [ ! -b "$p_blockdev" ] | |
64 | then | |
65 | loop=",loop" | |
66 | fi | |
67 | ||
68 | if [ -n "$p_blockdev" ] | |
69 | then | |
70 | umount="$p_mountpoint" | |
71 | mount -rt "$p_fstype" -o nosuid,nodev${loop} "$p_blockdev" "$p_mountpoint" | |
72 | fi | |
73 | ||
74 | if [ -n "$p_nfs" ] | |
75 | then | |
76 | umount="$p_mountpoint" | |
77 | mount -rt nfs "$p_nfs" -o nosuid,nodev "$p_mountpoint" | |
78 | fi | |
79 | ||
80 | updatetype=update | |
81 | ||
82 | if [ -z "$p_multi" ]; then | |
83 | exit 1 | |
84 | fi | |
85 | ||
86 | for f in main ctb nf nonus nonusctb nonusnf lcl | |
87 | do | |
88 | eval 'this_packages=$p_'$f'_packages' | |
89 | case "$this_packages" in | |
90 | '') | |
91 | continue | |
92 | ;; | |
93 | scan) | |
94 | eval 'this_binary=$p_'$f'_binary' | |
95 | if [ -z "$this_binary" ]; then continue; fi | |
96 | if [ "$updatetype" = update ] | |
97 | then | |
98 | dpkg --clear-avail | |
99 | updatetype=merge | |
100 | fi | |
101 | echo Running dpkg --record-avail -R "$p_mountpoint$this_binary" | |
102 | dpkg --record-avail -R "$p_mountpoint$this_binary" | |
103 | ;; | |
104 | *) | |
105 | packagesfile="$p_mountpoint$this_packages" | |
106 | case "$packagesfile" in | |
107 | *.gz | *.Z | *.GZ | *.z) | |
108 | echo -n "Uncompressing $packagesfile ... " | |
109 | zcat <"$packagesfile" >packages-$f | |
110 | echo done. | |
111 | dpkg --$updatetype-avail packages-$f | |
112 | updatetype=merge | |
113 | ;; | |
114 | '') | |
115 | ;; | |
116 | *) | |
117 | dpkg --$updatetype-avail "$packagesfile" | |
118 | updatetype=merge | |
119 | ;; | |
120 | esac | |
121 | ;; | |
122 | esac | |
123 | done | |
124 | ||
125 | cp -f $vardir/available $vardir/methods/$method | |
126 | ||
127 | echo -n 'Update OK. Hit RETURN. ' | |
128 | read response | |
129 | ||
130 | xit=0 |