~ubuntu-installer/kickseed/master

« back to all changes in this revision

Viewing changes to handlers/partition.sh

  • Committer: Colin Watson
  • Date: 2007-06-18 19:54:40 UTC
  • Revision ID: git-v1:c27c0eb26909628a8b2ed28295d7cf1412acfbf0
[project @ Arch-1:colin.watson@canonical.com--2005%kickseed--mainline--0--patch-28]
Translate to shell so that kickseed can run in d-i's initrd.

Original author: Colin Watson <colin.watson@canonical.com>
Date: 2005-01-25 12:56:52+00:00

r47320

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
 
 
3
partition_recipe=
 
4
 
 
5
partition_handler () {
 
6
        if [ -z "$partition_recipe" ]; then
 
7
                partition_recipe='Kickstart-supplied partitioning scheme :'
 
8
        fi
 
9
 
 
10
        size=
 
11
        grow=
 
12
        maxsize=$((1024 * 1024 * 1024))
 
13
        format=1
 
14
        asprimary=
 
15
        fstype=
 
16
 
 
17
        eval set -- "$(getopt -o '' -l size:,grow,maxsize:,noformat,onpart:,usepart:,ondisk:,ondrive:,asprimary,fstype:,start:,end: -- "$@")" || die_getopt partition
 
18
        while :; do
 
19
                case $1 in
 
20
                        --size)
 
21
                                size="$2"
 
22
                                shift 2
 
23
                                ;;
 
24
                        --grow)
 
25
                                grow=1
 
26
                                shift
 
27
                                ;;
 
28
                        --maxsize)
 
29
                                maxsize="$2"
 
30
                                shift 2
 
31
                                ;;
 
32
                        --noformat)
 
33
                                format=
 
34
                                shift
 
35
                                ;;
 
36
                        --asprimary)
 
37
                                asprimary=1
 
38
                                shift
 
39
                                ;;
 
40
                        --fstype)
 
41
                                fstype="$2"
 
42
                                shift 2
 
43
                                ;;
 
44
                        --onpart|--usepart|--ondisk|--ondrive|--start|--end)
 
45
                                die "unsupported restriction '$1'"
 
46
                                shift 2
 
47
                                ;;
 
48
                        --)     shift; break ;;
 
49
                        *)      die_getopt partition ;;
 
50
                esac
 
51
        done
 
52
 
 
53
        if [ $# -ne 1 ]; then
 
54
                die "partition command requires a mountpoint"
 
55
        fi
 
56
        mountpoint="$1"
 
57
 
 
58
        if [ -z "$size" ]; then
 
59
                die "partition command requires a size"
 
60
        fi
 
61
 
 
62
        if [ "$mountpoint" = swap ]; then
 
63
                filesystem=swap
 
64
                mountpoint=
 
65
        elif [ "$fstype" ]; then
 
66
                filesystem="$fstype"
 
67
        else
 
68
                filesystem=ext3
 
69
        fi
 
70
 
 
71
        if [ "$grow" ]; then
 
72
                priority="$size"
 
73
        else
 
74
                priority="$maxsize"
 
75
        fi
 
76
        partition_recipe="$partition_recipe $size $priority $maxsize $filesystem"
 
77
 
 
78
        if [ "$asprimary" ]; then
 
79
                partition_recipe="$partition_recipe \$primary{ }"
 
80
        fi
 
81
 
 
82
        if [ "$filesystem" = swap ]; then
 
83
                partition_recipe="$partition_recipe method{ swap }"
 
84
        elif [ "$format" ]; then
 
85
                partition_recipe="$partition_recipe method{ format }"
 
86
        else
 
87
                partition_recipe="$partition_recipe method{ keep }"
 
88
        fi
 
89
 
 
90
        if [ "$format" ]; then
 
91
                partition_recipe="$partition_recipe format{ }"
 
92
        fi
 
93
 
 
94
        if [ "$filesystem" != swap ]; then
 
95
                partition_recipe="$partition_recipe use_filesystem{ }"
 
96
                partition_recipe="$partition_recipe filesystem{ $filesystem }"
 
97
        fi
 
98
 
 
99
        if [ "$mountpoint" ]; then
 
100
                partition_recipe="$partition_recipe mountpoint{ $mountpoint }"
 
101
        fi
 
102
 
 
103
        partition_recipe="$partition_recipe ."
 
104
}
 
105
 
 
106
part_handler () {
 
107
        partition_handler "$@"
 
108
}
 
109
 
 
110
partition_handler_final () {
 
111
        if [ "$partition_recipe" ]; then
 
112
                preseed d-i partman-auto/expert_recipe string \
 
113
                        "$partition_recipe"
 
114
        fi
 
115
}
 
116
 
 
117
register_final partition_handler_final