diff options
Diffstat (limited to 'poky/scripts')
| -rwxr-xr-x | poky/scripts/buildall-qemu | 120 | ||||
| -rw-r--r-- | poky/scripts/lib/wic/engine.py | 5 | ||||
| -rw-r--r-- | poky/scripts/lib/wic/help.py | 26 | ||||
| -rw-r--r-- | poky/scripts/lib/wic/ksparser.py | 3 | ||||
| -rw-r--r-- | poky/scripts/lib/wic/misc.py | 14 | ||||
| -rw-r--r-- | poky/scripts/lib/wic/partition.py | 20 | ||||
| -rw-r--r-- | poky/scripts/lib/wic/plugins/source/rootfs.py | 133 | ||||
| -rwxr-xr-x | poky/scripts/runqemu | 11 | ||||
| -rwxr-xr-x | poky/scripts/tiny/ksize.py | 6 |
9 files changed, 45 insertions, 293 deletions
diff --git a/poky/scripts/buildall-qemu b/poky/scripts/buildall-qemu deleted file mode 100755 index ca9aafadf7..0000000000 --- a/poky/scripts/buildall-qemu +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/sh -# Copyright (c) 2020 Wind River Systems, Inc. -# -# SPDX-License-Identifier: GPL-2.0-only -# -# buildall-qemu: a tool for automating build testing of recipes -# TODO: Add support for selecting which qemu architectures to build -# TODO: Add support for queueing up multiple recipe builds -# TODO: Add more logging options (e.g. local.conf info, bitbake env info) - -usage () -{ - base=$(basename "$0") - echo "Usage: $base [options] [recipename/target]" - echo "Executes a build of a given target for selected LIBCs. With no options, default to both libc and musl." - echo "Options:" - echo "-l, --libc Specify one of \"glibc\" or \"musl\"" -} - - -buildall () -{ - # Get path to oe-core directory. Since oe-init-build-env prepends $PATH with - # the path to the scripts directory, get it from there - SCRIPTS_PATH="$(echo "$PATH" | cut -d ":" -f 1)" - OE_CORE_PATH=$(echo "$SCRIPTS_PATH" | sed 's|\(.*\)/.*|\1|') - - # Get target list and host machine information - TARGET_LIST=$(find "$OE_CORE_PATH"/meta/conf/machine -maxdepth 1 -type f | grep qemu | sed 's|.*/||' | sed -e 's/\.conf//') - - # Set LIBC value to use for the builds based on options provided by the user - if [ -n "$2" ] - then - LIBC_LIST="$2" - echo "$LIBC_LIST" - else - LIBC_LIST="glibc musl" - echo "$LIBC_LIST" - fi - - START_TIME=$(date "+%Y-%m-%d_%H:%M:%S") - LOG_FILE="$1-buildall.log" - OS_INFO=$(grep "PRETTY_NAME=" /etc/os-release | awk -F "=" '{print $2}' | sed -e 's/^"//' -e 's/"$//') - - # Append an existing log file for this build with .old if one exists - if [ -f "${LOG_FILE}" ] - then - mv "${LOG_FILE}" "${LOG_FILE}.old" - else - touch "${LOG_FILE}" - fi - - # Fill the log file with build and host info - echo "BUILDALL-QEMU LOG FOR $1" >> "${LOG_FILE}" - echo "START TIME: ${START_TIME}" >> "${LOG_FILE}" - echo "HOSTNAME: $(uname -n)" >> "${LOG_FILE}" - echo "HOST OS: ${OS_INFO}" >> "${LOG_FILE}" - echo "HOST KERNEL: $(uname -r)" >> "${LOG_FILE}" - echo "===============" >> "${LOG_FILE}" - echo "BUILD RESULTS:" >> "${LOG_FILE}" - - # start the builds for each MACHINE and TCLIBC - for j in ${LIBC_LIST} - do - echo "[$j]" >> "${LOG_FILE}" - for i in ${TARGET_LIST} - do - echo "$i" "$j"; \ - TCLIBC=$j MACHINE=$i bitbake "$1" && echo "PASS: $i" >> "${LOG_FILE}" || echo "FAIL: $i" >> "${LOG_FILE}" - done - done - - # Get pass/fail totals and add them to the end of the log - PASSED=$(grep "PASS:" "${LOG_FILE}" | wc -l) - FAILED=$(grep "FAIL:" "${LOG_FILE}" | wc -l) - - echo "===============" >> "${LOG_FILE}" - echo "PASSED: ${PASSED}" >> "${LOG_FILE}" - echo "FAILED: ${FAILED}" >> "${LOG_FILE}" -} - - -# fail entire script if any command fails -set -e - -# print usage and exit if not enough args given -[ $# -eq 0 ] && usage && exit 1 - -# handle arguments -RECIPE= -while [ $# -gt 0 ] -do - arg=$1 - case $arg in - -l|--libc) - if [ "$2" = "glibc" ] || [ "$2" = "musl" ] - then - LIBC_LIST="$2" - else - echo "Unrecognized libc option." - usage && exit 1 - fi - shift - shift - ;; - *) - RECIPE="$1" - shift - ;; - esac -done - -set -- "$RECIPE" - -# run buildall for the given recipe and LIBC -if [ -n "$1" ] -then - buildall "$1" "$LIBC_LIST" -fi - diff --git a/poky/scripts/lib/wic/engine.py b/poky/scripts/lib/wic/engine.py index 018815b966..9ff4394757 100644 --- a/poky/scripts/lib/wic/engine.py +++ b/poky/scripts/lib/wic/engine.py @@ -280,7 +280,7 @@ class Disk: def __getattr__(self, name): """Get path to the executable in a lazy way.""" if name in ("mdir", "mcopy", "mdel", "mdeltree", "sfdisk", "e2fsck", - "resize2fs", "mkswap", "mkdosfs", "debugfs","blkid"): + "resize2fs", "mkswap", "mkdosfs", "debugfs"): aname = "_%s" % name if aname not in self.__dict__: setattr(self, aname, find_executable(name, self.paths)) @@ -543,8 +543,7 @@ class Disk: logger.info("creating swap partition {}".format(pnum)) label = part.get("name") label_str = "-L {}".format(label) if label else '' - out = exec_cmd("{} --probe {}".format(self.blkid, self._get_part_image(pnum))) - uuid = out[out.index("UUID=\"")+6:out.index("UUID=\"")+42] + uuid = part.get("uuid") uuid_str = "-U {}".format(uuid) if uuid else '' with open(partfname, 'w') as sparse: os.ftruncate(sparse.fileno(), part['size'] * self._lsector_size) diff --git a/poky/scripts/lib/wic/help.py b/poky/scripts/lib/wic/help.py index bd3a2b97df..1e3d06a87b 100644 --- a/poky/scripts/lib/wic/help.py +++ b/poky/scripts/lib/wic/help.py @@ -971,24 +971,14 @@ DESCRIPTION has an effect with the rootfs source plugin. --include-path: This option is specific to wic. It adds the contents - of the given path or a rootfs to the resulting image. - The option contains two fields, the origin and the - destination. When the origin is a rootfs, it follows - the same logic as the rootfs-dir argument and the - permissions and owners are kept. When the origin is a - path, it is relative to the directory in which wic is - running not the rootfs itself so use of an absolute - path is recommended, and the owner and group is set to - root:root. If no destination is given it is - automatically set to the root of the rootfs. This - option only has an effect with the rootfs source - plugin. - - --change-directory: This option is specific to wic. It changes to the - given directory before copying the files. This - option is useful when we want to split a rootfs in - multiple partitions and we want to keep the right - permissions and usernames in all the partitions. + of the given path to the resulting image. The path is + relative to the directory in which wic is running not + the rootfs itself so use of an absolute path is + recommended. This option is most useful when multiple + copies of the rootfs are added to an image and it is + required to add extra content to only one of these + copies. This option only has an effect with the rootfs + source plugin. --extra-space: This option is specific to wic. It adds extra space after the space filled by the content diff --git a/poky/scripts/lib/wic/ksparser.py b/poky/scripts/lib/wic/ksparser.py index b8befe78e3..650b976223 100644 --- a/poky/scripts/lib/wic/ksparser.py +++ b/poky/scripts/lib/wic/ksparser.py @@ -137,8 +137,7 @@ class KickStart(): part.add_argument('--active', action='store_true') part.add_argument('--align', type=int) part.add_argument('--exclude-path', nargs='+') - part.add_argument('--include-path', nargs='+', action='append') - part.add_argument('--change-directory') + part.add_argument('--include-path', nargs='+') part.add_argument("--extra-space", type=sizetype) part.add_argument('--fsoptions', dest='fsopts') part.add_argument('--fstype', default='vfat', diff --git a/poky/scripts/lib/wic/misc.py b/poky/scripts/lib/wic/misc.py index 91975ba151..1f199b9f23 100644 --- a/poky/scripts/lib/wic/misc.py +++ b/poky/scripts/lib/wic/misc.py @@ -45,8 +45,7 @@ NATIVE_RECIPES = {"bmaptool": "bmap-tools", "parted": "parted", "sfdisk": "util-linux", "sgdisk": "gptfdisk", - "syslinux": "syslinux", - "tar": "tar" + "syslinux": "syslinux" } def runtool(cmdln_or_args): @@ -113,15 +112,6 @@ def exec_cmd(cmd_and_args, as_shell=False): """ return _exec_cmd(cmd_and_args, as_shell)[1] -def find_executable(cmd, paths): - recipe = cmd - if recipe in NATIVE_RECIPES: - recipe = NATIVE_RECIPES[recipe] - provided = get_bitbake_var("ASSUME_PROVIDED") - if provided and "%s-native" % recipe in provided: - return True - - return spawn.find_executable(cmd, paths) def exec_native_cmd(cmd_and_args, native_sysroot, pseudo=""): """ @@ -146,7 +136,7 @@ def exec_native_cmd(cmd_and_args, native_sysroot, pseudo=""): logger.debug("exec_native_cmd: %s", native_cmd_and_args) # If the command isn't in the native sysroot say we failed. - if find_executable(args[0], native_paths): + if spawn.find_executable(args[0], native_paths): ret, out = _exec_cmd(native_cmd_and_args, True) else: ret = 127 diff --git a/poky/scripts/lib/wic/partition.py b/poky/scripts/lib/wic/partition.py index 7d9dd616a6..2d95f78439 100644 --- a/poky/scripts/lib/wic/partition.py +++ b/poky/scripts/lib/wic/partition.py @@ -31,7 +31,6 @@ class Partition(): self.extra_space = args.extra_space self.exclude_path = args.exclude_path self.include_path = args.include_path - self.change_directory = args.change_directory self.fsopts = args.fsopts self.fstype = args.fstype self.label = args.label @@ -191,7 +190,7 @@ class Partition(): (self.mountpoint, self.size, self.fixed_size)) def prepare_rootfs(self, cr_workdir, oe_builddir, rootfs_dir, - native_sysroot, real_rootfs = True, pseudo_dir = None): + native_sysroot, real_rootfs = True): """ Prepare content for a rootfs partition i.e. create a partition and fill it from a /rootfs dir. @@ -199,14 +198,15 @@ class Partition(): Currently handles ext2/3/4, btrfs, vfat and squashfs. """ p_prefix = os.environ.get("PSEUDO_PREFIX", "%s/usr" % native_sysroot) - if (pseudo_dir): - pseudo = "export PSEUDO_PREFIX=%s;" % p_prefix - pseudo += "export PSEUDO_LOCALSTATEDIR=%s;" % pseudo_dir - pseudo += "export PSEUDO_PASSWD=%s;" % rootfs_dir - pseudo += "export PSEUDO_NOSYMLINKEXP=1;" - pseudo += "%s " % get_bitbake_var("FAKEROOTCMD") - else: - pseudo = None + p_localstatedir = os.environ.get("PSEUDO_LOCALSTATEDIR", + "%s/../pseudo" % rootfs_dir) + p_passwd = os.environ.get("PSEUDO_PASSWD", rootfs_dir) + p_nosymlinkexp = os.environ.get("PSEUDO_NOSYMLINKEXP", "1") + pseudo = "export PSEUDO_PREFIX=%s;" % p_prefix + pseudo += "export PSEUDO_LOCALSTATEDIR=%s;" % p_localstatedir + pseudo += "export PSEUDO_PASSWD=%s;" % p_passwd + pseudo += "export PSEUDO_NOSYMLINKEXP=%s;" % p_nosymlinkexp + pseudo += "%s " % get_bitbake_var("FAKEROOTCMD") rootfs = "%s/rootfs_%s.%s.%s" % (cr_workdir, self.label, self.lineno, self.fstype) diff --git a/poky/scripts/lib/wic/plugins/source/rootfs.py b/poky/scripts/lib/wic/plugins/source/rootfs.py index f1db83f8a1..705aeb5563 100644 --- a/poky/scripts/lib/wic/plugins/source/rootfs.py +++ b/poky/scripts/lib/wic/plugins/source/rootfs.py @@ -17,11 +17,10 @@ import shutil import sys from oe.path import copyhardlinktree -from pathlib import Path from wic import WicError from wic.pluginbase import SourcePlugin -from wic.misc import get_bitbake_var, exec_native_cmd +from wic.misc import get_bitbake_var logger = logging.getLogger('wic') @@ -33,22 +32,6 @@ class RootfsPlugin(SourcePlugin): name = 'rootfs' @staticmethod - def __validate_path(cmd, rootfs_dir, path): - if os.path.isabs(path): - logger.error("%s: Must be relative: %s" % (cmd, orig_path)) - sys.exit(1) - - # Disallow climbing outside of parent directory using '..', - # because doing so could be quite disastrous (we will delete the - # directory, or modify a directory outside OpenEmbedded). - full_path = os.path.realpath(os.path.join(rootfs_dir, path)) - if not full_path.startswith(os.path.realpath(rootfs_dir)): - logger.error("%s: Must point inside the rootfs:" % (cmd, path)) - sys.exit(1) - - return full_path - - @staticmethod def __get_rootfs_dir(rootfs_dir): if os.path.isdir(rootfs_dir): return os.path.realpath(rootfs_dir) @@ -61,15 +44,6 @@ class RootfsPlugin(SourcePlugin): return os.path.realpath(image_rootfs_dir) - @staticmethod - def __get_pseudo(native_sysroot, rootfs, pseudo_dir): - pseudo = "export PSEUDO_PREFIX=%s/usr;" % native_sysroot - pseudo += "export PSEUDO_LOCALSTATEDIR=%s;" % pseudo_dir - pseudo += "export PSEUDO_PASSWD=%s;" % rootfs - pseudo += "export PSEUDO_NOSYMLINKEXP=1;" - pseudo += "%s " % get_bitbake_var("FAKEROOTCMD") - return pseudo - @classmethod def do_prepare_partition(cls, part, source_params, cr, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, @@ -94,16 +68,10 @@ class RootfsPlugin(SourcePlugin): "it is not a valid path, exiting" % part.rootfs_dir) part.rootfs_dir = cls.__get_rootfs_dir(rootfs_dir) - pseudo_dir = os.path.join(part.rootfs_dir, "../pseudo") - if not os.path.lexists(pseudo_dir): - logger.warn("%s folder does not exist. " - "Usernames and permissions will be invalid " % pseudo_dir) - pseudo_dir = None new_rootfs = None - new_pseudo = None # Handle excluded paths. - if part.exclude_path or part.include_path or part.change_directory: + if part.exclude_path or part.include_path: # We need a new rootfs directory we can delete files from. Copy to # workdir. new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d" % part.lineno)) @@ -111,93 +79,25 @@ class RootfsPlugin(SourcePlugin): if os.path.lexists(new_rootfs): shutil.rmtree(os.path.join(new_rootfs)) - if part.change_directory: - cd = part.change_directory - if cd[-1] == '/': - cd = cd[:-1] - orig_dir = cls.__validate_path("--change-directory", part.rootfs_dir, cd) - else: - orig_dir = part.rootfs_dir - copyhardlinktree(orig_dir, new_rootfs) - - # Convert the pseudo directory to its new location - if (pseudo_dir): - new_pseudo = os.path.realpath( - os.path.join(cr_workdir, "pseudo%d" % part.lineno)) - if os.path.lexists(new_pseudo): - shutil.rmtree(new_pseudo) - os.mkdir(new_pseudo) - shutil.copy(os.path.join(pseudo_dir, "files.db"), - os.path.join(new_pseudo, "files.db")) - - pseudo_cmd = "%s -B -m %s -M %s" % (cls.__get_pseudo(native_sysroot, - new_rootfs, - new_pseudo), - orig_dir, new_rootfs) - exec_native_cmd(pseudo_cmd, native_sysroot) - - for in_path in part.include_path or []: - #parse arguments - include_path = in_path[0] - if len(in_path) > 2: - logger.error("'Invalid number of arguments for include-path") - sys.exit(1) - if len(in_path) == 2: - path = in_path[1] - else: - path = None - - # Pack files to be included into a tar file. - # We need to create a tar file, because that way we can keep the - # permissions from the files even when they belong to different - # pseudo enviroments. - # If we simply copy files using copyhardlinktree/copytree... the - # copied files will belong to the user running wic. - tar_file = os.path.realpath( - os.path.join(cr_workdir, "include-path%d.tar" % part.lineno)) - if os.path.isfile(include_path): - parent = os.path.dirname(os.path.realpath(include_path)) - tar_cmd = "tar c --owner=root --group=root -f %s -C %s %s" % ( - tar_file, parent, os.path.relpath(include_path, parent)) - exec_native_cmd(tar_cmd, native_sysroot) - else: - if include_path in krootfs_dir: - include_path = krootfs_dir[include_path] - include_path = cls.__get_rootfs_dir(include_path) - include_pseudo = os.path.join(include_path, "../pseudo") - if os.path.lexists(include_pseudo): - pseudo = cls.__get_pseudo(native_sysroot, include_path, - include_pseudo) - tar_cmd = "tar cf %s -C %s ." % (tar_file, include_path) - else: - pseudo = None - tar_cmd = "tar c --owner=root --group=root -f %s -C %s ." % ( - tar_file, include_path) - exec_native_cmd(tar_cmd, native_sysroot, pseudo) - - #create destination - if path: - destination = cls.__validate_path("--include-path", new_rootfs, path) - Path(destination).mkdir(parents=True, exist_ok=True) - else: - destination = new_rootfs + copyhardlinktree(part.rootfs_dir, new_rootfs) - #extract destination - untar_cmd = "tar xf %s -C %s" % (tar_file, destination) - if new_pseudo: - pseudo = cls.__get_pseudo(native_sysroot, new_rootfs, new_pseudo) - else: - pseudo = None - exec_native_cmd(untar_cmd, native_sysroot, pseudo) - os.remove(tar_file) + for path in part.include_path or []: + copyhardlinktree(path, new_rootfs) for orig_path in part.exclude_path or []: path = orig_path + if os.path.isabs(path): + logger.error("Must be relative: --exclude-path=%s" % orig_path) + sys.exit(1) - full_path = cls.__validate_path("--exclude-path", new_rootfs, path) + full_path = os.path.realpath(os.path.join(new_rootfs, path)) - if not os.path.lexists(full_path): - continue + # Disallow climbing outside of parent directory using '..', + # because doing so could be quite disastrous (we will delete the + # directory). + if not full_path.startswith(new_rootfs): + logger.error("'%s' points to a path outside the rootfs" % orig_path) + sys.exit(1) if path.endswith(os.sep): # Delete content only. @@ -212,5 +112,4 @@ class RootfsPlugin(SourcePlugin): shutil.rmtree(full_path) part.prepare_rootfs(cr_workdir, oe_builddir, - new_rootfs or part.rootfs_dir, native_sysroot, - pseudo_dir = new_pseudo or pseudo_dir) + new_rootfs or part.rootfs_dir, native_sysroot) diff --git a/poky/scripts/runqemu b/poky/scripts/runqemu index 310d79fdc5..6a77e3db9a 100755 --- a/poky/scripts/runqemu +++ b/poky/scripts/runqemu @@ -1196,10 +1196,6 @@ class BaseConfig(object): else: self.rootfs_options = '-drive file=%s,if=virtio,format=%s' % (self.rootfs, rootfs_format) - qb_rootfs_extra_opt = self.get("QB_ROOTFS_EXTRA_OPT") - if qb_rootfs_extra_opt and not qb_rootfs_extra_opt.startswith(","): - qb_rootfs_extra_opt = "," + qb_rootfs_extra_opt - if self.fstype in ('cpio.gz', 'cpio'): self.kernel_cmdline = 'root=/dev/ram0 rw debugshell' self.rootfs_options = '-initrd %s' % self.rootfs @@ -1212,15 +1208,14 @@ class BaseConfig(object): drive_type = self.get('QB_DRIVE_TYPE') if drive_type.startswith("/dev/sd"): logger.info('Using scsi drive') - vm_drive = '-drive if=none,id=hd,file=%s,format=%s -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd%s' \ - % (self.rootfs, rootfs_format, qb_rootfs_extra_opt) + vm_drive = '-drive if=none,id=hd,file=%s,format=%s -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd' \ + % (self.rootfs, rootfs_format) elif drive_type.startswith("/dev/hd"): logger.info('Using ide drive') vm_drive = "-drive file=%s,format=%s" % (self.rootfs, rootfs_format) elif drive_type.startswith("/dev/vdb"): logger.info('Using block virtio drive'); - vm_drive = '-drive id=disk0,file=%s,if=none,format=%s -device virtio-blk-device,drive=disk0%s' \ - % (self.rootfs, rootfs_format,qb_rootfs_extra_opt) + vm_drive = '-drive id=disk0,file=%s,if=none,format=%s -device virtio-blk-device,drive=disk0' % (self.rootfs, rootfs_format) else: # virtio might have been selected explicitly (just use it), or # is used as fallback (then warn about that). diff --git a/poky/scripts/tiny/ksize.py b/poky/scripts/tiny/ksize.py index 8316b85cb1..db2b9ec39f 100755 --- a/poky/scripts/tiny/ksize.py +++ b/poky/scripts/tiny/ksize.py @@ -4,7 +4,7 @@ # # SPDX-License-Identifier: GPL-2.0-or-later # -# Display details of the kernel build size, broken up by built-in.o. Sort +# Display details of the kernel build size, broken up by built-in.[o,a]. Sort # the objects by size. Run from the top level kernel build directory. # # Author: Darren Hart <dvhart@linux.intel.com> @@ -59,7 +59,7 @@ class Report: p = Popen("ls " + subglob, shell=True, stdout=PIPE, stderr=PIPE, universal_newlines=True) for f in p.communicate()[0].splitlines(): path = os.path.dirname(f) - r.parts.append(Report.create(f, path, str(path) + "/*/built-in.o")) + r.parts.append(Report.create(f, path, str(path) + "/*/built-in.[o,a]")) r.parts.sort(reverse=True) for b in r.parts: @@ -139,7 +139,7 @@ def main(): else: assert False, "unhandled option" - glob = "arch/*/built-in.o */built-in.o" + glob = "arch/*/built-in.[o,a] */built-in.[o,a]" vmlinux = Report.create("vmlinux", "Linux Kernel", glob) vmlinux.show() |
