Initial commit
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
dbus_system_confdir="${datadir}/dbus-1/system.d/"
|
||||
dbus_system_servicesdir="${datadir}/dbus-1/system-services/"
|
||||
@@ -0,0 +1,685 @@
|
||||
inherit uboot-config
|
||||
|
||||
CONVERSIONTYPES += "fitImage"
|
||||
|
||||
CONVERSION_CMD:fitImage = "run_assemble_fitimage ${IMAGE_NAME}.${type}"
|
||||
INITRAMFS_IMAGE="${IMAGE_NAME}.cpio.${INITRAMFS_CTYPE}"
|
||||
KERNEL_OUTPUT_DIR="${DEPLOY_DIR_IMAGE}"
|
||||
|
||||
do_image_cpio[depends] += "virtual/kernel:do_deploy"
|
||||
|
||||
run_assemble_fitimage() {
|
||||
export linux_comp="none"
|
||||
fitimage_assemble $1.its $1.fitImage 1
|
||||
|
||||
# The fitimage_assemble puts the image into DEPLOY_DIR_NAME due to
|
||||
# KERNEL_OUTPUT_DIR, but we really want it still in ${IMGDEPLOYDIR}, so
|
||||
# move it.
|
||||
mv ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}.fitImage .
|
||||
# Delete the spurious linux.bin created by our stubbed uboot_prep_kimage.
|
||||
rm linux.bin
|
||||
}
|
||||
|
||||
UBOOT_MKIMAGE_KERNEL_TYPE ?= "kernel"
|
||||
uboot_prep_kimage() {
|
||||
cp ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} linux.bin
|
||||
}
|
||||
|
||||
DEPENDS:append = " u-boot-tools-native dtc-native virtual/${TARGET_PREFIX}binutils"
|
||||
|
||||
# Description string
|
||||
FIT_DESC ?= "Kernel fitImage for ${DISTRO_NAME}/${PV}/${MACHINE}"
|
||||
|
||||
# Kernel fitImage Hash Algo
|
||||
FIT_HASH_ALG ?= "sha256"
|
||||
|
||||
# Kernel fitImage Signature Algo
|
||||
FIT_SIGN_ALG ?= "rsa2048"
|
||||
|
||||
# Kernel / U-Boot fitImage Padding Algo
|
||||
FIT_PAD_ALG ?= "pkcs-1.5"
|
||||
|
||||
# Generate keys for signing Kernel fitImage
|
||||
FIT_GENERATE_KEYS ?= "0"
|
||||
|
||||
# Size of private keys in number of bits
|
||||
FIT_SIGN_NUMBITS ?= "2048"
|
||||
|
||||
# args to openssl genrsa (Default is just the public exponent)
|
||||
FIT_KEY_GENRSA_ARGS ?= "-F4"
|
||||
|
||||
# args to openssl req (Default is -batch for non interactive mode and
|
||||
# -new for new certificate)
|
||||
FIT_KEY_REQ_ARGS ?= "-batch -new"
|
||||
|
||||
# Standard format for public key certificate
|
||||
FIT_KEY_SIGN_PKCS ?= "-x509"
|
||||
|
||||
# Sign individual images as well
|
||||
FIT_SIGN_INDIVIDUAL ?= "0"
|
||||
|
||||
FIT_CONF_PREFIX ?= "conf-"
|
||||
FIT_CONF_PREFIX[doc] = "Prefix to use for FIT configuration node name"
|
||||
|
||||
FIT_SUPPORTED_INITRAMFS_FSTYPES ?= "cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst cpio.gz ext2.gz cpio"
|
||||
|
||||
#
|
||||
# Emit the fitImage ITS header
|
||||
#
|
||||
# $1 ... .its filename
|
||||
fitimage_emit_fit_header() {
|
||||
cat << EOF >> $1
|
||||
/dts-v1/;
|
||||
|
||||
/ {
|
||||
description = "${FIT_DESC}";
|
||||
#address-cells = <1>;
|
||||
EOF
|
||||
}
|
||||
|
||||
#
|
||||
# Emit the fitImage section bits
|
||||
#
|
||||
# $1 ... .its filename
|
||||
# $2 ... Section bit type: imagestart - image section start
|
||||
# confstart - configuration section start
|
||||
# sectend - section end
|
||||
# fitend - fitimage end
|
||||
#
|
||||
fitimage_emit_section_maint() {
|
||||
case $2 in
|
||||
imagestart)
|
||||
cat << EOF >> $1
|
||||
|
||||
images {
|
||||
EOF
|
||||
;;
|
||||
confstart)
|
||||
cat << EOF >> $1
|
||||
|
||||
configurations {
|
||||
EOF
|
||||
;;
|
||||
sectend)
|
||||
cat << EOF >> $1
|
||||
};
|
||||
EOF
|
||||
;;
|
||||
fitend)
|
||||
cat << EOF >> $1
|
||||
};
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Emit the fitImage ITS kernel section
|
||||
#
|
||||
# $1 ... .its filename
|
||||
# $2 ... Image counter
|
||||
# $3 ... Path to kernel image
|
||||
# $4 ... Compression type
|
||||
fitimage_emit_section_kernel() {
|
||||
|
||||
kernel_csum="${FIT_HASH_ALG}"
|
||||
kernel_sign_algo="${FIT_SIGN_ALG}"
|
||||
kernel_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}"
|
||||
|
||||
ENTRYPOINT="${UBOOT_ENTRYPOINT}"
|
||||
if [ -n "${UBOOT_ENTRYSYMBOL}" ]; then
|
||||
ENTRYPOINT=`${HOST_PREFIX}nm vmlinux | \
|
||||
awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'`
|
||||
fi
|
||||
|
||||
cat << EOF >> $1
|
||||
kernel-$2 {
|
||||
description = "Linux kernel";
|
||||
data = /incbin/("$3");
|
||||
type = "${UBOOT_MKIMAGE_KERNEL_TYPE}";
|
||||
arch = "${UBOOT_ARCH}";
|
||||
os = "linux";
|
||||
compression = "$4";
|
||||
load = <${UBOOT_LOADADDRESS}>;
|
||||
entry = <$ENTRYPOINT>;
|
||||
hash-1 {
|
||||
algo = "$kernel_csum";
|
||||
};
|
||||
};
|
||||
EOF
|
||||
|
||||
if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$kernel_sign_keyname" ] ; then
|
||||
sed -i '$ d' $1
|
||||
cat << EOF >> $1
|
||||
signature-1 {
|
||||
algo = "$kernel_csum,$kernel_sign_algo";
|
||||
key-name-hint = "$kernel_sign_keyname";
|
||||
};
|
||||
};
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Emit the fitImage ITS DTB section
|
||||
#
|
||||
# $1 ... .its filename
|
||||
# $2 ... Image counter
|
||||
# $3 ... Path to DTB image
|
||||
fitimage_emit_section_dtb() {
|
||||
|
||||
dtb_csum="${FIT_HASH_ALG}"
|
||||
dtb_sign_algo="${FIT_SIGN_ALG}"
|
||||
dtb_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}"
|
||||
|
||||
dtb_loadline=""
|
||||
dtb_ext=${DTB##*.}
|
||||
if [ "${dtb_ext}" = "dtbo" ]; then
|
||||
if [ -n "${UBOOT_DTBO_LOADADDRESS}" ]; then
|
||||
dtb_loadline="load = <${UBOOT_DTBO_LOADADDRESS}>;"
|
||||
fi
|
||||
elif [ -n "${UBOOT_DTB_LOADADDRESS}" ]; then
|
||||
dtb_loadline="load = <${UBOOT_DTB_LOADADDRESS}>;"
|
||||
fi
|
||||
cat << EOF >> $1
|
||||
fdt-$2 {
|
||||
description = "Flattened Device Tree blob";
|
||||
data = /incbin/("$3");
|
||||
type = "flat_dt";
|
||||
arch = "${UBOOT_ARCH}";
|
||||
compression = "none";
|
||||
$dtb_loadline
|
||||
hash-1 {
|
||||
algo = "$dtb_csum";
|
||||
};
|
||||
};
|
||||
EOF
|
||||
|
||||
if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$dtb_sign_keyname" ] ; then
|
||||
sed -i '$ d' $1
|
||||
cat << EOF >> $1
|
||||
signature-1 {
|
||||
algo = "$dtb_csum,$dtb_sign_algo";
|
||||
key-name-hint = "$dtb_sign_keyname";
|
||||
};
|
||||
};
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Emit the fitImage ITS u-boot script section
|
||||
#
|
||||
# $1 ... .its filename
|
||||
# $2 ... Image counter
|
||||
# $3 ... Path to boot script image
|
||||
fitimage_emit_section_boot_script() {
|
||||
|
||||
bootscr_csum="${FIT_HASH_ALG}"
|
||||
bootscr_sign_algo="${FIT_SIGN_ALG}"
|
||||
bootscr_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}"
|
||||
|
||||
cat << EOF >> $1
|
||||
bootscr-$2 {
|
||||
description = "U-boot script";
|
||||
data = /incbin/("$3");
|
||||
type = "script";
|
||||
arch = "${UBOOT_ARCH}";
|
||||
compression = "none";
|
||||
hash-1 {
|
||||
algo = "$bootscr_csum";
|
||||
};
|
||||
};
|
||||
EOF
|
||||
|
||||
if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$bootscr_sign_keyname" ] ; then
|
||||
sed -i '$ d' $1
|
||||
cat << EOF >> $1
|
||||
signature-1 {
|
||||
algo = "$bootscr_csum,$bootscr_sign_algo";
|
||||
key-name-hint = "$bootscr_sign_keyname";
|
||||
};
|
||||
};
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Emit the fitImage ITS setup section
|
||||
#
|
||||
# $1 ... .its filename
|
||||
# $2 ... Image counter
|
||||
# $3 ... Path to setup image
|
||||
fitimage_emit_section_setup() {
|
||||
|
||||
setup_csum="${FIT_HASH_ALG}"
|
||||
|
||||
cat << EOF >> $1
|
||||
setup-$2 {
|
||||
description = "Linux setup.bin";
|
||||
data = /incbin/("$3");
|
||||
type = "x86_setup";
|
||||
arch = "${UBOOT_ARCH}";
|
||||
os = "linux";
|
||||
compression = "none";
|
||||
load = <0x00090000>;
|
||||
entry = <0x00090000>;
|
||||
hash-1 {
|
||||
algo = "$setup_csum";
|
||||
};
|
||||
};
|
||||
EOF
|
||||
}
|
||||
|
||||
#
|
||||
# Emit the fitImage ITS ramdisk section
|
||||
#
|
||||
# $1 ... .its filename
|
||||
# $2 ... Image counter
|
||||
# $3 ... Path to ramdisk image
|
||||
fitimage_emit_section_ramdisk() {
|
||||
|
||||
ramdisk_csum="${FIT_HASH_ALG}"
|
||||
ramdisk_sign_algo="${FIT_SIGN_ALG}"
|
||||
ramdisk_sign_keyname="${UBOOT_SIGN_IMG_KEYNAME}"
|
||||
ramdisk_loadline=""
|
||||
ramdisk_entryline=""
|
||||
|
||||
if [ -n "${UBOOT_RD_LOADADDRESS}" ]; then
|
||||
ramdisk_loadline="load = <${UBOOT_RD_LOADADDRESS}>;"
|
||||
fi
|
||||
if [ -n "${UBOOT_RD_ENTRYPOINT}" ]; then
|
||||
ramdisk_entryline="entry = <${UBOOT_RD_ENTRYPOINT}>;"
|
||||
fi
|
||||
|
||||
cat << EOF >> $1
|
||||
ramdisk-$2 {
|
||||
description = "${INITRAMFS_IMAGE}";
|
||||
data = /incbin/("$3");
|
||||
type = "ramdisk";
|
||||
arch = "${UBOOT_ARCH}";
|
||||
os = "linux";
|
||||
compression = "none";
|
||||
$ramdisk_loadline
|
||||
$ramdisk_entryline
|
||||
hash-1 {
|
||||
algo = "$ramdisk_csum";
|
||||
};
|
||||
};
|
||||
EOF
|
||||
|
||||
if [ "${UBOOT_SIGN_ENABLE}" = "1" -a "${FIT_SIGN_INDIVIDUAL}" = "1" -a -n "$ramdisk_sign_keyname" ] ; then
|
||||
sed -i '$ d' $1
|
||||
cat << EOF >> $1
|
||||
signature-1 {
|
||||
algo = "$ramdisk_csum,$ramdisk_sign_algo";
|
||||
key-name-hint = "$ramdisk_sign_keyname";
|
||||
};
|
||||
};
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# echoes symlink destination if it points below directory
|
||||
#
|
||||
# $1 ... file that's a potential symlink
|
||||
# $2 ... expected parent directory
|
||||
symlink_points_below() {
|
||||
file="$2/$1"
|
||||
dir=$2
|
||||
|
||||
if ! [ -L "$file" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
realpath="$(realpath --relative-to=$dir $file)"
|
||||
if [ -z "${realpath%%../*}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
echo "$realpath"
|
||||
}
|
||||
|
||||
#
|
||||
# Emit the fitImage ITS configuration section
|
||||
#
|
||||
# $1 ... .its filename
|
||||
# $2 ... Linux kernel ID
|
||||
# $3 ... DTB image name
|
||||
# $4 ... ramdisk ID
|
||||
# $5 ... u-boot script ID
|
||||
# $6 ... config ID
|
||||
# $7 ... default flag
|
||||
fitimage_emit_section_config() {
|
||||
|
||||
conf_csum="${FIT_HASH_ALG}"
|
||||
conf_sign_algo="${FIT_SIGN_ALG}"
|
||||
conf_padding_algo="${FIT_PAD_ALG}"
|
||||
if [ "${UBOOT_SIGN_ENABLE}" = "1" ] ; then
|
||||
conf_sign_keyname="${UBOOT_SIGN_KEYNAME}"
|
||||
fi
|
||||
|
||||
its_file="$1"
|
||||
kernel_id="$2"
|
||||
dtb_image="$3"
|
||||
ramdisk_id="$4"
|
||||
bootscr_id="$5"
|
||||
config_id="$6"
|
||||
default_flag="$7"
|
||||
|
||||
# Test if we have any DTBs at all
|
||||
sep=""
|
||||
conf_desc=""
|
||||
conf_node="${FIT_CONF_PREFIX}"
|
||||
kernel_line=""
|
||||
fdt_line=""
|
||||
ramdisk_line=""
|
||||
bootscr_line=""
|
||||
setup_line=""
|
||||
default_line=""
|
||||
|
||||
dtb_image_sect=$(symlink_points_below $dtb_image "${EXTERNAL_KERNEL_DEVICETREE}")
|
||||
if [ -z "$dtb_image_sect" ]; then
|
||||
dtb_image_sect=$dtb_image
|
||||
fi
|
||||
|
||||
dtb_image=$(echo $dtb_image | tr '/' '_')
|
||||
dtb_image_sect=$(echo "${dtb_image_sect}" | tr '/' '_')
|
||||
|
||||
# conf node name is selected based on dtb ID if it is present,
|
||||
# otherwise its selected based on kernel ID
|
||||
if [ -n "$dtb_image" ]; then
|
||||
conf_node=$conf_node$dtb_image
|
||||
else
|
||||
conf_node=$conf_node$kernel_id
|
||||
fi
|
||||
|
||||
if [ -n "$kernel_id" ]; then
|
||||
conf_desc="Linux kernel"
|
||||
sep=", "
|
||||
kernel_line="kernel = \"kernel-$kernel_id\";"
|
||||
fi
|
||||
|
||||
if [ -n "$dtb_image" ]; then
|
||||
conf_desc="$conf_desc${sep}FDT blob"
|
||||
sep=", "
|
||||
fdt_line="fdt = \"fdt-$dtb_image_sect\";"
|
||||
fi
|
||||
|
||||
if [ -n "$ramdisk_id" ]; then
|
||||
conf_desc="$conf_desc${sep}ramdisk"
|
||||
sep=", "
|
||||
ramdisk_line="ramdisk = \"ramdisk-$ramdisk_id\";"
|
||||
fi
|
||||
|
||||
if [ -n "$bootscr_id" ]; then
|
||||
conf_desc="$conf_desc${sep}u-boot script"
|
||||
sep=", "
|
||||
bootscr_line="bootscr = \"bootscr-$bootscr_id\";"
|
||||
fi
|
||||
|
||||
if [ -n "$config_id" ]; then
|
||||
conf_desc="$conf_desc${sep}setup"
|
||||
setup_line="setup = \"setup-$config_id\";"
|
||||
fi
|
||||
|
||||
if [ "$default_flag" = "1" ]; then
|
||||
# default node is selected based on dtb ID if it is present,
|
||||
# otherwise its selected based on kernel ID
|
||||
if [ -n "$dtb_image" ]; then
|
||||
default_line="default = \"${FIT_CONF_PREFIX}$dtb_image\";"
|
||||
else
|
||||
default_line="default = \"${FIT_CONF_PREFIX}$kernel_id\";"
|
||||
fi
|
||||
fi
|
||||
|
||||
cat << EOF >> $its_file
|
||||
$default_line
|
||||
$conf_node {
|
||||
description = "$default_flag $conf_desc";
|
||||
$kernel_line
|
||||
$fdt_line
|
||||
$ramdisk_line
|
||||
$bootscr_line
|
||||
$setup_line
|
||||
hash-1 {
|
||||
algo = "$conf_csum";
|
||||
};
|
||||
EOF
|
||||
|
||||
if [ -n "$conf_sign_keyname" ] ; then
|
||||
|
||||
sign_line="sign-images = "
|
||||
sep=""
|
||||
|
||||
if [ -n "$kernel_id" ]; then
|
||||
sign_line="$sign_line${sep}\"kernel\""
|
||||
sep=", "
|
||||
fi
|
||||
|
||||
if [ -n "$dtb_image" ]; then
|
||||
sign_line="$sign_line${sep}\"fdt\""
|
||||
sep=", "
|
||||
fi
|
||||
|
||||
if [ -n "$ramdisk_id" ]; then
|
||||
sign_line="$sign_line${sep}\"ramdisk\""
|
||||
sep=", "
|
||||
fi
|
||||
|
||||
if [ -n "$bootscr_id" ]; then
|
||||
sign_line="$sign_line${sep}\"bootscr\""
|
||||
sep=", "
|
||||
fi
|
||||
|
||||
if [ -n "$config_id" ]; then
|
||||
sign_line="$sign_line${sep}\"setup\""
|
||||
fi
|
||||
|
||||
sign_line="$sign_line;"
|
||||
|
||||
cat << EOF >> $its_file
|
||||
signature-1 {
|
||||
algo = "$conf_csum,$conf_sign_algo";
|
||||
key-name-hint = "$conf_sign_keyname";
|
||||
padding = "$conf_padding_algo";
|
||||
$sign_line
|
||||
};
|
||||
EOF
|
||||
fi
|
||||
|
||||
cat << EOF >> $its_file
|
||||
};
|
||||
EOF
|
||||
}
|
||||
|
||||
#
|
||||
# Assemble fitImage
|
||||
#
|
||||
# $1 ... .its filename
|
||||
# $2 ... fitImage name
|
||||
# $3 ... include ramdisk
|
||||
fitimage_assemble() {
|
||||
kernelcount=1
|
||||
dtbcount=""
|
||||
DTBS=""
|
||||
ramdiskcount=$3
|
||||
setupcount=""
|
||||
bootscr_id=""
|
||||
rm -f $1 ${KERNEL_OUTPUT_DIR}/$2
|
||||
|
||||
if [ -n "${UBOOT_SIGN_IMG_KEYNAME}" -a "${UBOOT_SIGN_KEYNAME}" = "${UBOOT_SIGN_IMG_KEYNAME}" ]; then
|
||||
bbfatal "Keys used to sign images and configuration nodes must be different."
|
||||
fi
|
||||
|
||||
fitimage_emit_fit_header $1
|
||||
|
||||
#
|
||||
# Step 1: Prepare a kernel image section.
|
||||
#
|
||||
fitimage_emit_section_maint $1 imagestart
|
||||
|
||||
uboot_prep_kimage
|
||||
fitimage_emit_section_kernel $1 $kernelcount linux.bin "$linux_comp"
|
||||
|
||||
#
|
||||
# Step 2: Prepare a DTB image section
|
||||
#
|
||||
|
||||
if [ -n "${KERNEL_DEVICETREE}" ]; then
|
||||
dtbcount=1
|
||||
for DTB in ${KERNEL_DEVICETREE}; do
|
||||
if echo $DTB | grep -q '/dts/'; then
|
||||
bbwarn "$DTB contains the full path to the the dts file, but only the dtb name should be used."
|
||||
DTB=`basename $DTB | sed 's,\.dts$,.dtb,g'`
|
||||
fi
|
||||
|
||||
# Skip ${DTB} if it's also provided in ${EXTERNAL_KERNEL_DEVICETREE}
|
||||
if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ] && [ -s ${EXTERNAL_KERNEL_DEVICETREE}/${DTB} ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
DTB_PATH="${KERNEL_OUTPUT_DIR}/dts/$DTB"
|
||||
if [ ! -e "$DTB_PATH" ]; then
|
||||
DTB_PATH="${KERNEL_OUTPUT_DIR}/$DTB"
|
||||
fi
|
||||
|
||||
# Skip DTB if we've picked it up previously
|
||||
echo "$DTBS" | tr ' ' '\n' | grep -xq "$DTB" && continue
|
||||
|
||||
DTBS="$DTBS $DTB"
|
||||
DTB=$(echo $DTB | tr '/' '_')
|
||||
fitimage_emit_section_dtb $1 $DTB $DTB_PATH
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -n "${EXTERNAL_KERNEL_DEVICETREE}" ]; then
|
||||
dtbcount=1
|
||||
for DTB in $(find "${EXTERNAL_KERNEL_DEVICETREE}" \( -name '*.dtb' -o -name '*.dtbo' \) -printf '%P\n' | sort); do
|
||||
# Skip DTB if we've picked it up previously
|
||||
echo "$DTBS" | tr ' ' '\n' | grep -xq "$DTB" && continue
|
||||
|
||||
DTBS="$DTBS $DTB"
|
||||
|
||||
# Also skip if a symlink. We'll later have each config section point at it
|
||||
[ $(symlink_points_below $DTB "${EXTERNAL_KERNEL_DEVICETREE}") ] && continue
|
||||
|
||||
DTB=$(echo $DTB | tr '/' '_')
|
||||
fitimage_emit_section_dtb $1 $DTB "${EXTERNAL_KERNEL_DEVICETREE}/$DTB"
|
||||
done
|
||||
fi
|
||||
|
||||
#
|
||||
# Step 3: Prepare a u-boot script section
|
||||
#
|
||||
|
||||
if [ -n "${UBOOT_ENV}" ] && [ -d "${STAGING_DIR_HOST}/boot" ]; then
|
||||
if [ -e "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY}" ]; then
|
||||
cp ${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} ${B}
|
||||
bootscr_id="${UBOOT_ENV_BINARY}"
|
||||
fitimage_emit_section_boot_script $1 "$bootscr_id" ${UBOOT_ENV_BINARY}
|
||||
else
|
||||
bbwarn "${STAGING_DIR_HOST}/boot/${UBOOT_ENV_BINARY} not found."
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Step 4: Prepare a setup section. (For x86)
|
||||
#
|
||||
if [ -e ${KERNEL_OUTPUT_DIR}/setup.bin ]; then
|
||||
setupcount=1
|
||||
fitimage_emit_section_setup $1 $setupcount ${KERNEL_OUTPUT_DIR}/setup.bin
|
||||
fi
|
||||
|
||||
#
|
||||
# Step 5: Prepare a ramdisk section.
|
||||
#
|
||||
if [ "x${ramdiskcount}" = "x1" ] && [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ]; then
|
||||
# Find and use the first initramfs image archive type we find
|
||||
found=
|
||||
for img in ${FIT_SUPPORTED_INITRAMFS_FSTYPES}; do
|
||||
initramfs_path="${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img"
|
||||
if [ -e "$initramfs_path" ]; then
|
||||
bbnote "Found initramfs image: $initramfs_path"
|
||||
found=true
|
||||
fitimage_emit_section_ramdisk $1 "$ramdiskcount" "$initramfs_path"
|
||||
break
|
||||
else
|
||||
bbnote "Did not find initramfs image: $initramfs_path"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$found" ] && [ -e ${INITRAMFS_IMAGE} ]; then
|
||||
found=true
|
||||
bbnote "Found initramfs image: ${INITRAMFS_IMAGE}"
|
||||
fitimage_emit_section_ramdisk $1 "$ramdiskcount" "${INITRAMFS_IMAGE}"
|
||||
fi
|
||||
|
||||
if [ -z "$found" ]; then
|
||||
bbfatal "Could not find a valid initramfs type for ${INITRAMFS_IMAGE_NAME}, the supported types are: ${FIT_SUPPORTED_INITRAMFS_FSTYPES}"
|
||||
fi
|
||||
fi
|
||||
|
||||
fitimage_emit_section_maint $1 sectend
|
||||
|
||||
# Force the first Kernel and DTB in the default config
|
||||
kernelcount=1
|
||||
if [ -n "$dtbcount" ]; then
|
||||
dtbcount=1
|
||||
fi
|
||||
|
||||
#
|
||||
# Step 6: Prepare a configurations section
|
||||
#
|
||||
fitimage_emit_section_maint $1 confstart
|
||||
|
||||
# kernel-fitimage.bbclass currently only supports a single kernel (no less or
|
||||
# more) to be added to the FIT image along with 0 or more device trees and
|
||||
# 0 or 1 ramdisk.
|
||||
# It is also possible to include an initramfs bundle (kernel and rootfs in one binary)
|
||||
# When the initramfs bundle is used ramdisk is disabled.
|
||||
# If a device tree is to be part of the FIT image, then select
|
||||
# the default configuration to be used is based on the dtbcount. If there is
|
||||
# no dtb present than select the default configuation to be based on
|
||||
# the kernelcount.
|
||||
if [ -n "$DTBS" ]; then
|
||||
i=1
|
||||
for DTB in ${DTBS}; do
|
||||
dtb_ext=${DTB##*.}
|
||||
if [ "$dtb_ext" = "dtbo" ]; then
|
||||
fitimage_emit_section_config $1 "" "$DTB" "" "$bootscr_id" "" "`expr $i = $dtbcount`"
|
||||
else
|
||||
fitimage_emit_section_config $1 $kernelcount "$DTB" "$ramdiskcount" "$bootscr_id" "$setupcount" "`expr $i = $dtbcount`"
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
else
|
||||
defaultconfigcount=1
|
||||
fitimage_emit_section_config $1 $kernelcount "" "$ramdiskcount" "$bootscr_id" "$setupcount" $defaultconfigcount
|
||||
fi
|
||||
|
||||
fitimage_emit_section_maint $1 sectend
|
||||
|
||||
fitimage_emit_section_maint $1 fitend
|
||||
|
||||
#
|
||||
# Step 7: Assemble the image
|
||||
#
|
||||
${UBOOT_MKIMAGE} \
|
||||
${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
|
||||
-f $1 \
|
||||
${KERNEL_OUTPUT_DIR}/$2
|
||||
|
||||
#
|
||||
# Step 8: Sign the image
|
||||
#
|
||||
if [ "x${UBOOT_SIGN_ENABLE}" = "x1" ] ; then
|
||||
${UBOOT_MKIMAGE_SIGN} \
|
||||
${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
|
||||
-F -k "${UBOOT_SIGN_KEYDIR}" \
|
||||
-r ${KERNEL_OUTPUT_DIR}/$2 \
|
||||
${UBOOT_MKIMAGE_SIGN_ARGS}
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,761 @@
|
||||
# Base image class extension, inlined into every image.
|
||||
|
||||
inherit image_version
|
||||
|
||||
FIT_IMAGE_INHERIT=""
|
||||
FIT_IMAGE_INHERIT:df-obmc-static-norootfs = "fit-image"
|
||||
inherit ${FIT_IMAGE_INHERIT}
|
||||
|
||||
# Phosphor image types
|
||||
#
|
||||
# Phosphor OpenBMC supports a fixed partition mtd layout,
|
||||
# A dynamic mtd with ubi layout, and a tar file for use with
|
||||
# The reference BMC software update implementation.
|
||||
|
||||
# Image composition
|
||||
FLASH_KERNEL_IMAGE ?= "fitImage-${INITRAMFS_IMAGE}-${MACHINE}-${MACHINE}"
|
||||
FLASH_KERNEL_IMAGE:df-obmc-ubi-fs ?= "fitImage-${MACHINE}.bin"
|
||||
|
||||
IMAGE_BASETYPE ?= "squashfs-xz"
|
||||
IMAGE_BASETYPE:df-obmc-static-norootfs ?= "cpio"
|
||||
OVERLAY_BASETYPE ?= "jffs2"
|
||||
FLASH_UBI_BASETYPE ?= "${IMAGE_BASETYPE}"
|
||||
FLASH_UBI_OVERLAY_BASETYPE ?= "ubifs"
|
||||
FLASH_EXT4_BASETYPE ?= "ext4"
|
||||
FLASH_EXT4_OVERLAY_BASETYPE ?= "ext4"
|
||||
|
||||
PHOSPHOR_IMAGE_TYPES += " \
|
||||
mtd-static \
|
||||
mtd-static-alltar \
|
||||
mtd-static-tar \
|
||||
mtd-static-norootfs \
|
||||
mtd-ubi \
|
||||
mtd-ubi-tar \
|
||||
mmc-ext4-tar \
|
||||
"
|
||||
IMAGE_TYPES += "${PHOSPHOR_IMAGE_TYPES}"
|
||||
IMAGE_TYPES_MASKED += "${PHOSPHOR_IMAGE_TYPES}"
|
||||
|
||||
IMAGE_TYPEDEP:mtd-static = "${IMAGE_BASETYPE}"
|
||||
IMAGE_TYPEDEP:mtd-static-tar = "${IMAGE_BASETYPE}"
|
||||
IMAGE_TYPEDEP:mtd-static-alltar = "mtd-static"
|
||||
IMAGE_TYPEDEP:mtd-static-norootfs = "${IMAGE_BASETYPE}"
|
||||
IMAGE_TYPEDEP:mtd-ubi = "${FLASH_UBI_BASETYPE}"
|
||||
IMAGE_TYPEDEP:mtd-ubi-tar = "${FLASH_UBI_BASETYPE}"
|
||||
IMAGE_TYPEDEP:mmc-ext4-tar = "${FLASH_EXT4_BASETYPE}"
|
||||
|
||||
# Flash characteristics in KB unless otherwise noted
|
||||
DISTROOVERRIDES .= ":flash-${FLASH_SIZE}"
|
||||
FLASH_PEB_SIZE ?= "64"
|
||||
# Flash page and overhead sizes in bytes
|
||||
FLASH_PAGE_SIZE ?= "1"
|
||||
FLASH_NOR_UBI_OVERHEAD ?= "64"
|
||||
|
||||
# Fixed partition offsets
|
||||
FLASH_UBOOT_SPL_SIZE ?= "64"
|
||||
FLASH_UBOOT_OFFSET ?= "0"
|
||||
FLASH_MANIFEST_OFFSET ?= "380"
|
||||
FLASH_MANIFEST_OFFSET:flash-65536 ?= "888"
|
||||
FLASH_MANIFEST_OFFSET:flash-131072 ?= "888"
|
||||
FLASH_UBOOT_ENV_OFFSET ?= "384"
|
||||
FLASH_UBOOT_ENV_OFFSET:flash-65536 ?= "896"
|
||||
FLASH_UBOOT_ENV_OFFSET:flash-131072 ?= "896"
|
||||
FLASH_KERNEL_OFFSET ?= "512"
|
||||
FLASH_KERNEL_OFFSET:flash-65536 ?= "1024"
|
||||
FLASH_KERNEL_OFFSET:flash-131072 ?= "1024"
|
||||
FLASH_UBI_OFFSET ?= "${FLASH_KERNEL_OFFSET}"
|
||||
FLASH_ROFS_OFFSET ?= "4864"
|
||||
FLASH_ROFS_OFFSET:flash-65536 ?= "10240"
|
||||
FLASH_ROFS_OFFSET:flash-131072 ?= "10240"
|
||||
FLASH_RWFS_OFFSET ?= "28672"
|
||||
FLASH_RWFS_OFFSET:flash-65536 ?= "43008"
|
||||
FLASH_RWFS_OFFSET:flash-131072 ?= "98304"
|
||||
|
||||
# UBI volume sizes in KB unless otherwise noted.
|
||||
FLASH_UBI_RWFS_SIZE ?= "6144"
|
||||
FLASH_UBI_RWFS_SIZE:flash-131072 ?= "32768"
|
||||
FLASH_UBI_RWFS_TXT_SIZE ?= "6MiB"
|
||||
FLASH_UBI_RWFS_TXT_SIZE:flash-131072 ?= "32MiB"
|
||||
|
||||
# eMMC sizes in KB unless otherwise noted.
|
||||
MMC_UBOOT_SIZE ?= "1024"
|
||||
MMC_BOOT_PARTITION_SIZE ?= "65536"
|
||||
|
||||
SIGNING_PUBLIC_KEY ?= ""
|
||||
SIGNING_PUBLIC_KEY_TYPE = "${@os.path.splitext(os.path.basename('${SIGNING_PUBLIC_KEY}'))[0]}"
|
||||
|
||||
SIGNING_KEY ?= "${STAGING_DIR_NATIVE}${datadir}/OpenBMC.priv"
|
||||
INSECURE_KEY = "${@'${SIGNING_KEY}' == '${STAGING_DIR_NATIVE}${datadir}/OpenBMC.priv'}"
|
||||
SIGNING_KEY_DEPENDS = "${@oe.utils.conditional('INSECURE_KEY', 'True', 'phosphor-insecure-signing-key-native:do_populate_sysroot', '', d)}"
|
||||
|
||||
VERSION_PURPOSE ?= "xyz.openbmc_project.Software.Version.VersionPurpose.BMC"
|
||||
|
||||
UBOOT_SUFFIX ?= "bin"
|
||||
|
||||
IMAGE_NAME_SUFFIX=""
|
||||
|
||||
python() {
|
||||
# Compute rwfs LEB count and LEB size.
|
||||
page_size = d.getVar('FLASH_PAGE_SIZE', True)
|
||||
nor_overhead_size = d.getVar('FLASH_NOR_UBI_OVERHEAD', True)
|
||||
overhead_size = max(int(page_size), int(nor_overhead_size))
|
||||
peb_size = d.getVar('FLASH_PEB_SIZE', True)
|
||||
leb_size = (int(peb_size) * 1024) - (2 * overhead_size)
|
||||
d.setVar('FLASH_LEB_SIZE', str(leb_size)) # In bytes
|
||||
|
||||
rwfs_size = d.getVar('FLASH_UBI_RWFS_SIZE', True)
|
||||
rwfs_size = int(rwfs_size) * 1024
|
||||
lebs = int((rwfs_size + leb_size - 1) / leb_size) # Rounding up
|
||||
d.setVar('FLASH_UBI_RWFS_LEBS', str(lebs))
|
||||
}
|
||||
|
||||
# Allow rwfs mkfs configuration through OVERLAY_MKFS_OPTS and OVERRIDES. However,
|
||||
# avoid setting 'ext4' or 'jffs2' in OVERRIDES as such raw filesystem types are
|
||||
# reserved for the primary image (and setting them currently breaks the build).
|
||||
# Instead, prefix the overlay override value with 'rwfs-' to avoid collisions.
|
||||
DISTROOVERRIDES .= ":static-rwfs-${OVERLAY_BASETYPE}"
|
||||
DISTROOVERRIDES .= ":ubi-rwfs-${FLASH_UBI_OVERLAY_BASETYPE}"
|
||||
DISTROOVERRIDES .= ":mmc-rwfs-${FLASH_EXT4_OVERLAY_BASETYPE}"
|
||||
|
||||
JFFS2_RWFS_CMD = "mkfs.jffs2 --root=jffs2 --faketime --output=${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.jffs2"
|
||||
UBIFS_RWFS_CMD = "mkfs.ubifs -r ubifs -c ${FLASH_UBI_RWFS_LEBS} -m ${FLASH_PAGE_SIZE} -e ${FLASH_LEB_SIZE} ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.ubifs"
|
||||
EXT4_RWFS_CMD = "mkfs.ext4 -F ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.rwfs.ext4"
|
||||
|
||||
FLASH_STATIC_RWFS_CMD:static-rwfs-jffs2 = "${JFFS2_RWFS_CMD}"
|
||||
FLASH_UBI_RWFS_CMD:ubi-rwfs-jffs2 = "${JFFS2_RWFS_CMD}"
|
||||
FLASH_UBI_RWFS_CMD:ubi-rwfs-ubifs = "${UBIFS_RWFS_CMD}"
|
||||
FLASH_EXT4_RWFS_CMD:mmc-rwfs-ext4 = "${EXT4_RWFS_CMD}"
|
||||
|
||||
mk_empty_image() {
|
||||
image_dst="$1"
|
||||
image_size_kb=$2
|
||||
dd if=/dev/zero bs=1k count=$image_size_kb \
|
||||
| tr '\000' '\377' > $image_dst
|
||||
}
|
||||
|
||||
mk_empty_image_zeros() {
|
||||
image_dst="$1"
|
||||
image_size_kb=$2
|
||||
dd if=/dev/zero of=$image_dst bs=1k count=$image_size_kb
|
||||
}
|
||||
|
||||
clean_rwfs() {
|
||||
type=$1
|
||||
shift
|
||||
|
||||
rm -f ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$type
|
||||
rm -rf $type
|
||||
mkdir $type
|
||||
}
|
||||
|
||||
make_rwfs() {
|
||||
type=$1
|
||||
cmd=$2
|
||||
shift
|
||||
shift
|
||||
opts="$@"
|
||||
|
||||
mkdir -p $type
|
||||
|
||||
$cmd $opts
|
||||
}
|
||||
|
||||
do_generate_rwfs_static() {
|
||||
clean_rwfs ${OVERLAY_BASETYPE}
|
||||
make_rwfs ${OVERLAY_BASETYPE} "${FLASH_STATIC_RWFS_CMD}" ${OVERLAY_MKFS_OPTS}
|
||||
}
|
||||
do_generate_rwfs_static[dirs] = " ${S}/static"
|
||||
do_generate_rwfs_static[depends] += " \
|
||||
mtd-utils-native:do_populate_sysroot \
|
||||
"
|
||||
|
||||
do_generate_rwfs_ubi() {
|
||||
clean_rwfs ${FLASH_UBI_OVERLAY_BASETYPE}
|
||||
make_rwfs ${FLASH_UBI_OVERLAY_BASETYPE} "${FLASH_UBI_RWFS_CMD}"
|
||||
}
|
||||
do_generate_rwfs_ubi[dirs] = " ${S}/ubi"
|
||||
do_generate_rwfs_ubi[depends] += " \
|
||||
mtd-utils-native:do_populate_sysroot \
|
||||
"
|
||||
|
||||
do_generate_rwfs_ext4() {
|
||||
clean_rwfs rwfs.${FLASH_EXT4_OVERLAY_BASETYPE}
|
||||
mk_empty_image ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.rwfs.ext4 1024
|
||||
make_rwfs ${FLASH_EXT4_OVERLAY_BASETYPE} "${FLASH_EXT4_RWFS_CMD}" ${OVERLAY_MKFS_OPTS}
|
||||
}
|
||||
do_generate_rwfs_ext4[dirs] = " ${S}/ext4"
|
||||
do_generate_rwfs_ext4[depends] += " \
|
||||
e2fsprogs-native:do_populate_sysroot \
|
||||
"
|
||||
|
||||
add_volume() {
|
||||
config_file=$1
|
||||
vol_id=$2
|
||||
vol_type=$3
|
||||
vol_name=$4
|
||||
image=$5
|
||||
vol_size=$6
|
||||
|
||||
echo \[$vol_name\] >> $config_file
|
||||
echo mode=ubi >> $config_file
|
||||
echo image=$image >> $config_file
|
||||
echo vol_type=$vol_type >> $config_file
|
||||
echo vol_name=$vol_name >> $config_file
|
||||
echo vol_id=$vol_id >> $config_file
|
||||
if [ ! -z $vol_size ]; then
|
||||
echo vol_size=$vol_size >> $config_file
|
||||
fi
|
||||
}
|
||||
|
||||
python do_generate_ubi() {
|
||||
version_id = do_get_versionID(d)
|
||||
d.setVar('VERSION_ID', version_id)
|
||||
bb.build.exec_func("do_make_ubi", d)
|
||||
}
|
||||
do_generate_ubi[dirs] = "${S}/ubi"
|
||||
do_generate_ubi[depends] += " \
|
||||
${PN}:do_image_${@d.getVar('FLASH_UBI_BASETYPE', True).replace('-', '_')} \
|
||||
virtual/kernel:do_deploy \
|
||||
u-boot:do_deploy \
|
||||
mtd-utils-native:do_populate_sysroot \
|
||||
"
|
||||
|
||||
do_make_ubi() {
|
||||
cfg=ubinize-${IMAGE_NAME}.cfg
|
||||
rm -f $cfg ubi-img
|
||||
# Construct the ubinize config file
|
||||
add_volume $cfg 0 static kernel-${VERSION_ID} \
|
||||
${DEPLOY_DIR_IMAGE}/${FLASH_KERNEL_IMAGE}
|
||||
|
||||
add_volume $cfg 1 static rofs-${VERSION_ID} \
|
||||
${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${FLASH_UBI_BASETYPE}
|
||||
|
||||
add_volume $cfg 2 dynamic rwfs ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${FLASH_UBI_OVERLAY_BASETYPE} ${FLASH_UBI_RWFS_TXT_SIZE}
|
||||
|
||||
# Build the ubi partition image
|
||||
ubinize -p ${FLASH_PEB_SIZE}KiB -m ${FLASH_PAGE_SIZE} -o ubi-img $cfg
|
||||
|
||||
# Concatenate the uboot and ubi partitions
|
||||
mk_empty_image ${IMGDEPLOYDIR}/${IMAGE_NAME}.ubi.mtd ${FLASH_SIZE}
|
||||
dd bs=1k conv=notrunc seek=${FLASH_UBOOT_OFFSET} \
|
||||
if=${DEPLOY_DIR_IMAGE}/u-boot.${UBOOT_SUFFIX} \
|
||||
of=${IMGDEPLOYDIR}/${IMAGE_NAME}.ubi.mtd
|
||||
dd bs=1k conv=notrunc seek=${FLASH_UBI_OFFSET} \
|
||||
if=ubi-img \
|
||||
of=${IMGDEPLOYDIR}/${IMAGE_NAME}.ubi.mtd
|
||||
|
||||
cd ${IMGDEPLOYDIR}
|
||||
ln -sf ${IMAGE_NAME}.ubi.mtd ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.ubi.mtd
|
||||
}
|
||||
do_make_ubi[dirs] = "${S}/ubi"
|
||||
do_make_ubi[depends] += " \
|
||||
${PN}:do_image_${@d.getVar('FLASH_UBI_BASETYPE', True).replace('-', '_')} \
|
||||
virtual/kernel:do_deploy \
|
||||
u-boot:do_deploy \
|
||||
mtd-utils-native:do_populate_sysroot \
|
||||
"
|
||||
|
||||
do_mk_static_nor_image() {
|
||||
# Assemble the flash image
|
||||
mk_empty_image ${IMGDEPLOYDIR}/${IMAGE_NAME}.static.mtd ${FLASH_SIZE}
|
||||
}
|
||||
|
||||
do_generate_image_uboot_file() {
|
||||
image_dst="$1"
|
||||
uboot_offset=${FLASH_UBOOT_OFFSET}
|
||||
|
||||
if [ ! -z ${SPL_BINARY} ]; then
|
||||
dd bs=1k conv=notrunc seek=${FLASH_UBOOT_OFFSET} \
|
||||
if=${DEPLOY_DIR_IMAGE}/u-boot-spl.${UBOOT_SUFFIX} \
|
||||
of=${image_dst}
|
||||
uboot_offset=${FLASH_UBOOT_SPL_SIZE}
|
||||
fi
|
||||
|
||||
dd bs=1k conv=notrunc seek=${uboot_offset} \
|
||||
if=${DEPLOY_DIR_IMAGE}/u-boot.${UBOOT_SUFFIX} \
|
||||
of=${image_dst}
|
||||
}
|
||||
|
||||
python do_generate_static() {
|
||||
import subprocess
|
||||
|
||||
bb.build.exec_func("do_mk_static_nor_image", d)
|
||||
|
||||
nor_image = os.path.join(d.getVar('IMGDEPLOYDIR', True),
|
||||
'%s.static.mtd' % d.getVar('IMAGE_NAME', True))
|
||||
|
||||
def _append_image(imgpath, start_kb, finish_kb):
|
||||
imgsize = os.path.getsize(imgpath)
|
||||
maxsize = (finish_kb - start_kb) * 1024
|
||||
bb.debug(1, 'Considering file size=' + str(imgsize) + ' name=' + imgpath)
|
||||
bb.debug(1, 'Spanning start=' + str(start_kb) + 'K end=' + str(finish_kb) + 'K')
|
||||
bb.debug(1, 'Compare needed=' + str(imgsize) + ' available=' + str(maxsize) + ' margin=' + str(maxsize - imgsize))
|
||||
if imgsize > maxsize:
|
||||
bb.fatal("Image '%s' is %d bytes too large!" % (imgpath, imgsize - maxsize))
|
||||
|
||||
subprocess.check_call(['dd', 'bs=1k', 'conv=notrunc',
|
||||
'seek=%d' % start_kb,
|
||||
'if=%s' % imgpath,
|
||||
'of=%s' % nor_image])
|
||||
|
||||
uboot_offset = int(d.getVar('FLASH_UBOOT_OFFSET', True))
|
||||
|
||||
spl_binary = d.getVar('SPL_BINARY', True)
|
||||
if spl_binary:
|
||||
_append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
|
||||
'u-boot-spl.%s' % d.getVar('UBOOT_SUFFIX',True)),
|
||||
int(d.getVar('FLASH_UBOOT_OFFSET', True)),
|
||||
int(d.getVar('FLASH_UBOOT_SPL_SIZE', True)))
|
||||
uboot_offset += int(d.getVar('FLASH_UBOOT_SPL_SIZE', True))
|
||||
|
||||
_append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
|
||||
'u-boot.%s' % d.getVar('UBOOT_SUFFIX',True)),
|
||||
uboot_offset,
|
||||
int(d.getVar('FLASH_UBOOT_ENV_OFFSET', True)))
|
||||
|
||||
_append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
|
||||
d.getVar('FLASH_KERNEL_IMAGE', True)),
|
||||
int(d.getVar('FLASH_KERNEL_OFFSET', True)),
|
||||
int(d.getVar('FLASH_ROFS_OFFSET', True)))
|
||||
|
||||
_append_image(os.path.join(d.getVar('IMGDEPLOYDIR', True),
|
||||
'%s.%s' % (
|
||||
d.getVar('IMAGE_LINK_NAME', True),
|
||||
d.getVar('IMAGE_BASETYPE', True))),
|
||||
int(d.getVar('FLASH_ROFS_OFFSET', True)),
|
||||
int(d.getVar('FLASH_RWFS_OFFSET', True)))
|
||||
|
||||
_append_image(os.path.join(d.getVar('IMGDEPLOYDIR', True),
|
||||
'%s.%s' % (
|
||||
d.getVar('IMAGE_LINK_NAME', True),
|
||||
d.getVar('OVERLAY_BASETYPE', True))),
|
||||
int(d.getVar('FLASH_RWFS_OFFSET', True)),
|
||||
int(d.getVar('FLASH_SIZE', True)))
|
||||
|
||||
bb.build.exec_func("do_mk_static_symlinks", d)
|
||||
}
|
||||
|
||||
do_mk_static_symlinks() {
|
||||
cd ${IMGDEPLOYDIR}
|
||||
ln -sf ${IMAGE_NAME}.static.mtd ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.static.mtd
|
||||
|
||||
# Maintain non-standard legacy links
|
||||
do_generate_image_uboot_file ${IMGDEPLOYDIR}/image-u-boot
|
||||
ln -sf ${IMAGE_NAME}.static.mtd ${IMGDEPLOYDIR}/flash-${MACHINE}
|
||||
ln -sf ${IMAGE_NAME}.static.mtd ${IMGDEPLOYDIR}/image-bmc
|
||||
ln -sf ${FLASH_KERNEL_IMAGE} ${IMGDEPLOYDIR}/image-kernel
|
||||
ln -sf ${IMAGE_LINK_NAME}.${IMAGE_BASETYPE} ${IMGDEPLOYDIR}/image-rofs
|
||||
ln -sf ${IMAGE_LINK_NAME}.${OVERLAY_BASETYPE} ${IMGDEPLOYDIR}/image-rwfs
|
||||
}
|
||||
do_generate_static[dirs] = "${S}/static"
|
||||
do_generate_static[depends] += " \
|
||||
${PN}:do_image_${@d.getVar('IMAGE_BASETYPE', True).replace('-', '_')} \
|
||||
virtual/kernel:do_deploy \
|
||||
u-boot:do_deploy \
|
||||
"
|
||||
|
||||
make_signatures() {
|
||||
signing_key="${SIGNING_KEY}"
|
||||
|
||||
if [ "${INSECURE_KEY}" = "True" ] && [ -n "${SIGNING_PUBLIC_KEY}" ]; then
|
||||
echo "Using SIGNING_PUBLIC_KEY"
|
||||
signing_key=""
|
||||
fi
|
||||
|
||||
if [ -n "${signing_key}" ] && [ -n "${SIGNING_PUBLIC_KEY}" ]; then
|
||||
echo "Both SIGNING_KEY and SIGNING_PUBLIC_KEY are defined, expecting only one"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
signature_files=""
|
||||
if [ -n "${signing_key}" ]; then
|
||||
for file in "$@"; do
|
||||
openssl dgst -sha256 -sign ${signing_key} -out "${file}.sig" $file
|
||||
signature_files="${signature_files} ${file}.sig"
|
||||
done
|
||||
|
||||
if [ -n "${signature_files}" ]; then
|
||||
sort_signature_files=$(echo "${signature_files}" | tr ' ' '\n' | sort | tr '\n' ' ')
|
||||
cat ${sort_signature_files} > image-full
|
||||
openssl dgst -sha256 -sign ${signing_key} -out image-full.sig image-full
|
||||
signature_files="${signature_files} image-full.sig"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
do_generate_static_alltar() {
|
||||
ln -sf ${S}/MANIFEST MANIFEST
|
||||
ln -sf ${S}/publickey publickey
|
||||
ln -sf ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.static.mtd image-bmc
|
||||
|
||||
make_signatures image-bmc MANIFEST publickey
|
||||
|
||||
tar -h -cvf ${IMGDEPLOYDIR}/${IMAGE_NAME}.static.mtd.all.tar \
|
||||
image-bmc MANIFEST publickey ${signature_files}
|
||||
|
||||
cd ${IMGDEPLOYDIR}
|
||||
|
||||
ln -sf ${IMAGE_NAME}.static.mtd.all.tar \
|
||||
${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.static.mtd.all.tar
|
||||
|
||||
# Maintain non-standard legacy link.
|
||||
ln -sf ${IMAGE_NAME}.static.mtd.all.tar \
|
||||
${IMGDEPLOYDIR}/${MACHINE}-${DATETIME}.all.tar
|
||||
|
||||
}
|
||||
do_generate_static_alltar[vardepsexclude] = "DATETIME"
|
||||
do_generate_static_alltar[dirs] = "${S}/static"
|
||||
do_generate_static_alltar[depends] += " \
|
||||
openssl-native:do_populate_sysroot \
|
||||
${SIGNING_KEY_DEPENDS} \
|
||||
${PN}:do_copy_signing_pubkey \
|
||||
"
|
||||
|
||||
make_image_links() {
|
||||
rwfs=$1
|
||||
rofs=$2
|
||||
shift
|
||||
shift
|
||||
|
||||
# Create some links to help make the tar archive in the format
|
||||
# expected by phosphor-bmc-code-mgmt.
|
||||
do_generate_image_uboot_file image-u-boot
|
||||
ln -sf ${DEPLOY_DIR_IMAGE}/${FLASH_KERNEL_IMAGE} image-kernel
|
||||
ln -sf ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$rofs image-rofs
|
||||
ln -sf ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$rwfs image-rwfs
|
||||
}
|
||||
|
||||
make_tar_of_images() {
|
||||
type=$1
|
||||
shift
|
||||
extra_files="$@"
|
||||
|
||||
# Create the tar archive
|
||||
tar -h -cvf ${IMGDEPLOYDIR}/${IMAGE_NAME}.$type.tar \
|
||||
image-u-boot image-kernel image-rofs image-rwfs $extra_files
|
||||
|
||||
cd ${IMGDEPLOYDIR}
|
||||
ln -sf ${IMAGE_NAME}.$type.tar ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$type.tar
|
||||
}
|
||||
|
||||
do_generate_static_tar() {
|
||||
ln -sf ${S}/MANIFEST MANIFEST
|
||||
ln -sf ${S}/publickey publickey
|
||||
make_image_links ${OVERLAY_BASETYPE} ${IMAGE_BASETYPE}
|
||||
make_signatures image-u-boot image-kernel image-rofs image-rwfs MANIFEST publickey
|
||||
make_tar_of_images static.mtd MANIFEST publickey ${signature_files}
|
||||
|
||||
# Maintain non-standard legacy link.
|
||||
cd ${IMGDEPLOYDIR}
|
||||
ln -sf ${IMAGE_NAME}.static.mtd.tar ${IMGDEPLOYDIR}/${MACHINE}-${DATETIME}.tar
|
||||
}
|
||||
do_generate_static_tar[dirs] = " ${S}/static"
|
||||
do_generate_static_tar[depends] += " \
|
||||
${PN}:do_image_${@d.getVar('IMAGE_BASETYPE', True).replace('-', '_')} \
|
||||
virtual/kernel:do_deploy \
|
||||
u-boot:do_deploy \
|
||||
openssl-native:do_populate_sysroot \
|
||||
${SIGNING_KEY_DEPENDS} \
|
||||
${PN}:do_copy_signing_pubkey \
|
||||
"
|
||||
do_generate_static_tar[vardepsexclude] = "DATETIME"
|
||||
|
||||
python do_generate_static_norootfs() {
|
||||
import hashlib
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
manifest = {
|
||||
"type": "phosphor-image-manifest",
|
||||
"version": 1,
|
||||
"info": {
|
||||
"purpose": d.getVar('VERSION_PURPOSE', True),
|
||||
"machine": d.getVar('MACHINE', True),
|
||||
"version": do_get_version(d).strip('"'),
|
||||
"build-id": do_get_buildID(d).strip('"'),
|
||||
},
|
||||
"partitions": [],
|
||||
# Create an empty hash-value so that the dictionary can be emitted,
|
||||
# hashed, and then updated.
|
||||
"manifest-sha256": "",
|
||||
}
|
||||
extended_version = do_get_extended_version(d).strip('"')
|
||||
if extended_version:
|
||||
manifest["info"]["extended-version"] = extended_version
|
||||
compatible_names = d.getVar('OBMC_COMPATIBLE_NAMES', True)
|
||||
if compatible_names:
|
||||
manifest["info"]["compatible-names"] = compatible_names.split()
|
||||
|
||||
manifest_json_file = os.path.join(d.getVar('IMGDEPLOYDIR', True),
|
||||
"phosphor-image-manifest.json")
|
||||
|
||||
nor_image_basename = '%s.static.mtd' % d.getVar('IMAGE_NAME', True)
|
||||
nor_image = os.path.join(d.getVar('IMGDEPLOYDIR', True), nor_image_basename)
|
||||
|
||||
def _add_manifest(partname, typename, offset, size, sha256_value = None):
|
||||
manifest["partitions"].append(
|
||||
{
|
||||
"name": partname,
|
||||
"type": typename,
|
||||
"offset": offset,
|
||||
"size": size,
|
||||
}
|
||||
)
|
||||
if typename == "fit":
|
||||
if "u-boot-fit" == partname:
|
||||
manifest["partitions"][-1]["num-nodes"] = 1
|
||||
elif "os-fit" == partname:
|
||||
manifest["partitions"][-1]["num-nodes"] = 3
|
||||
else:
|
||||
bb.fatal(f"Unknown FIT partition type: {partname}")
|
||||
if sha256_value:
|
||||
manifest["partitions"][-1]["sha256"] = sha256_value
|
||||
|
||||
|
||||
def _append_image(partname, typename, imgpath, start_kb, finish_kb):
|
||||
imgsize = os.path.getsize(imgpath)
|
||||
maxsize = (finish_kb - start_kb) * 1024
|
||||
bb.debug(1, 'Considering file size=' + str(imgsize) + ' name=' + imgpath)
|
||||
bb.debug(1, 'Spanning start=' + str(start_kb) + 'K end=' + str(finish_kb) + 'K')
|
||||
bb.debug(1, 'Compare needed=' + str(imgsize) + ' available=' + str(maxsize) + ' margin=' + str(maxsize - imgsize))
|
||||
if imgsize > maxsize:
|
||||
bb.fatal("Image '%s' is too large!" % imgpath)
|
||||
|
||||
with open(imgpath, "rb") as fp:
|
||||
sha256 = hashlib.sha256(fp.read()).hexdigest()
|
||||
|
||||
_add_manifest(partname, typename, start_kb * 1024, imgsize, sha256)
|
||||
|
||||
subprocess.check_call(['dd', 'bs=1k', 'conv=notrunc',
|
||||
'seek=%d' % start_kb,
|
||||
'if=%s' % imgpath,
|
||||
'of=%s' % nor_image])
|
||||
|
||||
uboot_offset = int(d.getVar('FLASH_UBOOT_OFFSET', True))
|
||||
|
||||
spl_binary = d.getVar('SPL_BINARY', True)
|
||||
if spl_binary:
|
||||
_append_image("spl", "u-boot",
|
||||
os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
|
||||
'u-boot-spl.%s' % d.getVar('UBOOT_SUFFIX',True)),
|
||||
int(d.getVar('FLASH_UBOOT_OFFSET', True)),
|
||||
int(d.getVar('FLASH_UBOOT_SPL_SIZE', True)))
|
||||
uboot_offset += int(d.getVar('FLASH_UBOOT_SPL_SIZE', True))
|
||||
|
||||
_append_image("u-boot-fit", "fit",
|
||||
os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
|
||||
'u-boot.%s' % d.getVar('UBOOT_SUFFIX',True)),
|
||||
uboot_offset,
|
||||
int(d.getVar('FLASH_MANIFEST_OFFSET', True)))
|
||||
|
||||
_add_manifest("manifest", "json",
|
||||
int(d.getVar('FLASH_MANIFEST_OFFSET', True)) * 1024,
|
||||
(int(d.getVar('FLASH_UBOOT_ENV_OFFSET', True)) -
|
||||
int(d.getVar('FLASH_MANIFEST_OFFSET', True))) * 1024)
|
||||
|
||||
_add_manifest("u-boot-env", "data",
|
||||
int(d.getVar('FLASH_UBOOT_ENV_OFFSET', True)) * 1024,
|
||||
(int(d.getVar('FLASH_KERNEL_OFFSET', True)) -
|
||||
int(d.getVar('FLASH_UBOOT_ENV_OFFSET', True))) * 1024)
|
||||
|
||||
_append_image("os-fit", "fit",
|
||||
os.path.join(d.getVar('IMGDEPLOYDIR', True),
|
||||
'%s.cpio.%s.fitImage' % (
|
||||
d.getVar('IMAGE_LINK_NAME', True),
|
||||
d.getVar('INITRAMFS_CTYPE', True))),
|
||||
int(d.getVar('FLASH_KERNEL_OFFSET', True)),
|
||||
int(d.getVar('FLASH_RWFS_OFFSET', True)))
|
||||
|
||||
_add_manifest("rwfs", "data",
|
||||
int(d.getVar('FLASH_RWFS_OFFSET', True)) * 1024,
|
||||
(int(d.getVar('FLASH_SIZE', True)) -
|
||||
int(d.getVar('FLASH_RWFS_OFFSET', True))) * 1024)
|
||||
|
||||
# Calculate the sha256 of the current manifest and update.
|
||||
manifest_raw = json.dumps(manifest, indent=4)
|
||||
manifest_raw = manifest_raw[:manifest_raw.find("manifest-sha256")]
|
||||
manifest["manifest-sha256"] = hashlib.sha256(
|
||||
manifest_raw.encode('utf-8')).hexdigest()
|
||||
|
||||
# Write the final manifest json and add it to the image.
|
||||
with open(manifest_json_file, "wb") as fp:
|
||||
fp.write(json.dumps(manifest, indent=4).encode('utf-8'))
|
||||
_append_image("manifest", "json", manifest_json_file,
|
||||
int(d.getVar('FLASH_MANIFEST_OFFSET', True)),
|
||||
int(d.getVar('FLASH_UBOOT_ENV_OFFSET', True)))
|
||||
|
||||
flash_symlink = os.path.join(
|
||||
d.getVar('IMGDEPLOYDIR', True),
|
||||
'flash-%s' % d.getVar('MACHINE', True))
|
||||
if os.path.exists(flash_symlink):
|
||||
os.remove(flash_symlink)
|
||||
os.symlink(nor_image_basename, flash_symlink)
|
||||
}
|
||||
do_generate_static_norootfs[depends] += " \
|
||||
${PN}:do_image_${@d.getVar('IMAGE_BASETYPE', True).replace('-', '_')} \
|
||||
u-boot:do_deploy \
|
||||
"
|
||||
|
||||
do_generate_ubi_tar() {
|
||||
ln -sf ${S}/MANIFEST MANIFEST
|
||||
ln -sf ${S}/publickey publickey
|
||||
make_image_links ${FLASH_UBI_OVERLAY_BASETYPE} ${FLASH_UBI_BASETYPE}
|
||||
make_signatures image-u-boot image-kernel image-rofs image-rwfs MANIFEST publickey
|
||||
make_tar_of_images ubi.mtd MANIFEST publickey ${signature_files}
|
||||
}
|
||||
do_generate_ubi_tar[dirs] = " ${S}/ubi"
|
||||
do_generate_ubi_tar[depends] += " \
|
||||
${PN}:do_image_${@d.getVar('FLASH_UBI_BASETYPE', True).replace('-', '_')} \
|
||||
virtual/kernel:do_deploy \
|
||||
u-boot:do_deploy \
|
||||
openssl-native:do_populate_sysroot \
|
||||
${SIGNING_KEY_DEPENDS} \
|
||||
${PN}:do_copy_signing_pubkey \
|
||||
"
|
||||
|
||||
do_generate_ext4_tar() {
|
||||
# Generate the U-Boot image
|
||||
mk_empty_image_zeros image-u-boot ${MMC_UBOOT_SIZE}
|
||||
do_generate_image_uboot_file image-u-boot
|
||||
|
||||
# Generate a compressed ext4 filesystem with the fitImage file in it to be
|
||||
# flashed to the boot partition of the eMMC
|
||||
install -d boot-image
|
||||
install -m 644 ${DEPLOY_DIR_IMAGE}/${FLASH_KERNEL_IMAGE} boot-image/fitImage
|
||||
mk_empty_image_zeros boot-image.${FLASH_EXT4_BASETYPE} ${MMC_BOOT_PARTITION_SIZE}
|
||||
mkfs.ext4 -F -i 4096 -d boot-image boot-image.${FLASH_EXT4_BASETYPE}
|
||||
# Error codes 0-3 indicate successfull operation of fsck
|
||||
fsck.ext4 -pvfD boot-image.${FLASH_EXT4_BASETYPE} || [ $? -le 3 ]
|
||||
zstd -f -k -T0 -c ${ZSTD_COMPRESSION_LEVEL} boot-image.${FLASH_EXT4_BASETYPE} > boot-image.${FLASH_EXT4_BASETYPE}.zst
|
||||
|
||||
# Generate the compressed ext4 rootfs
|
||||
zstd -f -k -T0 -c ${ZSTD_COMPRESSION_LEVEL} ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.${FLASH_EXT4_BASETYPE} > ${IMAGE_LINK_NAME}.${FLASH_EXT4_BASETYPE}.zst
|
||||
|
||||
ln -sf boot-image.${FLASH_EXT4_BASETYPE}.zst image-kernel
|
||||
ln -sf ${IMAGE_LINK_NAME}.${FLASH_EXT4_BASETYPE}.zst image-rofs
|
||||
ln -sf ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.rwfs.${FLASH_EXT4_OVERLAY_BASETYPE} image-rwfs
|
||||
ln -sf ${S}/MANIFEST MANIFEST
|
||||
ln -sf ${S}/publickey publickey
|
||||
|
||||
hostfw_update_file="${DEPLOY_DIR_IMAGE}/hostfw/update/image-hostfw"
|
||||
if [ -e "${hostfw_update_file}" ]; then
|
||||
ln -sf "${hostfw_update_file}" image-hostfw
|
||||
make_signatures image-u-boot image-kernel image-rofs image-rwfs MANIFEST publickey image-hostfw
|
||||
make_tar_of_images ext4.mmc MANIFEST publickey ${signature_files} image-hostfw
|
||||
else
|
||||
make_signatures image-u-boot image-kernel image-rofs image-rwfs MANIFEST publickey
|
||||
make_tar_of_images ext4.mmc MANIFEST publickey ${signature_files}
|
||||
fi
|
||||
}
|
||||
do_generate_ext4_tar[dirs] = " ${S}/ext4"
|
||||
do_generate_ext4_tar[depends] += " \
|
||||
zstd-native:do_populate_sysroot \
|
||||
${PN}:do_image_${FLASH_EXT4_BASETYPE} \
|
||||
virtual/kernel:do_deploy \
|
||||
u-boot:do_deploy \
|
||||
openssl-native:do_populate_sysroot \
|
||||
${SIGNING_KEY_DEPENDS} \
|
||||
${PN}:do_copy_signing_pubkey \
|
||||
phosphor-hostfw-image:do_deploy \
|
||||
"
|
||||
|
||||
def get_pubkey_basedir(d):
|
||||
return os.path.join(
|
||||
d.getVar('STAGING_DIR_TARGET', True),
|
||||
d.getVar('sysconfdir', True).strip(os.sep),
|
||||
'activationdata')
|
||||
|
||||
def get_pubkey_type(d):
|
||||
return os.listdir(get_pubkey_basedir(d))[0]
|
||||
|
||||
def get_pubkey_path(d):
|
||||
return os.path.join(
|
||||
get_pubkey_basedir(d),
|
||||
get_pubkey_type(d),
|
||||
'publickey')
|
||||
|
||||
python do_generate_phosphor_manifest() {
|
||||
purpose = d.getVar('VERSION_PURPOSE', True)
|
||||
version = do_get_version(d)
|
||||
build_id = do_get_buildID(d)
|
||||
target_machine = d.getVar('MACHINE', True)
|
||||
extended_version = do_get_extended_version(d)
|
||||
compatible_names = d.getVar('OBMC_COMPATIBLE_NAMES', True)
|
||||
with open('MANIFEST', 'w') as fd:
|
||||
fd.write('purpose={}\n'.format(purpose))
|
||||
fd.write('version={}\n'.format(version.strip('"')))
|
||||
fd.write('BuildId={}\n'.format(build_id.strip('"')))
|
||||
if extended_version:
|
||||
fd.write('ExtendedVersion={}\n'.format(extended_version))
|
||||
if compatible_names:
|
||||
for name in compatible_names.split():
|
||||
fd.write('CompatibleName={}\n'.format(name))
|
||||
fd.write('KeyType={}\n'.format(get_pubkey_type(d)))
|
||||
fd.write('HashType=RSA-SHA256\n')
|
||||
fd.write('MachineName={}\n'.format(target_machine))
|
||||
}
|
||||
do_generate_phosphor_manifest[dirs] = "${S}"
|
||||
do_generate_phosphor_manifest[depends] += " \
|
||||
os-release:do_populate_sysroot \
|
||||
phosphor-image-signing:do_populate_sysroot \
|
||||
"
|
||||
|
||||
python do_copy_signing_pubkey() {
|
||||
with open(get_pubkey_path(d), 'r') as read_fd:
|
||||
with open('publickey', 'w') as write_fd:
|
||||
write_fd.write(read_fd.read())
|
||||
}
|
||||
|
||||
do_copy_signing_pubkey[dirs] = "${S}"
|
||||
do_copy_signing_pubkey[depends] += " \
|
||||
phosphor-image-signing:do_populate_sysroot \
|
||||
"
|
||||
|
||||
addtask copy_signing_pubkey after do_rootfs
|
||||
addtask generate_phosphor_manifest after do_rootfs
|
||||
addtask generate_rwfs_static after do_rootfs
|
||||
addtask generate_rwfs_ubi after do_rootfs
|
||||
addtask generate_rwfs_ext4 after do_rootfs
|
||||
|
||||
python() {
|
||||
types = d.getVar('IMAGE_FSTYPES', True).split()
|
||||
|
||||
if any([x in types for x in ['mtd-static', 'mtd-static-alltar']]):
|
||||
bb.build.addtask(
|
||||
'do_generate_static',
|
||||
'do_image_complete',
|
||||
'do_generate_rwfs_static', d)
|
||||
if 'mtd-static-alltar' in types:
|
||||
bb.build.addtask(
|
||||
'do_generate_static_alltar',
|
||||
'do_image_complete',
|
||||
'do_generate_static do_generate_phosphor_manifest', d)
|
||||
if 'mtd-static-tar' in types:
|
||||
bb.build.addtask(
|
||||
'do_generate_static_tar',
|
||||
'do_image_complete',
|
||||
'do_generate_rwfs_static do_generate_phosphor_manifest', d)
|
||||
|
||||
if 'mtd-static-norootfs' in types:
|
||||
bb.build.addtask(
|
||||
'do_generate_static_norootfs',
|
||||
'do_image_complete',
|
||||
'do_image_cpio', d)
|
||||
|
||||
if 'mtd-ubi' in types:
|
||||
bb.build.addtask(
|
||||
'do_generate_ubi',
|
||||
'do_image_complete',
|
||||
'do_generate_rwfs_ubi', d)
|
||||
if 'mtd-ubi-tar' in types:
|
||||
bb.build.addtask(
|
||||
'do_generate_ubi_tar',
|
||||
'do_image_complete',
|
||||
'do_generate_rwfs_ubi do_generate_phosphor_manifest', d)
|
||||
|
||||
if 'mmc-ext4-tar' in types:
|
||||
bb.build.addtask(
|
||||
'do_generate_ext4_tar',
|
||||
'do_image_complete',
|
||||
'do_generate_rwfs_ext4 do_generate_phosphor_manifest', d)
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
UBOOT_BINARY := "u-boot.${UBOOT_SUFFIX}"
|
||||
BOOTBLOCK = "Poleg_bootblock.bin"
|
||||
FULL_SUFFIX = "full"
|
||||
MERGED_SUFFIX = "merged"
|
||||
UBOOT_SUFFIX:append = ".${MERGED_SUFFIX}"
|
||||
|
||||
IGPS_DIR = "${STAGING_DIR_NATIVE}/${datadir}/npcm7xx-igps"
|
||||
|
||||
# Prepare the Bootblock and U-Boot images using npcm7xx-bingo
|
||||
do_prepare_bootloaders() {
|
||||
local olddir="$(pwd)"
|
||||
cd ${DEPLOY_DIR_IMAGE}
|
||||
bingo ${IGPS_DIR}/BootBlockAndHeader_${IGPS_MACHINE}.xml \
|
||||
-o ${DEPLOY_DIR_IMAGE}/${BOOTBLOCK}.${FULL_SUFFIX}
|
||||
|
||||
bingo ${IGPS_DIR}/UbootHeader_${IGPS_MACHINE}.xml \
|
||||
-o ${DEPLOY_DIR_IMAGE}/${UBOOT_BINARY}.${FULL_SUFFIX}
|
||||
|
||||
bingo ${IGPS_DIR}/mergedBootBlockAndUboot.xml \
|
||||
-o ${DEPLOY_DIR_IMAGE}/${UBOOT_BINARY}.${MERGED_SUFFIX}
|
||||
cd "$olddir"
|
||||
}
|
||||
|
||||
do_prepare_bootloaders[depends] += " \
|
||||
u-boot:do_deploy \
|
||||
npcm7xx-bootblock:do_deploy \
|
||||
npcm7xx-bingo-native:do_populate_sysroot \
|
||||
npcm7xx-igps-native:do_populate_sysroot \
|
||||
"
|
||||
|
||||
addtask do_prepare_bootloaders before do_generate_static after do_generate_rwfs_static
|
||||
|
||||
# Include the full bootblock and u-boot in the final static image
|
||||
python do_generate_static:append() {
|
||||
_append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
|
||||
'u-boot.%s' % d.getVar('UBOOT_SUFFIX',True)),
|
||||
int(d.getVar('FLASH_UBOOT_OFFSET', True)),
|
||||
int(d.getVar('FLASH_KERNEL_OFFSET', True)))
|
||||
}
|
||||
|
||||
do_make_ubi:append() {
|
||||
# Concatenate the uboot and ubi partitions
|
||||
dd bs=1k conv=notrunc seek=${FLASH_UBOOT_OFFSET} \
|
||||
if=${DEPLOY_DIR_IMAGE}/u-boot.${UBOOT_SUFFIX} \
|
||||
of=${IMGDEPLOYDIR}/${IMAGE_NAME}.ubi.mtd
|
||||
}
|
||||
|
||||
do_make_ubi[depends] += "${PN}:do_prepare_bootloaders"
|
||||
do_generate_ubi_tar[depends] += "${PN}:do_prepare_bootloaders"
|
||||
do_generate_static_tar[depends] += "${PN}:do_prepare_bootloaders"
|
||||
@@ -0,0 +1,267 @@
|
||||
UBOOT_BINARY := "u-boot.${UBOOT_SUFFIX}"
|
||||
BB_HEADER_BINARY := "BootBlockAndHeader.bin"
|
||||
BL31_HEADER_BINARY := "bl31AndHeader.bin"
|
||||
OPTEE_HEADER_BINARY := "teeAndHeader.bin"
|
||||
KMT_TIPFW_BINARY := "Kmt_TipFwL0_Skmt_TipFwL1.bin"
|
||||
KMT_TIPFW_BB_BINARY = "Kmt_TipFw_BootBlock.bin"
|
||||
KMT_TIPFW_BB_BL31_BINARY = "Kmt_TipFw_BootBlock_BL31.bin"
|
||||
KMT_TIPFW_BB_BL31_TEE_BINARY = "Kmt_TipFw_BootBlock_BL31_Tee.bin"
|
||||
KMT_TIPFW_BB_UBOOT_BINARY = "u-boot.bin.merged"
|
||||
|
||||
BB_BL31_BINARY = "BootBlock_BL31_no_tip.bin"
|
||||
BB_BL31_TEE_BINARY = "BootBlock_BL31_Tee_no_tip.bin"
|
||||
BB_BL31_TEE_UBOOT_BINARY = "u-boot.bin.merged"
|
||||
|
||||
FULL_SUFFIX = "full"
|
||||
MERGED_SUFFIX = "merged"
|
||||
UBOOT_SUFFIX:append = ".${MERGED_SUFFIX}"
|
||||
UBOOT_HEADER_BINARY := "${UBOOT_BINARY}.${FULL_SUFFIX}"
|
||||
|
||||
IGPS_DIR = "${STAGING_DIR_NATIVE}/${datadir}/npcm8xx-igps"
|
||||
|
||||
BB_BIN = "arbel_a35_bootblock.bin"
|
||||
BL31_BIN = "bl31.bin"
|
||||
OPTEE_BIN = "tee.bin"
|
||||
UBOOT_BIN = "u-boot.bin"
|
||||
BB_NO_TIP_BIN = "arbel_a35_bootblock_no_tip.bin"
|
||||
|
||||
# Align images if needed
|
||||
python do_pad_binary() {
|
||||
TIP_IMAGE = d.getVar('TIP_IMAGE', True)
|
||||
def Pad_bin_file_inplace(inF, align):
|
||||
padding_size = 0
|
||||
padding_size_end = 0
|
||||
|
||||
F_size = os.path.getsize(inF)
|
||||
|
||||
padding_size = align - (F_size % align)
|
||||
|
||||
infile = open(inF, "ab")
|
||||
infile.seek(0, 2)
|
||||
infile.write(b'\x00' * padding_size)
|
||||
infile.close()
|
||||
|
||||
if TIP_IMAGE == "True":
|
||||
Pad_bin_file_inplace(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
|
||||
'%s' % d.getVar('BB_BIN',True)), int(d.getVar('PAD_ALIGN', True)))
|
||||
else:
|
||||
Pad_bin_file_inplace(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
|
||||
'%s' % d.getVar('BB_NO_TIP_BIN',True)), int(d.getVar('PAD_ALIGN', True)))
|
||||
|
||||
Pad_bin_file_inplace(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
|
||||
'%s' % d.getVar('BL31_BIN',True)), int(d.getVar('PAD_ALIGN', True)))
|
||||
|
||||
Pad_bin_file_inplace(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
|
||||
'%s' % d.getVar('OPTEE_BIN',True)), int(d.getVar('PAD_ALIGN', True)))
|
||||
|
||||
Pad_bin_file_inplace(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
|
||||
'%s' % d.getVar('UBOOT_BIN',True)), int(d.getVar('PAD_ALIGN', True)))
|
||||
}
|
||||
|
||||
# Prepare the Bootblock and U-Boot images using npcm8xx-bingo
|
||||
do_prepare_bootloaders() {
|
||||
local olddir="$(pwd)"
|
||||
cd ${DEPLOY_DIR_IMAGE}
|
||||
|
||||
bingo ${IGPS_DIR}/BL31_AndHeader.xml \
|
||||
-o ${BL31_HEADER_BINARY}
|
||||
|
||||
bingo ${IGPS_DIR}/OpTeeAndHeader.xml \
|
||||
-o ${OPTEE_HEADER_BINARY}
|
||||
|
||||
if [ "${TIP_IMAGE}" = "True" ]; then
|
||||
bingo ${IGPS_DIR}/BootBlockAndHeader_${DEVICE_GEN}_${IGPS_MACHINE}.xml \
|
||||
-o ${BB_HEADER_BINARY}
|
||||
else
|
||||
bingo ${IGPS_DIR}/BootBlockAndHeader_${DEVICE_GEN}_${IGPS_MACHINE}_NoTip.xml \
|
||||
-o ${BB_HEADER_BINARY}
|
||||
fi
|
||||
|
||||
bingo ${IGPS_DIR}/UbootHeader_${DEVICE_GEN}.xml \
|
||||
-o ${UBOOT_HEADER_BINARY}
|
||||
|
||||
cd "$olddir"
|
||||
}
|
||||
|
||||
check_keys() {
|
||||
if [ -n "${KEY_FOLDER}" ]; then
|
||||
echo "local"
|
||||
else
|
||||
echo "default"
|
||||
fi
|
||||
}
|
||||
|
||||
# Sign images for secure os be enabled and TIP mode only
|
||||
do_sign_binary() {
|
||||
if [ "${SECURED_IMAGE}" != "True" -o "${TIP_IMAGE}" != "True" ]; then
|
||||
return
|
||||
fi
|
||||
checked=`check_keys`
|
||||
if [ "${checked}" = "local" ]; then
|
||||
bbnote "Sign image with local keys"
|
||||
key_bb=${KEY_FOLDER}/${KEY_BB}
|
||||
key_bl31=${KEY_FOLDER}/${KEY_BL31}
|
||||
key_optee=${KEY_FOLDER}/${KEY_OPTEE}
|
||||
key_uboot=${KEY_FOLDER}/${KEY_UBOOT}
|
||||
else
|
||||
bbnote "Sign image with default keys"
|
||||
key_bb=${KEY_FOLDER_DEFAULT}/${KEY_BB}
|
||||
key_bl31=${KEY_FOLDER_DEFAULT}/${KEY_BL31}
|
||||
key_optee=${KEY_FOLDER_DEFAULT}/${KEY_OPTEE}
|
||||
key_uboot=${KEY_FOLDER_DEFAULT}/${KEY_UBOOT}
|
||||
fi
|
||||
bbnote "BB sign key from ${checked}: ${key_bb}"
|
||||
bbnote "BL31 sign key from ${checked}: ${key_bl31}"
|
||||
bbnote "OPTEE sign key from ${checked}: ${key_optee}"
|
||||
bbnote "UBOOT sign key from ${checked}: ${key_uboot}"
|
||||
# Used to embed the key index inside the image, usually at offset 0x140
|
||||
python3 ${IGPS_DIR}/BinarySignatureGenerator.py Replace_binary_single_byte \
|
||||
${DEPLOY_DIR_IMAGE}/${BB_HEADER_BINARY} 140 ${KEY_BB_INDEX}
|
||||
|
||||
python3 ${IGPS_DIR}/BinarySignatureGenerator.py Replace_binary_single_byte \
|
||||
${DEPLOY_DIR_IMAGE}/${BL31_HEADER_BINARY} 140 ${SKMT_BL31_KEY_INDEX}
|
||||
|
||||
python3 ${IGPS_DIR}/BinarySignatureGenerator.py Replace_binary_single_byte \
|
||||
${DEPLOY_DIR_IMAGE}/${OPTEE_HEADER_BINARY} 140 ${SKMT_BL32_KEY_INDEX}
|
||||
|
||||
python3 ${IGPS_DIR}/BinarySignatureGenerator.py Replace_binary_single_byte \
|
||||
${DEPLOY_DIR_IMAGE}/${UBOOT_HEADER_BINARY} 140 ${SKMT_BL33_KEY_INDEX}
|
||||
|
||||
# Sign specific image with specific key
|
||||
res=`python3 ${IGPS_DIR}/BinarySignatureGenerator.py Sign_binary \
|
||||
${DEPLOY_DIR_IMAGE}/${BB_HEADER_BINARY} 112 ${key_bb} 16 \
|
||||
${DEPLOY_DIR_IMAGE}/${BB_HEADER_BINARY} ${SIGN_TYPE} 0 ${KEY_BB_ID}
|
||||
|
||||
python3 ${IGPS_DIR}/BinarySignatureGenerator.py Sign_binary \
|
||||
${DEPLOY_DIR_IMAGE}/${BL31_HEADER_BINARY} 112 ${key_bl31} 16 \
|
||||
${DEPLOY_DIR_IMAGE}/${BL31_HEADER_BINARY} ${SIGN_TYPE} 0 ${KEY_BL31_ID}
|
||||
|
||||
python3 ${IGPS_DIR}/BinarySignatureGenerator.py Sign_binary \
|
||||
${DEPLOY_DIR_IMAGE}/${OPTEE_HEADER_BINARY} 112 ${key_optee} 16 \
|
||||
${DEPLOY_DIR_IMAGE}/${OPTEE_HEADER_BINARY} ${SIGN_TYPE} 0 ${KEY_OPTEE_ID}
|
||||
|
||||
python3 ${IGPS_DIR}/BinarySignatureGenerator.py Sign_binary \
|
||||
${DEPLOY_DIR_IMAGE}/${UBOOT_HEADER_BINARY} 112 ${key_uboot} 16 \
|
||||
${DEPLOY_DIR_IMAGE}/${UBOOT_HEADER_BINARY} ${SIGN_TYPE} 0 ${KEY_UBOOT_ID}`
|
||||
|
||||
# Stop full image build process when sign binary got failed
|
||||
set +e
|
||||
err=`echo $res | grep -E "missing|Invalid|failed"`
|
||||
if [ -n "${err}" ]; then
|
||||
bbfatal "Sign binary failed: keys are not found or invalid. Please check your KEY_FOLDER and KEY definition."
|
||||
fi
|
||||
set -e
|
||||
}
|
||||
|
||||
python do_merge_bootloaders() {
|
||||
TIP_IMAGE = d.getVar('TIP_IMAGE', True)
|
||||
def Merge_bin_files_and_pad(inF1, inF2, outF, align, align_end):
|
||||
padding_size = 0
|
||||
padding_size_end = 0
|
||||
F1_size = os.path.getsize(inF1)
|
||||
F2_size = os.path.getsize(inF2)
|
||||
|
||||
if ((F1_size % align) != 0):
|
||||
padding_size = align - (F1_size % align)
|
||||
|
||||
if ((F2_size % align_end) != 0):
|
||||
padding_size_end = align_end - (F2_size % align_end)
|
||||
|
||||
with open(outF, "wb") as file3:
|
||||
with open(inF1, "rb") as file1:
|
||||
data = file1.read()
|
||||
file3.write(data)
|
||||
|
||||
file3.write(b'\xFF' * padding_size)
|
||||
|
||||
with open(inF2, "rb") as file2:
|
||||
data = file2.read()
|
||||
file3.write(data)
|
||||
|
||||
file3.write(b'\xFF' * padding_size_end)
|
||||
|
||||
if TIP_IMAGE == "True":
|
||||
Merge_bin_files_and_pad(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('KMT_TIPFW_BINARY',True)),
|
||||
os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('BB_HEADER_BINARY',True)),
|
||||
os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('KMT_TIPFW_BB_BINARY',True)),
|
||||
int(d.getVar('BB_ALIGN', True)), int(d.getVar('ALIGN_END', True)))
|
||||
|
||||
Merge_bin_files_and_pad(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('KMT_TIPFW_BB_BINARY',True)),
|
||||
os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('BL31_HEADER_BINARY',True)),
|
||||
os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('KMT_TIPFW_BB_BL31_BINARY',True)),
|
||||
int(d.getVar('ATF_ALIGN', True)), int(d.getVar('ALIGN_END', True)))
|
||||
|
||||
Merge_bin_files_and_pad(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('KMT_TIPFW_BB_BL31_BINARY',True)),
|
||||
os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('OPTEE_HEADER_BINARY',True)),
|
||||
os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('KMT_TIPFW_BB_BL31_TEE_BINARY',True)),
|
||||
int(d.getVar('OPTEE_ALIGN', True)), int(d.getVar('ALIGN_END', True)))
|
||||
|
||||
Merge_bin_files_and_pad(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('KMT_TIPFW_BB_BL31_TEE_BINARY',True)),
|
||||
os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('UBOOT_HEADER_BINARY',True)),
|
||||
os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('KMT_TIPFW_BB_UBOOT_BINARY',True)),
|
||||
int(d.getVar('UBOOT_ALIGN', True)), int(d.getVar('ALIGN_END', True)))
|
||||
else:
|
||||
Merge_bin_files_and_pad(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('BB_HEADER_BINARY',True)),
|
||||
os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('BL31_HEADER_BINARY',True)),
|
||||
os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('BB_BL31_BINARY',True)),
|
||||
int(d.getVar('ATF_ALIGN', True)), int(d.getVar('ALIGN_END', True)))
|
||||
|
||||
Merge_bin_files_and_pad(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('BB_BL31_BINARY',True)),
|
||||
os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('OPTEE_HEADER_BINARY',True)),
|
||||
os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('BB_BL31_TEE_BINARY',True)),
|
||||
int(d.getVar('OPTEE_ALIGN', True)), int(d.getVar('ALIGN_END', True)))
|
||||
|
||||
Merge_bin_files_and_pad(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('BB_BL31_TEE_BINARY',True)),
|
||||
os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('UBOOT_HEADER_BINARY',True)),
|
||||
os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), '%s' % d.getVar('BB_BL31_TEE_UBOOT_BINARY',True)),
|
||||
int(d.getVar('UBOOT_ALIGN', True)), int(d.getVar('ALIGN_END', True)))
|
||||
}
|
||||
|
||||
do_pad_binary[depends] += " \
|
||||
${@'npcm8xx-tip-fw:do_deploy' if d.getVar('TIP_IMAGE', True) == 'True' else ''} \
|
||||
npcm8xx-bootblock:do_deploy \
|
||||
u-boot-nuvoton:do_deploy \
|
||||
trusted-firmware-a:do_deploy \
|
||||
optee-os:do_deploy \
|
||||
npcm7xx-bingo-native:do_populate_sysroot \
|
||||
npcm8xx-igps-native:do_populate_sysroot \
|
||||
"
|
||||
|
||||
# link images for we only need to flash partial image with idea name
|
||||
do_generate_ext4_tar:append() {
|
||||
cd ${DEPLOY_DIR_IMAGE}
|
||||
ln -sf ${UBOOT_BINARY}.${MERGED_SUFFIX} image-u-boot
|
||||
ln -sf ${DEPLOY_DIR_IMAGE}/${FLASH_KERNEL_IMAGE} image-kernel
|
||||
ln -sf ${S}/ext4/${IMAGE_LINK_NAME}.${FLASH_EXT4_BASETYPE}.zst image-rofs
|
||||
ln -sf ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.rwfs.${FLASH_EXT4_OVERLAY_BASETYPE} image-rwfs
|
||||
ln -sf ${IMAGE_NAME}.rootfs.wic.gz image-emmc.gz
|
||||
}
|
||||
|
||||
addtask do_pad_binary before do_prepare_bootloaders
|
||||
addtask do_sign_binary before do_merge_bootloaders after do_prepare_bootloaders
|
||||
addtask do_prepare_bootloaders before do_generate_static after do_generate_rwfs_static
|
||||
addtask do_merge_bootloaders before do_generate_static after do_sign_binary
|
||||
addtask do_merge_bootloaders before do_generate_ext4_tar after do_prepare_bootloaders
|
||||
|
||||
# Include the full bootblock and u-boot in the final static image
|
||||
python do_generate_static:append() {
|
||||
_append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True),
|
||||
'u-boot.%s' % d.getVar('UBOOT_SUFFIX',True)),
|
||||
int(d.getVar('FLASH_UBOOT_OFFSET', True)),
|
||||
int(d.getVar('FLASH_KERNEL_OFFSET', True)))
|
||||
}
|
||||
|
||||
do_make_ubi:append() {
|
||||
# Concatenate the uboot and ubi partitions
|
||||
dd bs=1k conv=notrunc seek=${FLASH_UBOOT_OFFSET} \
|
||||
if=${DEPLOY_DIR_IMAGE}/u-boot.${UBOOT_SUFFIX} \
|
||||
of=${IMGDEPLOYDIR}/${IMAGE_NAME}.ubi.mtd
|
||||
}
|
||||
|
||||
do_make_ubi[depends] += "${PN}:do_prepare_bootloaders"
|
||||
do_generate_ubi_tar[depends] += "${PN}:do_prepare_bootloaders"
|
||||
do_generate_ubi_tar[depends] += "${PN}:do_merge_bootloaders"
|
||||
do_generate_static_tar[depends] += "${PN}:do_prepare_bootloaders"
|
||||
do_generate_static_tar[depends] += "${PN}:do_merge_bootloaders"
|
||||
do_generate_ext4_tar[depends] += "${PN}:do_prepare_bootloaders"
|
||||
do_generate_ext4_tar[depends] += "${PN}:do_merge_bootloaders"
|
||||
@@ -0,0 +1,40 @@
|
||||
# Base image version class extension
|
||||
|
||||
DEPENDS:append = " os-release"
|
||||
|
||||
def do_get_os_release_value(d, key):
|
||||
import configparser
|
||||
import io
|
||||
path = d.getVar('STAGING_DIR_TARGET', True) + d.getVar('sysconfdir', True)
|
||||
path = os.path.join(path, 'os-release')
|
||||
parser = configparser.ConfigParser(strict=False)
|
||||
parser.optionxform = str
|
||||
value = ''
|
||||
try:
|
||||
with open(path, 'r') as fd:
|
||||
buf = '[root]\n' + fd.read()
|
||||
fd = io.StringIO(buf)
|
||||
parser.read_file(fd)
|
||||
value = parser['root'][key]
|
||||
except:
|
||||
pass
|
||||
return value
|
||||
|
||||
def do_get_version(d):
|
||||
version = do_get_os_release_value(d, 'VERSION_ID')
|
||||
return version
|
||||
|
||||
def do_get_versionID(d):
|
||||
import hashlib
|
||||
version = do_get_version(d)
|
||||
version = version.strip('"')
|
||||
version_id = (hashlib.sha512(version.encode('utf-8')).hexdigest())[:8]
|
||||
return version_id
|
||||
|
||||
def do_get_buildID(d):
|
||||
build_id = do_get_os_release_value(d, 'BUILD_ID')
|
||||
return build_id
|
||||
|
||||
def do_get_extended_version(d):
|
||||
extended_version = do_get_os_release_value(d, 'EXTENDED_VERSION')
|
||||
return extended_version
|
||||
@@ -0,0 +1,64 @@
|
||||
####
|
||||
# Copyright 2021 Intel Corporation
|
||||
#
|
||||
# Add a class to support serving license info through bmcweb.
|
||||
#
|
||||
# bmcweb serves static content from the /usr/share/www folder, so this class
|
||||
# copies the license info from /usr/share/common-licenses to
|
||||
# /usr/share/www/common-licenses so it will be statically served by bmcweb.
|
||||
#
|
||||
# Requires 'COPY_LIC_DIRS' to be enabled to create /usr/share/common-licenses.
|
||||
#
|
||||
# Class can be inherited in a project bbclass to copy the license info.
|
||||
#
|
||||
# Example:
|
||||
# inherit license_static
|
||||
####
|
||||
|
||||
STATIC_LICENSE_DIR = "${IMAGE_ROOTFS}${datadir}/www/common-licenses"
|
||||
|
||||
|
||||
def add_index_html_header(f):
|
||||
f.write("<!DOCTYPE html>")
|
||||
f.write("<html>")
|
||||
f.write("<body>")
|
||||
f.write("<p>")
|
||||
|
||||
|
||||
def add_index_html_footer(f):
|
||||
f.write("</p>")
|
||||
f.write("</body>")
|
||||
f.write("</html>")
|
||||
|
||||
|
||||
def create_index_files(d):
|
||||
import os
|
||||
|
||||
static_license_dir = d.getVar('STATIC_LICENSE_DIR')
|
||||
for dirpath, dirnames, filenames in os.walk(static_license_dir):
|
||||
with open(os.path.join(dirpath, "index.html"), "w") as f:
|
||||
add_index_html_header(f)
|
||||
full_list = filenames+dirnames
|
||||
full_list.sort()
|
||||
f.write("<br>".join(full_list))
|
||||
add_index_html_footer(f)
|
||||
|
||||
|
||||
def copy_license_files(d):
|
||||
import shutil
|
||||
|
||||
rootfs_license_dir = d.getVar('ROOTFS_LICENSE_DIR')
|
||||
static_license_dir = d.getVar('STATIC_LICENSE_DIR')
|
||||
shutil.copytree(rootfs_license_dir, static_license_dir)
|
||||
|
||||
|
||||
python do_populate_static_lic() {
|
||||
copy_lic_dirs = d.getVar('COPY_LIC_DIRS')
|
||||
if copy_lic_dirs == "1":
|
||||
copy_license_files(d)
|
||||
create_index_files(d)
|
||||
else:
|
||||
bb.warn("Static licenses not copied because 'COPY_LIC_DIRS' is disabled.")
|
||||
}
|
||||
|
||||
ROOTFS_POSTPROCESS_COMMAND:append = "do_populate_static_lic; "
|
||||
@@ -0,0 +1,5 @@
|
||||
MRW_API_SRC_URI ?= "git://github.com/open-power/serverwiz.git;branch=master;protocol=https"
|
||||
MRW_API_SRCREV ?= "60c8e10cbb11768cd1ba394b35cb1d6627efec42"
|
||||
|
||||
MRW_TOOLS_SRC_URI ?= "git://github.com/openbmc/phosphor-mrw-tools;branch=master;protocol=https"
|
||||
MRW_TOOLS_SRCREV ?= "b4edc27a3c25cf78c6eeb06f5e45c3b379da445d"
|
||||
@@ -0,0 +1,4 @@
|
||||
MRW_XML ??= "${MACHINE}.xml"
|
||||
mrw_datadir = "${datadir}/obmc-mrw"
|
||||
SKIP_BROKEN_MRW ?= "0"
|
||||
EXTRA_MRW_SCRIPT_ARGS = "${@bb.utils.contains("SKIP_BROKEN_MRW", "0", "", "--skip-broken-mrw", d)}"
|
||||
@@ -0,0 +1,177 @@
|
||||
# Utilities and shortcuts for recipes providing D-Bus services.
|
||||
# Variables:
|
||||
# DBUS_PACKAGES ?= "${PN}"
|
||||
# The list of packages to which files should be added.
|
||||
#
|
||||
# DBUS_SERVICE:${PN} += "org.openbmc.Foo.service"
|
||||
# A list of dbus service names. The class will look for a
|
||||
# dbus configuration file with the same base name with .conf
|
||||
# appended. If one is found, it is added to the package
|
||||
# and used verbatim. If it is not found, a default one
|
||||
# (with very open permissions) is generated and used.
|
||||
#
|
||||
# Additionally the class will instantiate obmc-phosphor-systemd
|
||||
# with any SYSTEMD_SERVICE:%s variables translated appropriately.
|
||||
#
|
||||
# If a service begins with 'dbus-' DBus activation will be
|
||||
# configured. The class will look for an activation file
|
||||
# with the 'dbus-' prefix removed. If found, it is added to
|
||||
# the package and used verbatim. If it is not found, a default
|
||||
# one is generated and used.
|
||||
|
||||
|
||||
inherit dbus-dir
|
||||
inherit obmc-phosphor-utils
|
||||
|
||||
RDEPENDS:${PN}:append:class-target = " dbus-perms"
|
||||
DBUS_PACKAGES ?= "${PN}"
|
||||
|
||||
_INSTALL_DBUS_CONFIGS=""
|
||||
_DEFAULT_DBUS_CONFIGS=""
|
||||
_INSTALL_DBUS_ACTIVATIONS=""
|
||||
_DEFAULT_DBUS_ACTIVATIONS=""
|
||||
|
||||
|
||||
python dbus_do_postinst() {
|
||||
def make_default_dbus_config(d, unit, user):
|
||||
bus = unit.base
|
||||
if unit.is_template:
|
||||
bus = '%s*' % bus
|
||||
|
||||
path = d.getVar('D', True)
|
||||
path += d.getVar('dbus_system_confdir', True)
|
||||
with open('%s/%s.conf' % (path, unit.base), 'w+') as fd:
|
||||
fd.write('<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"\n')
|
||||
fd.write(' "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">\n')
|
||||
fd.write('<busconfig>\n')
|
||||
fd.write(' <policy user="%s">\n' % user)
|
||||
fd.write(' <allow own="%s"/>\n' % bus)
|
||||
fd.write(' <allow send_destination="%s"/>\n' % bus)
|
||||
fd.write(' </policy>\n')
|
||||
fd.write('</busconfig>\n')
|
||||
fd.close()
|
||||
|
||||
|
||||
def make_default_dbus_activation(d, unit, user):
|
||||
dest = unit.base
|
||||
sd_unit = unit.name
|
||||
if unit.is_instance:
|
||||
dest = '%s.%s' % (unit.base, unit.instance)
|
||||
sd_unit = '%s@%s' % (unit.base, unit.instance)
|
||||
|
||||
path = d.getVar('D', True)
|
||||
path += d.getVar('dbus_system_servicesdir', True)
|
||||
with open('%s/%s.service' % (path, dest), 'w+') as fd:
|
||||
fd.write('[D-BUS Service]\n')
|
||||
fd.write('Name=%s\n' % dest)
|
||||
fd.write('Exec=/bin/false\n')
|
||||
fd.write('User=%s\n' % user)
|
||||
fd.write('SystemdService=dbus-%s.service\n' % sd_unit)
|
||||
fd.close()
|
||||
|
||||
|
||||
for service_user in listvar_to_list(d, '_DEFAULT_DBUS_CONFIGS'):
|
||||
service, user = service_user.split(':')
|
||||
make_default_dbus_config(d, SystemdUnit(service), user)
|
||||
for service_user in listvar_to_list(d, '_DEFAULT_DBUS_ACTIVATIONS'):
|
||||
service, user = service_user.split(':')
|
||||
make_default_dbus_activation(d, SystemdUnit(service), user)
|
||||
}
|
||||
|
||||
|
||||
python() {
|
||||
searchpaths = d.getVar('FILESPATH', True)
|
||||
|
||||
def get_user(d, service, pkg):
|
||||
user = d.getVar(
|
||||
'SYSTEMD_USER_%s' % service, True)
|
||||
if user is None:
|
||||
user = d.getVar(
|
||||
'SYSTEMD_USER_%s' % pkg, True) or 'root'
|
||||
return user
|
||||
|
||||
|
||||
def add_dbus_config(d, unit, pkg):
|
||||
path = bb.utils.which(searchpaths, '%s.conf' % unit.base)
|
||||
if not os.path.isfile(path):
|
||||
user = get_user(d, unit.name, pkg)
|
||||
set_doappend(d, '_DEFAULT_DBUS_CONFIGS', '%s:%s' % (
|
||||
unit.name, user))
|
||||
else:
|
||||
set_doappend(d, 'SRC_URI', 'file://%s.conf' % unit.base)
|
||||
set_doappend(d, '_INSTALL_DBUS_CONFIGS', '%s.conf' % unit.base)
|
||||
set_doappend(d, 'FILES:%s' % pkg, '%s%s.conf' \
|
||||
% (d.getVar('dbus_system_confdir', True), unit.base))
|
||||
|
||||
|
||||
def add_dbus_activation(d, unit, pkg):
|
||||
if not unit.is_activated or unit.is_template:
|
||||
return
|
||||
search_match = '%s.service' % unit.base
|
||||
if unit.is_instance:
|
||||
search_match = '%s.%s.service' % (unit.base, unit.instance)
|
||||
|
||||
path = bb.utils.which(searchpaths, search_match)
|
||||
|
||||
if not os.path.isfile(path):
|
||||
user = get_user(d, unit.base, pkg)
|
||||
set_doappend(d, '_DEFAULT_DBUS_ACTIVATIONS', '%s:%s' % (
|
||||
unit.name, user))
|
||||
else:
|
||||
set_doappend(d, 'SRC_URI', 'file://%s' % search_match)
|
||||
set_doappend(d, '_INSTALL_DBUS_ACTIVATIONS', search_match)
|
||||
set_doappend(d, 'FILES:%s' % pkg, '%s%s' \
|
||||
% (d.getVar('dbus_system_servicesdir', True), search_match))
|
||||
|
||||
|
||||
if d.getVar('CLASSOVERRIDE', True) != 'class-target':
|
||||
return
|
||||
|
||||
d.appendVarFlag('do_install', 'postfuncs', ' dbus_do_postinst')
|
||||
|
||||
for pkg in listvar_to_list(d, 'DBUS_PACKAGES'):
|
||||
if pkg not in (d.getVar('SYSTEMD_PACKAGES', True) or ''):
|
||||
set_doappend(d, 'SYSTEMD_PACKAGES', pkg)
|
||||
|
||||
svc = listvar_to_list(d, 'DBUS_SERVICE:%s' % pkg)
|
||||
svc = [SystemdUnit(x) for x in svc]
|
||||
inst = [x for x in svc if x.is_instance]
|
||||
tmpl = [x.template for x in svc if x.is_instance]
|
||||
tmpl = list(set(tmpl))
|
||||
tmpl = [SystemdUnit(x) for x in tmpl]
|
||||
svc = [x for x in svc if not x.is_instance]
|
||||
|
||||
for unit in inst:
|
||||
set_doappend(
|
||||
d, 'SYSTEMD_SERVICE:%s' % pkg, unit.name)
|
||||
|
||||
for unit in tmpl + svc:
|
||||
add_dbus_config(d, unit, pkg)
|
||||
add_dbus_activation(d, unit, pkg)
|
||||
set_doappend(
|
||||
d, 'SYSTEMD_SERVICE:%s' % pkg, unit.name)
|
||||
set_doappend(d, 'SYSTEMD_SUBSTITUTIONS',
|
||||
'BUSNAME:%s:%s' % (unit.base, unit.name))
|
||||
}
|
||||
|
||||
|
||||
do_install:append() {
|
||||
# install the dbus configuration files
|
||||
[ -z "${_INSTALL_DBUS_CONFIGS}" ] && \
|
||||
[ -z "${_DEFAULT_DBUS_CONFIGS}" ] || \
|
||||
install -d ${D}${dbus_system_confdir}
|
||||
for c in ${_INSTALL_DBUS_CONFIGS}; do
|
||||
install -m 0644 ${WORKDIR}/$c \
|
||||
${D}${dbus_system_confdir}$c
|
||||
done
|
||||
# install the dbus activation files
|
||||
[ -z "${_INSTALL_DBUS_ACTIVATIONS}" ] && \
|
||||
[ -z "${_DEFAULT_DBUS_ACTIVATIONS}" ] || \
|
||||
install -d ${D}${dbus_system_servicesdir}
|
||||
for s in ${_INSTALL_DBUS_ACTIVATIONS}; do
|
||||
install -m 0644 ${WORKDIR}/$s\
|
||||
${D}${dbus_system_servicesdir}$s
|
||||
done
|
||||
}
|
||||
|
||||
inherit obmc-phosphor-systemd
|
||||
@@ -0,0 +1,21 @@
|
||||
# IMAGE_FSTYPES must appear before image.bbclass
|
||||
# is inherited otherwise image.bbclass will inherit
|
||||
# "live" image fstypes that we don't want.
|
||||
IMAGE_FSTYPES = "tar.xz"
|
||||
|
||||
inherit image
|
||||
|
||||
LICENSE = "Apache-2.0"
|
||||
|
||||
IMAGE_INSTALL:append = " busybox packagegroup-obmc-phosphor-debugtools perf "
|
||||
|
||||
# Override from image_types.bbclass to restrict tarball to /usr tree.
|
||||
IMAGE_CMD:tar = "${IMAGE_CMD_TAR} -cvf ${IMGDEPLOYDIR}/${IMAGE_NAME}.tar -C ${IMAGE_ROOTFS}/usr ."
|
||||
|
||||
# Remove packages installed by 'extrausers'.
|
||||
IMAGE_INSTALL:remove = "base-passwd shadow"
|
||||
EXTRA_USERS_PARAMS = ""
|
||||
|
||||
# Remove extra packages defaulted by image.bbclass.
|
||||
PACKAGE_INSTALL = "${IMAGE_INSTALL}"
|
||||
IMAGE_LINGUAS = ""
|
||||
@@ -0,0 +1,114 @@
|
||||
inherit obmc-phosphor-utils
|
||||
DISCOVERY_SVC_PACKAGES ?= "${PN}"
|
||||
|
||||
python() {
|
||||
avahi_enabled = bb.utils.contains(
|
||||
'DISTRO_FEATURES', 'avahi', True, False, d)
|
||||
slp_enabled = bb.utils.contains(
|
||||
'DISTRO_FEATURES', 'slp', True, False, d)
|
||||
|
||||
if not avahi_enabled and not slp_enabled:
|
||||
return
|
||||
|
||||
syscnfdir = d.getVar('sysconfdir', True)
|
||||
dest_dir = d.getVar('D', True)
|
||||
|
||||
set_doappend(d, 'AVAHI_SERVICES_DIR', os.path.join(
|
||||
dest_dir+syscnfdir,
|
||||
'avahi',
|
||||
'services'))
|
||||
set_doappend(d, 'SLP_SERVICES_DIR', os.path.join(
|
||||
dest_dir+syscnfdir,
|
||||
'slp',
|
||||
'services'))
|
||||
|
||||
|
||||
for pkg in listvar_to_list(d, 'DISCOVERY_SVC_PACKAGES'):
|
||||
for service in listvar_to_list(d, 'REGISTERED_SERVICES:%s' % pkg):
|
||||
if avahi_enabled:
|
||||
set_doappend(d, 'RRECOMMENDS:%s' % pkg, 'avahi-daemon')
|
||||
svc_name, svc_type, svc_port, svc_txt_data = service.split(':')
|
||||
set_doappend(d, 'FILES:%s' % pkg, os.path.join(
|
||||
syscnfdir,
|
||||
'avahi',
|
||||
'services',
|
||||
'%s.service' % svc_name))
|
||||
|
||||
if slp_enabled:
|
||||
set_doappend(d, 'RRECOMMENDS:%s' % pkg, 'slpd-lite')
|
||||
svc_name, svc_type, svc_port, svc_txt_data = service.split(':')
|
||||
set_doappend(d, 'FILES:%s' % pkg, os.path.join(
|
||||
syscnfdir,
|
||||
'slp',
|
||||
'services',
|
||||
'%s.service' % svc_name))
|
||||
|
||||
}
|
||||
|
||||
python discovery_services_postinstall() {
|
||||
avahi_enabled = bb.utils.contains(
|
||||
'DISTRO_FEATURES', 'avahi', True, False, d)
|
||||
slp_enabled = bb.utils.contains(
|
||||
'DISTRO_FEATURES', 'slp', True, False, d)
|
||||
|
||||
if not avahi_enabled and not slp_enabled:
|
||||
return
|
||||
|
||||
avahi_service_dir = d.getVar('AVAHI_SERVICES_DIR', True).strip()
|
||||
slp_service_dir = d.getVar('SLP_SERVICES_DIR', True).strip()
|
||||
|
||||
if not os.path.exists(avahi_service_dir):
|
||||
os.makedirs(avahi_service_dir)
|
||||
|
||||
if not os.path.exists(slp_service_dir):
|
||||
os.makedirs(slp_service_dir)
|
||||
|
||||
def register_service_avahi(d, service_name, service_type, service_port, service_txt_data):
|
||||
service_txt_data = service_txt_data.split('|')
|
||||
service_file = os.path.join(
|
||||
avahi_service_dir,
|
||||
'%s.service' % service_name)
|
||||
with open(service_file, 'w') as fd:
|
||||
fd.write('<?xml version="1.0" ?>\n')
|
||||
fd.write('<!DOCTYPE service-group SYSTEM "avahi-service.dtd">\n')
|
||||
fd.write('<service-group>\n')
|
||||
fd.write(' <name replace-wildcards="yes">%s on %%h</name>\n'
|
||||
% service_name)
|
||||
fd.write(' <service>\n')
|
||||
fd.write(' <type>%s</type>\n' % service_type)
|
||||
fd.write(' <port>%s</port>\n' % service_port)
|
||||
for txt_record in service_txt_data:
|
||||
if txt_record:
|
||||
key, value = txt_record.split('=')
|
||||
if key.strip() and value.strip():
|
||||
fd.write(' <txt-record>%s</txt-record>\n' % txt_record)
|
||||
else:
|
||||
bb.fatal('Invalid Additional data : \'%s\'. Ignoring!' % txt_record)
|
||||
fd.write(' </service>\n')
|
||||
fd.write('</service-group>\n')
|
||||
|
||||
def register_service_slp(d, service_name, service_type, service_port):
|
||||
service_file = os.path.join(
|
||||
slp_service_dir,
|
||||
'%s.service' % service_name)
|
||||
with open(service_file, 'w') as fd:
|
||||
fd.write('%s %s %s' % (service_name, service_type, service_port))
|
||||
|
||||
def register_services(d,pkg):
|
||||
for service in listvar_to_list(d, 'REGISTERED_SERVICES:%s' % pkg):
|
||||
svc_info = service.split(":")
|
||||
try:
|
||||
svc_name, svc_type, svc_port, svc_txt_data = svc_info
|
||||
except:
|
||||
continue
|
||||
if avahi_enabled:
|
||||
avahi_svc_type = "_" + svc_name + "._" + svc_type
|
||||
register_service_avahi(d, svc_name, avahi_svc_type, svc_port, svc_txt_data)
|
||||
if slp_enabled:
|
||||
register_service_slp(d, svc_name, svc_type, svc_port)
|
||||
|
||||
for pkg in listvar_to_list(d, 'DISCOVERY_SVC_PACKAGES'):
|
||||
register_services(d, pkg)
|
||||
|
||||
}
|
||||
do_install[postfuncs] += "discovery_services_postinstall"
|
||||
@@ -0,0 +1,104 @@
|
||||
# Common code for generating Phosphor OpenBMC images.
|
||||
|
||||
# Additional IMAGE_FEATURES available with Phosphor OpenBMC:
|
||||
#
|
||||
# - obmc-bmc-state-mgmt - OpenBMC BMC state management
|
||||
# - obmc-bmcweb - OpenBMC webserver
|
||||
# - obmc-chassis-mgmt - OpenBMC chassis management
|
||||
# - obmc-chassis-state-mgmt - OpenBMC chassis state management
|
||||
# - obmc-console - OpenBMC serial over LAN
|
||||
# - obmc-dbus-monitor - OpenBMC dbus monitoring
|
||||
# - obmc-debug-collector - OpenBMC debug collector
|
||||
# - obmc-devtools - OpenBMC development and debugging tools
|
||||
# - obmc-fan-control - OpenBMC fan management
|
||||
# - obmc-fan-mgmt - Deprecated - use obmc-fan-control instead
|
||||
# - obmc-flash-mgmt - OpenBMC flash management
|
||||
# - obmc-fru-ipmi - OpenBMC IPMI FRU EEPROM support
|
||||
# - obmc-health-monitor - OpenBMC health monitoring
|
||||
# - obmc-host-ctl - OpenBMC host control
|
||||
# - obmc-host-ipmi - OpenBMC host IPMI
|
||||
# - obmc-host-state-mgmt - OpenBMC host state management
|
||||
# - obmc-ikvm - OpenBMC KVM over IP
|
||||
# - obmc-inventory - OpenBMC inventory support
|
||||
# - obmc-leds - OpenBMC LED support
|
||||
# - obmc-logging-mgmt - OpenBMC logging management
|
||||
# - obmc-remote-logging-mgmt - OpenBMC remote logging management
|
||||
# - obmc-rng - OpenBMC random number generator
|
||||
# - obmc-sensors - OpenBMC sensor support
|
||||
# - obmc-settings-mgmt - OpenBMC settings management
|
||||
# - obmc-software - OpenBMC software management
|
||||
# - obmc-system-mgmt - OpenBMC system management
|
||||
# - obmc-telemetry - OpenBMC telemetry solution
|
||||
# - obmc-user-mgmt - OpenBMC user management
|
||||
# - obmc-user-mgmt-ldap - OpenBMC LDAP users
|
||||
|
||||
inherit core-image
|
||||
inherit obmc-phosphor-utils
|
||||
|
||||
FEATURE_PACKAGES_obmc-bmc-state-mgmt ?= "packagegroup-obmc-apps-bmc-state-mgmt"
|
||||
FEATURE_PACKAGES_obmc-bmcweb ?= "packagegroup-obmc-apps-bmcweb"
|
||||
FEATURE_PACKAGES_obmc-chassis-mgmt ?= "${@bb.utils.contains('COMBINED_FEATURES', 'obmc-phosphor-chassis-mgmt', 'virtual-obmc-chassis-mgmt', '', d)}"
|
||||
FEATURE_PACKAGES_obmc-chassis-state-mgmt ?= "packagegroup-obmc-apps-chassis-state-mgmt"
|
||||
FEATURE_PACKAGES_obmc-console ?= "packagegroup-obmc-apps-console"
|
||||
FEATURE_PACKAGES_obmc-dbus-monitor ?= "packagegroup-obmc-apps-dbus-monitor"
|
||||
FEATURE_PACKAGES_obmc-devtools ?= "packagegroup-obmc-apps-devtools"
|
||||
FEATURE_PACKAGES_obmc-fan-control ?= "packagegroup-obmc-apps-fan-control"
|
||||
FEATURE_PACKAGES_obmc-fan-mgmt ?= "${@bb.utils.contains('COMBINED_FEATURES', 'obmc-phosphor-fan-mgmt', 'virtual-obmc-fan-mgmt', '', d)}"
|
||||
FEATURE_PACKAGES_obmc-flash-mgmt ?= "${@bb.utils.contains('COMBINED_FEATURES', 'obmc-phosphor-flash-mgmt', 'virtual-obmc-flash-mgmt', '', d)}"
|
||||
FEATURE_PACKAGES_obmc-fru-ipmi ?= "packagegroup-obmc-apps-fru-ipmi"
|
||||
FEATURE_PACKAGES_obmc-health-monitor ?= "packagegroup-obmc-apps-health-monitor"
|
||||
FEATURE_PACKAGES_obmc-host-ctl ?= "${@bb.utils.contains('COMBINED_FEATURES', 'obmc-host-ctl', 'virtual-obmc-host-ctl', '', d)}"
|
||||
FEATURE_PACKAGES_obmc-host-ipmi ?= "${@bb.utils.contains('COMBINED_FEATURES', 'obmc-host-ipmi', 'virtual-obmc-host-ipmi-hw', '', d)}"
|
||||
FEATURE_PACKAGES_obmc-host-state-mgmt ?= "packagegroup-obmc-apps-host-state-mgmt"
|
||||
FEATURE_PACKAGES_obmc-ikvm ?= "packagegroup-obmc-apps-ikvm"
|
||||
FEATURE_PACKAGES_obmc-inventory ?= "packagegroup-obmc-apps-inventory"
|
||||
FEATURE_PACKAGES_obmc-leds ?= "packagegroup-obmc-apps-leds"
|
||||
FEATURE_PACKAGES_obmc-logging-mgmt ?= "packagegroup-obmc-apps-logging"
|
||||
FEATURE_PACKAGES_obmc-remote-logging-mgmt ?= "packagegroup-obmc-apps-remote-logging"
|
||||
FEATURE_PACKAGES_obmc-rng ?= "packagegroup-obmc-apps-rng"
|
||||
FEATURE_PACKAGES_obmc-net-ipmi ?= "phosphor-ipmi-net"
|
||||
FEATURE_PACKAGES_obmc-sensors ?= "packagegroup-obmc-apps-sensors"
|
||||
FEATURE_PACKAGES_obmc-software ?= "packagegroup-obmc-apps-software"
|
||||
FEATURE_PACKAGES_obmc-system-mgmt ?= "${@bb.utils.contains('DISTRO_FEATURES', 'obmc-phosphor-system-mgmt', 'virtual-obmc-system-mgmt', '', d)}"
|
||||
FEATURE_PACKAGES_obmc-debug-collector ?= "packagegroup-obmc-apps-debug-collector"
|
||||
FEATURE_PACKAGES_obmc-settings-mgmt ?= "packagegroup-obmc-apps-settings"
|
||||
FEATURE_PACKAGES_obmc-network-mgmt ?= "packagegroup-obmc-apps-network"
|
||||
FEATURE_PACKAGES_obmc-telemetry ?= "packagegroup-obmc-apps-telemetry"
|
||||
FEATURE_PACKAGES_obmc-user-mgmt ?= "packagegroup-obmc-apps-user-mgmt"
|
||||
FEATURE_PACKAGES_obmc-user-mgmt-ldap ?= "packagegroup-obmc-apps-user-mgmt-ldap"
|
||||
FEATURE_PACKAGES_obmc-dmtf-pmci ?= "packagegroup-obmc-apps-dmtf-pmci"
|
||||
|
||||
# FIXME: phosphor-net-ipmi depends on phosphor-ipmi-host !?!? and
|
||||
# cannot be built on core-qemu machines because of the dependency
|
||||
# tree under phosphor-ipmi-host
|
||||
FEATURE_PACKAGES_obmc-net-ipmi:qemuall = ""
|
||||
|
||||
# EVB systems do not have a managed system.
|
||||
FEATURE_PACKAGES_obmc-system-mgmt:phosphor-evb = ""
|
||||
# QEMU systems are like EVBs and do not have a managed system.
|
||||
FEATURE_PACKAGES_obmc-system-mgmt:qemuall = ""
|
||||
|
||||
# Add new packages to be installed to a package group in
|
||||
# packagegroup-obmc-apps, not here.
|
||||
OBMC_IMAGE_BASE_INSTALL = " \
|
||||
packagegroup-obmc-apps-extras \
|
||||
${OBMC_IMAGE_EXTRA_INSTALL} \
|
||||
"
|
||||
|
||||
OBMC_IMAGE_EXTRA_INSTALL ?= ""
|
||||
|
||||
CORE_IMAGE_EXTRA_INSTALL += "${OBMC_IMAGE_BASE_INSTALL}"
|
||||
|
||||
remove_etc_version() {
|
||||
rm ${IMAGE_ROOTFS}${sysconfdir}/version
|
||||
}
|
||||
|
||||
enable_ldap_nsswitch() {
|
||||
sed -i 's/\(\(passwd\|group\):\s*\).*/\1files systemd ldap/' \
|
||||
"${IMAGE_ROOTFS}${sysconfdir}/nsswitch.conf"
|
||||
sed -i 's/\(shadow:\s*\).*/\1files ldap/' \
|
||||
"${IMAGE_ROOTFS}${sysconfdir}/nsswitch.conf"
|
||||
}
|
||||
|
||||
ROOTFS_POSTPROCESS_COMMAND += "${@bb.utils.contains('IMAGE_FEATURES', 'obmc-user-mgmt-ldap', 'enable_ldap_nsswitch ;', '', d)}"
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# Common code for recipes that create IPMI provider libraries
|
||||
|
||||
inherit obmc-phosphor-utils
|
||||
|
||||
# This LIBDIR is searched for the libraries.
|
||||
LIBDIR = "${D}/${libdir}/ipmid-providers/"
|
||||
|
||||
# The symlinks are installed in the following directories depending on the
|
||||
# variable.
|
||||
HOSTIPMI_LIBDIR = "${D}/${libdir}/host-ipmid/"
|
||||
NETIPMI_LIBDIR = "${D}/${libdir}/net-ipmid/"
|
||||
BLOBIPMI_LIBDIR = "${D}/${libdir}/blob-ipmid/"
|
||||
|
||||
python symlink_create_postinstall() {
|
||||
def install_symlink(d, libname, install_dir):
|
||||
import glob;
|
||||
|
||||
if not os.path.exists(install_dir):
|
||||
os.makedirs(install_dir)
|
||||
|
||||
lib_dir = d.getVar('LIBDIR', True)
|
||||
|
||||
# find the library extension libxxx.so.?
|
||||
install_file = lib_dir + libname + ".?"
|
||||
|
||||
filelist = glob.glob(install_file);
|
||||
|
||||
# get the library name
|
||||
path, file = os.path.split(filelist[0])
|
||||
source = "../ipmid-providers/" + file
|
||||
|
||||
# create the symlink
|
||||
os.symlink(source, os.path.join(install_dir, file))
|
||||
|
||||
for libname in listvar_to_list(d, 'HOSTIPMI_PROVIDER_LIBRARY'):
|
||||
install_dir = d.getVar('HOSTIPMI_LIBDIR', True)
|
||||
install_symlink(d, libname, install_dir)
|
||||
|
||||
for libname in listvar_to_list(d, 'NETIPMI_PROVIDER_LIBRARY'):
|
||||
install_dir = d.getVar('NETIPMI_LIBDIR', True)
|
||||
install_symlink(d, libname, install_dir)
|
||||
|
||||
for libname in listvar_to_list(d, 'BLOBIPMI_PROVIDER_LIBRARY'):
|
||||
install_dir = d.getVar('BLOBIPMI_LIBDIR', True)
|
||||
install_symlink(d, libname, install_dir)
|
||||
}
|
||||
do_install[postfuncs] += "symlink_create_postinstall"
|
||||
@@ -0,0 +1,17 @@
|
||||
do_kernel_configme:append() {
|
||||
# Remove previous CONFIG_LOCALVERSION
|
||||
sed -i '/CONFIG_LOCALVERSION/d' ${B}/.config
|
||||
|
||||
# Latest version after yocto patched (if any)
|
||||
latestVersion="-$(git rev-parse --verify HEAD)"
|
||||
shortLatestVersion="$(echo ${latestVersion} | cut -c1-8)"
|
||||
|
||||
shortLinuxVersionExt="$(echo ${LINUX_VERSION_EXTENSION} | cut -c1-8)"
|
||||
|
||||
if [ "${latestVersion}" != "${LINUX_VERSION_EXTENSION}" ]; then
|
||||
dirtyString="-dirty"
|
||||
echo "CONFIG_LOCALVERSION="\"${shortLinuxVersionExt}${dirtyString}${shortLatestVersion}\" >> ${B}/.config
|
||||
else
|
||||
echo "CONFIG_LOCALVERSION="\"${shortLinuxVersionExt}\" >> ${B}/.config
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
# Common code for applications providing a D-Bus service using sd-bus bindings.
|
||||
|
||||
# Class users should define DBUS_SERVICES prior to including.
|
||||
|
||||
DEPENDS += "systemd"
|
||||
RDEPENDS:${PN} += "libsystemd"
|
||||
|
||||
inherit obmc-phosphor-dbus-service
|
||||
@@ -0,0 +1,347 @@
|
||||
# Common code for systemd based services.
|
||||
#
|
||||
# Prior to inheriting this class, recipes can define services like this:
|
||||
#
|
||||
# SYSTEMD_SERVICE:${PN} = "foo.service bar.socket baz@.service"
|
||||
#
|
||||
# and these files will be added to the main package if they exist.
|
||||
#
|
||||
# Alternatively this class can just be inherited and
|
||||
# ${PN}.service will be added to the main package.
|
||||
#
|
||||
# Other variables:
|
||||
# INHIBIT_SYSTEMD_RESTART_POLICY_${unit}
|
||||
# Inhibit the warning that is displayed if a service unit without a
|
||||
# restart policy is detected.
|
||||
#
|
||||
# SYSTEMD_SUBSTITUTIONS = "var:val:file"
|
||||
# A specification for making python style {format} string
|
||||
# substitutions where:
|
||||
# var: the format string to search for
|
||||
# val: the value to replace with
|
||||
# file: the file in which to make the substitution
|
||||
#
|
||||
# SYSTEMD_USER_${PN}.service = "foo"
|
||||
# SYSTEMD_USER_${unit}.service = "foo"
|
||||
# The user for the unit/package.
|
||||
#
|
||||
# SYSTEMD_ENVIRONMENT_FILE:${PN} = "foo"
|
||||
# One or more environment files to be installed.
|
||||
#
|
||||
# SYSTEMD_LINK:${PN} = "tgt:name"
|
||||
# A specification for installing arbitrary links in
|
||||
# the ${systemd_system_unitdir} namespace, where:
|
||||
# tgt: the link target
|
||||
# name: the link name, relative to ${systemd_system_unitdir}
|
||||
#
|
||||
# SYSTEMD_OVERRIDE:${PN} = "src:dest"
|
||||
# A specification for installing unit overrides where:
|
||||
# src: the override file template
|
||||
# dest: the override install location, relative to ${systemd_system_unitdir}
|
||||
#
|
||||
# Typically SYSTEMD_SUBSTITUTIONS is used to deploy a range
|
||||
# of overrides from a single template file. To simply install
|
||||
# a single override use "foo.conf:my-service.d/foo.conf"
|
||||
|
||||
|
||||
inherit obmc-phosphor-utils
|
||||
inherit systemd
|
||||
inherit useradd
|
||||
|
||||
_INSTALL_SD_UNITS=""
|
||||
SYSTEMD_DEFAULT_TARGET ?= "multi-user.target"
|
||||
envfiledir ?= "${sysconfdir}/default"
|
||||
|
||||
# Big ugly hack to prevent useradd.bbclass post-parse sanity checker failure.
|
||||
# If there are users to be added, we'll add them in our post-parse.
|
||||
# If not...there don't seem to be any ill effects...
|
||||
USERADD_PACKAGES ?= " "
|
||||
USERADD_PARAM:${PN} ?= ";"
|
||||
|
||||
|
||||
def SystemdUnit(unit):
|
||||
class Unit(object):
|
||||
def __init__(self, unit):
|
||||
self.unit = unit
|
||||
|
||||
def __getattr__(self, item):
|
||||
if item == 'name':
|
||||
return self.unit
|
||||
if item == 'is_activated':
|
||||
return self.unit.startswith('dbus-')
|
||||
if item == 'is_template':
|
||||
return '@.' in self.unit
|
||||
if item == 'is_instance':
|
||||
return '@' in self.unit and not self.is_template
|
||||
if item in ['is_service', 'is_target']:
|
||||
return self.unit.split('.')[-1] == item
|
||||
if item == 'base':
|
||||
cls = self.unit.split('.')[-1]
|
||||
base = self.unit.replace('dbus-', '')
|
||||
base = base.replace('.%s' % cls, '')
|
||||
if self.is_instance:
|
||||
base = base.replace('@%s' % self.instance, '')
|
||||
if self.is_template:
|
||||
base = base.rstrip('@')
|
||||
return base
|
||||
if item == 'instance' and self.is_instance:
|
||||
inst = self.unit.rsplit('@')[-1]
|
||||
return inst.rsplit('.')[0]
|
||||
if item == 'template' and self.is_instance:
|
||||
cls = self.unit.split('.')[-1]
|
||||
return '%s@.%s' % (self.base, cls)
|
||||
if item == 'template' and self.is_template:
|
||||
return '.'.join(self.base.split('@')[:-1])
|
||||
|
||||
raise AttributeError(item)
|
||||
return Unit(unit)
|
||||
|
||||
|
||||
def systemd_parse_unit(d, path):
|
||||
import configparser
|
||||
parser = configparser.ConfigParser(strict=False)
|
||||
parser.optionxform = str
|
||||
parser.read('%s' % path)
|
||||
return parser
|
||||
|
||||
|
||||
python() {
|
||||
def check_sd_unit(d, unit):
|
||||
searchpaths = d.getVar('FILESPATH', True)
|
||||
path = bb.utils.which(searchpaths, '%s' % unit.name)
|
||||
if not os.path.isfile(path):
|
||||
# Unit does not exist in tree. Allow it to install from repo.
|
||||
# Return False here to indicate it does not exist.
|
||||
return False
|
||||
|
||||
parser = systemd_parse_unit(d, path)
|
||||
inhibit = listvar_to_list(d, 'INHIBIT_SYSTEMD_RESTART_POLICY_WARNING')
|
||||
if unit.is_service and \
|
||||
not unit.is_template and \
|
||||
unit.name not in inhibit and \
|
||||
not parser.has_option('Service', 'Restart'):
|
||||
bb.warn('Systemd unit \'%s\' does not '
|
||||
'have a restart policy defined.' % unit.name)
|
||||
return True
|
||||
|
||||
|
||||
def add_default_subs(d, file):
|
||||
for x in [
|
||||
'base_bindir',
|
||||
'bindir',
|
||||
'sbindir',
|
||||
'libexecdir',
|
||||
'envfiledir',
|
||||
'sysconfdir',
|
||||
'localstatedir',
|
||||
'datadir',
|
||||
'SYSTEMD_DEFAULT_TARGET' ]:
|
||||
set_doappend(d, 'SYSTEMD_SUBSTITUTIONS',
|
||||
'%s:%s:%s' % (x, d.getVar(x, True), file))
|
||||
|
||||
|
||||
def add_sd_unit(d, unit, pkg, unit_exist):
|
||||
# Do not add unit if it does not exist in tree.
|
||||
# It will be installed from repo.
|
||||
if not unit_exist:
|
||||
return
|
||||
|
||||
name = unit.name
|
||||
unit_dir = d.getVar('systemd_system_unitdir', True)
|
||||
set_doappend(d, 'SRC_URI', 'file://%s' % name)
|
||||
set_doappend(d, 'FILES:%s' % pkg, '%s/%s' % (unit_dir, name))
|
||||
set_doappend(d, '_INSTALL_SD_UNITS', name)
|
||||
add_default_subs(d, name)
|
||||
|
||||
|
||||
def add_sd_user(d, file, pkg):
|
||||
opts = [
|
||||
'--system',
|
||||
'--home',
|
||||
'/',
|
||||
'--no-create-home',
|
||||
'--shell /sbin/nologin',
|
||||
'--user-group']
|
||||
|
||||
var = 'SYSTEMD_USER_%s' % file
|
||||
user = listvar_to_list(d, var)
|
||||
if len(user) == 0:
|
||||
var = 'SYSTEMD_USER_%s' % pkg
|
||||
user = listvar_to_list(d, var)
|
||||
if len(user) != 0:
|
||||
if len(user) != 1:
|
||||
bb.fatal('Too many users assigned to %s: \'%s\'' % (var, ' '.join(user)))
|
||||
|
||||
user = user[0]
|
||||
set_doappend(d, 'SYSTEMD_SUBSTITUTIONS',
|
||||
'USER:%s:%s' % (user, file))
|
||||
if user not in d.getVar('USERADD_PARAM:%s' % pkg, True):
|
||||
set_doappend(
|
||||
d,
|
||||
'USERADD_PARAM:%s' % pkg,
|
||||
'%s' % (' '.join(opts + [user])),
|
||||
';')
|
||||
if pkg not in d.getVar('USERADD_PACKAGES', True):
|
||||
set_doappend(d, 'USERADD_PACKAGES', pkg)
|
||||
|
||||
|
||||
def add_env_file(d, name, pkg):
|
||||
set_doappend(d, 'SRC_URI', 'file://%s' % name)
|
||||
set_doappend(d, 'FILES:%s' % pkg, '%s/%s' \
|
||||
% (d.getVar('envfiledir', True), name))
|
||||
set_doappend(d, '_INSTALL_ENV_FILES', name)
|
||||
|
||||
|
||||
def install_link(d, spec, pkg):
|
||||
tgt, dest = spec.split(':')
|
||||
|
||||
set_doappend(d, 'FILES:%s' % pkg, '%s/%s' \
|
||||
% (d.getVar('systemd_system_unitdir', True), dest))
|
||||
set_doappend(d, '_INSTALL_LINKS', spec)
|
||||
|
||||
|
||||
def add_override(d, spec, pkg):
|
||||
tmpl, dest = spec.split(':')
|
||||
set_doappend(d, '_INSTALL_OVERRIDES', '%s' % spec)
|
||||
unit_dir = d.getVar('systemd_system_unitdir', True)
|
||||
set_doappend(d, 'FILES:%s' % pkg, '%s/%s' % (unit_dir, dest))
|
||||
add_default_subs(d, '%s' % dest)
|
||||
add_sd_user(d, '%s' % dest, pkg)
|
||||
|
||||
|
||||
if d.getVar('CLASSOVERRIDE', True) != 'class-target':
|
||||
return
|
||||
|
||||
d.appendVarFlag('do_install', 'postfuncs', ' systemd_do_postinst')
|
||||
|
||||
pn = d.getVar('PN', True)
|
||||
if d.getVar('SYSTEMD_SERVICE:%s' % pn, True) is None:
|
||||
d.setVar('SYSTEMD_SERVICE:%s' % pn, '%s.service' % pn)
|
||||
|
||||
for pkg in listvar_to_list(d, 'SYSTEMD_PACKAGES'):
|
||||
svc = listvar_to_list(d, 'SYSTEMD_SERVICE:%s' % pkg)
|
||||
svc = [SystemdUnit(x) for x in svc]
|
||||
tmpl = [x.template for x in svc if x.is_instance]
|
||||
tmpl = list(set(tmpl))
|
||||
tmpl = [SystemdUnit(x) for x in tmpl]
|
||||
svc = [x for x in svc if not x.is_instance]
|
||||
|
||||
for unit in tmpl + svc:
|
||||
unit_exist = check_sd_unit(d, unit)
|
||||
add_sd_unit(d, unit, pkg, unit_exist)
|
||||
add_sd_user(d, unit.name, pkg)
|
||||
for name in listvar_to_list(d, 'SYSTEMD_ENVIRONMENT_FILE:%s' % pkg):
|
||||
add_env_file(d, name, pkg)
|
||||
for spec in listvar_to_list(d, 'SYSTEMD_LINK:%s' % pkg):
|
||||
install_link(d, spec, pkg)
|
||||
for spec in listvar_to_list(d, 'SYSTEMD_OVERRIDE:%s' % pkg):
|
||||
add_override(d, spec, pkg)
|
||||
}
|
||||
|
||||
|
||||
python systemd_do_postinst() {
|
||||
def make_subs(d):
|
||||
all_subs = {}
|
||||
for spec in listvar_to_list(d, 'SYSTEMD_SUBSTITUTIONS'):
|
||||
spec, file = spec.rsplit(':', 1)
|
||||
all_subs.setdefault(file, []).append(spec)
|
||||
|
||||
for f, v in all_subs.items():
|
||||
subs = dict([ x.split(':') for x in v])
|
||||
if not subs:
|
||||
continue
|
||||
|
||||
path = d.getVar('D', True)
|
||||
path += d.getVar('systemd_system_unitdir', True)
|
||||
path += '/%s' % f
|
||||
with open(path, 'r') as fd:
|
||||
content = fd.read()
|
||||
with open(path, 'w+') as fd:
|
||||
try:
|
||||
fd.write(content.format(**subs))
|
||||
except KeyError as e:
|
||||
bb.fatal('No substitution found for %s in '
|
||||
'file \'%s\'' % (e, f))
|
||||
|
||||
|
||||
def install_envs(d):
|
||||
install_dir = d.getVar('D', True)
|
||||
install_dir += d.getVar('envfiledir', True)
|
||||
searchpaths = d.getVar('FILESPATH', True)
|
||||
|
||||
for f in listvar_to_list(d, '_INSTALL_ENV_FILES'):
|
||||
src = bb.utils.which(searchpaths, f)
|
||||
if not os.path.isfile(src):
|
||||
bb.fatal('Did not find SYSTEMD_ENVIRONMENT_FILE:'
|
||||
'\'%s\'' % src)
|
||||
|
||||
dest = os.path.join(install_dir, f)
|
||||
parent = os.path.dirname(dest)
|
||||
if not os.path.exists(parent):
|
||||
os.makedirs(parent)
|
||||
|
||||
with open(src, 'r') as fd:
|
||||
content = fd.read()
|
||||
with open(dest, 'w+') as fd:
|
||||
fd.write(content)
|
||||
|
||||
|
||||
def install_links(d):
|
||||
install_dir = d.getVar('D', True)
|
||||
install_dir += d.getVar('systemd_system_unitdir', True)
|
||||
|
||||
for spec in listvar_to_list(d, '_INSTALL_LINKS'):
|
||||
tgt, dest = spec.split(':')
|
||||
dest = os.path.join(install_dir, dest)
|
||||
parent = os.path.dirname(dest)
|
||||
if not os.path.exists(parent):
|
||||
os.makedirs(parent)
|
||||
os.symlink(tgt, dest)
|
||||
|
||||
|
||||
def install_overrides(d):
|
||||
install_dir = d.getVar('D', True)
|
||||
install_dir += d.getVar('systemd_system_unitdir', True)
|
||||
searchpaths = d.getVar('FILESPATH', True)
|
||||
|
||||
for spec in listvar_to_list(d, '_INSTALL_OVERRIDES'):
|
||||
tmpl, dest = spec.split(':')
|
||||
source = bb.utils.which(searchpaths, tmpl)
|
||||
if not os.path.isfile(source):
|
||||
bb.fatal('Did not find SYSTEMD_OVERRIDE '
|
||||
'template: \'%s\'' % source)
|
||||
|
||||
dest = os.path.join(install_dir, dest)
|
||||
parent = os.path.dirname(dest)
|
||||
if not os.path.exists(parent):
|
||||
os.makedirs(parent)
|
||||
|
||||
with open(source, 'r') as fd:
|
||||
content = fd.read()
|
||||
with open('%s' % dest, 'w+') as fd:
|
||||
fd.write(content)
|
||||
|
||||
|
||||
install_links(d)
|
||||
install_envs(d)
|
||||
install_overrides(d)
|
||||
make_subs(d)
|
||||
}
|
||||
|
||||
|
||||
do_install:append() {
|
||||
# install systemd service/socket/template files
|
||||
[ -z "${_INSTALL_SD_UNITS}" ] || \
|
||||
install -d ${D}${systemd_system_unitdir}
|
||||
for s in ${_INSTALL_SD_UNITS}; do
|
||||
install -m 0644 ${WORKDIR}/$s \
|
||||
${D}${systemd_system_unitdir}/$s
|
||||
sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
|
||||
-e 's,@BINDIR@,${bindir},g' \
|
||||
-e 's,@SBINDIR@,${sbindir},g' \
|
||||
-e 's,@LIBEXECDIR@,${libexecdir},g' \
|
||||
-e 's,@LOCALSTATEDIR@,${localstatedir},g' \
|
||||
-e 's,@DATADIR@,${datadir},g' \
|
||||
${D}${systemd_system_unitdir}/$s
|
||||
done
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
def set_doappend(d, var, val, sep=' '):
|
||||
values = (d.getVar(var, True) or '').split(sep)
|
||||
if filter(bool, values):
|
||||
d.appendVar(var, '%s%s' %(sep, val))
|
||||
else:
|
||||
d.setVar(var, val)
|
||||
|
||||
|
||||
def listvar_to_list(d, list_var, sep=' '):
|
||||
return list(filter(bool, (d.getVar(list_var, True) or '').split(sep)))
|
||||
|
||||
|
||||
def compose_list(d, fmtvar, *listvars, **kw):
|
||||
import itertools
|
||||
fmt = d.getVar(fmtvar, True)
|
||||
lists = [listvar_to_list(d, x) for x in listvars]
|
||||
lst = [fmt.format(*x) for x in itertools.product(*lists)]
|
||||
return (kw.get('sep') or ' ').join(lst)
|
||||
|
||||
|
||||
def compose_list_zip(d, fmtvar, *listvars, **kw):
|
||||
fmt = d.getVar(fmtvar, True)
|
||||
lists = [listvar_to_list(d, x) for x in listvars]
|
||||
lst = [fmt.format(*x) for x in zip(*lists)]
|
||||
return (kw.get('sep') or ' ').join(lst)
|
||||
@@ -0,0 +1,74 @@
|
||||
#This class applies patches to an XML file during do_patch(). The
|
||||
#patches themselves are specified in XML in a separate file that must
|
||||
#be in SRC_URI and end in .patch.xml. The patch XML file must also
|
||||
#have a <targetFile> element that specifies the base name of the file
|
||||
#that needs to be patched.
|
||||
#
|
||||
#See patchxml.py for details on the XML patch format.
|
||||
#
|
||||
|
||||
inherit python3native
|
||||
inherit obmc-phosphor-utils
|
||||
do_patch[depends] = "mrw-patch-native:do_populate_sysroot"
|
||||
|
||||
|
||||
def find_patch_files(d):
|
||||
all_patches = listvar_to_list(d, 'SRC_URI')
|
||||
xml_patches = [x for x in all_patches if x.endswith('.patch.xml') and
|
||||
x.startswith('file://')]
|
||||
|
||||
return [x.lstrip('file://') for x in xml_patches]
|
||||
|
||||
|
||||
def apply_xml_patch(base_patch_name, d):
|
||||
import xml.etree.ElementTree as et
|
||||
import subprocess
|
||||
|
||||
patch_file = os.path.join(d.getVar("WORKDIR", True), base_patch_name)
|
||||
|
||||
if not os.path.exists(patch_file):
|
||||
bb.fatal("Could not find patch file " + patch_file +
|
||||
" specified in SRC_URI")
|
||||
|
||||
patch_tree = et.parse(patch_file)
|
||||
patch_root = patch_tree.getroot()
|
||||
target_file_element = patch_root.find("targetFile")
|
||||
|
||||
if target_file_element is None:
|
||||
bb.fatal("Could not find <targetFile> element in patch file "
|
||||
+ patch_file)
|
||||
else:
|
||||
xml = target_file_element.text
|
||||
|
||||
xml = os.path.join(d.getVar("S", True), xml)
|
||||
|
||||
if not os.path.exists(xml):
|
||||
bb.fatal("Could not find XML file to patch: " + xml)
|
||||
|
||||
print("Applying XML fixes found in " + patch_file + " to " + xml)
|
||||
|
||||
cmd = []
|
||||
cmd.append(os.path.join(d.getVar("bindir", True), "obmc-mrw/patchxml.py"))
|
||||
cmd.append("-x")
|
||||
cmd.append(xml)
|
||||
cmd.append("-p")
|
||||
cmd.append(patch_file)
|
||||
cmd.append("-o")
|
||||
cmd.append(xml + ".patched")
|
||||
|
||||
try:
|
||||
subprocess.check_call(cmd)
|
||||
except subprocess.CalledProcessError as e:
|
||||
bb.fatal("Failed patching XML:\n%s" % e.output)
|
||||
|
||||
os.rename(xml, xml + ".orig")
|
||||
os.rename(xml + ".patched", xml)
|
||||
|
||||
|
||||
python xmlpatch_do_patch() {
|
||||
|
||||
for patch in find_patch_files(d):
|
||||
apply_xml_patch(patch, d)
|
||||
}
|
||||
|
||||
do_patch[postfuncs] += "xmlpatch_do_patch"
|
||||
@@ -0,0 +1 @@
|
||||
config_dir="${datadir}/phosphor-dbus-monitor"
|
||||
@@ -0,0 +1,4 @@
|
||||
yaml_dir = "${datadir}/phosphor-dbus-yaml/yaml"
|
||||
|
||||
PACKAGE_BEFORE_PN += "${PN}-yaml"
|
||||
FILES:${PN}-yaml += "${yaml_dir}"
|
||||
@@ -0,0 +1,5 @@
|
||||
bmc_dump_path="/var/lib/phosphor-debug-collector/dumps"
|
||||
dreport_plugin_dir = "${datadir}/dreport.d/plugins.d"
|
||||
dreport_include_dir = "${datadir}/dreport.d/include.d"
|
||||
dreport_conf_dir = "${datadir}/dreport.d/conf.d"
|
||||
dreport_dir = "${datadir}/dreport.d/"
|
||||
@@ -0,0 +1,63 @@
|
||||
####
|
||||
# Copyright 2020 Hewlett Packard Enterprise Development LP.
|
||||
# Copyright 2021 Intel Corporation
|
||||
#
|
||||
# Add a basic class to add a privileged user from an ssh
|
||||
# standpoint and a public key passed as an input parameter
|
||||
# from the local.conf file
|
||||
# Example:
|
||||
# INHERIT += "phosphor-deploy-ssh-keys"
|
||||
#
|
||||
# SSH_KEYS = "vejmarie:/home/openbmc/openbmc/meta-hpe/keys/test.pub"
|
||||
# or
|
||||
# SSH_KEYS = "vejmarie:/home/openbmc/openbmc/meta-hpe/keys/test.pub;root:/path/to/id_rsa.pub"
|
||||
####
|
||||
|
||||
inherit useradd_base
|
||||
|
||||
IMAGE_PREPROCESS_COMMAND += "deploy_local_user;"
|
||||
|
||||
deploy_local_user () {
|
||||
if [ "${SSH_KEYS}" == "" ]; then
|
||||
bbwarn "Trying to deploy SSH keys but input variable is empty (SSH_KEYS)"
|
||||
return
|
||||
fi
|
||||
|
||||
ssh_keys="${SSH_KEYS}"
|
||||
while [ "${ssh_keys}" != "" ]; do
|
||||
current_key=`echo "$ssh_keys" | cut -d ';' -f1`
|
||||
ssh_keys=`echo "$ssh_keys" | cut -s -d ';' -f2-`
|
||||
|
||||
username=`echo "$current_key" | awk -F":" '{ print $1}'`
|
||||
key_path=`echo "$current_key" | awk -F":" '{ print $2}'`
|
||||
|
||||
if [ ! -d ${IMAGE_ROOTFS}/home/${username} ]; then
|
||||
perform_useradd "${IMAGE_ROOTFS}" "-R ${IMAGE_ROOTFS} -p '' ${username}"
|
||||
fi
|
||||
|
||||
if [ ! -d ${IMAGE_ROOTFS}/home/${username}.ssh/ ]; then
|
||||
install -d ${IMAGE_ROOTFS}/home/${username}/.ssh/
|
||||
fi
|
||||
|
||||
if [ ! -f ${IMAGE_ROOTFS}/home/${username}/.ssh/authorized_keys ]; then
|
||||
install -m 0600 ${key_path} ${IMAGE_ROOTFS}/home/${username}/.ssh/authorized_keys
|
||||
else
|
||||
cat ${key_path} >> ${IMAGE_ROOTFS}/home/${username}/.ssh/authorized_keys
|
||||
fi
|
||||
|
||||
uid=`cat ${IMAGE_ROOTFS}/etc/passwd | grep "${username}:" | awk -F ":" '{print $3}'`
|
||||
guid=`cat ${IMAGE_ROOTFS}/etc/passwd | grep "${username}:" | awk -F ":" '{print $4}'`
|
||||
|
||||
chown -R ${uid}:${guid} ${IMAGE_ROOTFS}/home/${username}/.ssh
|
||||
chmod 600 ${IMAGE_ROOTFS}/home/${username}/.ssh/authorized_keys
|
||||
chmod 700 ${IMAGE_ROOTFS}/home/${username}/.ssh
|
||||
|
||||
is_group=`grep "priv-admin" ${IMAGE_ROOTFS}/etc/group || true`
|
||||
|
||||
if [ -z "${is_group}" ]; then
|
||||
perform_groupadd "${IMAGE_ROOTFS}" "-R ${IMAGE_ROOTFS} priv-admin"
|
||||
fi
|
||||
|
||||
perform_usermod "${IMAGE_ROOTFS}" "-R ${IMAGE_ROOTFS} -a -G priv-admin ${username}"
|
||||
done
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
presence_datadir="${datadir}/phosphor-fan-presence"
|
||||
control_datadir="${datadir}/phosphor-fan-control"
|
||||
monitor_datadir="${datadir}/phosphor-fan-monitor"
|
||||
@@ -0,0 +1,2 @@
|
||||
base_datadir="${datadir}/phosphor-inventory-manager"
|
||||
rules_datadir="${base_datadir}/events.d"
|
||||
@@ -0,0 +1,4 @@
|
||||
hostfw_datadir="${datadir}/phosphor-ipmi-fru/hostfw"
|
||||
inventory_datadir="${datadir}/phosphor-ipmi-fru/inventory"
|
||||
config_datadir="${datadir}/phosphor-ipmi-fru/config"
|
||||
properties_datadir="${datadir}/phosphor-ipmi-fru/properties"
|
||||
@@ -0,0 +1,27 @@
|
||||
# Common code for recipes that implement Phosphor IPMI Whitelist
|
||||
# packages
|
||||
|
||||
WHITELIST ?= "${PN}.conf"
|
||||
INSTALLDIR = "${D}${datadir}/phosphor-ipmi-host/"
|
||||
|
||||
python phosphor_ipmi_host_whitelist_postinstall() {
|
||||
def install_whitelist(d):
|
||||
# Create the install directory if needed
|
||||
whitelist_file = d.getVar('WHITELIST', True)
|
||||
install_dir = d.getVar('INSTALLDIR', True)
|
||||
if not os.path.exists(install_dir):
|
||||
os.makedirs(install_dir)
|
||||
install_file = os.path.join(install_dir, whitelist_file)
|
||||
|
||||
# Search for conf file in FILESPATH
|
||||
searchpaths = d.getVar('FILESPATH', True)
|
||||
path = bb.utils.which(searchpaths, whitelist_file)
|
||||
if not os.path.isfile(path):
|
||||
bb.fatal('Did not find conf file "%s"' % whitelist_file)
|
||||
|
||||
# Copy the conf file into install directory
|
||||
bb.utils.copyfile(path, install_file)
|
||||
|
||||
install_whitelist(d)
|
||||
}
|
||||
do_install[postfuncs] += "phosphor_ipmi_host_whitelist_postinstall"
|
||||
@@ -0,0 +1,4 @@
|
||||
sensor_datadir="${datadir}/phosphor-ipmi-host/sensor"
|
||||
sensor_yamldir="${datadir}/phosphor-ipmi-host/sensor-yamls"
|
||||
hostfw_datadir="${datadir}/phosphor-ipmi-fru/hostfw"
|
||||
config_datadir="${datadir}/phosphor-ipmi-host/config"
|
||||
@@ -0,0 +1,28 @@
|
||||
inherit phosphor-dbus-yaml
|
||||
|
||||
LOGGING_YAML_SUBDIRS ??= "${OBMC_ORG_YAML_SUBDIRS}"
|
||||
|
||||
do_install:append() {
|
||||
for yaml_d in ${LOGGING_YAML_SUBDIRS} ;
|
||||
do
|
||||
if [ -d ${S}/${yaml_d} ];
|
||||
then
|
||||
yaml_base=${S}
|
||||
elif [ -d ${S}/yaml/${yaml_d} ];
|
||||
then
|
||||
yaml_base=${S}/yaml
|
||||
else
|
||||
continue
|
||||
fi
|
||||
|
||||
|
||||
for yaml_f in $(find ${yaml_base}/${yaml_d} -name "*.errors.yaml" -or \
|
||||
-name "*.metadata.yaml") ;
|
||||
do
|
||||
subpath=$(realpath --relative-to=${yaml_base} ${yaml_f})
|
||||
install -d $(dirname ${D}${yaml_dir}/$subpath)
|
||||
|
||||
install -m 0644 ${yaml_f} ${D}${yaml_dir}/$subpath
|
||||
done
|
||||
done
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
callouts_datadir="${datadir}/phosphor-logging/callouts"
|
||||
@@ -0,0 +1,10 @@
|
||||
#
|
||||
# This function is intended to add root to corresponding groups if 'debug-tweaks' or 'allow-root-login' is in IMAGE_FEATURES.
|
||||
#
|
||||
update_root_user_groups () {
|
||||
if [ -e ${IMAGE_ROOTFS}/etc/group ]; then
|
||||
sed -i '/^\(ipmi\|web\|redfish\|priv-admin\):.*:.*:$/s/$/root/' ${IMAGE_ROOTFS}/etc/group
|
||||
fi
|
||||
}
|
||||
# Add root user to the needed groups
|
||||
ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'allow-root-login' ], "update_root_user_groups; ", "", d)}'
|
||||
@@ -0,0 +1 @@
|
||||
settings_datadir="${datadir}/phosphor-settings/default"
|
||||
@@ -0,0 +1,24 @@
|
||||
# eMMC-specific configuration for the phosphor-manager-software package
|
||||
|
||||
PACKAGECONFIG:append = " mmc_layout"
|
||||
|
||||
EXTRA_OEMESON:append = " \
|
||||
-Dactive-bmc-max-allowed=2 \
|
||||
-Dmedia-dir='/media' \
|
||||
-Doptional-images='image-hostfw' \
|
||||
"
|
||||
|
||||
RDEPENDS:phosphor-software-manager-updater-mmc += " \
|
||||
gptfdisk \
|
||||
parted \
|
||||
zstd \
|
||||
"
|
||||
|
||||
SYSTEMD_SERVICE:phosphor-software-manager-updater-mmc += " \
|
||||
obmc-flash-mmc@.service \
|
||||
obmc-flash-mmc-remove@.service \
|
||||
obmc-flash-mmc-setprimary@.service \
|
||||
obmc-flash-mmc-mount.service \
|
||||
obmc-flash-mmc-umount.service \
|
||||
obmc-flash-mmc-mirroruboot.service \
|
||||
"
|
||||
@@ -0,0 +1,37 @@
|
||||
# UBI-specific configuration for the phosphor-manager-software package
|
||||
|
||||
PACKAGECONFIG:append = " ubifs_layout"
|
||||
|
||||
RDEPENDS:phosphor-software-manager-updater-ubi += " \
|
||||
mtd-utils-ubifs \
|
||||
"
|
||||
|
||||
# Add ubi-fs configs
|
||||
EXTRA_OEMESON:append = " \
|
||||
-Dactive-bmc-max-allowed=2 \
|
||||
-Dmedia-dir='/media' \
|
||||
"
|
||||
|
||||
SYSTEMD_SERVICE:phosphor-software-manager-updater-ubi += " \
|
||||
obmc-flash-bmc-ubirw.service \
|
||||
obmc-flash-bmc-ubiro@.service \
|
||||
obmc-flash-bmc-ubirw-remove.service \
|
||||
obmc-flash-bmc-ubiro-remove@.service \
|
||||
obmc-flash-bmc-ubiremount.service \
|
||||
obmc-flash-bmc-updateubootvars@.service \
|
||||
obmc-flash-bmc-cleanup.service \
|
||||
obmc-flash-bmc-mirroruboot.service \
|
||||
"
|
||||
|
||||
# Name of the mtd device where the ubi volumes should be created
|
||||
BMC_RW_MTD ??= "bmc"
|
||||
BMC_RO_MTD ??= "bmc"
|
||||
BMC_KERNEL_MTD ??= "bmc"
|
||||
DISTROOVERRIDES .= ":flash-${FLASH_SIZE}"
|
||||
BMC_RW_SIZE ??= "0x600000"
|
||||
BMC_RW_SIZE:flash-131072 = "0x2000000"
|
||||
SYSTEMD_SUBSTITUTIONS += "RW_MTD:${BMC_RW_MTD}:obmc-flash-bmc-ubirw.service"
|
||||
SYSTEMD_SUBSTITUTIONS += "RO_MTD:${BMC_RO_MTD}:obmc-flash-bmc-ubiro@.service"
|
||||
SYSTEMD_SUBSTITUTIONS += "KERNEL_MTD:${BMC_KERNEL_MTD}:obmc-flash-bmc-ubiro@.service"
|
||||
SYSTEMD_SUBSTITUTIONS += "RW_SIZE:${BMC_RW_SIZE}:obmc-flash-bmc-ubirw.service"
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
inherit skeleton
|
||||
|
||||
DEPENDS:append:class-target = " glib-2.0 obmc-libobmc-intf"
|
||||
|
||||
do_compile:class-native() {
|
||||
:
|
||||
}
|
||||
|
||||
do_install:append:class-target() {
|
||||
oe_runmake install DESTDIR=${D}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
SRCREV ?= "d8c6f5a38f20b9d2eac921af46a90eb33716f51d"
|
||||
SKELETON_URI ?= "git://github.com/openbmc/skeleton;branch=master;protocol=https"
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${WORKDIR}/git/LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
|
||||
@@ -0,0 +1,6 @@
|
||||
inherit skeleton-rev
|
||||
|
||||
HOMEPAGE = "http://github.com/openbmc/skeleton"
|
||||
|
||||
SRC_URI += "${SKELETON_URI}"
|
||||
S = "${WORKDIR}/git/${SKELETON_DIR}"
|
||||
Reference in New Issue
Block a user