diff options
Diffstat (limited to 'scripts/lib/wic/ksparser.py')
| -rw-r--r-- | scripts/lib/wic/ksparser.py | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py index 0894e2b199..62c490274a 100644 --- a/scripts/lib/wic/ksparser.py +++ b/scripts/lib/wic/ksparser.py | |||
| @@ -113,6 +113,9 @@ def systemidtype(arg): | |||
| 113 | class KickStart(): | 113 | class KickStart(): |
| 114 | """"Kickstart parser implementation.""" | 114 | """"Kickstart parser implementation.""" |
| 115 | 115 | ||
| 116 | DEFAULT_EXTRA_SPACE = 10*1024 | ||
| 117 | DEFAULT_OVERHEAD_FACTOR = 1.3 | ||
| 118 | |||
| 116 | def __init__(self, confpath): | 119 | def __init__(self, confpath): |
| 117 | 120 | ||
| 118 | self.partitions = [] | 121 | self.partitions = [] |
| @@ -127,16 +130,24 @@ class KickStart(): | |||
| 127 | part.add_argument('mountpoint', nargs='?') | 130 | part.add_argument('mountpoint', nargs='?') |
| 128 | part.add_argument('--active', action='store_true') | 131 | part.add_argument('--active', action='store_true') |
| 129 | part.add_argument('--align', type=int) | 132 | part.add_argument('--align', type=int) |
| 130 | part.add_argument("--extra-space", type=sizetype, default=10*1024) | 133 | part.add_argument("--extra-space", type=sizetype) |
| 131 | part.add_argument('--fsoptions', dest='fsopts') | 134 | part.add_argument('--fsoptions', dest='fsopts') |
| 132 | part.add_argument('--fstype') | 135 | part.add_argument('--fstype') |
| 133 | part.add_argument('--label') | 136 | part.add_argument('--label') |
| 134 | part.add_argument('--no-table', action='store_true') | 137 | part.add_argument('--no-table', action='store_true') |
| 135 | part.add_argument('--ondisk', '--ondrive', dest='disk') | 138 | part.add_argument('--ondisk', '--ondrive', dest='disk') |
| 136 | part.add_argument("--overhead-factor", type=overheadtype, default=1.3) | 139 | part.add_argument("--overhead-factor", type=overheadtype) |
| 137 | part.add_argument('--part-type') | 140 | part.add_argument('--part-type') |
| 138 | part.add_argument('--rootfs-dir') | 141 | part.add_argument('--rootfs-dir') |
| 139 | part.add_argument('--size', type=sizetype, default=0) | 142 | |
| 143 | # --size and --fixed-size cannot be specified together; options | ||
| 144 | # ----extra-space and --overhead-factor should also raise a parser | ||
| 145 | # --error, but since nesting mutually exclusive groups does not work, | ||
| 146 | # ----extra-space/--overhead-factor are handled later | ||
| 147 | sizeexcl = part.add_mutually_exclusive_group() | ||
| 148 | sizeexcl.add_argument('--size', type=sizetype, default=0) | ||
| 149 | sizeexcl.add_argument('--fixed-size', type=sizetype, default=0) | ||
| 150 | |||
| 140 | part.add_argument('--source') | 151 | part.add_argument('--source') |
| 141 | part.add_argument('--sourceparams') | 152 | part.add_argument('--sourceparams') |
| 142 | part.add_argument('--system-id', type=systemidtype) | 153 | part.add_argument('--system-id', type=systemidtype) |
| @@ -170,11 +181,33 @@ class KickStart(): | |||
| 170 | lineno += 1 | 181 | lineno += 1 |
| 171 | if line and line[0] != '#': | 182 | if line and line[0] != '#': |
| 172 | try: | 183 | try: |
| 173 | parsed = parser.parse_args(shlex.split(line)) | 184 | line_args = shlex.split(line) |
| 185 | parsed = parser.parse_args(line_args) | ||
| 174 | except ArgumentError as err: | 186 | except ArgumentError as err: |
| 175 | raise KickStartError('%s:%d: %s' % \ | 187 | raise KickStartError('%s:%d: %s' % \ |
| 176 | (confpath, lineno, err)) | 188 | (confpath, lineno, err)) |
| 177 | if line.startswith('part'): | 189 | if line.startswith('part'): |
| 190 | # using ArgumentParser one cannot easily tell if option | ||
| 191 | # was passed as argument, if said option has a default | ||
| 192 | # value; --overhead-factor/--extra-space cannot be used | ||
| 193 | # with --fixed-size, so at least detect when these were | ||
| 194 | # passed with non-0 values ... | ||
| 195 | if parsed.fixed_size: | ||
| 196 | if parsed.overhead_factor or parsed.extra_space: | ||
| 197 | err = "%s:%d: arguments --overhead-factor and --extra-space not "\ | ||
| 198 | "allowed with argument --fixed-size" \ | ||
| 199 | % (confpath, lineno) | ||
| 200 | raise KickStartError(err) | ||
| 201 | else: | ||
| 202 | # ... and provide defaults if not using | ||
| 203 | # --fixed-size iff given option was not used | ||
| 204 | # (again, one cannot tell if option was passed but | ||
| 205 | # with value equal to 0) | ||
| 206 | if '--overhead-factor' not in line_args: | ||
| 207 | parsed.overhead_factor = self.DEFAULT_OVERHEAD_FACTOR | ||
| 208 | if '--extra-space' not in line_args: | ||
| 209 | parsed.extra_space = self.DEFAULT_EXTRA_SPACE | ||
| 210 | |||
| 178 | self.partnum += 1 | 211 | self.partnum += 1 |
| 179 | self.partitions.append(Partition(parsed, self.partnum)) | 212 | self.partitions.append(Partition(parsed, self.partnum)) |
| 180 | elif line.startswith('include'): | 213 | elif line.startswith('include'): |
