Skip to content

Commit

Permalink
wip: use commit sha for uuid
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Langowski <pawel.langowski@3mdeb.com>
  • Loading branch information
PLangowski committed Feb 21, 2025
1 parent 8e6f8b6 commit 6615c93
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions meta-dts-distro/recipes-dts/images/dts-base-image.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ IMAGE_INSTALL:append = " \
lshw \
"

LAYER_COMMIT_SHA = "${@'$(cd ${LAYERDIR} && git rev-parse HEAD)'}"

# Enable local auto-login of the root user (local = serial port and
# virtual console)
DTS_LOCAL_GETTY ?= " \
Expand All @@ -32,3 +34,17 @@ local_autologin () {
}

ROOTFS_POSTPROCESS_COMMAND += "local_autologin; "

python do_rootfs_wicenv:append() {
import hashlib, uuid
commit_sha = d.getVar('LAYER_COMMIT_SHA')
boot_sha = "boot-" + commit_sha
uuid_root = uuid.UUID(hashlib.md5(commit_sha.encode()).hexdigest())
uuid_boot = uuid.UUID(hashlib.md5(boot_sha.encode()).hexdigest())
with open(os.path.join(outdir, basename) + '.env', 'a') as envf:
envf.write('ROOT_UUID="%s"\n' % uuid_root)
envf.write('BOOT_UUID="%s"\n' % uuid_boot)
envf.close()
bb.utils.copyfile(os.path.join(outdir, basename) + '.env', os.path.join(depdir, basename) + '.env')

}
4 changes: 2 additions & 2 deletions meta-dts-distro/wic/usb-stick-dts.wks.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bootloader --timeout=0 --append=" rootwait"

part /boot --source bootimg-biosplusefi --sourceparams="loader=grub-efi" --ondisk sda --label dts-boot --align 1024 --use-uuid --active --system-id 0xef
part / --source rootfs --fstype=ext4 --ondisk sda --label dts-root --align 1024 --use-uuid --fixed-size 1024
part /boot --source bootimg-biosplusefi --sourceparams="loader=grub-efi" --ondisk sda --label dts-boot --align 1024 --uuid ${BOOT_UUID} --active --system-id 0xef
part / --source rootfs --fstype=ext4 --ondisk sda --label dts-root --align 1024 --uuid ${ROOT_UUID} --fixed-size 1024

0 comments on commit 6615c93

Please sign in to comment.