chiark / gitweb /
dpkg (1.18.25) stretch; urgency=medium
[dpkg] / dselect / methods / floppy / setup
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/floppy"
22
23 defaultfloppy=fd0
24 defaultfstype=msdos
25 if [ -f shvar.$option ]
26 then
27         . ./shvar.$option
28         defaultfloppy="`echo \"$defaultfloppy\" | sed -e 's,^/dev/,,'`"
29 fi
30
31 while [ -z "$floppy" ]
32 do
33         echo -n '
34 Which floppy disk drive do you wish to use ?  Give the name in
35 /dev (eg fd0) or the MSDOS drive letter (eg A).  ['$defaultfloppy']  '
36         read floppy
37         if [ -z "$floppy" ]
38         then
39                 floppy="$defaultfloppy"
40         fi
41         case "$floppy" in
42         [ABab] | [ABab]: )
43                 floppy="`echo $floppy | \
44                         sed -e 's/:$//; s,^[Aa],/dev/fd0,; s,^[Bb],/dev/fd1,'`"
45                 ;;
46         /* )
47                 ;;
48         * )
49                 floppy="/dev/$floppy"
50                 ;;
51         esac
52         if ! [ -b "$floppy" ]
53         then
54                 echo "$floppy is not a block device."
55                 floppy=""
56         fi
57 done
58
59 while [ -z "$fstype" ]
60 do
61         echo -n '
62 What kind of filesystem is on the floppies ?  ['$defaultfstype']  '
63         read fstype
64         if [ -z "$fstype" ]
65         then
66                 fstype="$defaultfstype"
67         fi
68         if ! grep "     $fstype$" /proc/filesystems >/dev/null
69         then
70                 echo \
71         "Your kernel does not appear to support that filesystem type."
72                 fstype=""
73         fi
74 done
75
76 echo
77
78 outputparam () {
79         echo "$2" | sed -e "s/'/'\\\\''/; s/^/$1='/; s/$/'/" >&3
80 }
81
82 exec 3>shvar.$option.new
83
84 outputparam defaultfloppy "$floppy"
85 outputparam defaultfstype "$fstype"
86
87 mv shvar.$option.new shvar.$option
88
89 exit 0