summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/partition.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/wic/partition.py')
-rw-r--r--scripts/lib/wic/partition.py52
1 files changed, 32 insertions, 20 deletions
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index 795707ec5d..b34691d313 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -164,6 +164,9 @@ class Partition():
164 164
165 plugins = PluginMgr.get_plugins('source') 165 plugins = PluginMgr.get_plugins('source')
166 166
167 # Don't support '-' in plugin names
168 self.source = self.source.replace("-", "_")
169
167 if self.source not in plugins: 170 if self.source not in plugins:
168 raise WicError("The '%s' --source specified for %s doesn't exist.\n\t" 171 raise WicError("The '%s' --source specified for %s doesn't exist.\n\t"
169 "See 'wic list source-plugins' for a list of available" 172 "See 'wic list source-plugins' for a list of available"
@@ -178,7 +181,7 @@ class Partition():
178 splitted = self.sourceparams.split(',') 181 splitted = self.sourceparams.split(',')
179 srcparams_dict = dict((par.split('=', 1) + [None])[:2] for par in splitted if par) 182 srcparams_dict = dict((par.split('=', 1) + [None])[:2] for par in splitted if par)
180 183
181 plugin = PluginMgr.get_plugins('source')[self.source] 184 plugin = plugins[self.source]
182 plugin.do_configure_partition(self, srcparams_dict, creator, 185 plugin.do_configure_partition(self, srcparams_dict, creator,
183 cr_workdir, oe_builddir, bootimg_dir, 186 cr_workdir, oe_builddir, bootimg_dir,
184 kernel_dir, native_sysroot) 187 kernel_dir, native_sysroot)
@@ -222,19 +225,19 @@ class Partition():
222 if (pseudo_dir): 225 if (pseudo_dir):
223 # Canonicalize the ignore paths. This corresponds to 226 # Canonicalize the ignore paths. This corresponds to
224 # calling oe.path.canonicalize(), which is used in bitbake.conf. 227 # calling oe.path.canonicalize(), which is used in bitbake.conf.
225 ignore_paths = [rootfs] + (get_bitbake_var("PSEUDO_IGNORE_PATHS") or "").split(",") 228 include_paths = [rootfs_dir] + (get_bitbake_var("PSEUDO_INCLUDE_PATHS") or "").split(",")
226 canonical_paths = [] 229 canonical_paths = []
227 for path in ignore_paths: 230 for path in include_paths:
228 if "$" not in path: 231 if "$" not in path:
229 trailing_slash = path.endswith("/") and "/" or "" 232 trailing_slash = path.endswith("/") and "/" or ""
230 canonical_paths.append(os.path.realpath(path) + trailing_slash) 233 canonical_paths.append(os.path.realpath(path) + trailing_slash)
231 ignore_paths = ",".join(canonical_paths) 234 include_paths = ",".join(canonical_paths)
232 235
233 pseudo = "export PSEUDO_PREFIX=%s;" % p_prefix 236 pseudo = "export PSEUDO_PREFIX=%s;" % p_prefix
234 pseudo += "export PSEUDO_LOCALSTATEDIR=%s;" % pseudo_dir 237 pseudo += "export PSEUDO_LOCALSTATEDIR=%s;" % pseudo_dir
235 pseudo += "export PSEUDO_PASSWD=%s;" % rootfs_dir 238 pseudo += "export PSEUDO_PASSWD=%s;" % rootfs_dir
236 pseudo += "export PSEUDO_NOSYMLINKEXP=1;" 239 pseudo += "export PSEUDO_NOSYMLINKEXP=1;"
237 pseudo += "export PSEUDO_IGNORE_PATHS=%s;" % ignore_paths 240 pseudo += "export PSEUDO_INCLUDE_PATHS=%s;" % include_paths
238 pseudo += "%s " % get_bitbake_var("FAKEROOTCMD") 241 pseudo += "%s " % get_bitbake_var("FAKEROOTCMD")
239 else: 242 else:
240 pseudo = None 243 pseudo = None
@@ -244,7 +247,7 @@ class Partition():
244 # from bitbake variable 247 # from bitbake variable
245 rsize_bb = get_bitbake_var('ROOTFS_SIZE') 248 rsize_bb = get_bitbake_var('ROOTFS_SIZE')
246 rdir = get_bitbake_var('IMAGE_ROOTFS') 249 rdir = get_bitbake_var('IMAGE_ROOTFS')
247 if rsize_bb and rdir == rootfs_dir: 250 if rsize_bb and (rdir == rootfs_dir or (rootfs_dir.split('/')[-2] == "tmp-wic" and rootfs_dir.split('/')[-1][:6] == "rootfs")):
248 # Bitbake variable ROOTFS_SIZE is calculated in 251 # Bitbake variable ROOTFS_SIZE is calculated in
249 # Image._get_rootfs_size method from meta/lib/oe/image.py 252 # Image._get_rootfs_size method from meta/lib/oe/image.py
250 # using IMAGE_ROOTFS_SIZE, IMAGE_ROOTFS_ALIGNMENT, 253 # using IMAGE_ROOTFS_SIZE, IMAGE_ROOTFS_ALIGNMENT,
@@ -284,19 +287,8 @@ class Partition():
284 287
285 extraopts = self.mkfs_extraopts or "-F -i 8192" 288 extraopts = self.mkfs_extraopts or "-F -i 8192"
286 289
287 if os.getenv('SOURCE_DATE_EPOCH'): 290 # use hash_seed to generate reproducible ext4 images
288 sde_time = int(os.getenv('SOURCE_DATE_EPOCH')) 291 (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts, pseudo)
289 if pseudo:
290 pseudo = "export E2FSPROGS_FAKE_TIME=%s;%s " % (sde_time, pseudo)
291 else:
292 pseudo = "export E2FSPROGS_FAKE_TIME=%s; " % sde_time
293
294 # Set hash_seed to generate deterministic directory indexes
295 namespace = uuid.UUID("e7429877-e7b3-4a68-a5c9-2f2fdf33d460")
296 if self.fsuuid:
297 namespace = uuid.UUID(self.fsuuid)
298 hash_seed = str(uuid.uuid5(namespace, str(sde_time)))
299 extraopts += " -E hash_seed=%s" % hash_seed
300 292
301 label_str = "" 293 label_str = ""
302 if self.label: 294 if self.label:
@@ -344,6 +336,23 @@ class Partition():
344 336
345 self.check_for_Y2038_problem(rootfs, native_sysroot) 337 self.check_for_Y2038_problem(rootfs, native_sysroot)
346 338
339 def get_hash_seed_ext4(self, extraopts, pseudo):
340 if os.getenv('SOURCE_DATE_EPOCH'):
341 sde_time = int(os.getenv('SOURCE_DATE_EPOCH'))
342 if pseudo:
343 pseudo = "export E2FSPROGS_FAKE_TIME=%s;%s " % (sde_time, pseudo)
344 else:
345 pseudo = "export E2FSPROGS_FAKE_TIME=%s; " % sde_time
346
347 # Set hash_seed to generate deterministic directory indexes
348 namespace = uuid.UUID("e7429877-e7b3-4a68-a5c9-2f2fdf33d460")
349 if self.fsuuid:
350 namespace = uuid.UUID(self.fsuuid)
351 hash_seed = str(uuid.uuid5(namespace, str(sde_time)))
352 extraopts += " -E hash_seed=%s" % hash_seed
353
354 return (extraopts, pseudo)
355
347 def prepare_rootfs_btrfs(self, rootfs, cr_workdir, oe_builddir, rootfs_dir, 356 def prepare_rootfs_btrfs(self, rootfs, cr_workdir, oe_builddir, rootfs_dir,
348 native_sysroot, pseudo): 357 native_sysroot, pseudo):
349 """ 358 """
@@ -437,13 +446,16 @@ class Partition():
437 446
438 extraopts = self.mkfs_extraopts or "-i 8192" 447 extraopts = self.mkfs_extraopts or "-i 8192"
439 448
449 # use hash_seed to generate reproducible ext4 images
450 (extraopts, pseudo) = self.get_hash_seed_ext4(extraopts, None)
451
440 label_str = "" 452 label_str = ""
441 if self.label: 453 if self.label:
442 label_str = "-L %s" % self.label 454 label_str = "-L %s" % self.label
443 455
444 mkfs_cmd = "mkfs.%s -F %s %s -U %s %s" % \ 456 mkfs_cmd = "mkfs.%s -F %s %s -U %s %s" % \
445 (self.fstype, extraopts, label_str, self.fsuuid, rootfs) 457 (self.fstype, extraopts, label_str, self.fsuuid, rootfs)
446 exec_native_cmd(mkfs_cmd, native_sysroot) 458 exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
447 459
448 self.check_for_Y2038_problem(rootfs, native_sysroot) 460 self.check_for_Y2038_problem(rootfs, native_sysroot)
449 461