diff options
Diffstat (limited to 'scripts/lib')
| -rw-r--r-- | scripts/lib/image/help.py | 8 | ||||
| -rw-r--r-- | scripts/lib/wic/3rdparty/pykickstart/commands/partition.py | 4 | ||||
| -rw-r--r-- | scripts/lib/wic/3rdparty/pykickstart/options.py | 21 | ||||
| -rw-r--r-- | scripts/lib/wic/kickstart/__init__.py | 2 | ||||
| -rw-r--r-- | scripts/lib/wic/kickstart/custom_commands/partition.py | 36 | ||||
| -rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-efi.py | 2 | ||||
| -rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-pcbios.py | 2 | ||||
| -rw-r--r-- | scripts/lib/wic/utils/partitionedfs.py | 4 |
8 files changed, 49 insertions, 30 deletions
diff --git a/scripts/lib/image/help.py b/scripts/lib/image/help.py index 6b74f57662..0d8a6adfaa 100644 --- a/scripts/lib/image/help.py +++ b/scripts/lib/image/help.py | |||
| @@ -673,10 +673,10 @@ DESCRIPTION | |||
| 673 | 673 | ||
| 674 | The following are supported 'part' options: | 674 | The following are supported 'part' options: |
| 675 | 675 | ||
| 676 | --size: The minimum partition size in MBytes. Specify an | 676 | --size: The minimum partition size. Specify an integer value |
| 677 | integer value such as 500. Do not append the number | 677 | such as 500. Multipliers k, M ang G can be used. If |
| 678 | with "MB". You do not need this option if you use | 678 | not specified, the size is in MB. |
| 679 | --source. | 679 | You do not need this option if you use --source. |
| 680 | 680 | ||
| 681 | --source: This option is a wic-specific option that names the | 681 | --source: This option is a wic-specific option that names the |
| 682 | source of the data that will populate the | 682 | source of the data that will populate the |
diff --git a/scripts/lib/wic/3rdparty/pykickstart/commands/partition.py b/scripts/lib/wic/3rdparty/pykickstart/commands/partition.py index 56b91aa9d9..b564b1a7ab 100644 --- a/scripts/lib/wic/3rdparty/pykickstart/commands/partition.py +++ b/scripts/lib/wic/3rdparty/pykickstart/commands/partition.py | |||
| @@ -78,7 +78,7 @@ class FC3_PartData(BaseData): | |||
| 78 | if self.recommended: | 78 | if self.recommended: |
| 79 | retval += " --recommended" | 79 | retval += " --recommended" |
| 80 | if self.size and self.size != 0: | 80 | if self.size and self.size != 0: |
| 81 | retval += " --size=%s" % self.size | 81 | retval += " --size=%sk" % self.size |
| 82 | if hasattr(self, "start") and self.start != 0: | 82 | if hasattr(self, "start") and self.start != 0: |
| 83 | retval += " --start=%s" % self.start | 83 | retval += " --start=%s" % self.start |
| 84 | 84 | ||
| @@ -216,7 +216,7 @@ class FC3_Partition(KickstartCommand): | |||
| 216 | callback=part_cb, nargs=1, type="string") | 216 | callback=part_cb, nargs=1, type="string") |
| 217 | op.add_option("--recommended", dest="recommended", action="store_true", | 217 | op.add_option("--recommended", dest="recommended", action="store_true", |
| 218 | default=False) | 218 | default=False) |
| 219 | op.add_option("--size", dest="size", action="store", type="int", | 219 | op.add_option("--size", dest="size", action="store", type="size", |
| 220 | nargs=1) | 220 | nargs=1) |
| 221 | op.add_option("--start", dest="start", action="store", type="int", | 221 | op.add_option("--start", dest="start", action="store", type="int", |
| 222 | nargs=1) | 222 | nargs=1) |
diff --git a/scripts/lib/wic/3rdparty/pykickstart/options.py b/scripts/lib/wic/3rdparty/pykickstart/options.py index 341c5d7298..b2d8e3e516 100644 --- a/scripts/lib/wic/3rdparty/pykickstart/options.py +++ b/scripts/lib/wic/3rdparty/pykickstart/options.py | |||
| @@ -143,6 +143,24 @@ def _check_string(option, opt, value): | |||
| 143 | else: | 143 | else: |
| 144 | return value | 144 | return value |
| 145 | 145 | ||
| 146 | def _check_size(option, opt, value): | ||
| 147 | # Former default was MB | ||
| 148 | if (value.isdigit()): | ||
| 149 | return int(value) * 1024L | ||
| 150 | |||
| 151 | mapping = {"opt": opt, "value": value} | ||
| 152 | if (not value[:-1].isdigit()): | ||
| 153 | raise OptionValueError(_("Option %(opt)s: invalid size value: %(value)r") % mapping) | ||
| 154 | |||
| 155 | size = int(value[:-1]) | ||
| 156 | if (value.endswith("k") or value.endswith("K")): | ||
| 157 | return size | ||
| 158 | if (value.endswith("M")): | ||
| 159 | return size * 1024L | ||
| 160 | if (value.endswith("G")): | ||
| 161 | return size * 1024L * 1024L | ||
| 162 | raise OptionValueError(_("Option %(opt)s: invalid size value: %(value)r") % mapping) | ||
| 163 | |||
| 146 | # Creates a new Option class that supports several new attributes: | 164 | # Creates a new Option class that supports several new attributes: |
| 147 | # - required: any option with this attribute must be supplied or an exception | 165 | # - required: any option with this attribute must be supplied or an exception |
| 148 | # is thrown | 166 | # is thrown |
| @@ -169,10 +187,11 @@ class KSOption (Option): | |||
| 169 | ACTIONS = Option.ACTIONS + ("map", "map_extend",) | 187 | ACTIONS = Option.ACTIONS + ("map", "map_extend",) |
| 170 | STORE_ACTIONS = Option.STORE_ACTIONS + ("map", "map_extend",) | 188 | STORE_ACTIONS = Option.STORE_ACTIONS + ("map", "map_extend",) |
| 171 | 189 | ||
| 172 | TYPES = Option.TYPES + ("ksboolean", "string") | 190 | TYPES = Option.TYPES + ("ksboolean", "string", "size") |
| 173 | TYPE_CHECKER = copy(Option.TYPE_CHECKER) | 191 | TYPE_CHECKER = copy(Option.TYPE_CHECKER) |
| 174 | TYPE_CHECKER["ksboolean"] = _check_ksboolean | 192 | TYPE_CHECKER["ksboolean"] = _check_ksboolean |
| 175 | TYPE_CHECKER["string"] = _check_string | 193 | TYPE_CHECKER["string"] = _check_string |
| 194 | TYPE_CHECKER["size"] = _check_size | ||
| 176 | 195 | ||
| 177 | def _check_required(self): | 196 | def _check_required(self): |
| 178 | if self.required and not self.takes_value(): | 197 | if self.required and not self.takes_value(): |
diff --git a/scripts/lib/wic/kickstart/__init__.py b/scripts/lib/wic/kickstart/__init__.py index b1406a0457..10959213d1 100644 --- a/scripts/lib/wic/kickstart/__init__.py +++ b/scripts/lib/wic/kickstart/__init__.py | |||
| @@ -74,7 +74,7 @@ def get_image_size(ks, default = None): | |||
| 74 | if p.mountpoint == "/" and p.size: | 74 | if p.mountpoint == "/" and p.size: |
| 75 | __size = p.size | 75 | __size = p.size |
| 76 | if __size > 0: | 76 | if __size > 0: |
| 77 | return int(__size) * 1024L * 1024L | 77 | return int(__size) * 1024L |
| 78 | else: | 78 | else: |
| 79 | return default | 79 | return default |
| 80 | 80 | ||
diff --git a/scripts/lib/wic/kickstart/custom_commands/partition.py b/scripts/lib/wic/kickstart/custom_commands/partition.py index 54a494e033..7a307065f2 100644 --- a/scripts/lib/wic/kickstart/custom_commands/partition.py +++ b/scripts/lib/wic/kickstart/custom_commands/partition.py | |||
| @@ -99,7 +99,7 @@ class Wic_PartData(Mic_PartData): | |||
| 99 | 99 | ||
| 100 | def get_extra_block_count(self, current_blocks): | 100 | def get_extra_block_count(self, current_blocks): |
| 101 | """ | 101 | """ |
| 102 | The --size param is reflected in self.size (in MB), and we already | 102 | The --size param is reflected in self.size (in kB), and we already |
| 103 | have current_blocks (1k) blocks, calculate and return the | 103 | have current_blocks (1k) blocks, calculate and return the |
| 104 | number of (1k) blocks we need to add to get to --size, 0 if | 104 | number of (1k) blocks we need to add to get to --size, 0 if |
| 105 | we're already there or beyond. | 105 | we're already there or beyond. |
| @@ -110,7 +110,7 @@ class Wic_PartData(Mic_PartData): | |||
| 110 | if not self.size: | 110 | if not self.size: |
| 111 | return 0 | 111 | return 0 |
| 112 | 112 | ||
| 113 | requested_blocks = self.size * 1024 | 113 | requested_blocks = self.size |
| 114 | 114 | ||
| 115 | msger.debug("Requested blocks %d, current_blocks %d" % \ | 115 | msger.debug("Requested blocks %d, current_blocks %d" % \ |
| 116 | (requested_blocks, current_blocks)) | 116 | (requested_blocks, current_blocks)) |
| @@ -171,7 +171,7 @@ class Wic_PartData(Mic_PartData): | |||
| 171 | Handle an already-created partition e.g. xxx.ext3 | 171 | Handle an already-created partition e.g. xxx.ext3 |
| 172 | """ | 172 | """ |
| 173 | rootfs = oe_builddir | 173 | rootfs = oe_builddir |
| 174 | du_cmd = "du -Lbms %s" % rootfs | 174 | du_cmd = "du -Lbks %s" % rootfs |
| 175 | out = exec_cmd(du_cmd) | 175 | out = exec_cmd(du_cmd) |
| 176 | rootfs_size = out.split()[0] | 176 | rootfs_size = out.split()[0] |
| 177 | 177 | ||
| @@ -247,8 +247,8 @@ class Wic_PartData(Mic_PartData): | |||
| 247 | print "rootfs_dir: %s" % rootfs_dir | 247 | print "rootfs_dir: %s" % rootfs_dir |
| 248 | msger.error("ERROR: mkfs.%s returned '%s' instead of 0 (which you probably don't want to ignore, use --debug for details) when creating filesystem from rootfs directory: %s" % (self.fstype, rc, rootfs_dir)) | 248 | msger.error("ERROR: mkfs.%s returned '%s' instead of 0 (which you probably don't want to ignore, use --debug for details) when creating filesystem from rootfs directory: %s" % (self.fstype, rc, rootfs_dir)) |
| 249 | 249 | ||
| 250 | # get the rootfs size in the right units for kickstart (Mb) | 250 | # get the rootfs size in the right units for kickstart (kB) |
| 251 | du_cmd = "du -Lbms %s" % rootfs | 251 | du_cmd = "du -Lbks %s" % rootfs |
| 252 | out = exec_cmd(du_cmd) | 252 | out = exec_cmd(du_cmd) |
| 253 | rootfs_size = out.split()[0] | 253 | rootfs_size = out.split()[0] |
| 254 | 254 | ||
| @@ -292,8 +292,8 @@ class Wic_PartData(Mic_PartData): | |||
| 292 | if rc: | 292 | if rc: |
| 293 | msger.error("ERROR: mkfs.%s returned '%s' instead of 0 (which you probably don't want to ignore, use --debug for details) when creating filesystem from rootfs directory: %s" % (self.fstype, rc, rootfs_dir)) | 293 | msger.error("ERROR: mkfs.%s returned '%s' instead of 0 (which you probably don't want to ignore, use --debug for details) when creating filesystem from rootfs directory: %s" % (self.fstype, rc, rootfs_dir)) |
| 294 | 294 | ||
| 295 | # get the rootfs size in the right units for kickstart (Mb) | 295 | # get the rootfs size in the right units for kickstart (kB) |
| 296 | du_cmd = "du -Lbms %s" % rootfs | 296 | du_cmd = "du -Lbks %s" % rootfs |
| 297 | out = exec_cmd(du_cmd) | 297 | out = exec_cmd(du_cmd) |
| 298 | rootfs_size = out.split()[0] | 298 | rootfs_size = out.split()[0] |
| 299 | 299 | ||
| @@ -341,8 +341,8 @@ class Wic_PartData(Mic_PartData): | |||
| 341 | chmod_cmd = "chmod 644 %s" % rootfs | 341 | chmod_cmd = "chmod 644 %s" % rootfs |
| 342 | exec_cmd(chmod_cmd) | 342 | exec_cmd(chmod_cmd) |
| 343 | 343 | ||
| 344 | # get the rootfs size in the right units for kickstart (Mb) | 344 | # get the rootfs size in the right units for kickstart (kB) |
| 345 | du_cmd = "du -Lbms %s" % rootfs | 345 | du_cmd = "du -Lbks %s" % rootfs |
| 346 | out = exec_cmd(du_cmd) | 346 | out = exec_cmd(du_cmd) |
| 347 | rootfs_size = out.split()[0] | 347 | rootfs_size = out.split()[0] |
| 348 | 348 | ||
| @@ -361,8 +361,8 @@ class Wic_PartData(Mic_PartData): | |||
| 361 | (image_rootfs, rootfs) | 361 | (image_rootfs, rootfs) |
| 362 | exec_native_cmd(pseudo + squashfs_cmd, native_sysroot) | 362 | exec_native_cmd(pseudo + squashfs_cmd, native_sysroot) |
| 363 | 363 | ||
| 364 | # get the rootfs size in the right units for kickstart (Mb) | 364 | # get the rootfs size in the right units for kickstart (kB) |
| 365 | du_cmd = "du -Lbms %s" % rootfs | 365 | du_cmd = "du -Lbks %s" % rootfs |
| 366 | out = exec_cmd(du_cmd) | 366 | out = exec_cmd(du_cmd) |
| 367 | rootfs_size = out.split()[0] | 367 | rootfs_size = out.split()[0] |
| 368 | 368 | ||
| @@ -395,7 +395,7 @@ class Wic_PartData(Mic_PartData): | |||
| 395 | """ | 395 | """ |
| 396 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) | 396 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) |
| 397 | 397 | ||
| 398 | dd_cmd = "dd if=/dev/zero of=%s bs=1M seek=%d count=0" % \ | 398 | dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \ |
| 399 | (fs, self.size) | 399 | (fs, self.size) |
| 400 | exec_cmd(dd_cmd) | 400 | exec_cmd(dd_cmd) |
| 401 | 401 | ||
| @@ -417,11 +417,11 @@ class Wic_PartData(Mic_PartData): | |||
| 417 | """ | 417 | """ |
| 418 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) | 418 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) |
| 419 | 419 | ||
| 420 | dd_cmd = "dd if=/dev/zero of=%s bs=1M seek=%d count=0" % \ | 420 | dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \ |
| 421 | (fs, self.size) | 421 | (fs, self.size) |
| 422 | exec_cmd(dd_cmd) | 422 | exec_cmd(dd_cmd) |
| 423 | 423 | ||
| 424 | mkfs_cmd = "mkfs.%s -b %d %s" % (self.fstype, self.size * 1024, rootfs) | 424 | mkfs_cmd = "mkfs.%s -b %d %s" % (self.fstype, self.size, rootfs) |
| 425 | (rc, out) = exec_native_cmd(mkfs_cmd, native_sysroot) | 425 | (rc, out) = exec_native_cmd(mkfs_cmd, native_sysroot) |
| 426 | if rc: | 426 | if rc: |
| 427 | msger.error("ERROR: mkfs.%s returned '%s' instead of 0 (which you probably don't want to ignore, use --debug for details)" % (self.fstype, rc)) | 427 | msger.error("ERROR: mkfs.%s returned '%s' instead of 0 (which you probably don't want to ignore, use --debug for details)" % (self.fstype, rc)) |
| @@ -442,7 +442,7 @@ class Wic_PartData(Mic_PartData): | |||
| 442 | """ | 442 | """ |
| 443 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) | 443 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) |
| 444 | 444 | ||
| 445 | blocks = self.size * 1024 | 445 | blocks = self.size |
| 446 | 446 | ||
| 447 | dosfs_cmd = "mkdosfs -n boot -S 512 -C %s %d" % (fs, blocks) | 447 | dosfs_cmd = "mkdosfs -n boot -S 512 -C %s %d" % (fs, blocks) |
| 448 | exec_native_cmd(dosfs_cmd, native_sysroot) | 448 | exec_native_cmd(dosfs_cmd, native_sysroot) |
| @@ -474,8 +474,8 @@ class Wic_PartData(Mic_PartData): | |||
| 474 | 474 | ||
| 475 | os.rmdir(tmpdir) | 475 | os.rmdir(tmpdir) |
| 476 | 476 | ||
| 477 | # get the rootfs size in the right units for kickstart (Mb) | 477 | # get the rootfs size in the right units for kickstart (kB) |
| 478 | du_cmd = "du -Lbms %s" % fs | 478 | du_cmd = "du -Lbks %s" % fs |
| 479 | out = exec_cmd(du_cmd) | 479 | out = exec_cmd(du_cmd) |
| 480 | fs_size = out.split()[0] | 480 | fs_size = out.split()[0] |
| 481 | 481 | ||
| @@ -490,7 +490,7 @@ class Wic_PartData(Mic_PartData): | |||
| 490 | """ | 490 | """ |
| 491 | fs = "%s/fs.%s" % (cr_workdir, self.fstype) | 491 | fs = "%s/fs.%s" % (cr_workdir, self.fstype) |
| 492 | 492 | ||
| 493 | dd_cmd = "dd if=/dev/zero of=%s bs=1M seek=%d count=0" % \ | 493 | dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \ |
| 494 | (fs, self.size) | 494 | (fs, self.size) |
| 495 | exec_cmd(dd_cmd) | 495 | exec_cmd(dd_cmd) |
| 496 | 496 | ||
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py index e4067b6dbf..ee57881e90 100644 --- a/scripts/lib/wic/plugins/source/bootimg-efi.py +++ b/scripts/lib/wic/plugins/source/bootimg-efi.py | |||
| @@ -228,7 +228,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
| 228 | chmod_cmd = "chmod 644 %s" % bootimg | 228 | chmod_cmd = "chmod 644 %s" % bootimg |
| 229 | exec_cmd(chmod_cmd) | 229 | exec_cmd(chmod_cmd) |
| 230 | 230 | ||
| 231 | du_cmd = "du -Lbms %s" % bootimg | 231 | du_cmd = "du -Lbks %s" % bootimg |
| 232 | out = exec_cmd(du_cmd) | 232 | out = exec_cmd(du_cmd) |
| 233 | bootimg_size = out.split()[0] | 233 | bootimg_size = out.split()[0] |
| 234 | 234 | ||
diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py index 8a1aca1ad1..c4786a6e0e 100644 --- a/scripts/lib/wic/plugins/source/bootimg-pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg-pcbios.py | |||
| @@ -190,7 +190,7 @@ class BootimgPcbiosPlugin(SourcePlugin): | |||
| 190 | chmod_cmd = "chmod 644 %s" % bootimg | 190 | chmod_cmd = "chmod 644 %s" % bootimg |
| 191 | exec_cmd(chmod_cmd) | 191 | exec_cmd(chmod_cmd) |
| 192 | 192 | ||
| 193 | du_cmd = "du -Lbms %s" % bootimg | 193 | du_cmd = "du -Lbks %s" % bootimg |
| 194 | out = exec_cmd(du_cmd) | 194 | out = exec_cmd(du_cmd) |
| 195 | bootimg_size = out.split()[0] | 195 | bootimg_size = out.split()[0] |
| 196 | 196 | ||
diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py index 9df93dca2f..c72bb29b02 100644 --- a/scripts/lib/wic/utils/partitionedfs.py +++ b/scripts/lib/wic/utils/partitionedfs.py | |||
| @@ -92,8 +92,8 @@ class Image: | |||
| 92 | 92 | ||
| 93 | ks_pnum = len(self.partitions) | 93 | ks_pnum = len(self.partitions) |
| 94 | 94 | ||
| 95 | # Converting MB to sectors for parted | 95 | # Converting kB to sectors for parted |
| 96 | size = size * 1024 * 1024 / self.sector_size | 96 | size = size * 1024 / self.sector_size |
| 97 | 97 | ||
| 98 | # We still need partition for "/" or non-subvolume | 98 | # We still need partition for "/" or non-subvolume |
| 99 | if mountpoint == "/" or not fsopts: | 99 | if mountpoint == "/" or not fsopts: |
