summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/lib/mic/kickstart/custom_commands/partition.py57
-rw-r--r--scripts/lib/mic/plugins/source/bootimg-efi.py10
-rw-r--r--scripts/lib/mic/plugins/source/bootimg-pcbios.py10
-rw-r--r--scripts/lib/mic/utils/oe/misc.py1
4 files changed, 68 insertions, 10 deletions
diff --git a/scripts/lib/mic/kickstart/custom_commands/partition.py b/scripts/lib/mic/kickstart/custom_commands/partition.py
index 4974a87d93..91d751eb16 100644
--- a/scripts/lib/mic/kickstart/custom_commands/partition.py
+++ b/scripts/lib/mic/kickstart/custom_commands/partition.py
@@ -56,6 +56,12 @@ class Wic_PartData(Mic_PartData):
56 56
57 return retval 57 return retval
58 58
59 def get_size(self):
60 """
61 Accessor for partition size, 0 or --size before set_size().
62 """
63 return self.size
64
59 def set_size(self, size): 65 def set_size(self, size):
60 """ 66 """
61 Accessor for actual partition size, which must be set by source 67 Accessor for actual partition size, which must be set by source
@@ -70,6 +76,29 @@ class Wic_PartData(Mic_PartData):
70 """ 76 """
71 self.source_file = source_file 77 self.source_file = source_file
72 78
79 def get_extra_block_count(self, current_blocks):
80 """
81 The --size param is reflected in self.size (in MB), and we already
82 have current_blocks (1k) blocks, calculate and return the
83 number of (1k) blocks we need to add to get to --size, 0 if
84 we're already there or beyond.
85 """
86 msger.debug("Requested partition size for %s: %d" % \
87 (self.mountpoint, self.size))
88
89 if not self.size:
90 return 0
91
92 requested_blocks = self.size * 1024
93
94 msger.debug("Requested blocks %d, current_blocks %d" % \
95 (requested_blocks, current_blocks))
96
97 if requested_blocks > current_blocks:
98 return requested_blocks - current_blocks
99 else:
100 return 0
101
73 def prepare(self, cr, cr_workdir, oe_builddir, rootfs_dir, bootimg_dir, 102 def prepare(self, cr, cr_workdir, oe_builddir, rootfs_dir, bootimg_dir,
74 kernel_dir, native_sysroot): 103 kernel_dir, native_sysroot):
75 """ 104 """
@@ -147,16 +176,22 @@ class Wic_PartData(Mic_PartData):
147 """ 176 """
148 populate_script = "%s/usr/bin/populate-extfs.sh" % native_sysroot 177 populate_script = "%s/usr/bin/populate-extfs.sh" % native_sysroot
149 178
150 image_extra_space = 10240
151
152 image_rootfs = rootfs_dir 179 image_rootfs = rootfs_dir
153 rootfs = "%s/rootfs.%s" % (cr_workdir, self.fstype) 180 rootfs = "%s/rootfs.%s" % (cr_workdir, self.fstype)
154 181
155 du_cmd = "du -ks %s" % image_rootfs 182 du_cmd = "du -ks %s" % image_rootfs
156 rc, out = exec_cmd(du_cmd) 183 rc, out = exec_cmd(du_cmd)
157 actual_rootfs_size = out.split()[0] 184 actual_rootfs_size = int(out.split()[0])
185
186 extra_blocks = self.get_extra_block_count(actual_rootfs_size)
187
188 if extra_blocks < IMAGE_EXTRA_SPACE:
189 extra_blocks = IMAGE_EXTRA_SPACE
190
191 rootfs_size = actual_rootfs_size + extra_blocks
158 192
159 rootfs_size = int(actual_rootfs_size) + image_extra_space 193 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
194 (extra_blocks, self.mountpoint, rootfs_size))
160 195
161 dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=0 bs=1k" % \ 196 dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=0 bs=1k" % \
162 (rootfs, rootfs_size) 197 (rootfs, rootfs_size)
@@ -187,16 +222,22 @@ class Wic_PartData(Mic_PartData):
187 222
188 Currently handles ext2/3/4 and btrfs. 223 Currently handles ext2/3/4 and btrfs.
189 """ 224 """
190 image_extra_space = 10240
191
192 image_rootfs = rootfs_dir 225 image_rootfs = rootfs_dir
193 rootfs = "%s/rootfs.%s" % (cr_workdir, self.fstype) 226 rootfs = "%s/rootfs.%s" % (cr_workdir, self.fstype)
194 227
195 du_cmd = "du -ks %s" % image_rootfs 228 du_cmd = "du -ks %s" % image_rootfs
196 rc, out = exec_cmd(du_cmd) 229 rc, out = exec_cmd(du_cmd)
197 actual_rootfs_size = out.split()[0] 230 actual_rootfs_size = int(out.split()[0])
231
232 extra_blocks = self.get_extra_block_count(actual_rootfs_size)
233
234 if extra_blocks < IMAGE_EXTRA_SPACE:
235 extra_blocks = IMAGE_EXTRA_SPACE
236
237 rootfs_size = actual_rootfs_size + extra_blocks
198 238
199 rootfs_size = int(actual_rootfs_size) + image_extra_space 239 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
240 (extra_blocks, self.mountpoint, rootfs_size))
200 241
201 dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=0 bs=1k" % \ 242 dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=0 bs=1k" % \
202 (rootfs, rootfs_size) 243 (rootfs, rootfs_size)
diff --git a/scripts/lib/mic/plugins/source/bootimg-efi.py b/scripts/lib/mic/plugins/source/bootimg-efi.py
index 3e0997bacf..1974b062b2 100644
--- a/scripts/lib/mic/plugins/source/bootimg-efi.py
+++ b/scripts/lib/mic/plugins/source/bootimg-efi.py
@@ -131,7 +131,15 @@ class BootimgEFIPlugin(SourcePlugin):
131 rc, out = exec_cmd(du_cmd) 131 rc, out = exec_cmd(du_cmd)
132 blocks = int(out.split()[0]) 132 blocks = int(out.split()[0])
133 133
134 blocks += BOOTDD_EXTRA_SPACE 134 extra_blocks = part.get_extra_block_count(blocks)
135
136 if extra_blocks < BOOTDD_EXTRA_SPACE:
137 extra_blocks = BOOTDD_EXTRA_SPACE
138
139 blocks += extra_blocks
140
141 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
142 (extra_blocks, part.mountpoint, blocks))
135 143
136 # Ensure total sectors is an integral number of sectors per 144 # Ensure total sectors is an integral number of sectors per
137 # track or mcopy will complain. Sectors are 512 bytes, and we 145 # track or mcopy will complain. Sectors are 512 bytes, and we
diff --git a/scripts/lib/mic/plugins/source/bootimg-pcbios.py b/scripts/lib/mic/plugins/source/bootimg-pcbios.py
index 3cd446f052..fad150f940 100644
--- a/scripts/lib/mic/plugins/source/bootimg-pcbios.py
+++ b/scripts/lib/mic/plugins/source/bootimg-pcbios.py
@@ -154,7 +154,15 @@ class BootimgPcbiosPlugin(SourcePlugin):
154 rc, out = exec_cmd(du_cmd) 154 rc, out = exec_cmd(du_cmd)
155 blocks = int(out.split()[0]) 155 blocks = int(out.split()[0])
156 156
157 blocks += BOOTDD_EXTRA_SPACE 157 extra_blocks = part.get_extra_block_count(blocks)
158
159 if extra_blocks < BOOTDD_EXTRA_SPACE:
160 extra_blocks = BOOTDD_EXTRA_SPACE
161
162 blocks += extra_blocks
163
164 msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
165 (extra_blocks, part.mountpoint, blocks))
158 166
159 # Ensure total sectors is an integral number of sectors per 167 # Ensure total sectors is an integral number of sectors per
160 # track or mcopy will complain. Sectors are 512 bytes, and we 168 # track or mcopy will complain. Sectors are 512 bytes, and we
diff --git a/scripts/lib/mic/utils/oe/misc.py b/scripts/lib/mic/utils/oe/misc.py
index 77dfe03630..6b01955a88 100644
--- a/scripts/lib/mic/utils/oe/misc.py
+++ b/scripts/lib/mic/utils/oe/misc.py
@@ -108,6 +108,7 @@ def add_wks_var(key, val):
108 wks_vars[key] = val 108 wks_vars[key] = val
109 109
110BOOTDD_EXTRA_SPACE = 16384 110BOOTDD_EXTRA_SPACE = 16384
111IMAGE_EXTRA_SPACE = 10240
111 112
112__bitbake_env_lines = "" 113__bitbake_env_lines = ""
113 114