summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorKostiantyn Bushko <kbushko@intellias.com>2020-01-17 13:37:14 +0200
committerKostiantyn Bushko <kbushko@intellias.com>2020-01-20 23:00:41 +0200
commitad01ab114dd83edda61c06aa01fd899c80ee0a68 (patch)
treee0935246d73ef1d4710cfc4b7036e273c325309a /scripts
parentc0498308fdd1388c98bf45d72af0284418170ec0 (diff)
downloadmeta-updater-ad01ab114dd83edda61c06aa01fd899c80ee0a68.tar.gz
build and run image without ostree support for qemux86-64
Signed-off-by: Kostiantyn Bushko <kbushko@intellias.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/envsetup.sh33
-rw-r--r--scripts/qemucommand.py34
-rwxr-xr-xscripts/run-qemu-ota3
3 files changed, 53 insertions, 17 deletions
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"
5BUILDDIR="build" 5BUILDDIR="build"
6DISTRO="poky-sota-systemd" 6DISTRO="poky-sota-systemd"
7BASE_CONF="local.conf.base.append" 7BASE_CONF="local.conf.base.append"
8declare -A supported_distros=( ["poky-sota-systemd"]="local.conf.systemd.append" ["poky-sota"]="local.conf.base.append" )
9 8
10[[ "$#" -lt 1 ]] && { echo "Usage: ${SCRIPT} <machine> [builddir] [distro=< poky-sota-systemd | poky-sota >]"; return 1; } 9# A definition of a dictionary with a list of configuration files that must be appended
10# to resulting conf/local.conf file for each particular distribution.
11declare -A supported_distros=(
12 ["poky-sota-systemd"]="local.conf.systemd.append"
13 ["poky-sota"]="local.conf.base.append"
14 ["poky"]="local.conf.systemd.append local.conf.nonostree.append"
15)
16
17[[ "$#" -lt 1 ]] && { echo "Usage: ${SCRIPT} <machine> [builddir] [distro=< poky-sota-systemd | poky-sota | poky >]"; return 1; }
11[[ "$#" -ge 2 ]] && { BUILDDIR="$2"; } 18[[ "$#" -ge 2 ]] && { BUILDDIR="$2"; }
12[[ "$#" -eq 3 ]] && { DISTRO="$3"; } 19[[ "$#" -eq 3 ]] && { DISTRO="$3"; }
13 20
14# detect if this script is sourced: see http://stackoverflow.com/a/38128348/6255594 21# detect if this script is sourced: see http://stackoverflow.com/a/38128348/6255594
15SOURCED=0 22SOURCED=0
16if [ -n "$ZSH_EVAL_CONTEXT" ]; then 23if [[ -n "$ZSH_EVAL_CONTEXT" ]]; then
17 [[ "$ZSH_EVAL_CONTEXT" =~ :file$ ]] && { SOURCED=1; SOURCEDIR=$(cd "$(dirname -- "$0")" && pwd -P); } 24 [[ "$ZSH_EVAL_CONTEXT" =~ :file$ ]] && { SOURCED=1; SOURCEDIR=$(cd "$(dirname -- "$0")" && pwd -P); }
18elif [ -n "$BASH_VERSION" ]; then 25elif [[ -n "$BASH_VERSION" ]]; then
19 [[ "$0" != "${BASH_SOURCE[0]}" ]] && { SOURCED=1; SOURCEDIR=$(cd "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P); } 26 [[ "$0" != "${BASH_SOURCE[0]}" ]] && { SOURCED=1; SOURCEDIR=$(cd "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P); }
20fi 27fi
21 28
@@ -26,23 +33,25 @@ if [[ $SOURCED -ne 1 ]]; then
26fi 33fi
27 34
28METADIR=${METADIR:-${SOURCEDIR}/../..} 35METADIR=${METADIR:-${SOURCEDIR}/../..}
29DISTRO_CONF=${supported_distros[$DISTRO]}
30[[ -n $DISTRO_CONF ]] && { echo "Using $DISTRO_CONF for the specified distro $DISTRO"; } || { echo "The specified distro $DISTRO is not supported"; return 1; }
31 36
32if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then 37if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then
38 declare -a DISTRO_CONFIGS=${supported_distros[$DISTRO]}
39 [[ -n ${DISTRO_CONFIGS[@]} ]] && { echo "Using (${DISTRO_CONFIGS[*]}) for the specified distro '$DISTRO'"; } || { echo "The specified distro $DISTRO is not supported"; return 1; }
40
33 source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" 41 source "$METADIR/poky/oe-init-build-env" "$BUILDDIR"
34 42
35 echo "METADIR := \"\${@os.path.abspath('${METADIR}')}\"" >> conf/bblayers.conf 43 echo "METADIR := \"\${@os.path.abspath('${METADIR}')}\"" >> conf/bblayers.conf
36 cat "${METADIR}/meta-updater/conf/include/bblayers/sota.inc" >> conf/bblayers.conf 44 cat "${METADIR}/meta-updater/conf/include/bblayers/sota.inc" >> conf/bblayers.conf
37 cat "${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc" >> conf/bblayers.conf 45 cat "${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc" >> conf/bblayers.conf
38
39 sed -e "s/##MACHINE##/$MACHINE/g" \ 46 sed -e "s/##MACHINE##/$MACHINE/g" \
40 -e "s/##DISTRO##/$DISTRO/g" \ 47 -e "s/##DISTRO##/$DISTRO/g" \
41 "${METADIR}/meta-updater/conf/$BASE_CONF" >> conf/local.conf 48 "${METADIR}/meta-updater/conf/$BASE_CONF" >> conf/local.conf
42 49
43 if [ "$BASE_CONF" != "$DISTRO_CONF" ]; then 50 for config in ${DISTRO_CONFIGS[@]}; do
44 cat "${METADIR}/meta-updater/conf/$DISTRO_CONF" >> conf/local.conf 51 if [[ "$BASE_CONF" != "$config" ]]; then
45 fi 52 cat "${METADIR}/meta-updater/conf/$config" >> conf/local.conf
53 fi
54 done
46else 55else
47 source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" 56 source "$METADIR/poky/oe-init-build-env" "$BUILDDIR"
48fi 57fi \ 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():
40 40
41class QemuCommand(object): 41class QemuCommand(object):
42 def __init__(self, args): 42 def __init__(self, args):
43 print(args)
44 self.enable_u_boot = None
43 self.dry_run = args.dry_run 45 self.dry_run = args.dry_run
44 self.overlay = args.overlay 46 self.overlay = args.overlay
45 self.host_fwd = None 47 self.host_fwd = None
48 self.kernel = None
49 self.drive_interface = "ide"
50
51 if hasattr(args, 'uboot_enable'):
52 self.enable_u_boot = args.uboot_enable.lower() in ("yes", "true", "1")
53
54 # Rise an exception if U-Boot is disabled and overlay option is used
55 if not self.enable_u_boot and self.overlay:
56 raise EnvironmentError("An overlay option is currently supported only with U-Boot loader!")
57
58 # If booting with u-boot is disabled we use "ext4" root fs instead of custom one "ota-ext4"
59 if not self.enable_u_boot:
60 self.drive_interface = "virtio"
61 EXTENSIONS['qemux86-64'] = 'ext4'
46 62
47 if args.machine: 63 if args.machine:
48 self.machine = args.machine 64 self.machine = args.machine
@@ -59,9 +75,7 @@ class QemuCommand(object):
59 # overlay so that we can keep it around just in case. 75 # overlay so that we can keep it around just in case.
60 if args.efi: 76 if args.efi:
61 self.bios = 'OVMF.fd' 77 self.bios = 'OVMF.fd'
62 else: 78 elif self.enable_u_boot:
63 if args.bootloader:
64 uboot_path = args.bootloader
65 uboot_path = abspath(join(args.dir, self.machine, 'u-boot-qemux86-64.rom')) 79 uboot_path = abspath(join(args.dir, self.machine, 'u-boot-qemux86-64.rom'))
66 if self.overlay: 80 if self.overlay:
67 new_uboot_path = self.overlay + '.u-boot.rom' 81 new_uboot_path = self.overlay + '.u-boot.rom'
@@ -77,6 +91,8 @@ class QemuCommand(object):
77 if not exists(uboot_path) and not (self.dry_run and not exists(self.overlay)): 91 if not exists(uboot_path) and not (self.dry_run and not exists(self.overlay)):
78 raise ValueError("U-Boot image %s does not exist" % uboot_path) 92 raise ValueError("U-Boot image %s does not exist" % uboot_path)
79 self.bios = uboot_path 93 self.bios = uboot_path
94 else:
95 self.kernel = abspath(join(args.dir, self.machine, 'bzImage-qemux86-64.bin'))
80 96
81 # If using an overlay, we need to keep the "backing" image around, as 97 # If using an overlay, we need to keep the "backing" image around, as
82 # bitbake will often clean it up, and the overlay silently depends on 98 # bitbake will often clean it up, and the overlay silently depends on
@@ -140,10 +156,14 @@ class QemuCommand(object):
140 156
141 cmdline = [ 157 cmdline = [
142 "qemu-system-x86_64", 158 "qemu-system-x86_64",
143 "-bios", self.bios
144 ] 159 ]
160 if self.enable_u_boot:
161 cmdline += ["-bios", self.bios]
162 else:
163 cmdline += ["-kernel", self.kernel]
164
145 if not self.overlay: 165 if not self.overlay:
146 cmdline += ["-drive", "file=%s,if=ide,format=raw,snapshot=on" % self.image] 166 cmdline += ["-drive", "file=%s,if=%s,format=raw,snapshot=on" % (self.image, self.drive_interface)]
147 cmdline += [ 167 cmdline += [
148 "-serial", "tcp:127.0.0.1:%d,server,nowait" % self.serial_port, 168 "-serial", "tcp:127.0.0.1:%d,server,nowait" % self.serial_port,
149 "-m", self.mem, 169 "-m", self.mem,
@@ -177,6 +197,10 @@ class QemuCommand(object):
177 cmdline += ['-cpu', 'Haswell'] 197 cmdline += ['-cpu', 'Haswell']
178 if self.overlay: 198 if self.overlay:
179 cmdline.append(self.overlay) 199 cmdline.append(self.overlay)
200
201 # If booting with u-boot is disabled, add kernel command line arguments through qemu -append option
202 if not self.enable_u_boot:
203 cmdline += ["-append", "root=/dev/vda rw highres=off console=ttyS0 ip=dhcp"]
180 return cmdline 204 return cmdline
181 205
182 def img_command_line(self): 206 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():
13 parser = ArgumentParser(description='Run meta-updater image in qemu') 13 parser = ArgumentParser(description='Run meta-updater image in qemu')
14 parser.add_argument('imagename', default='core-image-minimal', nargs='?', 14 parser.add_argument('imagename', default='core-image-minimal', nargs='?',
15 help="Either the name of the bitbake image target, or a path to the image to run") 15 help="Either the name of the bitbake image target, or a path to the image to run")
16 parser.add_argument('--uboot-enable', default='yes',
17 help='(yes/no). Determines whether or not to use U-Boot loader for running image, '
18 'if yes then u-boot binary file will be passed as -bios option into QEMU cmd line.')
16 parser.add_argument('mac', default=None, nargs='?') 19 parser.add_argument('mac', default=None, nargs='?')
17 parser.add_argument('--dir', default=DEFAULT_DIR, 20 parser.add_argument('--dir', default=DEFAULT_DIR,
18 help='Path to build directory containing the image and u-boot-qemux86-64.rom') 21 help='Path to build directory containing the image and u-boot-qemux86-64.rom')