dpkg (1.18.25) stretch; urgency=medium
[dpkg] / dselect / methods / disk / update
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
25if [ -z "$p_main_packages" ] && [ -z "$p_ctb_packages" ] && \
26 [ -z "$p_nf_packages" ] && [ -z "$p_nus_packages " ] && \
27 [ -z "$p_lcl_packages" ]
28then
29 echo '
30No Packages files available, cannot update available packages list.
31Hit RETURN to continue. '
32 read response
33 exit 0
34fi
35
36xit=1
37trap '
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
46if [ -n "$p_blockdev" ]
47then
48 umount="$p_mountpoint"
49 mount -rt "$p_fstype" -o nosuid,nodev "$p_blockdev" "$p_mountpoint"
50fi
51
52if [ -n "$p_nfs" ]
53then
54 umount="$p_mountpoint"
55 mount -rt nfs "$p_nfs" -o nosuid,nodev "$p_mountpoint"
56fi
57
58updatetype=update
59
60for f in main ctb nf nus lcl
61do
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
97done
98
99echo -n 'Update OK. Hit RETURN. '
100read response
101
102xit=0