File: do_option

package info (click to toggle)
partman-basicfilesystems 148
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,556 kB
  • sloc: sh: 1,149; makefile: 2
file content (161 lines) | stat: -rwxr-xr-x 3,633 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/sh

. /lib/partman/lib/base.sh

dev=$2
id=$3
part=$dev/$id

cd $dev

[ -f $part/method -a -f $part/acting_filesystem ] || exit 0
filesystem=$(cat $part/acting_filesystem)

do_fatmountpoint () {
	local noninteractive tpl
	noninteractive=true
	while true; do
		if [ -f "$part/mountpoint" ]; then
			old_mountpoint=$(cat $part/mountpoint)
		else
			old_mountpoint=/
		fi
		case "$filesystem" in
		    fat16|fat32|ntfs)
			tpl=partman-basicfilesystems/fat_mountpoint
			;;
		    *)
			tpl=partman-basicfilesystems/mountpoint
			;;
		esac
		db_set $tpl "$old_mountpoint"
		db_input critical $tpl || $noninteractive
		db_go || return 1
		db_get $tpl

		case "$RET" in
		    Do?not?mount?it)
				rm -f $part/mountpoint
			break
			;;
		    Enter?manually)
			if do_mountpoint_manual; then break; fi
			noninteractive="return 1"
			;;
		    *)
			echo $RET >$part/mountpoint
			break
		esac
	done
}

do_mountpoint_manual () {
	local noninteractive
	noninteractive=true
	while true; do
		new_mountpoint=''
		while [ ! "$new_mountpoint" ]; do
			if [ -f "$part/mountpoint" ]; then
				old_mountpoint=$(cat $part/mountpoint)
			else
				old_mountpoint=/
			fi
			db_set partman-basicfilesystems/mountpoint_manual "$old_mountpoint"
			db_input critical partman-basicfilesystems/mountpoint_manual || \
				$noninteractive
			db_go || return 1
			db_get partman-basicfilesystems/mountpoint_manual

			if expr "$RET" : '/[^ ]*$' >/dev/null; then
				new_mountpoint=$RET
			else
				db_input high partman-basicfilesystems/bad_mountpoint || true
				db_go || true
			fi
		done
		echo $RET >$part/mountpoint
		break
	done
}

case $1 in
    mountpoint)
	code=0
	if [ "$filesystem" = fat16 ] || [ "$filesystem" = fat32 ] || [ "$filesystem" = ntfs ]; then
		do_fatmountpoint || code=$?
	else
		select_mountpoint $dev $id || code=$?
	fi
	if [ "$code" -eq 0 ]; then
		update_partition $dev $id
	fi
	;;
    options)
	select_mountoptions $dev $id
	;;
    format_swap)
	>$part/format
	update_partition $dev $id
	;;
    dont_format_swap)
	if [ -f $part/format ]; then
		rm $part/format
		update_partition $dev $id
	fi
	;;
    label)
	label=''
	if [ -f $part/label ]; then
		label=$(cat $part/label)
	fi
	db_set partman-basicfilesystems/choose_label "$label"
	db_input critical partman-basicfilesystems/choose_label || true
	db_go || exit 1
	db_get partman-basicfilesystems/choose_label
	if [ "$RET" ]; then
		echo "$RET" >$part/label
	else
		rm -f $part/label
	fi
	db_reset partman-basicfilesystems/choose_label
	;;
    reserved_for_root)
	if [ -f $part/reserved_for_root ]; then
		reserved=$(cat $part/reserved_for_root)
	else
		reserved=5
	fi
	db_set partman-basicfilesystems/specify_reserved "$reserved%"
	db_input critical partman-basicfilesystems/specify_reserved || true
	db_go || exit 1
	db_get partman-basicfilesystems/specify_reserved
	RET=`expr "$RET" : '\([0-9][0-9]\?\)\([,. %].*\)\?$'`
	if [ "$RET" ]; then
		echo "$RET" >$part/reserved_for_root
	else
		rm -f $part/reserved_for_root
	fi
	db_reset partman-basicfilesystems/specify_reserved
	;;
    usage)
	db_metaget partman-basicfilesystems/text/typical_usage description
	typical_usage="$RET"
	if [ -f $part/usage ]; then
		usage=$(cat $part/usage)
	else
		usage="$typical_usage"
	fi
	db_subst partman-basicfilesystems/specify_usage CHOICES "$typical_usage, news, largefile, largefile4"
	db_set partman-basicfilesystems/specify_usage "$usage"
	db_input critical partman-basicfilesystems/specify_usage || true
	db_go || exit 1
	db_get partman-basicfilesystems/specify_usage
	if [ "$RET" != "$typical_usage" ]; then
		echo "$RET" >$part/usage
	else
		rm -f $part/usage
	fi
	;;
esac

exit 0