test: Generate the pkg-old.deb from controlled parts
[dpkg.git] / dselect / methods / media / update.sh
blobf0a703f405f09fe976d014aaa379f39c897580f4
1 #!/bin/sh
3 # Copyright © 1995-1998 Ian Jackson <ijackson@chiark.greenend.org.uk>
4 # Copyright © 1998 Heiko Schlittermann <hs@schlittermann.de>
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.
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.
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/>.
19 set -e
20 vardir="$1"
21 method=$2
22 option=$3
23 iarch=$(dpkg --print-architecture)
25 cd "$vardir/methods/$method"
27 . ./shvar.$option
29 #debug() { echo "DEBUG: $@"; }
30 debug() {
31 true
34 packages=0
35 for f in main ctb nf lcl; do
36 eval 'this_packages=$p_'$f'_packages'
38 if [ -n "$this_packages" ]; then
39 packages=1
41 done
43 if [ $packages eq 0 ]; then
44 echo '
45 No Packages files available, cannot update available packages list.
46 Hit RETURN to continue. '
47 read response
48 exit 0
51 xit=1
52 trap '
53 for area in main ctb nf lcl; do
54 rm -f packages-$area
55 done
56 if [ -n "$umount" ]; then
57 umount "$umount" >/dev/null 2>&1
59 exit $xit
60 ' 0
62 if [ ! -b "$p_blockdev" ]; then
63 loop=",loop"
66 if [ -n "$p_blockdev" ]; then
67 umount="$p_mountpoint"
68 mount -rt "$p_fstype" -o nosuid,nodev${loop} "$p_blockdev" "$p_mountpoint"
71 updatetype=update
73 if [ -z "$p_multi" ]; then
74 exit 1
77 for f in main ctb nf lcl; do
78 eval 'this_packages=$p_'$f'_packages'
79 case "$this_packages" in
80 '')
81 continue
83 scan)
84 eval 'this_binary=$p_'$f'_binary'
85 if [ -z "$this_binary" ]; then
86 continue
88 if [ "$updatetype" = update ]; then
89 dpkg --clear-avail
90 updatetype=merge
92 echo Running dpkg --record-avail -R "$p_mountpoint$this_binary"
93 dpkg --record-avail -R "$p_mountpoint$this_binary"
96 packagesfile="$p_mountpoint$this_packages"
97 case "$packagesfile" in
98 *.gz)
99 echo -n "Uncompressing $packagesfile ... "
100 zcat <"$packagesfile" >packages-$f
101 echo done.
102 dpkg --$updatetype-avail packages-$f
103 updatetype=merge
108 dpkg --$updatetype-avail "$packagesfile"
109 updatetype=merge
111 esac
113 esac
114 done
116 cp -f $vardir/available $vardir/methods/$method
118 echo -n 'Update OK. Hit RETURN. '
119 read response
121 xit=0