File: partman

package info (click to toggle)
partman-base 105
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,620 kB
  • ctags: 172
  • sloc: ansic: 2,111; sh: 1,674; makefile: 63
file content (119 lines) | stat: -rwxr-xr-x 2,644 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
112
113
114
115
116
117
118
119
#!/bin/sh

. /lib/partman/definitions.sh

abort () {
	if [ -f /var/run/parted_server.pid ]; then
		stop_parted_server
	fi
	exit $1
}

db_capb backup

# Measure the width of partman/text/number here to make things faster.
# number_width is used only in visual.d/number
db_metaget partman/text/number description
RET=$(printf "$RET" '')
RET=$(stralign 50 "$RET" | sed 's/[^ ]//g')
number_width=$((2 + 50 - ${#RET}))
export number_width


# Here is maybe not a good place to set deci (TODO)
#db_metaget partman/text/deci description
#deci="$RET"
#export deci

# The comma has special meaning for debconf.  Lets force dot untill we
# discover where the comma has to be escaped..
deci='.'

# Commented due to #240145
#if [ -e /var/lib/partman ]; then
#	rm -rf /var/lib/partman
#fi

mkdir -p /var/lib/partman

while true; do
	initcount=$(ls /lib/partman/init.d/* | wc -l)
	db_progress START 0 $initcount partman/progress/init/title

	for s in /lib/partman/init.d/*; do
		if [ -x $s ]; then
			#logger -t partman "Running init.d/$s"

			base=$(basename $s | sed 's/[0-9]*//')
			# Not every init script has, or needs, its own progress
			# template. Add them to slow init scripts only.
			if ! db_progress INFO partman/progress/init/$base; then
				db_progress INFO partman/progress/init/fallback
			fi
			if ! $s; then
				db_progress STOP
				abort 10
			fi
		fi
		db_progress STEP 1
	done
	db_progress STOP

	skip_choose_partition=no
	for s in /lib/partman/auto.d/*; do
		if [ -x $s ]; then
			#logger -t partman "Running auto.d/$s"
			$s
			exitcode=$?
			if [ $exitcode -eq 255 ]; then
				abort 10 # back up to main menu
			elif [ $exitcode -ge 100 ]; then
				# Partitioning complete; go straight to
				# confirmation. (To present choose_partition
				# so that the user can edit the results of
				# manual partitioning, just exit 0 instead.)
				skip_choose_partition=yes
			elif [ $exitcode -ne 0 ]; then
				continue 2
			fi
		fi
	done

	while true; do
		if [ "$skip_choose_partition" != yes ]; then
			ask_user /lib/partman/choose_partition
			exitcode=$?
		else
			exitcode=100
		fi
		if [ $exitcode -eq 255 ]; then
			abort 10 # back up to main menu
		elif [ $exitcode -ge 100 ] && confirm_changes "partman"; then
			break
		fi
		skip_choose_partition=no
	done

	for s in /lib/partman/commit.d/*; do
		if [ -x $s ]; then
			#logger -t partman "Running commit.d/$s"
			$s || continue 2
		fi
	done

	for s in /lib/partman/finish.d/*; do
		if [ -x $s ]; then
			#logger -t partman "Running finish.d/$s"
			$s || {
				status=$?
				if [ "$status" = 1 ]; then
					continue 2
				else
					abort $status
				fi
			}
		fi
	done

	break
done