File: do_option

package info (click to toggle)
partman-base 128lenny1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,664 kB
  • ctags: 199
  • sloc: ansic: 2,143; sh: 2,040; makefile: 58
file content (111 lines) | stat: -rwxr-xr-x 2,903 bytes parent folder | download
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
#!/bin/sh -e

set -e

. /lib/partman/lib/base.sh

dev=${1%//*}
id=${1#*//}

cd $dev
device=$(humandev $(cat device))

# If the user wants to modify a device or partition
# the device may not be locked
if [ -e "$dev/locked" ]; then
	locked=$(cat "$dev/locked")
	db_subst partman-base/devicelocked DEVICE "$device"
	db_subst partman-base/devicelocked MESSAGE "$locked"
	db_set partman-base/devicelocked false
	db_input critical partman-base/devicelocked
	db_capb
	db_go || true
	db_capb backup align
	exit 0
fi

# Two scenarios to check for here:
# 1) If the user wants to modify a partition - it may not be locked
# 2) If the user wants to modify a device - none of its partitions may be locked
open_dialog PARTITIONS
while { read_line num tmpid size type fs path name; [ "$tmpid" ]; }; do
	if [ -n "$id" ]; then
		[ "$id" = "$tmpid" ] || continue
	fi

	if [ -e "$dev/$tmpid/locked" ]; then
		locked=$(cat "$dev/$tmpid/locked")
		db_subst partman-base/partlocked DEVICE "$device"
		db_subst partman-base/partlocked PARTITION "$num"
		db_subst partman-base/partlocked MESSAGE "$locked"
		db_set partman-base/partlocked false
		db_input critical partman-base/partlocked
		db_capb
		db_go || true
		db_capb backup align
		close_dialog
		exit 0
	fi
done
close_dialog


if [ -z "$id" ]; then
	# ask_user /lib/partman/storage_device "$dev" "$id" || true
	open_dialog GET_LABEL_TYPE
	read_line x
	close_dialog
	# do not try to create partition table on sw RAID device or LVM LV
	if [ "$x" = loop ]; then
		exit 0
	fi
	mklabel=$(echo /lib/partman/storage_device/[0-9][0-9]label/do_option)
	[ -x "$mklabel" ] || exit 0
	$mklabel label "$dev" || true
	exit 0
else
	open_dialog PARTITION_INFO $id
	read_line num id size type fs path name
	close_dialog
	[ "$id" ] || exit 0
	case "$fs" in
	    free)
		ask_user /lib/partman/free_space "$dev" "$id" || true
		;;
	    *)
		while true; do
			set +e
			device="$(humandev $(cat device))"
			db_subst partman/active_partition DEVICE "$device"
			db_subst partman/active_partition PARTITION "$num"
			if [ -f  $id/detected_filesystem ]; then
				filesystem=$(cat $id/detected_filesystem)
				RET=''
				db_metaget partman/filesystem_long/"$filesystem" description || RET=''
				if [ "$RET" ]; then
					filesystem="$RET"
				fi
				db_subst partman/text/there_is_detected FILESYSTEM "$filesystem"
				db_metaget partman/text/there_is_detected description
			else
				db_metaget partman/text/none_detected description
			fi
			db_subst partman/active_partition OTHERINFO "${RET}"

			if [ -f $id/detected_filesystem ] && [ -f $id/format ]; then
				db_metaget partman/text/destroyed description
				db_subst partman/active_partition DESTROYED "${RET}"
			else
				db_subst partman/active_partition DESTROYED ''
			fi

			ask_user /lib/partman/active_partition "$dev" "$id"
			exitcode="$?"
			if [ "$exitcode" -ge 100 ]; then
				break
			fi
			set -e
		done
		;;
	esac
fi