summaryrefslogtreecommitdiff
path: root/poky/scripts/lib
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2020-05-26 20:25:03 +0300
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2020-05-26 20:25:03 +0300
commit35a774200999ac2fca48693c1c169bf99d2f63ea (patch)
tree0b2f65ce3a90f41d1c2542d0fd20b1604fd83fe5 /poky/scripts/lib
parent497a23ef6661ad6ca7b75009e48a592c1620d46c (diff)
downloadopenbmc-2.8.0.tar.xz
reset upstream subtrees to HEAD2.8.0-rc12.8.0
Reset the following subtrees on HEAD: poky: ed3bdd7fbc(dunfell) meta-raspberrypi: 8066fac91d(dunfell) meta-security: d83f7cb0c9(dunfell) meta-openembedded: e413c1ef62(dunfell) Change-Id: Ifd3228663b08911c890d7631310294cccb3dd232 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'poky/scripts/lib')
-rw-r--r--poky/scripts/lib/wic/engine.py5
-rw-r--r--poky/scripts/lib/wic/help.py26
-rw-r--r--poky/scripts/lib/wic/ksparser.py3
-rw-r--r--poky/scripts/lib/wic/misc.py14
-rw-r--r--poky/scripts/lib/wic/partition.py20
-rw-r--r--poky/scripts/lib/wic/plugins/source/rootfs.py133
6 files changed, 39 insertions, 162 deletions
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)