summaryrefslogtreecommitdiff
path: root/meta-phosphor/classes
diff options
context:
space:
mode:
Diffstat (limited to 'meta-phosphor/classes')
-rw-r--r--meta-phosphor/classes/image_types_phosphor.bbclass101
-rw-r--r--meta-phosphor/classes/obmc-phosphor-image.bbclass8
-rw-r--r--meta-phosphor/classes/obmc-phosphor-python3-autotools.bbclass17
-rw-r--r--meta-phosphor/classes/phosphor-networkd-rev.bbclass2
-rw-r--r--meta-phosphor/classes/skeleton-rev.bbclass2
5 files changed, 126 insertions, 4 deletions
diff --git a/meta-phosphor/classes/image_types_phosphor.bbclass b/meta-phosphor/classes/image_types_phosphor.bbclass
index e29f4ff47..10388d257 100644
--- a/meta-phosphor/classes/image_types_phosphor.bbclass
+++ b/meta-phosphor/classes/image_types_phosphor.bbclass
@@ -19,15 +19,19 @@ FLASH_UBI_OVERLAY_BASETYPE ?= "ubifs"
FLASH_EXT4_BASETYPE ?= "ext4"
FLASH_EXT4_OVERLAY_BASETYPE ?= "ext4"
-IMAGE_TYPES += "mtd-static mtd-static-alltar mtd-static-tar mtd-ubi mtd-ubi-tar mmc-ext4-tar"
+IMAGE_TYPES += "mtd-static mtd-static-alltar mtd-static-tar mtd-ubi mtd-ubi-tar mmc-verity mmc-ext4-tar"
IMAGE_TYPEDEP_mtd-static = "${IMAGE_BASETYPE}"
IMAGE_TYPEDEP_mtd-static-tar = "${IMAGE_BASETYPE}"
IMAGE_TYPEDEP_mtd-static-alltar = "mtd-static"
IMAGE_TYPEDEP_mtd-ubi = "${FLASH_UBI_BASETYPE}"
IMAGE_TYPEDEP_mtd-ubi-tar = "${FLASH_UBI_BASETYPE}"
+IMAGE_TYPEDEP_mmc-verity = "${FLASH_EXT4_BASETYPE}"
IMAGE_TYPEDEP_mmc-ext4-tar = "${FLASH_EXT4_BASETYPE}"
-IMAGE_TYPES_MASKED += "mtd-static mtd-static-alltar mtd-static-tar mtd-ubi mtd-ubi-tar mmc-ext4-tar"
+IMAGE_TYPES_MASKED += "mtd-static mtd-static-alltar mtd-static-tar mtd-ubi mtd-ubi-tar mmc-verity mmc-ext4-tar"
+
+IMAGE_BLOCK_SIZE ?= "4096"
+EXTRA_IMAGECMD_ext4 = "-b ${IMAGE_BLOCK_SIZE}"
# Flash characteristics in KB unless otherwise noted
DISTROOVERRIDES .= ":flash-${FLASH_SIZE}"
@@ -216,6 +220,95 @@ do_make_ubi[depends] += " \
mtd-utils-native:do_populate_sysroot \
"
+python do_generate_mmc_verity() {
+ import os
+ import subprocess
+
+ rootfs_image = os.path.join(d.getVar('IMGDEPLOYDIR', True),
+ '%s.%s' % (
+ d.getVar('IMAGE_LINK_NAME', True),
+ d.getVar('FLASH_EXT4_BASETYPE', True)))
+
+ verity_image = 'verity-%s.%s' % (
+ d.getVar('IMAGE_LINK_NAME', True),
+ d.getVar('FLASH_EXT4_BASETYPE', True))
+
+ subprocess.check_call(['dd',
+ 'if=%s' % rootfs_image,
+ 'of=%s' % verity_image])
+
+ # dm-verity values
+ sector_size = 512
+ block_size = int(d.getVar('IMAGE_BLOCK_SIZE', True))
+ verity_algo = "sha256"
+ rootfs_image_size = os.stat(rootfs_image).st_size
+
+ def align_up(number, boundary):
+ return ((number + (boundary - 1)) // boundary) * boundary
+
+ # verity metadata must be aligned on the block boundary subsequent to the
+ # end of the data
+ verity_hash_offset = align_up(rootfs_image_size, block_size)
+
+ verity_hash_blocks = verity_hash_offset // block_size
+
+ # the output of 'veritysetup format' looks like:
+ # VERITY header information for obmc-phosphor-image-witherspoon.squashfs-xz
+ # UUID: 269b5934-de5b-45b0-99a3-56b219a7b544
+ # Hash type: 1
+ # Data blocks: 4523
+ # Data block size: 4096
+ # Hash block size: 4096
+ # Hash algorithm: sha256
+ # Salt: 8fca9eff342fc0cf2964057257ea80813a223cb2e540a38458142edeb190e12e
+ # Root hash: 38ef00d23fa89300dcf66e7494d25246d03bf846b4119b34e7b1587c0b6fe1d9
+ verity_hash_file = "verity-hash-verification-data"
+ with open(verity_hash_file, 'w') as f:
+ subprocess.check_call(['veritysetup',
+ 'format',
+ '--hash=%s'% verity_algo,
+ '--data-block-size=%i' % block_size,
+ '--hash-block-size=%i' % block_size,
+ '--hash-offset=%i' % verity_hash_offset,
+ '%s' % verity_image,
+ '%s' % verity_image], stdout=f, stderr=f)
+
+ for line in open(verity_hash_file, "r"):
+ if "Salt" in line:
+ verity_salt = line.split()[-1]
+ if "Root" in line:
+ verity_root = line.split()[-1]
+
+ verity_image_size = os.stat(verity_image).st_size
+
+ # Make an appropriately sized image for MMC
+ mmc_image_name = "%s.mmc" % d.getVar('IMAGE_NAME', True)
+ mmc_image_path = os.path.join(d.getVar('IMGDEPLOYDIR', True),
+ '%s' % mmc_image_name)
+
+ # CSD size accommodates MMC limitations that are relevant to QEMU
+ csd_size = (1 << (9 + 9 - 1 + 2))
+
+ with open(mmc_image_path, 'w') as fd:
+ os.posix_fallocate(fd.fileno(), 0, align_up(verity_image_size, csd_size))
+ subprocess.check_call(['dd',
+ 'if=%s' % verity_image,
+ 'of=%s' % mmc_image_path,
+ 'conv=notrunc'])
+
+ os.chdir("%s" % d.getVar('IMGDEPLOYDIR', True))
+ mmc_link_name = os.path.join(d.getVar('IMGDEPLOYDIR', True),
+ '%s.mmc' % d.getVar('IMAGE_LINK_NAME', True))
+ if os.path.lexists(mmc_link_name):
+ os.remove(mmc_link_name)
+ os.symlink(mmc_image_name, mmc_link_name)
+}
+do_generate_mmc_verity[dirs] = "${S}/mmc"
+do_generate_mmc_verity[depends] += " \
+ ${PN}:do_image_${FLASH_EXT4_BASETYPE} \
+ cryptsetup-native:do_populate_sysroot \
+ "
+
do_mk_static_nor_image() {
# Assemble the flash image
mk_empty_image ${IMGDEPLOYDIR}/${IMAGE_NAME}.static.mtd ${FLASH_SIZE}
@@ -483,6 +576,10 @@ python() {
'do_image_complete',
'do_generate_rwfs_ubi do_generate_phosphor_manifest', d)
+ if 'mmc-verity' in types:
+ bb.build.addtask(
+ 'do_generate_mmc_verity',
+ 'do_image_complete','', d)
if 'mmc-ext4-tar' in types:
bb.build.addtask(
'do_generate_ext4_tar',
diff --git a/meta-phosphor/classes/obmc-phosphor-image.bbclass b/meta-phosphor/classes/obmc-phosphor-image.bbclass
index b428205ab..8ce0acd52 100644
--- a/meta-phosphor/classes/obmc-phosphor-image.bbclass
+++ b/meta-phosphor/classes/obmc-phosphor-image.bbclass
@@ -105,6 +105,14 @@ remove_etc_version() {
}
ROOTFS_POSTPROCESS_COMMAND += "remove_etc_version ; "
+# Disable the pager to prevent systemd injecting control characters into the
+# output stream that are not interpreted by busybox tools.
+disable_systemd_pager() {
+ echo "SYSTEMD_PAGER=" >> ${IMAGE_ROOTFS}${sysconfdir}/profile
+ echo "export SYSTEMD_PAGER" >> ${IMAGE_ROOTFS}${sysconfdir}/profile
+}
+ROOTFS_POSTPROCESS_COMMAND += "disable_systemd_pager ; "
+
# The shadow recipe provides the binaries(like useradd, usermod) needed by the
# phosphor-user-manager.
ROOTFS_RO_UNNEEDED_remove = "shadow"
diff --git a/meta-phosphor/classes/obmc-phosphor-python3-autotools.bbclass b/meta-phosphor/classes/obmc-phosphor-python3-autotools.bbclass
new file mode 100644
index 000000000..d76598a36
--- /dev/null
+++ b/meta-phosphor/classes/obmc-phosphor-python3-autotools.bbclass
@@ -0,0 +1,17 @@
+inherit obmc-phosphor-utils
+inherit python3native
+
+DEPENDS += "python3"
+
+export BUILD_SYS
+export HOST_SYS
+export STAGING_INCDIR
+export STAGING_LIBDIR
+
+PYTHON_AUTOTOOLS_PACKAGE ?= "${PN}"
+
+python() {
+ for pkg in listvar_to_list(d, 'PYTHON_AUTOTOOLS_PACKAGE'):
+ set_append(d, 'FILES_%s' % pkg,
+ d.getVar('PYTHON_SITEPACKAGES_DIR', True))
+}
diff --git a/meta-phosphor/classes/phosphor-networkd-rev.bbclass b/meta-phosphor/classes/phosphor-networkd-rev.bbclass
index 1c8a01a6c..378d2020c 100644
--- a/meta-phosphor/classes/phosphor-networkd-rev.bbclass
+++ b/meta-phosphor/classes/phosphor-networkd-rev.bbclass
@@ -1,2 +1,2 @@
SRC_URI += "git://github.com/openbmc/phosphor-networkd"
-SRCREV = "cb42fe26febc9e457a9c4279278bd8c85f60851a"
+SRCREV = "dbd328d7e037b1af13fb0f20f3708e2261b9e0b6"
diff --git a/meta-phosphor/classes/skeleton-rev.bbclass b/meta-phosphor/classes/skeleton-rev.bbclass
index 181a892fd..4ae3c03a9 100644
--- a/meta-phosphor/classes/skeleton-rev.bbclass
+++ b/meta-phosphor/classes/skeleton-rev.bbclass
@@ -1,4 +1,4 @@
-SRCREV ?= "c8334f3258cb80839e49defe386d33c196929215"
+SRCREV ?= "1146f8c6e5f955fb10f5e846de31052be942a7f2"
SKELETON_URI ?= "git://github.com/openbmc/skeleton"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${WORKDIR}/git/LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"