builds and runs on intel-x86 and rpi4 with acceptable realtime performance
This commit is contained in:
1 parent
2bce6fa556
commit
3faf544f0b
120 files changed
+6317
-1
No files matched your search
@@ -0,0 +1,61 @@
|
||||
# Summarize sstate usage at the end of the build
|
||||
python buildstats_summary () {
|
||||
import collections
|
||||
import os.path
|
||||
|
||||
bsdir = e.data.expand("${BUILDSTATS_BASE}/${BUILDNAME}")
|
||||
if not os.path.exists(bsdir):
|
||||
return
|
||||
|
||||
sstatetasks = (e.data.getVar('SSTATETASKS') or '').split()
|
||||
built = collections.defaultdict(lambda: [set(), set(), set(), set()])
|
||||
for pf in os.listdir(bsdir):
|
||||
taskdir = os.path.join(bsdir, pf)
|
||||
if not os.path.isdir(taskdir):
|
||||
continue
|
||||
|
||||
tasks = os.listdir(taskdir)
|
||||
for t in sstatetasks:
|
||||
target_source, native_source, native_sstate, target_sstate = built[t]
|
||||
if t in tasks and "-native" in pf:
|
||||
native_source.add(pf)
|
||||
elif t in tasks:
|
||||
target_source.add(pf)
|
||||
elif t + '_setscene' in tasks and "-native" in pf:
|
||||
native_sstate.add(pf)
|
||||
elif t + '_setscene' in tasks:
|
||||
target_sstate.add(pf)
|
||||
|
||||
header_printed = False
|
||||
for t in sstatetasks:
|
||||
target_source, native_source, native_sstate, target_sstate = built[t]
|
||||
if target_source | native_source | native_sstate | target_sstate:
|
||||
if not header_printed:
|
||||
header_printed = True
|
||||
bb.note("Build completion summary:")
|
||||
|
||||
bb.note("{0}:".format(t))
|
||||
|
||||
target_sstate_count = len(target_sstate)
|
||||
native_sstate_count = len(native_sstate)
|
||||
target_source_count = len(target_source)
|
||||
native_source_count = len(native_source)
|
||||
bb.note("target from sstate {0}, native from sstate {1}, target from source {2}, native from source {3}".format(target_sstate_count, native_sstate_count, target_source_count, native_source_count))
|
||||
total_source_count = target_source_count + native_source_count
|
||||
total_sstate_count = target_sstate_count + native_sstate_count
|
||||
total_native_count = native_source_count + native_sstate_count
|
||||
total_target_count = target_source_count + target_sstate_count
|
||||
total_count = total_source_count + total_sstate_count
|
||||
bb.note("total from source {0}, total from sstate {1}, total native {2}, total target {3}, sum total {4}".format(total_source_count, total_sstate_count, total_native_count, total_target_count, total_count))
|
||||
|
||||
#do_package_qa, do_packagedata, and do_package_write_rpm won't have native sstate, so declare them as 0% reuse
|
||||
if native_sstate_count == 0:
|
||||
bb.note("native from source {0} of {1} (0% sstate reuse), from source {2} of {3} ({4:.1f}% sstate reuse), {5} total".format(native_source_count, total_native_count, target_source_count, total_target_count, round(100 * target_sstate_count / total_target_count, 1), total_count))
|
||||
# Avoid division-by-zero if only native packages were built
|
||||
elif total_target_count == 0:
|
||||
bb.note("native from source {0} of {1} ({2:.1f}% sstate reuse), from source {3} of {4} (0% sstate reuse), {5} total".format(native_source_count, total_native_count, round(100 * native_sstate_count / total_native_count, 1), target_source_count, total_target_count, total_count))
|
||||
else:
|
||||
bb.note("native from source {0} of {1} ({2:.1f}% sstate reuse), from source {3} of {4} ({5:.1f}% sstate reuse), {6} total".format(native_source_count, total_native_count, round(100 * native_sstate_count / total_native_count, 1), target_source_count, total_target_count, round(100 * target_sstate_count / total_target_count, 1), total_count))
|
||||
}
|
||||
addhandler buildstats_summary
|
||||
buildstats_summary[eventmask] = "bb.event.BuildCompleted"
|
||||
@@ -0,0 +1,22 @@
|
||||
#
|
||||
#
|
||||
# e.g.
|
||||
# In the depreated old recipe, write as follows:
|
||||
# inherit dprecate
|
||||
# ALTERNATIVE_NEW_RECIPE = "new_recipe_name"
|
||||
#
|
||||
|
||||
ALTERNATIVE_NEW_RECIPE ?= ""
|
||||
|
||||
python do_warn_deprecate() {
|
||||
pn = d.getVar('BPN')
|
||||
alternative_new_recipe = d.getVar('ALTERNATIVE_NEW_RECIPE')
|
||||
if alternative_new_recipe:
|
||||
bb.warn("Deprecated recipe %s, use %s instead" % (pn, alternative_new_recipe))
|
||||
else:
|
||||
bb.warn("Deprecated recipe %s")
|
||||
}
|
||||
|
||||
do_warn_deprecate[nostamp] = "1"
|
||||
|
||||
addtask warn_deprecate before do_build
|
||||
@@ -0,0 +1,152 @@
|
||||
#
|
||||
# Copyright (C) 2024 Wind River Systems, Inc
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
|
||||
# To avoid confusions with PR Server
|
||||
VENDOR_REVISION_PREFIX ??= ".vr"
|
||||
|
||||
VENDOR_REVISION_SKIP ??= ""
|
||||
|
||||
# Set it to "0" to enable VR for non-WRLinux provided recipes.
|
||||
VENDOR_REVISION_WRLINUX_SUPPORTED_ONLY ??= "1"
|
||||
|
||||
def get_src_patches(d):
|
||||
import oe.patch
|
||||
local_patches = set()
|
||||
bb.fetch.get_hashvalue(d)
|
||||
for patch in oe.patch.src_patches(d):
|
||||
_, _, local, _, _, parm = bb.fetch.decodeurl(patch)
|
||||
local_patches.add(local)
|
||||
return local_patches
|
||||
|
||||
def is_work_shared(d):
|
||||
sharedworkdir = os.path.join(d.getVar('TMPDIR'), 'work-shared')
|
||||
|
||||
# Due to meta-xilinx used the xlnx-embeddedsw class to hard link
|
||||
# copy the source files from work share directory to the working
|
||||
# directory. Add it as corner case of work-shared recipes
|
||||
if bb.data.inherits_class("xlnx-embeddedsw", d):
|
||||
return True
|
||||
|
||||
return d.getVar('S').startswith(sharedworkdir)
|
||||
|
||||
def vr_need_skip(d):
|
||||
|
||||
# Only enable vr for supported recipes
|
||||
if bb.utils.to_boolean(d.getVar('VENDOR_REVISION_WRLINUX_SUPPORTED_ONLY')):
|
||||
# Check whether the recipe is from Wind River Linux layers
|
||||
pf = d.getVar('PF')
|
||||
layer = bb.utils.get_file_layer(d.getVar('FILE'), d)
|
||||
if not layer in d.getVar('RECIPE_LIST_LAYERS_ORIG').split():
|
||||
bb.debug(1, 'Skipping VR for %s since it is not from a WRLinux layer.' % d.getVar('PF'))
|
||||
return True
|
||||
|
||||
bpn = d.getVar('BPN')
|
||||
wrl_supported = d.getVar('WRLINUX_SUPPORTED_RECIPE') or d.getVar('WRLINUX_SUPPORTED_RECIPE:pn-%s' % bpn)
|
||||
if (not wrl_supported) or wrl_supported.strip() != '1':
|
||||
bb.debug(1, 'Skipping VR for %s since it is not a WRLinux supported recipe.' % pf)
|
||||
return True
|
||||
|
||||
|
||||
if bb.utils.to_boolean(d.getVar('VENDOR_REVISION_SKIP')):
|
||||
return True
|
||||
|
||||
if is_work_shared(d):
|
||||
return False
|
||||
|
||||
packages = d.getVar('PACKAGES')
|
||||
if (not packages) or bb.data.inherits_class('nopackages', d) or \
|
||||
bb.data.inherits_class('nativesdk', d):
|
||||
return True
|
||||
|
||||
# Skip VR when no patches
|
||||
if get_src_patches(d):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def get_var_short(var):
|
||||
return '/'.join(var.split('/')[-4:]).replace('/', '_')
|
||||
|
||||
def get_file_short(d):
|
||||
return get_var_short(d.getVar('FILE'))
|
||||
|
||||
def get_current_vendor_revision(d):
|
||||
year_version = d.getVar('WRLINUX_YEAR_VERSION')
|
||||
if not year_version:
|
||||
bb.warn('Failed to get WRLINUX_YEAR_VERSION')
|
||||
year_version = '0'
|
||||
update_version = d.getVar('WRLINUX_UPDATE_VERSION') or '0'
|
||||
if int(update_version) <10:
|
||||
# Prepend 0 when less than 10
|
||||
update_version = '0%s' % update_version
|
||||
|
||||
vendor_revision = '%s%s' % (year_version, update_version)
|
||||
|
||||
vr_prefix = d.getVar('VENDOR_REVISION_PREFIX') or ''
|
||||
if vr_prefix:
|
||||
vendor_revision = vr_prefix + vendor_revision
|
||||
|
||||
vr_suffix = d.getVar('VENDOR_REVISION_SUFFIX') or ''
|
||||
if vr_suffix:
|
||||
vendor_revision += vr_suffix
|
||||
|
||||
return vendor_revision
|
||||
|
||||
addhandler append_vr_to_pr
|
||||
append_vr_to_pr[eventmask] = "bb.event.RecipeTaskPreProcess"
|
||||
python append_vr_to_pr() {
|
||||
"""
|
||||
Set PR:append = "VENDOR_REVISION" for the recipes
|
||||
"""
|
||||
|
||||
pf = d.getVar('PF')
|
||||
# Skip when WRLINUX_VENDOR_REVISION_FILE is NULL
|
||||
if not d.getVar('WRLINUX_VENDOR_REVISION_FILE'):
|
||||
bb.debug(1, 'Skipping VR for %s since WRLINUX_VENDOR_REVISION_FILE is NULL.' % pf)
|
||||
return
|
||||
|
||||
# Skip when gen-vendor-revision is inherited
|
||||
if bb.data.inherits_class('gen-vendor-revision', d):
|
||||
bb.debug(1, 'Skipping VR for %s since gen-vendor-revision is inherited' % pf)
|
||||
return
|
||||
|
||||
if vr_need_skip(d):
|
||||
return
|
||||
|
||||
# Directly use VENDOR_REVISION if the recipe sets it.
|
||||
vr = d.getVar('VENDOR_REVISION')
|
||||
if not vr:
|
||||
file_short = get_file_short(d)
|
||||
val = d.getVarFlag('VENDOR_REVISION', file_short)
|
||||
if val:
|
||||
# The first item is VENDOR_REVISION
|
||||
vr = val.split()[0]
|
||||
# The d.getVarFlag("VENDOR_REVISION", "tmp-glibc_work-shared_qemux86-64_kernel-source")
|
||||
# return None when kernel doesn't have patches, and vr_need_skip()
|
||||
# can't skip work-shared recipes. The None is a string here.
|
||||
if vr == 'None':
|
||||
return
|
||||
|
||||
if not vr:
|
||||
# It's a new recipe, defult to current VR
|
||||
vr = get_current_vendor_revision(d)
|
||||
|
||||
bb.debug(1, 'Appending VENDOR_REVISION %s to PR' % vr)
|
||||
d.appendVar('PR', vr)
|
||||
}
|
||||
|
||||
GLOBAL_VENDOR_REVISION_WARN ??= '1'
|
||||
addhandler warn_for_global_vr
|
||||
warn_for_global_vr[eventmask] = "bb.event.ConfigParsed"
|
||||
python warn_for_global_vr() {
|
||||
# The VENDOR_REVISION should be set via recipe level, otherwise, there
|
||||
# might be PR bombs or no effect, so warn for global VENDOR_REVISION
|
||||
global_vr = d.getVar('VENDOR_REVISION')
|
||||
if global_vr and bb.utils.to_boolean(d.getVar('GLOBAL_VENDOR_REVISION_WARN')):
|
||||
bb.warn('The global VENDOR_REVISION (%s) may cause unneeded packages upgrading,' % global_vr)
|
||||
bb.warn('or make VENDOR_REVISION invalid.')
|
||||
bb.warn('The above warning can be disabled by GLOBAL_VENDOR_REVISION_WARN = "0"\n')
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
# transfer "SECURITY_CFLAGS:pn-recipe = ..." to
|
||||
# "SECURITY_CFLAGS:pn-mlib-recipe = ..." and
|
||||
# transfer "SECURITY_CFLAGS:pn-recipe:powerpc = ..."
|
||||
# to "SECURITY_CFLAGS:pn-mlib-recipe:powerpc = ..."
|
||||
|
||||
python transfer_security_cflags () {
|
||||
mlprefix = e.data.getVar('MLPREFIX', True)
|
||||
|
||||
if mlprefix:
|
||||
pn = e.data.getVar('PN', True)
|
||||
bpn = e.data.getVar('BPN', True)
|
||||
cflags = e.data.getVar("SECURITY_CFLAGS:pn-%s" % bpn, True)
|
||||
if cflags is not None:
|
||||
e.data.setVar("SECURITY_CFLAGS:pn-%s" % pn, cflags)
|
||||
|
||||
arch = e.data.getVar('HOST_ARCH', True)
|
||||
cflags = e.data.getVar("SECURITY_CFLAGS:pn-%s:%s" %(bpn, arch), True)
|
||||
if cflags is not None:
|
||||
e.data.setVar("SECURITY_CFLAGS:pn-%s:%s" %(pn, arch), cflags)
|
||||
}
|
||||
|
||||
addhandler transfer_security_cflags
|
||||
transfer_security_cflags[eventmask] = "bb.event.RecipeParsed"
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
IMAGE_INSTALL:append = " ostree ostree-upgrade-mgr os-release"
|
||||
IMAGE_CLASSES += "image_types_ostree image_types_ota"
|
||||
IMAGE_FSTYPES += "otaimg "
|
||||
|
||||
inherit image_types_ostree image_types_ota
|
||||
|
||||
IMAGE_TYPEDEP:wic += "otaimg ostree"
|
||||
|
||||
WKS_FILE_DEPENDS = "mtools-native dosfstools-native e2fsprogs-native parted-native"
|
||||
@@ -0,0 +1,174 @@
|
||||
#
|
||||
# Copyright (C) 2024 Wind River Systems, Inc
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
|
||||
inherit enable-vendor-revision
|
||||
|
||||
VENDOR_REVISION_DIR ?= "${TMPDIR}/vendor-revisions/${MACHINE}"
|
||||
VENDOR_REVISION_ALL ?= "${VENDOR_REVISION_DIR}/wrlinux-vendor-revision.conf"
|
||||
|
||||
# For fixed RCPL users which can be set in their own conf file such as
|
||||
# conf/layer.conf, for example, ccm01 to ccm99:
|
||||
#VENDOR_REVISION_SUFFIX = ".ccm01"
|
||||
VENDOR_REVISION_SUFFIX ??= ""
|
||||
|
||||
addhandler gen_vr_fatal
|
||||
gen_vr_fatal[eventmask] = "bb.event.BuildStarted"
|
||||
python gen_vr_fatal() {
|
||||
bb.fatal('Only bitbake -p is supported when gen-vendor-revision.bbclass is enabled!')
|
||||
}
|
||||
|
||||
addhandler gen_vr_prepare
|
||||
gen_vr_prepare[eventmask] = "bb.event.CacheLoadStarted"
|
||||
python gen_vr_prepare() {
|
||||
vendor_revision_dir = d.getVar('VENDOR_REVISION_DIR')
|
||||
# Need a fresh VENDOR_REVISION_DIR and CACHE dir
|
||||
for k in ('VENDOR_REVISION_DIR', 'CACHE'):
|
||||
value = d.getVar(k)
|
||||
bb.note("Removing %s" % value)
|
||||
bb.utils.remove(value, True)
|
||||
bb.utils.mkdirhier(value)
|
||||
}
|
||||
|
||||
# Generate VENDOR_REVISION for each recipe
|
||||
addhandler gen_vr_recipe_handler
|
||||
gen_vr_recipe_handler[eventmask] = "bb.event.RecipeParsed"
|
||||
python gen_vr_recipe_handler() {
|
||||
"""
|
||||
Generate VENDOR_REVISION for each recipe, the format is:
|
||||
VENDOR_REVISION[recipe_file] ?= 'vr cveid1:patch1 notcve:patch2'
|
||||
"""
|
||||
|
||||
import hashlib
|
||||
|
||||
# Only generate vr for supported recipes
|
||||
bpn = d.getVar('BPN')
|
||||
wrl_supported = d.getVar('WRLINUX_SUPPORTED_RECIPE') or d.getVar('WRLINUX_SUPPORTED_RECIPE:pn-%s' % bpn)
|
||||
if wrl_supported and wrl_supported.strip() == '0':
|
||||
return
|
||||
|
||||
if vr_need_skip(d):
|
||||
return
|
||||
|
||||
def get_cve_patch(patch):
|
||||
ret = []
|
||||
patch_bn = os.path.basename(patch)
|
||||
# Open in 'text' mode doesn't work for very a few patches such as:
|
||||
# hddtemp_0.3-beta15-52.diff: 'utf-8' codec can't decode byte 0xe8 in
|
||||
# position 3851: invalid continuation byte
|
||||
with open(patch, 'rb') as f:
|
||||
# Get md5
|
||||
md5 = hashlib.md5()
|
||||
md5.update(f.read())
|
||||
hash = md5.hexdigest()
|
||||
patch_bn += ':%s' % md5.hexdigest()
|
||||
# Reset file postion
|
||||
f.seek(0, 0)
|
||||
for line in f:
|
||||
if not 'CVE:' in str(line):
|
||||
continue
|
||||
line = line.decode('utf-8')
|
||||
if line.startswith('CVE:') and 'CVE-' in line:
|
||||
line_split = line.split('CVE:')
|
||||
for cveid in line_split[1].split():
|
||||
cveid = cveid.strip()
|
||||
if cveid.startswith('CVE-'):
|
||||
ret.append('%s:%s' % (cveid, patch_bn))
|
||||
if not ret:
|
||||
ret.append('notcve:%s' % patch_bn)
|
||||
return ret
|
||||
|
||||
def update_vr(patches):
|
||||
"""
|
||||
Check whether recipe's VENDOR_REVISION need update or not
|
||||
* If old_vr == new_vf
|
||||
- No check is needed since they are in the same
|
||||
RCPL, just update it.
|
||||
|
||||
* If old_vr != new_vr:
|
||||
- If the patches are the same:
|
||||
Nothing changed, use the old_vr to avoid unneeded updates by dnf.
|
||||
|
||||
- If the patches are different:
|
||||
Update to the new_vr
|
||||
"""
|
||||
|
||||
patches.sort()
|
||||
new_patches = ' '.join(patches)
|
||||
|
||||
file_short = get_file_short(d)
|
||||
vr = get_current_vendor_revision(d)
|
||||
old_val = d.getVarFlag('VENDOR_REVISION', file_short)
|
||||
|
||||
# No checking is needed in the following cases:
|
||||
# - No old_val: It's a new vr, just update it
|
||||
if old_val:
|
||||
old_vr = old_val.split()[0]
|
||||
if old_vr:
|
||||
# In different RCPL, check whether need update
|
||||
if old_vr != vr:
|
||||
old_patches = ' '.join(old_val.split()[1:])
|
||||
# The patches are the same, no update is needed
|
||||
if old_patches == new_patches:
|
||||
vr = old_vr
|
||||
|
||||
# Replace .vr -> ${VENDOR_REVISION_PREFIX}
|
||||
vr_prefix = d.getVar("VENDOR_REVISION_PREFIX") or ""
|
||||
vr = vr.removeprefix(vr_prefix)
|
||||
vr = '${VENDOR_REVISION_PREFIX}%s' % vr
|
||||
out_lines = []
|
||||
val = ""
|
||||
if new_patches:
|
||||
val = '%s %s' % (vr, new_patches)
|
||||
out_lines.append("VENDOR_REVISION[%s] ??= '%s'" % (file_short, val))
|
||||
|
||||
if is_work_shared(d):
|
||||
s_short = get_var_short(d.getVar('S'))
|
||||
if val:
|
||||
out_lines.append("VENDOR_REVISION[%s] ?= '%s'" % (s_short, val))
|
||||
else:
|
||||
out_lines.append("VENDOR_REVISION[%s] ??= '${@d.getVarFlag(\"VENDOR_REVISION\", \"%s\")}'" \
|
||||
% (file_short, s_short))
|
||||
if out_lines:
|
||||
out_file = os.path.join(d.getVar('VENDOR_REVISION_DIR'), file_short)
|
||||
with open(out_file, 'w') as f:
|
||||
f.write('%s\n' % '\n'.join(out_lines))
|
||||
|
||||
patches = []
|
||||
localdata = bb.data.createCopy(d)
|
||||
localdata.setVar('OVERRIDES', localdata.getVar('OVERRIDES') + localdata.getVar('GEN_VENDOR_REVISION_OVERRIDES'))
|
||||
for local in get_src_patches(localdata):
|
||||
patches += get_cve_patch(local)
|
||||
update_vr(patches)
|
||||
}
|
||||
|
||||
# Generate vendor-revision.conf
|
||||
addhandler gen_vr_all_handler
|
||||
gen_vr_all_handler[eventmask] = "bb.event.ParseCompleted"
|
||||
python gen_vr_all_handler () {
|
||||
"""
|
||||
Collect each recipe's vendor revision in VENDOR_REVISION_DIR and save
|
||||
to VENDOR_REVISION_ALL
|
||||
"""
|
||||
import glob
|
||||
vendor_revision_dir = d.getVar('VENDOR_REVISION_DIR')
|
||||
patches = []
|
||||
output = d.getVar('VENDOR_REVISION_ALL')
|
||||
output_dir = os.path.dirname(output)
|
||||
for recipe in glob.glob(os.path.join(vendor_revision_dir, '*')):
|
||||
with open(recipe) as f:
|
||||
for line in f:
|
||||
if not line in (patches):
|
||||
patches.append(line)
|
||||
patches.sort()
|
||||
with open(output, 'w') as f:
|
||||
f.write('require %s\n\n' % "wrlinux-vendor-revision-manual.inc")
|
||||
f.write(''.join(patches))
|
||||
bb.note('The recipes with patches are saved to %s' % output)
|
||||
}
|
||||
|
||||
# Workaround Exception during build_dependencies for fetcher_hashes_dummyfunc
|
||||
# https://git.openembedded.org/openembedded-core/commit/?id=a8e7b0f932b9ea69b3a218fca18041676c65aba0
|
||||
fetcher_hashes_dummyfunc[vardepvalue] = ""
|
||||
Executable
+567
@@ -0,0 +1,567 @@
|
||||
# OSTree deployment
|
||||
|
||||
OSTREE_GPG_DEP = "${@'' if (d.getVar('GPG_BIN', True) or '').startswith('/') else 'gnupg-native:do_populate_sysroot pinentry-native:do_populate_sysroot'}"
|
||||
GPG_BIN ??= ""
|
||||
GPG_PATH ??= ""
|
||||
OSTREE_COMMIT_DEV ??= "0"
|
||||
OSTREE_CREATE_TARBALL ??= "0"
|
||||
|
||||
DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'policycoreutils-native', '', d)}"
|
||||
|
||||
do_image_ostree[depends] = "ostree-native:do_populate_sysroot \
|
||||
openssl-native:do_populate_sysroot \
|
||||
coreutils-native:do_populate_sysroot \
|
||||
wic-tools:do_populate_sysroot \
|
||||
virtual/kernel:do_deploy \
|
||||
${OSTREE_INITRAMFS_IMAGE}:do_image_complete \
|
||||
${@'grub:do_populate_sysroot' if d.getVar('OSTREE_BOOTLOADER_INCLUDE', True) == 'grub' else ''} \
|
||||
${@'virtual/bootloader:do_deploy u-boot-tools-native:do_populate_sysroot' if d.getVar('OSTREE_BOOTLOADER_INCLUDE', True) == 'u-boot' else ''}"
|
||||
|
||||
do_prepare_recipe_sysroot[depends] += "${OSTREE_GPG_DEP}"
|
||||
|
||||
#export REPRODUCIBLE_TIMESTAMP_ROOTFS ??= "`date --date="20${WRLINUX_YEAR_VERSION}-01-01 +${WRLINUX_WW_VERSION}weeks" +%s`"
|
||||
export BUILD_REPRODUCIBLE_BINARIES = "1"
|
||||
|
||||
export OSTREE_REPO
|
||||
export OSTREE_BRANCHNAME
|
||||
|
||||
export SYSTEMD_USED = "${@oe.utils.ifelse(d.getVar('VIRTUAL-RUNTIME_init_manager', True) == 'systemd', 'true', '')}"
|
||||
export GRUB_USED = "${@oe.utils.ifelse(d.getVar('OSTREE_BOOTLOADER', True) == 'grub', 'true', '')}"
|
||||
export FLUXDATA = "${@bb.utils.contains('DISTRO_FEATURES', 'luks', 'luks_fluxdata', 'fluxdata', d)}"
|
||||
|
||||
repo_apache_config () {
|
||||
local _repo_path
|
||||
local _repo_alias
|
||||
|
||||
cd $OSTREE_REPO && _repo_path=$(pwd) && cd -
|
||||
_repo_alias="/${OSTREE_OSNAME}/${MACHINE}/"
|
||||
|
||||
echo "* Generating apache2 config fragment for $OSTREE_REPO..."
|
||||
(echo "Alias \"$_repo_alias\" \"$_repo_path/\""
|
||||
echo ""
|
||||
echo "<Directory $_repo_path>"
|
||||
echo " Options Indexes FollowSymLinks"
|
||||
echo " Require all granted"
|
||||
echo "</Directory>") > ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.http.conf
|
||||
}
|
||||
|
||||
python ostree_check_rpm_public_key () {
|
||||
gpg_path = d.getVar('GPG_PATH', True)
|
||||
if not gpg_path:
|
||||
gpg_path = d.getVar('TMPDIR', True) + '/.gnupg'
|
||||
|
||||
if not os.path.exists(gpg_path):
|
||||
status, output = oe.utils.getstatusoutput('mkdir -m 0700 -p %s' % gpg_path)
|
||||
if status:
|
||||
raise bb.fatal('Failed to create gpg keying %s: %s' %
|
||||
(gpg_path, output))
|
||||
gpg_bin = d.getVar('GPG_BIN', True) or \
|
||||
bb.utils.which(os.getenv('PATH'), 'gpg')
|
||||
gpg_keyid = d.getVar('OSTREE_GPGID', True) or ''
|
||||
if gpg_keyid == "":
|
||||
return
|
||||
|
||||
# Check OSTREE_GPG_NAME and OSTREE_GPG_PASSPHRASE
|
||||
cmd = "%s --homedir %s --list-keys \"%s\"" % \
|
||||
(gpg_bin, gpg_path, gpg_keyid)
|
||||
bb.note(cmd)
|
||||
status, output = oe.utils.getstatusoutput(cmd)
|
||||
if not status:
|
||||
return
|
||||
|
||||
# Import RPM_GPG_NAME if not found
|
||||
gpg_key = d.getVar('OSTREE_GPGDIR', True) + '/' + 'RPM-GPG-PRIVKEY-' + gpg_keyid
|
||||
cmd = '%s --batch --homedir %s --passphrase %s --import "%s"' % \
|
||||
(gpg_bin, gpg_path, d.getVar('OSTREE_GPG_PASSPHRASE', True), gpg_key)
|
||||
bb.note(cmd)
|
||||
status, output = oe.utils.getstatusoutput(cmd)
|
||||
if status:
|
||||
bb.fatal('Could not import GPG key for ostree signing: %s' % output)
|
||||
}
|
||||
ostree_check_rpm_public_key[lockfiles] = "${TMPDIR}/gpg_key.lock"
|
||||
do_package_write_rpm[prefuncs] += "ostree_check_rpm_public_key"
|
||||
do_rootfs[prefuncs] += "ostree_check_rpm_public_key"
|
||||
|
||||
selinux_set_labels (){
|
||||
touch ${OSTREE_ROOTFS}/usr/${sysconfdir}/selinux/fixfiles_exclude_dirs
|
||||
echo "/ostree" >> ${OSTREE_ROOTFS}/usr/${sysconfdir}/selinux/fixfiles_exclude_dirs
|
||||
echo "/sysroot" >> ${OSTREE_ROOTFS}/usr/${sysconfdir}/selinux/fixfiles_exclude_dirs
|
||||
if [ -f ${OSTREE_ROOTFS}/.autorelabel ]; then
|
||||
mv ${OSTREE_ROOTFS}/.autorelabel ${OSTREE_ROOTFS}/usr/${sysconfdir}
|
||||
fi
|
||||
|
||||
POL_TYPE=$(sed -n -e "s&^SELINUXTYPE[[:space:]]*=[[:space:]]*\([0-9A-Za-z_]\+\)&\1&p" ${OSTREE_ROOTFS}/usr/${sysconfdir}/selinux/config)
|
||||
sed -i "\/bin\/rm/a \\\t/usr/sbin/setfiles -F -q /etc/selinux/${POL_TYPE}/contexts/files/file_contexts /etc" ${OSTREE_ROOTFS}/usr/bin/selinux-autorelabel.sh
|
||||
sed -i "s/.autorelabel/etc\/.autorelabel/g" ${OSTREE_ROOTFS}/usr/bin/selinux-autorelabel.sh
|
||||
|
||||
if ! setfiles -m -r ${OSTREE_ROOTFS} ${OSTREE_ROOTFS}/usr/${sysconfdir}/selinux/${POL_TYPE}/contexts/files/file_contexts ${OSTREE_ROOTFS}
|
||||
then
|
||||
bbfatal "selinux_set_labels error."
|
||||
fi
|
||||
}
|
||||
|
||||
create_tarball_and_ostreecommit[vardepsexclude] = "DATETIME"
|
||||
create_tarball_and_ostreecommit() {
|
||||
local _image_basename=$1
|
||||
local _timestamp=$2
|
||||
|
||||
# The timestamp format of ostree requires
|
||||
_timestamp=`LC_ALL=C date --date=@$_timestamp`
|
||||
|
||||
if [ ${OSTREE_CREATE_TARBALL} = "1" ] ; then
|
||||
# Create a tarball that can be then commited to OSTree repo
|
||||
OSTREE_TAR=${DEPLOY_DIR_IMAGE}/${_image_basename}-${MACHINE}-${DATETIME}.rootfs.ostree.tar.bz2
|
||||
tar -C ${OSTREE_ROOTFS} --xattrs --xattrs-include='*' -cjf ${OSTREE_TAR} .
|
||||
sync
|
||||
|
||||
ln -snf ${_image_basename}-${MACHINE}-${DATETIME}.rootfs.ostree.tar.bz2 \
|
||||
${DEPLOY_DIR_IMAGE}/${_image_basename}-${MACHINE}.rootfs.ostree.tar.bz2
|
||||
fi
|
||||
|
||||
# Commit the result
|
||||
if [ -z "${OSTREE_GPGID}" ]; then
|
||||
bbwarn "You are using an unsupported configuration by using ostree repo without gpg. " \
|
||||
"This usually indicates a failure to find /usr/bin/gpg, " \
|
||||
"or you tried to use an invalid GPG database. " \
|
||||
"It could also be possible that OSTREE_GPGID, OSTREE_GPG_PASSPHRASE, " \
|
||||
"OSTREE_GPGDIR has a bad value."
|
||||
ostree --repo=${OSTREE_REPO_TEMP} commit \
|
||||
--tree=dir=${OSTREE_ROOTFS} \
|
||||
--skip-if-unchanged \
|
||||
--branch=${_image_basename} \
|
||||
--timestamp="${_timestamp}" \
|
||||
--subject="Commit-id: ${_image_basename}-${MACHINE}-${DATETIME}"
|
||||
# Pull new commmit into old repo
|
||||
flock ${OSTREE_REPO}.lock ostree --repo=${OSTREE_REPO} pull-local ${OSTREE_REPO_TEMP} ${_image_basename}
|
||||
else
|
||||
# Setup gpg key for signing
|
||||
if [ -n "${OSTREE_GPGID}" ] && [ -n "${OSTREE_GPG_PASSPHRASE}" ] && [ -n "$gpg_path" ] ; then
|
||||
gpg_ver=`$gpg_bin --version | head -1 | awk '{ print $3 }' | awk -F. '{ print $1 }'`
|
||||
echo '#!/bin/bash' > ${WORKDIR}/gpg
|
||||
echo 'exarg=""' >> ${WORKDIR}/gpg
|
||||
if [ "$gpg_ver" = "1" ] ; then
|
||||
# GPGME has to be tricked into running a helper script to provide a passphrase when using gpg 1
|
||||
echo 'echo "$@" |grep -q batch && exarg="--passphrase ${OSTREE_GPG_PASSPHRASE}"' >> ${WORKDIR}/gpg
|
||||
elif [ "$gpg_ver" = "2" ] ; then
|
||||
gpg_connect=$(dirname $gpg_bin)/gpg-connect-agent
|
||||
if [ ! -f $gpg_connect ] ; then
|
||||
bb.fatal "ERROR Could not locate gpg-connect-agent at: $gpg_connect"
|
||||
fi
|
||||
if [ -f "$gpg_path/gpg-agent.conf" ] ; then
|
||||
if ! grep -q allow-loopback-pin "$gpg_path/gpg-agent.conf" ; then
|
||||
echo allow-loopback-pinentry >> "$gpg_path/gpg-agent.conf"
|
||||
$gpg_connect --homedir $gpg_path reloadagent /bye
|
||||
fi
|
||||
else
|
||||
echo allow-loopback-pinentry > "$gpg_path/gpg-agent.conf"
|
||||
$gpg_connect --homedir $gpg_path reloadagent /bye
|
||||
fi
|
||||
$gpg_bin --homedir=$gpg_path -o /dev/null -u "${OSTREE_GPGID}" --pinentry=loopback --passphrase ${OSTREE_GPG_PASSPHRASE} -s /dev/null
|
||||
fi
|
||||
echo "exec $gpg_bin \$exarg \$@" >> ${WORKDIR}/gpg
|
||||
chmod 700 ${WORKDIR}/gpg
|
||||
fi
|
||||
if [ -n "${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'Y', '', d)}" ]; then
|
||||
PATH="${WORKDIR}:$PATH" ostree --repo=${OSTREE_REPO_TEMP} commit \
|
||||
--tree=dir=${OSTREE_ROOTFS} \
|
||||
--selinux-policy ${OSTREE_ROOTFS} \
|
||||
--skip-if-unchanged \
|
||||
--gpg-sign="${OSTREE_GPGID}" \
|
||||
--gpg-homedir=$gpg_path \
|
||||
--branch=${_image_basename} \
|
||||
--timestamp="${_timestamp}" \
|
||||
--subject="Commit-id: ${_image_basename}-${MACHINE}-${DATETIME}"
|
||||
else
|
||||
PATH="${WORKDIR}:$PATH" ostree --repo=${OSTREE_REPO_TEMP} commit \
|
||||
--tree=dir=${OSTREE_ROOTFS} \
|
||||
--skip-if-unchanged \
|
||||
--gpg-sign="${OSTREE_GPGID}" \
|
||||
--gpg-homedir=$gpg_path \
|
||||
--branch=${_image_basename} \
|
||||
--timestamp="${_timestamp}" \
|
||||
--subject="Commit-id: ${_image_basename}-${MACHINE}-${DATETIME}"
|
||||
fi
|
||||
# Pull new commmit into old repo
|
||||
flock ${OSTREE_REPO}.lock ostree --repo=${OSTREE_REPO} pull-local ${OSTREE_REPO_TEMP} ${_image_basename}
|
||||
|
||||
gpgconf=$(dirname $gpg_bin)/gpgconf
|
||||
if [ ! -f $gpgconf ] ; then
|
||||
bb.fatal "ERROR Could not find $gpgconf"
|
||||
fi
|
||||
GNUPGHOME="$gpg_path" flock ${OSTREE_REPO}.lock $gpgconf --kill gpg-agent
|
||||
fi
|
||||
}
|
||||
|
||||
IMAGE_CMD:ostree () {
|
||||
gpg_path="${GPG_PATH}"
|
||||
if [ -z "$gpg_path" ] ; then
|
||||
gpg_path="${TMPDIR}/.gnupg"
|
||||
fi
|
||||
gpg_bin="${GPG_BIN}"
|
||||
if [ -z "$gpg_bin" ] ; then
|
||||
gpg_bin=`which gpg`
|
||||
fi
|
||||
if [ "${gpg_bin#/}" = "$gpg_bin" ] ; then
|
||||
bb.fatal "The GPG_BIN variable must be an absolute path to the gpg binary"
|
||||
fi
|
||||
|
||||
if [ -z "$OSTREE_REPO" ]; then
|
||||
bbfatal "OSTREE_REPO should be set in your local.conf"
|
||||
fi
|
||||
|
||||
if [ -z "$OSTREE_BRANCHNAME" ]; then
|
||||
bbfatal "OSTREE_BRANCHNAME should be set in your local.conf"
|
||||
fi
|
||||
|
||||
OSTREE_REPO_TEMP="${WORKDIR}/ostree_repo.temp.$$"
|
||||
OSTREE_ROOTFS=`mktemp -du ${WORKDIR}/ostree-root-XXXXX`
|
||||
cp -a ${IMAGE_ROOTFS} ${OSTREE_ROOTFS}
|
||||
if [ "${@oe.types.boolean(d.getVar('IS_FMU_ENABLED'))}" = "True" ]; then
|
||||
rm -rf ${OSTREE_ROOTFS}${APP_DIRECTORY}/*
|
||||
fi
|
||||
chmod a+rx ${OSTREE_ROOTFS}
|
||||
sync
|
||||
|
||||
cd ${OSTREE_ROOTFS}
|
||||
|
||||
# Create sysroot directory to which physical sysroot will be mounted
|
||||
mkdir sysroot
|
||||
ln -sf sysroot/ostree ostree
|
||||
|
||||
rm -rf tmp/*
|
||||
ln -sf sysroot/tmp tmp
|
||||
|
||||
mkdir -p usr/rootdirs
|
||||
|
||||
mv etc usr/
|
||||
# Implement UsrMove
|
||||
dirs="bin sbin lib lib64"
|
||||
|
||||
for dir in ${dirs} ; do
|
||||
if [ -d ${dir} ] && [ ! -L ${dir} ] ; then
|
||||
mv ${dir} usr/rootdirs/
|
||||
rm -rf ${dir}
|
||||
ln -sf usr/rootdirs/${dir} ${dir}
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$SYSTEMD_USED" ]; then
|
||||
mkdir -p usr/etc/tmpfiles.d
|
||||
tmpfiles_conf=usr/etc/tmpfiles.d/00ostree-tmpfiles.conf
|
||||
echo "d /var/rootdirs 0755 root root -" >>${tmpfiles_conf}
|
||||
# disable the annoying logs on the console
|
||||
echo "w /proc/sys/kernel/printk - - - - 3" >> ${tmpfiles_conf}
|
||||
else
|
||||
mkdir -p usr/etc/init.d
|
||||
tmpfiles_conf=usr/etc/init.d/tmpfiles.sh
|
||||
echo '#!/bin/sh' > ${tmpfiles_conf}
|
||||
echo "mkdir -p /var/rootdirs; chmod 755 /var/rootdirs" >> ${tmpfiles_conf}
|
||||
|
||||
ln -s ../init.d/tmpfiles.sh usr/etc/rcS.d/S20tmpfiles.sh
|
||||
fi
|
||||
|
||||
# Preserve data in /home to be later copied to /var/home by
|
||||
# sysroot generating procedure
|
||||
mkdir -p usr/homedirs
|
||||
if [ -d "home" ] && [ ! -L "home" ]; then
|
||||
mv home usr/homedirs/home
|
||||
mkdir var/home
|
||||
ln -sf var/home home
|
||||
echo "d /var/home 0755 root root -" >>${tmpfiles_conf}
|
||||
fi
|
||||
|
||||
echo "d /var/rootdirs/opt 0755 root root -" >>${tmpfiles_conf}
|
||||
if [ -d opt ]; then
|
||||
mkdir -p usr/rootdirs/opt
|
||||
for dir in `ls opt`; do
|
||||
mv opt/$dir usr/rootdirs/opt/
|
||||
echo "L /opt/$dir - - - - /usr/rootdirs/opt/$dir" >>${tmpfiles_conf}
|
||||
done
|
||||
fi
|
||||
rm -rf opt
|
||||
ln -sf var/rootdirs/opt opt
|
||||
|
||||
if [ -d var/lib/rpm ]; then
|
||||
mkdir -p usr/rootdirs/var/lib/
|
||||
mv var/lib/rpm usr/rootdirs/var/lib/
|
||||
echo "L /var/lib/rpm - - - - /usr/rootdirs/var/lib/rpm" >>${tmpfiles_conf}
|
||||
fi
|
||||
if [ -d var/lib/dnf ]; then
|
||||
mkdir -p usr/rootdirs/var/lib/
|
||||
mv var/lib/dnf usr/rootdirs/var/lib/
|
||||
echo "L /var/lib/dnf - - - - /usr/rootdirs/var/lib/dnf " >>${tmpfiles_conf}
|
||||
fi
|
||||
|
||||
# Move persistent directories to /var
|
||||
dirs="mnt media srv"
|
||||
|
||||
for dir in ${dirs}; do
|
||||
if [ -d ${dir} ] && [ ! -L ${dir} ]; then
|
||||
if [ "$(ls -A $dir)" ]; then
|
||||
bbwarn "Data in /$dir directory is not preserved by OSTree. Consider moving it under /usr"
|
||||
fi
|
||||
|
||||
if [ -n "$SYSTEMD_USED" ]; then
|
||||
echo "d /var/rootdirs/${dir} 0755 root root -" >>${tmpfiles_conf}
|
||||
else
|
||||
echo "mkdir -p /var/rootdirs/${dir}; chown 755 /var/rootdirs/${dir}" >>${tmpfiles_conf}
|
||||
fi
|
||||
rm -rf ${dir}
|
||||
ln -sf var/rootdirs/${dir} ${dir}
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -d root ] && [ ! -L root ]; then
|
||||
if [ "$(ls -A root)" ]; then
|
||||
bberror "Data in /root directory is not preserved by OSTree."
|
||||
fi
|
||||
|
||||
if [ -n "$SYSTEMD_USED" ]; then
|
||||
echo "d /var/rootdirs/root 0755 root root -" >>${tmpfiles_conf}
|
||||
else
|
||||
echo "mkdir -p /var/rootdirs/root; chown 755 /var/rootdirs/root" >>${tmpfiles_conf}
|
||||
fi
|
||||
|
||||
rm -rf root
|
||||
ln -sf var/rootdirs/root root
|
||||
fi
|
||||
|
||||
# deploy SOTA credentials
|
||||
if [ -n "${SOTA_AUTOPROVISION_CREDENTIALS}" ]; then
|
||||
EXPDATE=`openssl pkcs12 -in ${SOTA_AUTOPROVISION_CREDENTIALS} -password "pass:" -nodes 2>/dev/null | openssl x509 -noout -enddate | cut -f2 -d "="`
|
||||
|
||||
if [ `date +%s` -ge `date -d "${EXPDATE}" +%s` ]; then
|
||||
bberror "Certificate ${SOTA_AUTOPROVISION_CREDENTIALS} has expired on ${EXPDATE}"
|
||||
fi
|
||||
|
||||
mkdir -p var/sota
|
||||
cp ${SOTA_AUTOPROVISION_CREDENTIALS} var/sota/sota_provisioning_credentials.p12
|
||||
if [ -n "${SOTA_AUTOPROVISION_URL_FILE}" ]; then
|
||||
export SOTA_AUTOPROVISION_URL=`cat ${SOTA_AUTOPROVISION_URL_FILE}`
|
||||
fi
|
||||
echo "SOTA_GATEWAY_URI=${SOTA_AUTOPROVISION_URL}" > var/sota/sota_provisioning_url.env
|
||||
fi
|
||||
|
||||
|
||||
# Creating boot directories is required for "ostree admin deploy"
|
||||
|
||||
mkdir -p boot/loader.0
|
||||
mkdir -p boot/loader.1
|
||||
ln -sf boot/loader.0 boot/loader
|
||||
|
||||
checksum=`sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " "`
|
||||
|
||||
# cp ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} boot/vmlinuz-${checksum}
|
||||
# cp ${DEPLOY_DIR_IMAGE}/${OSTREE_INITRAMFS_IMAGE}-${MACHINE}${RAMDISK_EXT} boot/initramfs-${checksum}
|
||||
|
||||
#deploy the device tree file
|
||||
mkdir -p usr/lib/ostree-boot
|
||||
cp ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} usr/lib/ostree-boot/vmlinuz-${checksum}
|
||||
cp ${DEPLOY_DIR_IMAGE}/${OSTREE_INITRAMFS_IMAGE}-${MACHINE}${RAMDISK_EXT} usr/lib/ostree-boot/initramfs-${checksum}
|
||||
if [ -n "${@bb.utils.contains('DISTRO_FEATURES', 'efi-secure-boot', 'Y', '', d)}" ]; then
|
||||
if [ -f ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL}.p7b ] ; then
|
||||
cp ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL}.p7b usr/lib/ostree-boot/vmlinuz.p7b
|
||||
cp ${DEPLOY_DIR_IMAGE}/${OSTREE_INITRAMFS_IMAGE}-${MACHINE}${RAMDISK_EXT}.p7b usr/lib/ostree-boot/initramfs.p7b
|
||||
fi
|
||||
if [ -f ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL}.sig ] ; then
|
||||
cp ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL}.sig usr/lib/ostree-boot/vmlinuz.sig
|
||||
cp ${DEPLOY_DIR_IMAGE}/${OSTREE_INITRAMFS_IMAGE}-${MACHINE}${RAMDISK_EXT}.sig usr/lib/ostree-boot/initramfs.sig
|
||||
fi
|
||||
fi
|
||||
if [ -d boot/efi ]; then
|
||||
cp -a boot/efi usr/lib/ostree-boot/
|
||||
fi
|
||||
|
||||
if [ -f ${DEPLOY_DIR_IMAGE}/uEnv.txt ]; then
|
||||
cp ${DEPLOY_DIR_IMAGE}/uEnv.txt usr/lib/ostree-boot/
|
||||
fi
|
||||
|
||||
if [ -f ${DEPLOY_DIR_IMAGE}/boot.scr ]; then
|
||||
cp ${DEPLOY_DIR_IMAGE}/boot.scr usr/lib/ostree-boot/boot.scr
|
||||
# Modify the boot.scr
|
||||
if [ -e usr/lib/ostree-boot/boot.scr ] ; then
|
||||
tail -c+73 usr/lib/ostree-boot/boot.scr > usr/lib/ostree-boot/boot.scr.raw
|
||||
if [ -e /bin/perl ] ; then
|
||||
/bin/perl -p -i -e "s#^( *setenv BRANCH) .*#\$1 ${OSTREE_BRANCHNAME}# if (\$_ !~ /oBRANCH/) " usr/lib/ostree-boot/boot.scr.raw
|
||||
else
|
||||
/usr/bin/perl -p -i -e "s#^( *setenv BRANCH) .*#\$1 ${OSTREE_BRANCHNAME}# if (\$_ !~ /oBRANCH/) " usr/lib/ostree-boot/boot.scr.raw
|
||||
fi
|
||||
mkimage -A arm -T script -O linux -d usr/lib/ostree-boot/boot.scr.raw usr/lib/ostree-boot/boot.scr
|
||||
if [ -f $DEPLOY_DIR_IMAGE/boot.itb ]; then
|
||||
mkimage -A arm -T script -O linux -f auto -C none -d usr/lib/ostree-boot/boot.scr.raw usr/lib/ostree-boot/boot.itb
|
||||
fi
|
||||
rm -f usr/lib/ostree-boot/boot.scr.raw
|
||||
fi
|
||||
mkdir -p boot
|
||||
cp usr/lib/ostree-boot/boot.scr boot/
|
||||
fi
|
||||
|
||||
for i in ${KERNEL_DEVICETREE}; do
|
||||
if [ -f ${DEPLOY_DIR_IMAGE}/$(basename $i) ]; then
|
||||
if [ "$(dirname $i)" = "overlays" ] ; then
|
||||
[ ! -d usr/lib/ostree-boot/overlays ] && mkdir -p usr/lib/ostree-boot/overlays
|
||||
cp ${DEPLOY_DIR_IMAGE}/$(basename $i) usr/lib/ostree-boot/overlays
|
||||
else
|
||||
cp ${DEPLOY_DIR_IMAGE}/$(basename $i) usr/lib/ostree-boot/
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
#deploy the GPG pub key
|
||||
if [ -n "${OSTREE_GPGID}" ]; then
|
||||
if [ -f $gpg_path/pubring.gpg ]; then
|
||||
cp $gpg_path/pubring.gpg usr/share/ostree/trusted.gpg.d/pubring.gpg
|
||||
fi
|
||||
if [ -f $gpg_path/pubring.kbx ]; then
|
||||
cp $gpg_path/pubring.kbx usr/share/ostree/trusted.gpg.d/pubkbx.gpg
|
||||
fi
|
||||
fi
|
||||
|
||||
# cp ${DEPLOY_DIR_IMAGE}/${MACHINE}.dtb usr/lib/ostree-boot
|
||||
touch usr/lib/ostree-boot/.ostree-bootcsumdir-source
|
||||
|
||||
# Copy image manifest
|
||||
cat ${IMAGE_MANIFEST} | cut -d " " -f1,3 > usr/package.manifest
|
||||
|
||||
# add the required mount
|
||||
echo "LABEL=otaboot /boot auto defaults 0 0" >>usr/etc/fstab
|
||||
if [ -n "${GRUB_USED}" ]; then
|
||||
echo "LABEL=otaefi /boot/efi auto ro 0 0" >>usr/etc/fstab
|
||||
fi
|
||||
echo "LABEL=fluxdata /var auto defaults 0 0" >>usr/etc/fstab
|
||||
if [ "${@oe.types.boolean(d.getVar('IS_FMU_ENABLED'))}" = "True" ]; then
|
||||
echo "LABEL=apps /apps auto defaults 0 0" >>usr/etc/fstab
|
||||
fi
|
||||
|
||||
# Install a trap handler to remove the temporary ostree_repo
|
||||
trap "rm -rf ${OSTREE_REPO_TEMP}" EXIT
|
||||
cd ${WORKDIR}
|
||||
|
||||
rm -rf ${OSTREE_REPO_TEMP}
|
||||
ostree --repo=${OSTREE_REPO_TEMP} init --mode=bare
|
||||
if [ ! -d ${OSTREE_REPO} ]; then
|
||||
flock ${OSTREE_REPO}.lock ostree --repo=${OSTREE_REPO} init --mode=archive-z2
|
||||
else
|
||||
ostree pull-local --repo=${OSTREE_REPO_TEMP} ${OSTREE_REPO} ${OSTREE_BRANCHNAME} || (exit 0)
|
||||
fi
|
||||
|
||||
# Preserve OSTREE_BRANCHNAME for future information
|
||||
mkdir -p ${OSTREE_ROOTFS}/usr/share/sota/
|
||||
|
||||
if [ -n "${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'Y', '', d)}" ]; then
|
||||
selinux_set_labels
|
||||
fi
|
||||
|
||||
timestamp=`date +%s`
|
||||
if [ "${OSTREE_COMMIT_DEV}" = "1" ] ; then
|
||||
echo -n "${OSTREE_BRANCHNAME}-dev" > ${OSTREE_ROOTFS}/usr/share/sota/branchname
|
||||
create_tarball_and_ostreecommit "${OSTREE_BRANCHNAME}-dev" "$timestamp"
|
||||
fi
|
||||
|
||||
if [ "${OSTREE_NORPMDATA}" = 1 ] || [ ! -e ${OSTREE_ROOTFS}/usr/bin/rpm ] ; then
|
||||
# Clean up package management data for factory deploy
|
||||
rm -rf ${OSTREE_ROOTFS}/usr/rootdirs/var/lib/rpm/*
|
||||
rm -rf ${OSTREE_ROOTFS}/usr/rootdirs/var/lib/dnf/*
|
||||
fi
|
||||
|
||||
# Make factory older than development which is helpful for ostree admin upgrade
|
||||
timestamp=`expr $timestamp - 1`
|
||||
echo -n "${OSTREE_BRANCHNAME}" > ${OSTREE_ROOTFS}/usr/share/sota/branchname
|
||||
create_tarball_and_ostreecommit "${OSTREE_BRANCHNAME}" "$timestamp"
|
||||
|
||||
# Cleanup and remove trap handler
|
||||
rm -rf ${OSTREE_REPO_TEMP}
|
||||
trap - EXIT
|
||||
|
||||
flock ${OSTREE_REPO}.lock ostree summary -u --repo=${OSTREE_REPO}
|
||||
repo_apache_config
|
||||
|
||||
rm -rf ${OSTREE_ROOTFS}
|
||||
}
|
||||
|
||||
python __anonymous() {
|
||||
gpg_path = d.getVar('GPG_PATH', True)
|
||||
if not gpg_path:
|
||||
gpg_path = d.getVar('TMPDIR', True) + '/.gnupg'
|
||||
if len(gpg_path) > 80:
|
||||
msg = "The default GPG_PATH '%s'\n" % gpg_path
|
||||
msg += "of %d characters is too long.\n" % len(gpg_path)
|
||||
msg += "Due to GPG homedir path length limit, please set GPG_PATH shorter than 80 characters"
|
||||
raise bb.parse.SkipRecipe(msg)
|
||||
}
|
||||
|
||||
def get_fluxdata_size(d):
|
||||
import subprocess
|
||||
|
||||
overhead_factor = float(d.getVar("IMAGE_OVERHEAD_FACTOR"))
|
||||
fluxdata_dir = d.expand("${WORKDIR}/rootfs_ota_var")
|
||||
output = subprocess.check_output(["du", "-ks", fluxdata_dir])
|
||||
size_kb = int(output.split()[0])
|
||||
base_size = size_kb * overhead_factor
|
||||
bb.debug(1, '%f = %d * %f' % (base_size, size_kb, overhead_factor))
|
||||
|
||||
if base_size != int(base_size):
|
||||
base_size = int(base_size + 1)
|
||||
else:
|
||||
base_size = int(base_size)
|
||||
|
||||
# Extra 512MB for /var
|
||||
base_size += 512*1024
|
||||
bb.debug(1, 'returning %d' % (base_size))
|
||||
return base_size
|
||||
|
||||
def get_apps_size(d):
|
||||
import subprocess
|
||||
|
||||
overhead_factor = float(d.getVar("IMAGE_OVERHEAD_FACTOR"))
|
||||
fluxdata_dir = d.expand("${WORKDIR}/rootfs_ota_apps")
|
||||
output = subprocess.check_output(["du", "-ks", fluxdata_dir])
|
||||
size_kb = int(output.split()[0])
|
||||
base_size = size_kb * overhead_factor
|
||||
bb.debug(1, '%f = %d * %f' % (base_size, size_kb, overhead_factor))
|
||||
|
||||
if base_size != int(base_size):
|
||||
base_size = int(base_size + 1)
|
||||
else:
|
||||
base_size = int(base_size)
|
||||
|
||||
# Extra 512MB for /apps
|
||||
base_size += 512*1024
|
||||
bb.debug(1, 'returning %d' % (base_size))
|
||||
return base_size
|
||||
|
||||
python do_write_wks_template:prepend() {
|
||||
fluxdata_dir = d.expand("${WORKDIR}/rootfs_ota_var")
|
||||
if os.path.exists(fluxdata_dir):
|
||||
root_size = d.getVar("OSTREE_WKS_ROOT_SIZE") or None
|
||||
if root_size is None:
|
||||
# KB --> MB
|
||||
_size = get_rootfs_size(d)//1024 + 1
|
||||
root_size = "--size=%dM --overhead-factor 1" % _size
|
||||
d.setVar('OSTREE_WKS_ROOT_SIZE', root_size)
|
||||
|
||||
if oe.types.boolean(d.getVar('IS_FMU_ENABLED')):
|
||||
apps_size = d.getVar("OSTREE_WKS_APPS_SIZE") or None
|
||||
if apps_size is None:
|
||||
_size = get_apps_size(d)
|
||||
apps_size = "--size=%dM --overhead-factor 1" % _size
|
||||
d.setVar('OSTREE_WKS_APPS_SIZE', apps_size)
|
||||
|
||||
fluxdata_size = d.getVar("OSTREE_WKS_FLUX_SIZE") or None
|
||||
if fluxdata_size is None:
|
||||
# KB --> MB
|
||||
_size = get_fluxdata_size(d)//1024 + 1
|
||||
fluxdata_size = "--size=%dM --overhead-factor 1" % _size
|
||||
d.setVar('OSTREE_WKS_FLUX_SIZE', fluxdata_size)
|
||||
}
|
||||
|
||||
# Need add do_write_wks_template firstly, otherwise
|
||||
# do_write_wks_template:prepend doesn't work
|
||||
python () {
|
||||
if d.getVar('USING_WIC'):
|
||||
wks_file_u = d.getVar('WKS_FULL_PATH', False)
|
||||
wks_file = d.expand(wks_file_u)
|
||||
base, ext = os.path.splitext(wks_file)
|
||||
if ext == '.in' and os.path.exists(wks_file):
|
||||
bb.build.addtask('do_write_wks_template', 'do_image_wic', 'do_image_otaimg', d)
|
||||
}
|
||||
Executable
+236
@@ -0,0 +1,236 @@
|
||||
# Image to use with u-boot as BIOS and OSTree deployment system
|
||||
|
||||
#inherit image_types
|
||||
|
||||
# Boot filesystem size in MiB
|
||||
# OSTree updates may require some space on boot file system for
|
||||
# boot scripts, kernel and initramfs images
|
||||
#
|
||||
|
||||
do_image_otaimg[depends] += "e2fsprogs-native:do_populate_sysroot \
|
||||
${@'grub:do_populate_sysroot' if d.getVar('OSTREE_BOOTLOADER_INCLUDE', True) == 'grub' else ''} \
|
||||
${@'virtual/bootloader:do_deploy' if d.getVar('OSTREE_BOOTLOADER_INCLUDE', True) == 'u-boot' else ''}"
|
||||
|
||||
export FLUXDATA = "${@bb.utils.contains('DISTRO_FEATURES', 'luks', 'luks_fluxdata', 'fluxdata', d)}"
|
||||
export ROOT_LABEL = "${@bb.utils.contains('DISTRO_FEATURES', 'luks', 'luks_otaroot', 'otaroot', d)}"
|
||||
|
||||
calculate_size () {
|
||||
BASE=$1
|
||||
SCALE=$2
|
||||
MIN=$3
|
||||
MAX=$4
|
||||
EXTRA=$5
|
||||
ALIGN=$6
|
||||
|
||||
SIZE=`echo "$BASE * $SCALE" | bc -l`
|
||||
REM=`echo $SIZE | cut -d "." -f 2`
|
||||
SIZE=`echo $SIZE | cut -d "." -f 1`
|
||||
|
||||
if [ -n "$REM" -o ! "$REM" -eq 0 ]; then
|
||||
SIZE=`expr $SIZE \+ 1`
|
||||
fi
|
||||
|
||||
if [ "$SIZE" -lt "$MIN" ]; then
|
||||
$SIZE=$MIN
|
||||
fi
|
||||
|
||||
SIZE=`expr $SIZE \+ $EXTRA`
|
||||
SIZE=`expr $SIZE \+ $ALIGN \- 1`
|
||||
SIZE=`expr $SIZE \- $SIZE \% $ALIGN`
|
||||
|
||||
if [ -n "$MAX" ]; then
|
||||
if [ "$SIZE" -gt "$MAX" ]; then
|
||||
return -1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "${SIZE}"
|
||||
}
|
||||
|
||||
export OSTREE_OSNAME
|
||||
export OSTREE_BRANCHNAME
|
||||
export OSTREE_REPO
|
||||
export OSTREE_BOOTLOADER
|
||||
export WKS_FULL_PATH
|
||||
|
||||
IMAGE_CMD:otaimg () {
|
||||
if ${@bb.utils.contains('IMAGE_FSTYPES', 'otaimg', 'true', 'false', d)}; then
|
||||
if [ -z "$OSTREE_REPO" ]; then
|
||||
bbfatal "OSTREE_REPO should be set in your local.conf"
|
||||
fi
|
||||
|
||||
if [ -z "$OSTREE_OSNAME" ]; then
|
||||
bbfatal "OSTREE_OSNAME should be set in your local.conf"
|
||||
fi
|
||||
|
||||
if [ -z "$OSTREE_BRANCHNAME" ]; then
|
||||
bbfatal "OSTREE_BRANCHNAME should be set in your local.conf"
|
||||
fi
|
||||
|
||||
PHYS_SYSROOT=`mktemp -d ${WORKDIR}/ota-sysroot-XXXXX`
|
||||
|
||||
ostree admin --sysroot=${PHYS_SYSROOT} init-fs ${PHYS_SYSROOT}
|
||||
ostree admin --sysroot=${PHYS_SYSROOT} os-init ${OSTREE_OSNAME}
|
||||
ostree config --repo=${PHYS_SYSROOT}/ostree/repo set core.add-remotes-config-dir false
|
||||
if [ "${OSTREE_SKIP_BOOT_DIFF}" != "0" ] ; then
|
||||
ostree config --repo=${PHYS_SYSROOT}/ostree/repo set upgrade.skip-boot-diff ${OSTREE_SKIP_BOOT_DIFF}
|
||||
fi
|
||||
if [ "${OSTREE_USE_AB}" != 1 ] ; then
|
||||
ostree config --repo=${PHYS_SYSROOT}/ostree/repo set upgrade.no-ab 1
|
||||
fi
|
||||
ostree config --repo=${PHYS_SYSROOT}/ostree/repo set upgrade.branch ${OSTREE_BRANCHNAME}
|
||||
if [ -n "${OSTREE_REMOTE_URL}" ] ; then
|
||||
do_gpg=""
|
||||
if [ "${OSTREE_GPGID}" = "" ] ; then
|
||||
do_gpg=--no-gpg-verify
|
||||
fi
|
||||
if [ "${@oe.types.boolean(d.getVar('IS_FMU_ENABLED'))}" = "True" ] &&
|
||||
[ "${@oe.types.boolean(d.getVar('FMU_OSTREE_GPG_VERIFY'))}" = "False" ]; then
|
||||
do_gpg=--no-gpg-verify
|
||||
fi
|
||||
ostree config --repo=${PHYS_SYSROOT}/ostree/repo set upgrade.remote ${OSTREE_REMOTE_NAME}
|
||||
ostree remote --repo=${PHYS_SYSROOT}/ostree/repo add ${do_gpg} ${OSTREE_REMOTE_NAME} ${OSTREE_REMOTE_URL}
|
||||
fi
|
||||
|
||||
|
||||
mkdir -p ${PHYS_SYSROOT}/boot/loader.0
|
||||
ln -s loader.0 ${PHYS_SYSROOT}/boot/loader
|
||||
|
||||
if [ "${OSTREE_BOOTLOADER}" = "grub" ]; then
|
||||
mkdir -p ${PHYS_SYSROOT}/boot/efi/EFI/BOOT
|
||||
if [ -n "${@bb.utils.contains('DISTRO_FEATURES', 'efi-secure-boot', 'Y', '', d)}" ]; then
|
||||
cp ${DEPLOY_DIR_IMAGE}/grubx64.efi ${PHYS_SYSROOT}/boot/efi/EFI/BOOT/bootx64.efi
|
||||
if [ -f ${DEPLOY_DIR_IMAGE}/grub.cfg.p7b ] ; then
|
||||
cp ${DEPLOY_DIR_IMAGE}/grub.cfg.p7b ${PHYS_SYSROOT}/boot/efi/EFI/BOOT/
|
||||
fi
|
||||
if [ -f ${DEPLOY_DIR_IMAGE}/grub.cfg.sig ] ; then
|
||||
cp ${DEPLOY_DIR_IMAGE}/grub.cfg.sig ${PHYS_SYSROOT}/boot/efi/EFI/BOOT/
|
||||
fi
|
||||
else
|
||||
cp ${DEPLOY_DIR_IMAGE}/grub-efi-bootx64.efi ${PHYS_SYSROOT}/boot/efi/EFI/BOOT/bootx64.efi
|
||||
fi
|
||||
cp ${DEPLOY_DIR_IMAGE}/grub.cfg ${PHYS_SYSROOT}/boot/efi/EFI/BOOT/
|
||||
#create the OS vendor fallback boot dir
|
||||
mkdir ${PHYS_SYSROOT}/boot/efi/EFI/${DISTRO}
|
||||
cp ${DEPLOY_DIR_IMAGE}/grub.cfg ${PHYS_SYSROOT}/boot/efi/EFI/${DISTRO}
|
||||
|
||||
# Create an empty GRUB Environment Block
|
||||
echo "# GRUB Environment Block" > ${PHYS_SYSROOT}/boot/efi/EFI/BOOT/boot.env
|
||||
if [ "${OSTREE_USE_AB}" != "1" ] ; then
|
||||
printf "ab=0\n" >> ${PHYS_SYSROOT}/boot/efi/EFI/BOOT/boot.env
|
||||
else
|
||||
echo -n "#####" >> ${PHYS_SYSROOT}/boot/efi/EFI/BOOT/boot.env
|
||||
fi
|
||||
printf "boot_tried_count=0\n" >> ${PHYS_SYSROOT}/boot/efi/EFI/BOOT/boot.env
|
||||
echo -n "###############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################" >> ${PHYS_SYSROOT}/boot/efi/EFI/BOOT/boot.env
|
||||
elif [ "${OSTREE_BOOTLOADER}" = "u-boot" ]; then
|
||||
touch ${PHYS_SYSROOT}/boot/loader/uEnv.txt
|
||||
else
|
||||
bberror "Invalid bootloader: ${OSTREE_BOOTLOADER}"
|
||||
fi;
|
||||
|
||||
ostree --repo=${PHYS_SYSROOT}/ostree/repo pull-local --remote=${OSTREE_OSNAME} ${OSTREE_REPO} ${OSTREE_BRANCHNAME}
|
||||
export OSTREE_BOOT_PARTITION="/boot"
|
||||
kargs_list=""
|
||||
for arg in ${OSTREE_KERNEL_ARGS}; do
|
||||
kargs_list="${kargs_list} --karg-append=$arg"
|
||||
done
|
||||
|
||||
ostree admin --sysroot=${PHYS_SYSROOT} deploy ${kargs_list} --os=${OSTREE_OSNAME} ${OSTREE_BRANCHNAME}
|
||||
if [ "${OSTREE_USE_AB}" != "1" ] ; then
|
||||
# Provide a rollback deployment when using a single disk
|
||||
ostree admin --sysroot=${PHYS_SYSROOT} deploy --os=${OSTREE_OSNAME} ${OSTREE_BRANCHNAME}
|
||||
fi
|
||||
|
||||
if [ -d ${PHYS_SYSROOT}/ostree/1/boot/efi ] ; then
|
||||
cp -a ${PHYS_SYSROOT}/ostree/1/boot/efi ${PHYS_SYSROOT}/boot
|
||||
fi
|
||||
|
||||
if [ "${OSTREE_BOOTLOADER}" = "u-boot" ]; then
|
||||
rm -rf ${WORKDIR}/rootfs_ota_uboot
|
||||
mkdir -p ${WORKDIR}/rootfs_ota_uboot
|
||||
|
||||
bootdir=$(grep ^bootdir= ${PHYS_SYSROOT}/boot/loader/uEnv.txt || echo "")
|
||||
bootdir=${bootdir#bootdir=}
|
||||
if [ "$bootdir" != "" ] && [ -e "${PHYS_SYSROOT}/boot$bootdir" ] ; then
|
||||
cp -r ${PHYS_SYSROOT}/boot$bootdir/* ${WORKDIR}/rootfs_ota_uboot
|
||||
fi
|
||||
printf "123A" > ${WORKDIR}/rootfs_ota_uboot/boot_ab_flag
|
||||
# The first 0 is the boot count, the second zero is the boot entry default
|
||||
printf '00WR' > ${WORKDIR}/rootfs_ota_uboot/boot_cnt
|
||||
if [ "${OSTREE_USE_AB}" != "1" ] ; then
|
||||
printf '1' > ${WORKDIR}/rootfs_ota_uboot/no_ab
|
||||
fi
|
||||
|
||||
if [ "${OSTREE_COPY_IMAGE_BOOT_FILES}" = "1" ] ; then
|
||||
# Copy IMAGE_BOOT_FILES
|
||||
set -f
|
||||
bfiles="${IMAGE_BOOT_FILES}"
|
||||
for f in $bfiles; do
|
||||
set +f
|
||||
argFROM=$(echo "$f" |sed -e 's#;.*##')
|
||||
argTO=$(echo "$f" |sed -e 's#.*;##')
|
||||
if [ "$argFROM" != "$argTO" ] ; then
|
||||
if [ ! -e ${WORKDIR}/rootfs_ota_uboot/$argTO ] ; then
|
||||
d=$(dirname ${WORKDIR}/rootfs_ota_uboot/$argTO)
|
||||
[ ! -d $d ] && mkdir $d
|
||||
argFROM_head=`echo $argFROM | cut -b 1`
|
||||
if [ "$argFROM_head" = "/" ]; then
|
||||
cp $argFROM ${WORKDIR}/rootfs_ota_uboot/$argTO
|
||||
else
|
||||
cp ${DEPLOY_DIR_IMAGE}/$argFROM ${WORKDIR}/rootfs_ota_uboot/$argTO
|
||||
fi
|
||||
fi
|
||||
else
|
||||
cp ${DEPLOY_DIR_IMAGE}/$f ${WORKDIR}/rootfs_ota_uboot
|
||||
fi
|
||||
done
|
||||
set +f
|
||||
fi
|
||||
# Modify the boot.scr
|
||||
if [ -e ${WORKDIR}/rootfs_ota_uboot/boot.scr ] ; then
|
||||
tail -c+73 ${WORKDIR}/rootfs_ota_uboot/boot.scr > ${WORKDIR}/rootfs_ota_uboot/boot.scr.raw
|
||||
if [ -e /bin/perl ] ; then
|
||||
/bin/perl -p -i -e "s#^( *setenv BRANCH) .*#\$1 ${OSTREE_BRANCHNAME}# if (\$_ !~ /oBRANCH/) " ${WORKDIR}/rootfs_ota_uboot/boot.scr.raw
|
||||
else
|
||||
/usr/bin/perl -p -i -e "s#^( *setenv BRANCH) .*#\$1 ${OSTREE_BRANCHNAME}# if (\$_ !~ /oBRANCH/) " ${WORKDIR}/rootfs_ota_uboot/boot.scr.raw
|
||||
fi
|
||||
mkimage -A arm -T script -O linux -d ${WORKDIR}/rootfs_ota_uboot/boot.scr.raw ${WORKDIR}/rootfs_ota_uboot/boot.scr
|
||||
if [ -e $WORKDIR/rootfs_ota_uboot/boot.itb ] ; then
|
||||
mkimage -A arm -T script -O linux -f auto -C none -d $WORKDIR/rootfs_ota_uboot/boot.scr.raw $WORKDIR/rootfs_ota_uboot/boot.itb
|
||||
fi
|
||||
rm -f ${WORKDIR}/rootfs_ota_uboot/boot.scr.raw
|
||||
fi
|
||||
fi
|
||||
|
||||
#create an image with the free space equal the rootfs size
|
||||
wic_deployed_var_path=$(find ${PHYS_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/deploy/ -maxdepth 2 -name "var"|head -1)
|
||||
rm -rf ${WORKDIR}/rootfs_ota_var
|
||||
cp ${wic_deployed_var_path} -ar ${WORKDIR}/rootfs_ota_var
|
||||
|
||||
# rootfs data for EFI partition
|
||||
if [ -d ${PHYS_SYSROOT}/boot/efi ]; then
|
||||
rm -rf ${WORKDIR}/rootfs_ota_efi
|
||||
mv ${PHYS_SYSROOT}/boot/efi ${WORKDIR}/rootfs_ota_efi
|
||||
mkdir -p ${PHYS_SYSROOT}/boot/efi
|
||||
fi
|
||||
|
||||
# boot partition
|
||||
# OSTREE needs to create symlinks to locate the real kernel image, and efi partition does not support symlinks
|
||||
|
||||
rm -rf ${WORKDIR}/rootfs_ota_boot
|
||||
mv ${PHYS_SYSROOT}/boot ${WORKDIR}/rootfs_ota_boot
|
||||
mkdir -p ${PHYS_SYSROOT}/boot
|
||||
|
||||
# rootfs partition
|
||||
rm -rf ${WORKDIR}/rootfs_ota
|
||||
mv ${PHYS_SYSROOT} ${WORKDIR}/rootfs_ota
|
||||
|
||||
if [ "${@oe.types.boolean(d.getVar('IS_FMU_ENABLED'))}" = "True" ]; then
|
||||
rm -rf ${WORKDIR}/rootfs_ota_apps
|
||||
cp ${IMAGE_ROOTFS}${APP_DIRECTORY} -ar ${WORKDIR}/rootfs_ota_apps
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
IMAGE_TYPEDEP:otaimg = "ostree"
|
||||
@@ -0,0 +1,47 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
inherit siteinfo
|
||||
|
||||
# If applicable on the architecture, this routine will rename the header and
|
||||
# add a unique identifier to the name for the ABI/bitsize that is being used.
|
||||
# A wrapper will be generated for the architecture that knows how to call
|
||||
# all of the ABI variants for that given architecture.
|
||||
#
|
||||
oe_multilib_header:prepend:class-nativesdk() {
|
||||
|
||||
case ${HOST_OS} in
|
||||
*-musl*)
|
||||
return
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
# For MIPS: "n32" is a special case, which needs to be
|
||||
# distinct from both 64-bit and 32-bit.
|
||||
case ${TARGET_ARCH} in
|
||||
mips*) case "${MIPSPKGSFX_ABI}" in
|
||||
"-n32")
|
||||
ident=n32
|
||||
;;
|
||||
*)
|
||||
ident=${SITEINFO_BITS}
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*) ident=${SITEINFO_BITS}
|
||||
esac
|
||||
for each_header in "$@" ; do
|
||||
if [ ! -f "${D}/${includedir}/$each_header" ]; then
|
||||
bberror "oe_multilib_header: Unable to find header $each_header."
|
||||
continue
|
||||
fi
|
||||
stem=$(echo $each_header | sed 's#\.h$##')
|
||||
# if mips64/n32 set ident to n32
|
||||
mv ${D}/${includedir}/$each_header ${D}/${includedir}/${stem}-${ident}.h
|
||||
|
||||
sed -e "s#ENTER_HEADER_FILENAME_HERE#${stem}#g" ${COREBASE}/scripts/multilib_header_wrapper.h > ${D}/${includedir}/$each_header
|
||||
done
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
# Class to avoid copying packages into the feed if they haven't materially changed
|
||||
#
|
||||
# Copyright (C) 2015 Intel Corporation
|
||||
# Released under the MIT license (see COPYING.MIT for details)
|
||||
#
|
||||
# This class effectively intercepts packages as they are written out by
|
||||
# do_package_write_*, causing them to be written into a different
|
||||
# directory where we can compare them to whatever older packages might
|
||||
# be in the "real" package feed directory, and avoid copying the new
|
||||
# package to the feed if it has not materially changed. The idea is to
|
||||
# avoid unnecessary churn in the packages when dependencies trigger task
|
||||
# reexecution (and thus repackaging). Enabling the class is simple:
|
||||
#
|
||||
# INHERIT += "packagefeed-stability"
|
||||
#
|
||||
# Caveats:
|
||||
# 1) Latest PR values in the build system may not match those in packages
|
||||
# seen on the target (naturally)
|
||||
# 2) If you rebuild from sstate without the existing package feed present,
|
||||
# you will lose the "state" of the package feed i.e. the preserved old
|
||||
# package versions. Not the end of the world, but would negate the
|
||||
# entire purpose of this class.
|
||||
#
|
||||
# Note that running -c cleanall on a recipe will purposely delete the old
|
||||
# package files so they will definitely be copied the next time.
|
||||
|
||||
# Skip comparing if PE, PV and PR are the same when set to 1
|
||||
PACKAGE_COMPARE_FAST ?= "0"
|
||||
|
||||
python() {
|
||||
if bb.data.inherits_class('native', d) or bb.data.inherits_class('cross', d):
|
||||
return
|
||||
# Package backend agnostic intercept
|
||||
# This assumes that the package_write task is called package_write_<pkgtype>
|
||||
# and that the directory in which packages should be written is
|
||||
# pointed to by the variable DEPLOY_DIR_<PKGTYPE>
|
||||
for pkgclass in (d.getVar('PACKAGE_CLASSES') or '').split():
|
||||
if pkgclass.startswith('package_'):
|
||||
pkgtype = pkgclass.split('_', 1)[1]
|
||||
pkgwritefunc = 'do_package_write_%s' % pkgtype
|
||||
sstate_outputdirs = d.getVarFlag(pkgwritefunc, 'sstate-outputdirs', False)
|
||||
deploydirvar = 'DEPLOY_DIR_%s' % pkgtype.upper()
|
||||
deploydirvarref = '${' + deploydirvar + '}'
|
||||
pkgcomparefunc = 'do_package_compare_%s' % pkgtype
|
||||
|
||||
if bb.data.inherits_class('image', d):
|
||||
d.appendVarFlag('do_rootfs', 'recrdeptask', ' ' + pkgcomparefunc)
|
||||
|
||||
if bb.data.inherits_class('populate_sdk_base', d):
|
||||
d.appendVarFlag('do_populate_sdk', 'recrdeptask', ' ' + pkgcomparefunc)
|
||||
|
||||
if bb.data.inherits_class('populate_sdk_ext', d):
|
||||
d.appendVarFlag('do_populate_sdk_ext', 'recrdeptask', ' ' + pkgcomparefunc)
|
||||
|
||||
if bb.data.inherits_class('nopackages', d) or d.getVarFlag(pkgwritefunc, 'noexec') or \
|
||||
not d.getVarFlag(pkgwritefunc, 'task'):
|
||||
# Packaging is disabled for this recipe, we shouldn't do anything
|
||||
continue
|
||||
|
||||
d.appendVarFlag('do_build', 'recrdeptask', ' ' + pkgcomparefunc)
|
||||
|
||||
if deploydirvarref in sstate_outputdirs:
|
||||
deplor_dir_pkgtype = d.expand(deploydirvarref + '-prediff')
|
||||
# Set intermediate output directory
|
||||
d.setVarFlag(pkgwritefunc, 'sstate-outputdirs', sstate_outputdirs.replace(deploydirvarref, deplor_dir_pkgtype))
|
||||
# Update SSTATE_ALLOW_OVERLAP_FILES to avoid shared location conflicted error
|
||||
d.appendVar('SSTATE_ALLOW_OVERLAP_FILES', ' %s' % deplor_dir_pkgtype)
|
||||
|
||||
d.setVar(pkgcomparefunc, d.getVar('do_package_compare', False))
|
||||
d.setVarFlags(pkgcomparefunc, d.getVarFlags('do_package_compare', False))
|
||||
d.appendVarFlag(pkgcomparefunc, 'depends', ' build-compare-native:do_populate_sysroot')
|
||||
# Target recipe uses gcc-cross' objdump, but nativesdk uses host's objdump
|
||||
mlprefix = d.getVar('MLPREFIX')
|
||||
if (not bb.utils.to_boolean(d.getVar('INHIBIT_DEFAULT_DEPS'))) and \
|
||||
(not bb.data.inherits_class('nativesdk', d)):
|
||||
target_arch = d.getVar('TARGET_ARCH')
|
||||
d.appendVarFlag(pkgcomparefunc, 'depends', ' %sgcc-cross-%s:do_populate_sysroot' % (mlprefix, target_arch))
|
||||
bb.build.addtask(pkgcomparefunc, 'do_build', 'do_packagedata ' + pkgwritefunc, d)
|
||||
}
|
||||
|
||||
# This isn't the real task function - it's a template that we use in the
|
||||
# anonymous python code above
|
||||
fakeroot python do_package_compare () {
|
||||
currenttask = d.getVar('BB_CURRENTTASK')
|
||||
pkgtype = currenttask.rsplit('_', 1)[1]
|
||||
package_compare_impl(pkgtype, d)
|
||||
}
|
||||
|
||||
def package_compare_impl(pkgtype, d):
|
||||
import errno
|
||||
import fnmatch
|
||||
import glob
|
||||
import subprocess
|
||||
import oe.sstatesig
|
||||
|
||||
pn = d.getVar('PN')
|
||||
deploydir = d.getVar('DEPLOY_DIR_%s' % pkgtype.upper())
|
||||
prepath = deploydir + '-prediff/'
|
||||
|
||||
pkgwritetask = 'package_write_%s' % pkgtype
|
||||
manifest, _ = oe.sstatesig.sstate_get_manifest_filename(pkgwritetask, d)
|
||||
|
||||
# Skip comparing if PE, PV and PR are the same
|
||||
skip = True
|
||||
if bb.utils.to_boolean(d.getVar('PACKAGE_COMPARE_FAST')):
|
||||
with open(manifest, 'r') as f:
|
||||
for line in f.readlines():
|
||||
bn = os.path.basename(line.strip())
|
||||
line_new = os.path.join(deploydir, bn)
|
||||
if not os.path.exists(line_new):
|
||||
skip = False
|
||||
break
|
||||
if skip and bb.utils.to_boolean(d.getVar('PACKAGE_COMPARE_FAST')):
|
||||
bb.note("Skipping package comparing since all packages' PE, PV and PR are the same")
|
||||
return
|
||||
|
||||
# Find out PKGR values are
|
||||
pkgdatadir = d.getVar('PKGDATA_DIR')
|
||||
packages = []
|
||||
try:
|
||||
with open(os.path.join(pkgdatadir, pn), 'r') as f:
|
||||
for line in f:
|
||||
if line.startswith('PACKAGES:'):
|
||||
packages = line.split(':', 1)[1].split()
|
||||
break
|
||||
except IOError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
pass
|
||||
|
||||
if not packages:
|
||||
bb.debug(2, '%s: no packages, nothing to do' % pn)
|
||||
return
|
||||
|
||||
pkgrvalues = {}
|
||||
rpkgnames = {}
|
||||
rdepends = {}
|
||||
pkgvvalues = {}
|
||||
for pkg in packages:
|
||||
with open(os.path.join(pkgdatadir, 'runtime', pkg), 'r') as f:
|
||||
for line in f:
|
||||
if line.startswith('PKGR:'):
|
||||
pkgrvalues[pkg] = line.split(':', 1)[1].strip()
|
||||
if line.startswith('PKGV:'):
|
||||
pkgvvalues[pkg] = line.split(':', 1)[1].strip()
|
||||
elif line.startswith('PKG:%s:' % pkg):
|
||||
rpkgnames[pkg] = line.split(':')[2].strip()
|
||||
elif line.startswith('RDEPENDS:%s:' % pkg):
|
||||
rdepends[pkg] = line.split(':', 1)[1].strip()
|
||||
|
||||
# Prepare a list of the runtime package names for packages that were
|
||||
# actually produced
|
||||
rpkglist = []
|
||||
for pkg, rpkg in rpkgnames.items():
|
||||
if os.path.exists(os.path.join(pkgdatadir, 'runtime', pkg + '.packaged')):
|
||||
rpkglist.append((rpkg, pkg))
|
||||
rpkglist.sort(key=lambda x: len(x[0]), reverse=True)
|
||||
|
||||
pvu = d.getVar('PV', False)
|
||||
if '$' + '{SRCPV}' in pvu:
|
||||
pvprefix = pvu.split('$' + '{SRCPV}', 1)[0]
|
||||
# Expand Var such as LINUX_VERSION
|
||||
d.setVar('PACKAGE_COMPARE_PVPREFIX', pvprefix)
|
||||
pvprefix = d.getVar('PACKAGE_COMPARE_PVPREFIX')
|
||||
else:
|
||||
pvprefix = None
|
||||
|
||||
files = []
|
||||
docopy = False
|
||||
mlprefix = d.getVar('MLPREFIX')
|
||||
pcmanifest = os.path.join(prepath, d.expand('pkg-compare-manifest-${MULTIMACH_TARGET_SYS}-${PN}'))
|
||||
pcmanifest_oldlines = []
|
||||
if os.path.exists(pcmanifest):
|
||||
with open(pcmanifest, 'r') as f:
|
||||
pcmanifest_oldlines = f.readlines()
|
||||
# Copy recipe's all packages if one of the packages are different to make
|
||||
# they have the same PR.
|
||||
with open(manifest, 'r') as f:
|
||||
for line in f:
|
||||
if line.startswith(prepath):
|
||||
srcpath = line.rstrip()
|
||||
if os.path.isfile(srcpath):
|
||||
destpath = os.path.join(deploydir, os.path.relpath(srcpath, prepath))
|
||||
|
||||
# This is crude but should work assuming the output
|
||||
# package file name starts with the package name
|
||||
# and rpkglist is sorted by length (descending)
|
||||
pkgbasename = os.path.basename(destpath)
|
||||
pkgname = None
|
||||
for rpkg, pkg in rpkglist:
|
||||
if mlprefix and pkgtype == 'rpm' and rpkg.startswith(mlprefix):
|
||||
rpkg = rpkg[len(mlprefix):]
|
||||
if pkgbasename.startswith(rpkg):
|
||||
pkgr = pkgrvalues[pkg]
|
||||
destpathspec = destpath.replace(pkgr, '*')
|
||||
if pvprefix:
|
||||
pkgv = pkgvvalues[pkg]
|
||||
if pkgv.startswith(pvprefix):
|
||||
destpathspec = destpathspec.replace(pkgv, pvprefix + "*")
|
||||
pkgname = pkg
|
||||
break
|
||||
else:
|
||||
bb.warn('Unable to map %s back to package' % pkgbasename)
|
||||
destpathspec = destpath
|
||||
|
||||
oldfile = None
|
||||
oldfiles = sorted(glob.glob(destpathspec), key=os.path.getmtime)
|
||||
if oldfiles:
|
||||
oldfile = oldfiles[-1]
|
||||
# Save old packages for removing in case this is a
|
||||
# fresh build with old packges
|
||||
for oldline in oldfiles:
|
||||
oldline += '\n'
|
||||
if not oldline in pcmanifest_oldlines:
|
||||
with open(pcmanifest, 'a') as f:
|
||||
f.write(oldline)
|
||||
if not docopy:
|
||||
if oldfile:
|
||||
result = subprocess.call(['env', 'PSEUDO_DISABLED=1', 'pkg-diff.sh', oldfile, srcpath])
|
||||
if result != 0:
|
||||
docopy = True
|
||||
bb.note("%s and %s are different, will copy packages" % (oldfile, srcpath))
|
||||
else:
|
||||
docopy = True
|
||||
bb.note("No old packages found for %s, will copy packages" % pkgname)
|
||||
|
||||
files.append((pkgname, pkgbasename, srcpath, destpath))
|
||||
|
||||
# Remove all the old files and copy again if docopy
|
||||
if docopy:
|
||||
bb.note('Copying packages for recipe %s' % pn)
|
||||
try:
|
||||
with open(pcmanifest, 'r') as f:
|
||||
for line in f:
|
||||
fn = line.rstrip()
|
||||
if fn and os.path.exists(fn):
|
||||
os.remove(fn)
|
||||
bb.note('Removed old package %s' % fn)
|
||||
except IOError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
pass
|
||||
|
||||
# Create new manifest
|
||||
with open(pcmanifest, 'w') as f:
|
||||
for pkgname, pkgbasename, srcpath, destpath in files:
|
||||
destdir = os.path.dirname(destpath)
|
||||
bb.utils.mkdirhier(destdir)
|
||||
# Remove allarch rpm pkg if it is already existed (for
|
||||
# multilib), they're identical in theory, but sstate.bbclass
|
||||
# copies it again, so keep align with that.
|
||||
if os.path.exists(destpath) and pkgtype == 'rpm' \
|
||||
and d.getVar('PACKAGE_ARCH') == 'all':
|
||||
os.unlink(destpath)
|
||||
if (os.stat(srcpath).st_dev == os.stat(destdir).st_dev):
|
||||
# Remove destpath in case it exists
|
||||
if os.path.exists(destpath):
|
||||
bb.note('Removing %s' % destpath)
|
||||
os.unlink(destpath)
|
||||
# Use a hard link to save space
|
||||
os.link(srcpath, destpath)
|
||||
else:
|
||||
shutil.copyfile(srcpath, destpath)
|
||||
f.write('%s\n' % destpath)
|
||||
else:
|
||||
# Remove pcmanifest if no package is copied
|
||||
if os.path.exists(pcmanifest):
|
||||
os.unlink(pcmanifest)
|
||||
bb.note('Not copying packages for recipe %s' % pn)
|
||||
|
||||
do_cleansstate[postfuncs] += "pfs_cleanpkgs"
|
||||
python pfs_cleanpkgs () {
|
||||
import errno
|
||||
for pkgclass in (d.getVar('PACKAGE_CLASSES') or '').split():
|
||||
if pkgclass.startswith('package_'):
|
||||
pkgtype = pkgclass.split('_', 1)[1]
|
||||
deploydir = d.getVar('DEPLOY_DIR_%s' % pkgtype.upper())
|
||||
prepath = deploydir + '-prediff'
|
||||
pcmanifest = os.path.join(prepath, d.expand('pkg-compare-manifest-${MULTIMACH_TARGET_SYS}-${PN}'))
|
||||
try:
|
||||
with open(pcmanifest, 'r') as f:
|
||||
for line in f:
|
||||
fn = line.rstrip()
|
||||
if fn:
|
||||
try:
|
||||
os.remove(fn)
|
||||
except OSError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
pass
|
||||
os.remove(pcmanifest)
|
||||
except IOError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
pass
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
#
|
||||
# Copyright (C) 2024 Wind River Systems, Inc.
|
||||
#
|
||||
# Utilities for processing items depending on the Rolling Cumulative Patch Layer (RCPL)
|
||||
# version being used.
|
||||
#
|
||||
# python function ifRcplInRange(d, first, last, tval, fval) returns tval
|
||||
# if the RCPL is in a particular range, and fval if it is not.
|
||||
#
|
||||
# `first` must be specified. When `last` is provided, this function returns
|
||||
# `tval` if the RCPL number is in range [first, last] (inclusive for both lower bound
|
||||
# and upper bound) and `fval` if the RCPL number is outside the range.
|
||||
#
|
||||
# When `last` is not provided, this function returns `tval` if the RCPL number
|
||||
# is >= `first` and `fval` if the RCPL number is < `first`.
|
||||
#
|
||||
# An anonymous python function processes values for SRC_URI_APPEND_RCPL[] flags and
|
||||
# appends them to SRC_URI if the RCPL is in range.
|
||||
#
|
||||
#
|
||||
# Example usages:
|
||||
#
|
||||
# inherit rcpl-filter
|
||||
#
|
||||
# SRC_URI = "... \
|
||||
# ${@ifRcplInRange(d,tval='file://CVE-2022-37434.patch',first=15)} \
|
||||
# ${@ifRcplInRange(d,13,13,'file://CVE-2023-45853.patch')} \
|
||||
# "
|
||||
#
|
||||
# Include the CVE-2022-37434 patch starting at RCPL0015 (including RCPL0015).
|
||||
# Include the CVE-2023-45853 patch only for RCPL0013. Note that the following
|
||||
# two lines are equivalent.
|
||||
#
|
||||
# ${@ifRcplInRange(d,15,tval='file://CVE-2022-37434.patch')}
|
||||
# ${@ifRcplInRange(d,1,14,fval='file://CVE-2022-37434.patch')}
|
||||
#
|
||||
# Another way to do this is by using variable flags.
|
||||
#
|
||||
# RCPL 15 and above
|
||||
# SRC_URI_APPEND_RCPL[15-] = "file://CVE-2022-37434.patch"
|
||||
# only RCPL 13
|
||||
# SRC_URI_APPEND_RCPL[13] = "file://CVE-2023-45853.patch"
|
||||
# RCPLs 13-18
|
||||
# SRC_URI_APPEND_RCPL[13-18] = "file://CVE-2023-45853.patch"
|
||||
#
|
||||
# The inline function is more general, and can be used to set values
|
||||
# anywhere based on an RCPL range.
|
||||
#
|
||||
|
||||
# ifRcplInRange(d,first,last,tval,fval)
|
||||
# first the lowest number RCPL in the range (inclusive)
|
||||
# last the highest number RCPL in the range (inclusive)
|
||||
# tval value returned when the RCPL is in the range
|
||||
# fval value returned when the RCPL is not in the range
|
||||
#
|
||||
def ifRcplInRange(d, first, last=None, tval="", fval=""):
|
||||
rcpl = int(d.getVar("WRLINUX_UPDATE_VERSION"))
|
||||
return tval if rcpl >= first and (last is None or rcpl <= last) else fval
|
||||
|
||||
python() {
|
||||
# get a dictionary of flags and quit if there aren't any
|
||||
#
|
||||
flags = d.getVarFlags("SRC_URI_APPEND_RCPL")
|
||||
if not flags:
|
||||
return
|
||||
|
||||
current_rcpl = int(d.getVar("WRLINUX_UPDATE_VERSION"))
|
||||
|
||||
# process the dictionary entries
|
||||
# the keys are of the form "m" or "m-n"
|
||||
#
|
||||
for i in flags.keys():
|
||||
range = i.split("-")
|
||||
first = int(range[0])
|
||||
# assume "m-n"
|
||||
try:
|
||||
last = int(range[1])
|
||||
# "m" meaning "m only"
|
||||
except IndexError:
|
||||
last = first
|
||||
# "m-" meaning "m and above"
|
||||
except ValueError:
|
||||
last = current_rcpl
|
||||
|
||||
if current_rcpl >= first and current_rcpl <= last:
|
||||
d.appendVar('SRC_URI', " "+flags[i])
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#inherit wrlinux-image
|
||||
rtopts_update_sudoers () {
|
||||
sed -i 's/# %sudo/%sudo/' ${IMAGE_ROOTFS}/etc/sudoers
|
||||
}
|
||||
|
||||
rtopts_set_kernel_opts () {
|
||||
mkdir -p ${IMAGE_ROOTFS}/etc/sysctl.d
|
||||
echo 'kernel.sched_rt_runtime_us = -1' > ${IMAGE_ROOTFS}/etc/sysctl.d/kernel.sched_rt_runtime_us.conf
|
||||
# echo '0' > ${IMAGE_ROOTFS}/sys/devices/system/machinecheck/machinecheck0/check_interval
|
||||
echo 'kernel.timer_migration = 0' > ${IMAGE_ROOTFS}/etc/sysctl.d/kernel.timer_migration.conf
|
||||
#echo 'processor.max_cstate = 1' > ${IMAGE_ROOTFS}/etc/sysctl.d/processor.max_cstate.conf
|
||||
#echo 'intel.max_cstate = 1' > ${IMAGE_ROOTFS}/etc/sysctl.d/intel.max_cstate.conf
|
||||
echo 'isolcpus = 2,3' > ${IMAGE_ROOTFS}/etc/sysctl.d/isolcpus.conf
|
||||
}
|
||||
|
||||
#not RT related directly, but required for linuxcnc build for RT testing
|
||||
#rtopts_symlink_lib64 () {
|
||||
# ln -s /lib ${IMAGE_ROOTFS}/lib64
|
||||
#}
|
||||
|
||||
EXPORT_FUNCTIONS update_sudoers set_kernel_opts #symlink_lib64
|
||||
@@ -0,0 +1,41 @@
|
||||
#
|
||||
# Copyright (C) 2025 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
python do_create_spdx:prepend() {
|
||||
import oe.packagedata
|
||||
|
||||
purl_qualifiers = "distro=%s-%s&arch=%s" % ("yocto" if d.getVar("DISTRO") == "poky" else d.getVar("DISTRO"), \
|
||||
d.getVar("DISTRO_VERSION"), \
|
||||
d.getVar("MACHINE"), \
|
||||
)
|
||||
purl_qualifiers_extend = d.getVar("SPDX_PURL_QUALIFIERS_EXTEND")
|
||||
if purl_qualifiers_extend:
|
||||
purl_qualifiers += "&%s" % purl_qualifiers_extend
|
||||
|
||||
purl_type = d.getVar("IMAGE_PKGTYPE")
|
||||
if purl_type == "ipk":
|
||||
purl_type = "yocto"
|
||||
purl_qualifiers = "file_extension=ipk&" + purl_qualifiers
|
||||
|
||||
purl_subpath = d.getVar("SPDX_PURL_SUBPATH")
|
||||
purl_subpath = "#" + purl_subpath if purl_subpath else ""
|
||||
|
||||
bb.build.exec_func("read_subpackage_metadata", d)
|
||||
|
||||
for package in d.getVar("PACKAGES", True).split():
|
||||
if not oe.packagedata.packaged(package, d):
|
||||
continue
|
||||
pkg_name = d.getVar("PKG:%s" % package) or package
|
||||
purl = "pkg:%s/%s/%s@%s?%s%s" % (purl_type, \
|
||||
d.getVar("DISTRO"), \
|
||||
pkg_name, \
|
||||
d.getVar("EXTENDPKGV"), \
|
||||
purl_qualifiers, \
|
||||
purl_subpath \
|
||||
)
|
||||
|
||||
d.setVar("SPDX_PACKAGE_URL:%s" % package, purl)
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
#
|
||||
# Copyright (C) 2012-2023 Wind River Systems, Inc.
|
||||
#
|
||||
|
||||
inherit core-image
|
||||
|
||||
#
|
||||
# Package groups must be defined here. Note convention: each group
|
||||
# "xxx" has a single package dependency on a "packagegroup-xxx" package
|
||||
# defined in ../packagegroups.
|
||||
#
|
||||
FEATURE_PACKAGES_wr-core-util = "packagegroup-wr-core-util"
|
||||
FEATURE_PACKAGES_wr-core-sys-util = "packagegroup-wr-core-sys-util"
|
||||
FEATURE_PACKAGES_wr-core-net = "packagegroup-wr-core-net"
|
||||
FEATURE_PACKAGES_wr-core-interactive = "packagegroup-wr-core-interactive"
|
||||
FEATURE_PACKAGES_wr-core-libs-extended = "packagegroup-wr-core-libs-extended"
|
||||
FEATURE_PACKAGES_wr-core-db = "packagegroup-wr-core-db"
|
||||
FEATURE_PACKAGES_wr-core-perl = "packagegroup-wr-core-perl"
|
||||
FEATURE_PACKAGES_wr-core-python = "packagegroup-wr-core-python"
|
||||
FEATURE_PACKAGES_wr-core-mail = "packagegroup-wr-core-mail"
|
||||
FEATURE_PACKAGES_ssh-sftp-servers ??= ""
|
||||
FEATURE_PACKAGES_wr-bsps = "packagegroup-wr-bsps"
|
||||
|
||||
# ensure we have password and group files before we do_rootfs
|
||||
check_for_passwd_group() {
|
||||
if [ ! -f $D/${sysconfdir}/passwd -o ! -f $D/${sysconfdir}/group ]; then
|
||||
bberror "Nothing provides ${sysconfdir}/passwd and/or ${sysconfdir}/group"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
ROOTFS_POSTPROCESS_COMMAND:prepend = "check_for_passwd_group ; "
|
||||
|
||||
WRPRELIMPKGDATADIR ?= "${TMPDIR}/pkgdata-prelim"
|
||||
WRPKGDATADIR ?= "${TMPDIR}/pkgdata"
|
||||
|
||||
python do_image_info() {
|
||||
prelim_dirs = d.getVar('WRPRELIMPKGDATADIR', True) or ""
|
||||
built_dirs = d.getVar('WRPKGDATADIR', True) or ""
|
||||
|
||||
package_install = d.getVar('PACKAGE_INSTALL', True) or ""
|
||||
package_install_attemptonly = d.getVar('PACKAGE_INSTALL_ATTEMPTONLY', True) or ""
|
||||
|
||||
globs = d.getVar('IMAGE_INSTALL_COMPLEMENTARY', True) or ""
|
||||
for translation in d.getVar('IMAGE_LINGUAS', True).split():
|
||||
translated = translation.split('-')[0]
|
||||
globs += ' *-locale-%s' % translated
|
||||
if translated != translation:
|
||||
globs += ' *-locale-%s' % translation
|
||||
|
||||
bb.plain('PKGDATA dirs: %s %s' % (prelim_dirs, built_dirs))
|
||||
bb.plain('INSTALL: %s' % package_install)
|
||||
bb.plain('INSTALL ATTEMPT: %s' % package_install_attemptonly)
|
||||
bb.plain('GLOBS: %s' % globs)
|
||||
}
|
||||
|
||||
addtask image_info
|
||||
do_image_info[nostamp] = "1"
|
||||
|
||||
python () {
|
||||
if oe.types.boolean(d.getVar('FORCE_PASSWD_EXPIRE')):
|
||||
for user in d.getVar('FORCE_EXPIRED_USERS').split():
|
||||
d.appendVar('EXTRA_USERS_PARAMS', f' passwd-expire {user};')
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
target_build_msg = "The meta-anaconda layer has been included, and the \
|
||||
current build is a regular target build. After it is finished, create \
|
||||
a new installer build with DISTRO = 'wrlinux-installer', \
|
||||
INSTALLER_TARGET_BUILD = '<target-build-topdir>|<target-build-image>' \
|
||||
and INSTALLER_TARGET_IMAGE = '<target-image-pn>' in local.conf"
|
||||
|
||||
target_build_warnmsg = "WARNING: The meta-anaconda layer has been included, \
|
||||
and the current build is a regular target build. It requires to enable \
|
||||
feature/installer-support template. Add option \
|
||||
--templates=feature/installer-support to setup.sh, or set WRTEMPLATE += \
|
||||
'feature/installer-support' in local.conf"
|
||||
|
||||
installer_build_msg = "The meta-anaconda layer has been included, and the \
|
||||
current build is a installer build, if set INSTALLER_TARGET_BUILD = \
|
||||
'<target-build-topdir>', and INSTALLER_TARGET_IMAGE = '<target-image-pn>' \
|
||||
the installer is to do RPMs install; if set INSTALLER_TARGET_BUILD = \
|
||||
'<target-build-image>', the installer is to do image copy install."
|
||||
|
||||
def get_installer_banner(d):
|
||||
if d.getVar('DISTRO',True) == 'wrlinux-installer':
|
||||
return d.getVar('installer_build_msg')
|
||||
elif "feature/installer-support" in d.getVar("WRTEMPLATE").split():
|
||||
return d.getVar('target_build_msg')
|
||||
else:
|
||||
return d.getVar('target_build_warnmsg')
|
||||
|
||||
CONFIG_BANNER[installer] = "${@get_installer_banner(d)}"
|
||||
@@ -0,0 +1,30 @@
|
||||
#
|
||||
# Copyright (C) 2018 Wind River Systems, Inc.
|
||||
#
|
||||
|
||||
def base_get_metadata_git_branch(path, d):
|
||||
"""
|
||||
Try to return where m/master points to when HEAD isn't on any branch.
|
||||
"""
|
||||
import subprocess
|
||||
|
||||
try:
|
||||
cmd = 'git rev-parse --abbrev-ref HEAD'.split()
|
||||
branch = subprocess.check_output(cmd, cwd=path).decode('utf-8').strip()
|
||||
if branch == 'HEAD':
|
||||
bb.debug(1, "Trying to get branch name from m/master...")
|
||||
# Check whether HEAD == m/master
|
||||
cmd1 = 'git rev-parse HEAD'.split()
|
||||
cmd2 = 'git rev-parse m/master^0'.split()
|
||||
if subprocess.check_output(cmd1, cwd=path) == subprocess.check_output(cmd2, cwd=path):
|
||||
cmd = 'git rev-parse --abbrev-ref m/master'.split()
|
||||
branch = subprocess.check_output(cmd, cwd=path).decode('utf-8')
|
||||
if branch == 'HEAD':
|
||||
bb.debug(1, "Trying to get tag name...")
|
||||
cmd = 'git describe HEAD'.split()
|
||||
branch = subprocess.check_output(cmd, cwd=path).decode('utf-8')
|
||||
|
||||
except subprocess.CalledProcessError:
|
||||
branch = '<unknown>'
|
||||
|
||||
return branch.strip().replace('base/', '')
|
||||
Reference in new issue
Block a user