~ubuntu-branches/ubuntu/maverick/partman-target/maverick

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
#!/bin/sh

. /lib/partman/lib/base.sh

# At least one file system to mount on /
no_root () {
	mountpoints=$(
		for i in /lib/partman/fstab.d/*; do
			[ -x "$i" ] || continue
			$i
		done |
		while read fs mp type options dump pass; do
			echo $mp
		done
	)

	for mp in $mountpoints; do
		if [ "$mp" = / ]; then
			return 0
		fi
	done

	db_input critical partman-target/no_root || true
	db_go || true
	exit 1
}

# No two file systems with one and the same mount point
same_mountpoints () {
	mountpoints=$(
		for i in /lib/partman/fstab.d/*; do
			[ -x "$i" ] || continue
			$i
		done |
		while read fs mp type options dump pass; do
			case "$mp" in
			    (/*)
				echo $mp,$fs;;
			esac
		done |
		sort
	)

	oldmp=' '
	for x in $mountpoints; do
		mp=${x%,*}
		fs=${x#*,}
		if [ "$mp" = "$oldmp" ]; then
			db_subst partman-target/same_mountpoint PART1 $(humandev $oldfs)
			db_subst partman-target/same_mountpoint PART2 $(humandev $fs)
			db_subst partman-target/same_mountpoint MOUNTPOINT "$mp"
			db_input critical partman-target/same_mountpoint || true
			db_go || true
			exit 1
		else
			oldmp="$mp"
			oldfs="$fs"
		fi
	done
}

# Some directories must be on the root file system
must_be_on_root () {
	mountpoints=$(
		for i in /lib/partman/fstab.d/*; do
			[ -x "$i" ] || continue
			$i
		done |
		while read fs mp type options dump pass; do
			echo $mp
		done
	)

	for mp in $mountpoints; do
		case $mp in
		    /bin|/etc|/lib*|/media|/sbin)
			db_subst partman-target/must_be_on_root MOUNTPOINT "$mp"
			db_input critical partman-target/must_be_on_root || true
			db_go || true
			exit 1
		esac
	done
}

no_root
same_mountpoints
must_be_on_root