Commit | Line | Data |
---|---|---|
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 | ||
16 | set -e | |
17 | vardir="$1" | |
18 | method=$2 | |
19 | option=$3 | |
20 | ||
21 | cd "$vardir/methods/disk" | |
22 | ||
23 | . ./shvar.$option | |
24 | ||
25 | if [ -z "$p_main_packages" ] && [ -z "$p_ctb_packages" ] && \ | |
26 | [ -z "$p_nf_packages" ] && [ -z "$p_nus_packages " ] && \ | |
27 | [ -z "$p_lcl_packages" ] | |
28 | then | |
29 | echo ' | |
30 | No Packages files available, cannot update available packages list. | |
31 | Hit RETURN to continue. ' | |
32 | read response | |
33 | exit 0 | |
34 | fi | |
35 | ||
36 | xit=1 | |
37 | trap ' | |
38 | rm -f packages-main packages-ctb packages-nf packages-nus packages-lcl | |
39 | if [ -n "$umount" ] | |
40 | then | |
41 | umount "$umount" >/dev/null 2>&1 | |
42 | fi | |
43 | exit $xit | |
44 | ' 0 | |
45 | ||
46 | if [ -n "$p_blockdev" ] | |
47 | then | |
48 | umount="$p_mountpoint" | |
49 | mount -rt "$p_fstype" -o nosuid,nodev "$p_blockdev" "$p_mountpoint" | |
50 | fi | |
51 | ||
52 | if [ -n "$p_nfs" ] | |
53 | then | |
54 | umount="$p_mountpoint" | |
55 | mount -rt nfs "$p_nfs" -o nosuid,nodev "$p_mountpoint" | |
56 | fi | |
57 | ||
58 | updatetype=update | |
59 | ||
60 | for f in main ctb nf nus lcl | |
61 | do | |
62 | eval 'this_packages=$p_'$f'_packages' | |
63 | case "$this_packages" in | |
64 | '') | |
65 | continue | |
66 | ;; | |
67 | scan) | |
68 | eval 'this_binary=$p_'$f'_binary' | |
69 | if [ -z "$this_binary" ]; then continue; fi | |
70 | if [ "$updatetype" = update ] | |
71 | then | |
72 | dpkg --admindir $vardir --clear-avail | |
73 | updatetype=merge | |
74 | fi | |
75 | echo Running dpkg --record-avail -R "$p_mountpoint$this_binary" | |
76 | dpkg --admindir $vardir --record-avail -R "$p_mountpoint$this_binary" | |
77 | ;; | |
78 | *) | |
79 | packagesfile="$p_mountpoint$this_packages" | |
80 | case "$packagesfile" in | |
81 | *.gz | *.Z | *.GZ | *.z) | |
82 | echo -n "Uncompressing $packagesfile ... " | |
83 | zcat <"$packagesfile" >packages-$f | |
84 | echo done. | |
85 | dpkg --admindir $vardir --$updatetype-avail packages-$f | |
86 | updatetype=merge | |
87 | ;; | |
88 | '') | |
89 | ;; | |
90 | *) | |
91 | dpkg --admindir $vardir --$updatetype-avail "$packagesfile" | |
92 | updatetype=merge | |
93 | ;; | |
94 | esac | |
95 | ;; | |
96 | esac | |
97 | done | |
98 | ||
99 | echo -n 'Update OK. Hit RETURN. ' | |
100 | read response | |
101 | ||
102 | xit=0 |