From 1d7f34ab94c1cb47240db88190cc11cb034c33de Mon Sep 17 00:00:00 2001 From: Kostiantyn Bushko Date: Fri, 17 Jan 2020 13:37:14 +0200 Subject: build and run image without ostree support for qemux86-64 Signed-off-by: Kostiantyn Bushko --- conf/local.conf.nonostree.append | 11 +++++++++++ scripts/envsetup.sh | 33 +++++++++++++++++++++------------ scripts/qemucommand.py | 34 +++++++++++++++++++++++++++++----- scripts/run-qemu-ota | 3 +++ 4 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 conf/local.conf.nonostree.append diff --git a/conf/local.conf.nonostree.append b/conf/local.conf.nonostree.append new file mode 100644 index 0000000..0e63e98 --- /dev/null +++ b/conf/local.conf.nonostree.append @@ -0,0 +1,11 @@ + +DISTRO_FEATURES_append = " systemd" +VIRTUAL-RUNTIME_init_manager = "systemd" + +PREFERRED_RPROVIDER_virtual/network-configuration ??= "networkd-dhcp-conf" + +SOTA_DEPLOY_CREDENTIALS ?= "1" +PACKAGECONFIG_pn-aktualizr = "" + +IMAGE_INSTALL_append += "aktualizr" +IMAGE_INSTALL_append += "aktualizr-shared-prov" diff --git a/scripts/envsetup.sh b/scripts/envsetup.sh index 19a5c94..5b3b068 100755 --- a/scripts/envsetup.sh +++ b/scripts/envsetup.sh @@ -5,17 +5,24 @@ MACHINE="$1" BUILDDIR="build" DISTRO="poky-sota-systemd" BASE_CONF="local.conf.base.append" -declare -A supported_distros=( ["poky-sota-systemd"]="local.conf.systemd.append" ["poky-sota"]="local.conf.base.append" ) -[[ "$#" -lt 1 ]] && { echo "Usage: ${SCRIPT} [builddir] [distro=< poky-sota-systemd | poky-sota >]"; return 1; } +# A definition of a dictionary with a list of configuration files that must be appended +# to resulting conf/local.conf file for each particular distribution. +declare -A supported_distros=( + ["poky-sota-systemd"]="local.conf.systemd.append" + ["poky-sota"]="local.conf.base.append" + ["poky"]="local.conf.systemd.append local.conf.nonostree.append" +) + +[[ "$#" -lt 1 ]] && { echo "Usage: ${SCRIPT} [builddir] [distro=< poky-sota-systemd | poky-sota | poky >]"; return 1; } [[ "$#" -ge 2 ]] && { BUILDDIR="$2"; } [[ "$#" -eq 3 ]] && { DISTRO="$3"; } # detect if this script is sourced: see http://stackoverflow.com/a/38128348/6255594 SOURCED=0 -if [ -n "$ZSH_EVAL_CONTEXT" ]; then +if [[ -n "$ZSH_EVAL_CONTEXT" ]]; then [[ "$ZSH_EVAL_CONTEXT" =~ :file$ ]] && { SOURCED=1; SOURCEDIR=$(cd "$(dirname -- "$0")" && pwd -P); } -elif [ -n "$BASH_VERSION" ]; then +elif [[ -n "$BASH_VERSION" ]]; then [[ "$0" != "${BASH_SOURCE[0]}" ]] && { SOURCED=1; SOURCEDIR=$(cd "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P); } fi @@ -26,23 +33,25 @@ if [[ $SOURCED -ne 1 ]]; then fi METADIR=${METADIR:-${SOURCEDIR}/../..} -DISTRO_CONF=${supported_distros[$DISTRO]} -[[ -n $DISTRO_CONF ]] && { echo "Using $DISTRO_CONF for the specified distro $DISTRO"; } || { echo "The specified distro $DISTRO is not supported"; return 1; } if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then + declare -a DISTRO_CONFIGS=${supported_distros[$DISTRO]} + [[ -n ${DISTRO_CONFIGS[@]} ]] && { echo "Using (${DISTRO_CONFIGS[*]}) for the specified distro '$DISTRO'"; } || { echo "The specified distro $DISTRO is not supported"; return 1; } + source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" echo "METADIR := \"\${@os.path.abspath('${METADIR}')}\"" >> conf/bblayers.conf cat "${METADIR}/meta-updater/conf/include/bblayers/sota.inc" >> conf/bblayers.conf cat "${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc" >> conf/bblayers.conf - sed -e "s/##MACHINE##/$MACHINE/g" \ -e "s/##DISTRO##/$DISTRO/g" \ - "${METADIR}/meta-updater/conf/$BASE_CONF" >> conf/local.conf + "${METADIR}/meta-updater/conf/$BASE_CONF" >> conf/local.conf - if [ "$BASE_CONF" != "$DISTRO_CONF" ]; then - cat "${METADIR}/meta-updater/conf/$DISTRO_CONF" >> conf/local.conf - fi + for config in ${DISTRO_CONFIGS[@]}; do + if [[ "$BASE_CONF" != "$config" ]]; then + cat "${METADIR}/meta-updater/conf/$config" >> conf/local.conf + fi + done else source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" -fi +fi \ No newline at end of file diff --git a/scripts/qemucommand.py b/scripts/qemucommand.py index 8d3ee0e..bd7b890 100644 --- a/scripts/qemucommand.py +++ b/scripts/qemucommand.py @@ -40,9 +40,25 @@ def random_mac(): class QemuCommand(object): def __init__(self, args): + print(args) + self.enable_u_boot = None self.dry_run = args.dry_run self.overlay = args.overlay self.host_fwd = None + self.kernel = None + self.drive_interface = "ide" + + if hasattr(args, 'uboot_enable'): + self.enable_u_boot = args.uboot_enable.lower() in ("yes", "true", "1") + + # Rise an exception if U-Boot is disabled and overlay option is used + if not self.enable_u_boot and self.overlay: + raise EnvironmentError("An overlay option is currently supported only with U-Boot loader!") + + # If booting with u-boot is disabled we use "ext4" root fs instead of custom one "ota-ext4" + if not self.enable_u_boot: + self.drive_interface = "virtio" + EXTENSIONS['qemux86-64'] = 'ext4' if args.machine: self.machine = args.machine @@ -59,9 +75,7 @@ class QemuCommand(object): # overlay so that we can keep it around just in case. if args.efi: self.bios = 'OVMF.fd' - else: - if args.bootloader: - uboot_path = args.bootloader + elif self.enable_u_boot: uboot_path = abspath(join(args.dir, self.machine, 'u-boot-qemux86-64.rom')) if self.overlay: new_uboot_path = self.overlay + '.u-boot.rom' @@ -77,6 +91,8 @@ class QemuCommand(object): if not exists(uboot_path) and not (self.dry_run and not exists(self.overlay)): raise ValueError("U-Boot image %s does not exist" % uboot_path) self.bios = uboot_path + else: + self.kernel = abspath(join(args.dir, self.machine, 'bzImage-qemux86-64.bin')) # If using an overlay, we need to keep the "backing" image around, as # bitbake will often clean it up, and the overlay silently depends on @@ -140,10 +156,14 @@ class QemuCommand(object): cmdline = [ "qemu-system-x86_64", - "-bios", self.bios ] + if self.enable_u_boot: + cmdline += ["-bios", self.bios] + else: + cmdline += ["-kernel", self.kernel] + if not self.overlay: - cmdline += ["-drive", "file=%s,if=ide,format=raw,snapshot=on" % self.image] + cmdline += ["-drive", "file=%s,if=%s,format=raw,snapshot=on" % (self.image, self.drive_interface)] cmdline += [ "-serial", "tcp:127.0.0.1:%d,server,nowait" % self.serial_port, "-m", self.mem, @@ -177,6 +197,10 @@ class QemuCommand(object): cmdline += ['-cpu', 'Haswell'] if self.overlay: cmdline.append(self.overlay) + + # If booting with u-boot is disabled, add kernel command line arguments through qemu -append option + if not self.enable_u_boot: + cmdline += ["-append", "root=/dev/vda rw highres=off console=ttyS0 ip=dhcp"] return cmdline def img_command_line(self): diff --git a/scripts/run-qemu-ota b/scripts/run-qemu-ota index 5652797..59301a4 100755 --- a/scripts/run-qemu-ota +++ b/scripts/run-qemu-ota @@ -13,6 +13,9 @@ def main(): parser = ArgumentParser(description='Run meta-updater image in qemu') parser.add_argument('imagename', default='core-image-minimal', nargs='?', help="Either the name of the bitbake image target, or a path to the image to run") + parser.add_argument('--uboot-enable', default='yes', + help='(yes/no). Determines whether or not to use U-Boot loader for running image, ' + 'if yes then u-boot binary file will be passed as -bios option into QEMU cmd line.') parser.add_argument('mac', default=None, nargs='?') parser.add_argument('--dir', default=DEFAULT_DIR, help='Path to build directory containing the image and u-boot-qemux86-64.rom') -- cgit v1.2.3-54-g00ecf