diff options
Diffstat (limited to 'meta/classes')
28 files changed, 1747 insertions, 0 deletions
diff --git a/meta/classes/webos_app_generate_security_files.bbclass b/meta/classes/webos_app_generate_security_files.bbclass new file mode 100644 index 0000000000..ac21866de1 --- /dev/null +++ b/meta/classes/webos_app_generate_security_files.bbclass @@ -0,0 +1,179 @@ +# Copyright (c) 2015-2017 LG Electronics, Inc. +# +# webos_app_generate_security_files +# +# This class is to be inherited by the recipe for every application that needs +# to generate permission and role files from its appinfo.json. +# This will happen implicitly, as all such applications will inherit from +# webos_app, which inherits this class. +# +# Keep this code in sync with that in appinstalld that does the same thing +# until [DRD-4417] is implemented. +# + +inherit webos_system_bus + +WEBOS_SYSTEM_BUS_CONFIGURE_FILES ??= "TRUE" + +def webos_app_generate_security_files_write_permission_file(d, app_info): + import os + import json + + app_id = app_info["id"] + key = app_id + "-*" + type = app_info["type"] + + permission = {} + + if "requiredPermissions" in app_info: + permission[key] = app_info["requiredPermissions"] + else: + permission[key] = [] + pub_bus = False + prv_bus = False + trust_level = app_info.get("trustLevel", "default") + if trust_level == "default": + pub_bus = True + elif trust_level == "trusted": + pub_bus = True + prv_bus = True + elif trust_level == "netcast": + # According to https://wiki.lgsvl.com/display/webOSDocs/Security+Level+for+web+applications + # netcast level dosn't have access to public and private bus + pass + else: + bb.fatal("Unexpected trustLevel: " + trust_level) + + if type == "web": + if "com.palm." in app_id or "com.webos." in app_id: + prv_bus = True + elif type == "qml": + prv_bus = True + pub_bus = True + + if prv_bus: + permission[key].append("private") + pub_bus = True + + if pub_bus: + permission[key].append("public") + + dst_dir = d.getVar("D", True) + permissions_dir = d.getVar("webos_sysbus_permissionsdir", True) + permission_file = permissions_dir + "/" + app_id + ".app.json" + + if not os.path.exists(dst_dir + permissions_dir): + os.makedirs(dst_dir + permissions_dir) + + with open(dst_dir + permission_file, "w") as f: + json.dump(permission, f, indent=4) + f.write("\n") + + return permission_file + +def webos_app_generate_security_files_write_role_file(d, app_info): + import os + import json + + app_id = app_info["id"] + + role = {} + + role["appId"] = app_id + role["type"] = "regular" + role["allowedNames"] = [app_id + "-*"] + role["permissions"] = [{"service": app_id + "-*", "outbound": ["*"] }] + + dst_dir = d.getVar("D", True) + roles_dir = d.getVar("webos_sysbus_rolesdir", True) + role_file = roles_dir + "/" + app_id + ".app.json" + + if not os.path.exists(dst_dir + roles_dir): + os.makedirs(dst_dir + roles_dir) + + with open(dst_dir + role_file, "w") as f: + json.dump(role, f, indent=4) + f.write("\n") + + return role_file + +def webos_app_generate_security_files_get_immediate_subdirectories(root): + import os + return [name for name in os.listdir(root) + if os.path.isdir(os.path.join(root, name))] + +def webos_app_generate_security_files_comment_remover(text): + import re + + def replacer(match): + s = match.group(0) + return "" if s.startswith('/') else s + + pattern = re.compile(r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', + re.DOTALL | re.MULTILINE + ) + return re.sub(pattern, replacer, text) + +def webos_app_generate_security_files_read_json(file): + """ Read a JSON file with comments: //, /**/ """ + + import json + + with open(file, "r") as f: + content = f.read() + + content = webos_app_generate_security_files_comment_remover(content) + return json.loads(content) + +fakeroot python do_configure_security() { + import json + import os.path + + if d.getVar("WEBOS_SYSTEM_BUS_CONFIGURE_FILES", True) != "TRUE": + return + + dst_dir = d.getVar("D", True) + app_dir = dst_dir + d.getVar("webos_applicationsdir", True) + + # ignore component that isn't app + if not os.path.exists(app_dir): + return + + roles_dir = dst_dir + d.getVar("webos_sysbus_rolesdir", True) + pub_roles_dir = dst_dir + d.getVar("webos_sysbus_pubrolesdir", True) + prv_roles_dir = dst_dir + d.getVar("webos_sysbus_prvrolesdir", True) + + apps = webos_app_generate_security_files_get_immediate_subdirectories(app_dir) + + pkg_name = d.getVar("PN", True) + for app in apps: + app_info_file = app_dir + "/" + app + "/appinfo.json" + + # ignore app that doesn't have appinfo.json + if not os.path.exists(app_info_file): + continue + + # ignore app that already has role file + role_file = roles_dir + "/" + app + ".role.json" + if os.path.exists(role_file): + continue + + # ignore app that already has public role file + pub_role_file = pub_roles_dir + "/" + app + ".json" + if os.path.exists(pub_role_file): + continue + + # ignore app that already has private role file + prv_role_file = prv_roles_dir + "/" + app + ".json" + if os.path.exists(prv_role_file): + continue + + app_info = webos_app_generate_security_files_read_json(app_info_file) + + type = app_info["type"] + if type in ["qml", "web"]: + role_file = webos_app_generate_security_files_write_role_file(d, app_info) + permission_file = webos_app_generate_security_files_write_permission_file(d, app_info) +} + +addtask configure_security after do_install before do_package diff --git a/meta/classes/webos_arch_indep.bbclass b/meta/classes/webos_arch_indep.bbclass new file mode 100644 index 0000000000..b6d450ca65 --- /dev/null +++ b/meta/classes/webos_arch_indep.bbclass @@ -0,0 +1,17 @@ +# Copyright (c) 2012-2014 LG Electronics, Inc. +# +# webos_arch_indep +# +# This class is to be inherited by the recipe for every component that is CPU +# architecture independent. +# + +inherit allarch + +python () { + if bb.data.inherits_class('webos_machine_dep', d) or bb.data.inherits_class('webos_machine_impl_dep', d): + pa = d.getVar('PACKAGE_ARCH', True) + if pa == "all": + pn = d.getVar('PN', True) + bb.error("%s: You should inherit webos_machine_dep or webos_machine_impl_dep _after_ webos_arch_indep to set PACKAGE_ARCH to MACHINE_ARCH" % pn) +} diff --git a/meta/classes/webos_autotools.bbclass b/meta/classes/webos_autotools.bbclass new file mode 100644 index 0000000000..feb81f920a --- /dev/null +++ b/meta/classes/webos_autotools.bbclass @@ -0,0 +1,10 @@ +# Copyright (c) 2012-2013 LG Electronics, Inc. +# +# webos_autotools +# +# This class is to be inherited by the recipe for every component that uses +# autotools for configuration. +# + +inherit autotools + diff --git a/meta/classes/webos_cmake.bbclass b/meta/classes/webos_cmake.bbclass new file mode 100644 index 0000000000..aa94626f96 --- /dev/null +++ b/meta/classes/webos_cmake.bbclass @@ -0,0 +1,183 @@ +# Copyright (c) 2012-2015 LG Electronics, Inc. +# +# webos_cmake +# +# This class is to be inherited by every recipe in meta-webos whose component +# uses CMake. It adds a dependency on cmake-modules-webos-native, which will be +# extraneous until the component is converted, but who cares? +# +# Expects that webos_submissions or webos_enhanced_submissions will also be +# inherited (for WEBOS_COMPONENT_VERSION). + +# Extra variable is needed to be able to inhibit this dependency in case +# we have some recipe which can reuse this bbclass but without this dependency. +WEBOS_CMAKE_DEPENDS = "cmake-modules-webos-native" +DEPENDS_append = " ${WEBOS_CMAKE_DEPENDS}" + +inherit cmake +inherit webos_filesystem_paths + +WEBOS_PKGCONFIG_BUILDDIR = "${B}" + +EXTRA_OECMAKE += "-DWEBOS_INSTALL_ROOT:PATH=/" + +WEBOS_TARGET_MACHINE_IMPL ?= "emulator" +WEBOS_TARGET_CORE_OS ?= "rockhopper" + +# XXX Should error if WEBOS_COMPONENT_VERSION is unset +EXTRA_OECMAKE += "-DWEBOS_COMPONENT_VERSION:STRING=${WEBOS_COMPONENT_VERSION}" + +EXTRA_OECMAKE_TARGET_CORE_OS = "${@ \ + '-DWEBOS_TARGET_CORE_OS:STRING=${WEBOS_TARGET_CORE_OS}' \ + if bb.data.inherits_class('webos_core_os_dep', d) and not bb.data.inherits_class('native', d) else \ + '' \ +}" +EXTRA_OECMAKE_TARGET_CORE_OS[vardepvalue] = "${EXTRA_OECMAKE_TARGET_CORE_OS}" +EXTRA_OECMAKE += "${EXTRA_OECMAKE_TARGET_CORE_OS}" + +# XXX Add webos_kernel_dep() to webOS.cmake that adds WEBOS_TARGET_KERNEL_HEADERS to the search path +EXTRA_OECMAKE_KERNEL_HEADERS = "${@ \ + '-DWEBOS_TARGET_KERNEL_HEADERS:STRING=${STAGING_KERNEL_DIR}/include' \ + if bb.data.inherits_class('webos_kernel_dep', d) and not bb.data.inherits_class('native', d) else \ + '' \ +}" +EXTRA_OECMAKE_KERNEL_HEADERS[vardepsexclude] = "${@ \ + '' \ + if bb.data.inherits_class('webos_kernel_dep', d) and not bb.data.inherits_class('native', d) else \ + 'STAGING_KERNEL_DIR' \ +}" +EXTRA_OECMAKE += "${EXTRA_OECMAKE_KERNEL_HEADERS}" + +EXTRA_OECMAKE_MACHINE_ACTUAL ?= "${MACHINE}" +EXTRA_OECMAKE_MACHINE = "${@ \ + '-DWEBOS_TARGET_MACHINE:STRING=${EXTRA_OECMAKE_MACHINE_ACTUAL}' \ + if bb.data.inherits_class('webos_machine_dep', d) and not bb.data.inherits_class('native', d) else \ + '' \ +}" +EXTRA_OECMAKE_MACHINE[vardepvalue] = "${EXTRA_OECMAKE_MACHINE}" +EXTRA_OECMAKE += "${EXTRA_OECMAKE_MACHINE}" + +# If SOC_FAMILY is empty, don't add -DWEBOS_TARGET_SOC_FAMILY. +EXTRA_OECMAKE_SOC_FAMILY = "${@ \ + '-DWEBOS_TARGET_SOC_FAMILY:STRING=' + d.getVar('SOC_FAMILY', True) \ + if bb.data.inherits_class('webos_soc_family_dep', d) and not bb.data.inherits_class('native', d) and (d.getVar('SOC_FAMILY', True) or '') != '' else \ + '' \ +}" +EXTRA_OECMAKE_SOC_FAMILY[vardepvalue] = "${EXTRA_OECMAKE_SOC_FAMILY}" +EXTRA_OECMAKE += "${EXTRA_OECMAKE_SOC_FAMILY}" + +EXTRA_OECMAKE_MACHINE_IMPL = "${@ \ + '-DWEBOS_TARGET_MACHINE_IMPL:STRING=${WEBOS_TARGET_MACHINE_IMPL}' \ + if bb.data.inherits_class('webos_machine_impl_dep', d) and not bb.data.inherits_class('native', d) else \ + '' \ +}" +EXTRA_OECMAKE_MACHINE_IMPL[vardepvalue] = "${EXTRA_OECMAKE_MACHINE_IMPL}" +EXTRA_OECMAKE += "${EXTRA_OECMAKE_MACHINE_IMPL}" + +EXTRA_OECMAKE_MACHINE_VARIANT = "${@ \ + '-DWEBOS_TARGET_MACHINE_VARIANT:STRING=${WEBOS_TARGET_MACHINE_VARIANT}' \ + if bb.data.inherits_class('webos_machine_variant_dep', d) and not bb.data.inherits_class('native', d) else \ + '' \ +}" +EXTRA_OECMAKE_MACHINE_VARIANT[vardepvalue] = "${EXTRA_OECMAKE_MACHINE_VARIANT}" +#EXTRA_OECMAKE += "${EXTRA_OECMAKE_MACHINE_VARIANT}" + +# If DISTRO is unset, don't add -DWEBOS_TARGET_DISTRO. If it is set, always pass +# it, even for -native components. +EXTRA_OECMAKE_DISTRO = "${@ \ + '-DWEBOS_TARGET_DISTRO:STRING=' + d.getVar('DISTRO', True) \ + if bb.data.inherits_class('webos_distro_dep', d) and (d.getVar('DISTRO', True) or '') != '' else \ + '' \ +}" +EXTRA_OECMAKE_DISTRO[vardepvalue] = "${EXTRA_OECMAKE_DISTRO}" +EXTRA_OECMAKE += "${EXTRA_OECMAKE_DISTRO}" + +EXTRA_OECMAKE_DISTRO_VARIANT = "${@ \ + '-DWEBOS_TARGET_DISTRO_VARIANT:STRING=${WEBOS_TARGET_DISTRO_VARIANT}' \ + if bb.data.inherits_class('webos_distro_variant_dep', d) and not bb.data.inherits_class('native', d) else \ + '' \ +}" +EXTRA_OECMAKE_DISTRO_VARIANT[vardepvalue] = "${EXTRA_OECMAKE_DISTRO_VARIANT}" +#EXTRA_OECMAKE += "${EXTRA_OECMAKE_DISTRO_VARIANT}" + +# This information is always useful to have around +EXTRA_OECMAKE += "-Wdev" + +# Fixup in case CMake files don't recognize the new value i586 for +# CMAKE_SYSTEM_PROCESSOR (e.g. nodejs) +do_generate_toolchain_file_append() { + sed '/CMAKE_SYSTEM_PROCESSOR/ s/i586/i686/' -i ${WORKDIR}/toolchain.cmake +} + +# Record how cmake was invoked +do_configure_append() { + # Keep in sync with how cmake_do_configure() invokes cmake + echo $(which cmake) \ + ${OECMAKE_SITEFILE} \ + ${S} \ + -DCMAKE_INSTALL_PREFIX:PATH=${prefix} \ + -DCMAKE_INSTALL_SO_NO_EXE=0 \ + -DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake \ + -DCMAKE_VERBOSE_MAKEFILE=1 \ + ${EXTRA_OECMAKE} \ + -Wno-dev > ${WORKDIR}/cmake.status +} + +# Used in webOS.cmake _webos_set_from_env +export webos_bootdir +export webos_browserpluginsdir +export webos_defaultconfdir +export webos_execstatedir +export webos_firmwaredir +export webos_homedir +export webos_logdir +export webos_mediadir +export webos_mntdir +export webos_pkgconfigdir +export webos_preservedtmpdir +export webos_qtpluginsdir +export webos_runtimeinfodir +export webos_srcdir +export webos_udevscriptsdir +export webos_upstartconfdir +export webos_prefix +export webos_localstatedir +export webos_sysconfdir +export webos_accttemplatesdir +export webos_applicationsdir +export webos_frameworksdir +export webos_keysdir +export webos_pluginsdir +export webos_servicesdir +export webos_soundsdir +export webos_sysmgrdir +export webos_db8datadir +export webos_filecachedir +export webos_preferencesdir +export webos_sysbus_pubservicesdir +export webos_sysbus_prvservicesdir +export webos_sysbus_pubrolesdir +export webos_sysbus_prvrolesdir +export webos_sysbus_dynpubservicesdir +export webos_sysbus_dynprvservicesdir +export webos_sysbus_dynpubrolesdir +export webos_sysbus_dynprvrolesdir +export webos_sysbus_devpubservicesdir +export webos_sysbus_devprvservicesdir +export webos_sysbus_devpubrolesdir +export webos_sysbus_devprvrolesdir +export webos_sysmgr_datadir +export webos_sysmgr_localstatedir +export webos_cryptofsdir +export webos_browserstoragedir +export webos_downloadeddir +export webos_downloadeddir +export webos_downloaded_applicationsdir +export webos_downloaded_applicationsdir +export webos_downloaded_frameworksdir +export webos_downloaded_pluginsdir +export webos_downloaded_servicesdir +export webos_persistentstoragedir +export webos_db8mediadir +export webos_mountablestoragedir +export webos_mountablestoragedir diff --git a/meta/classes/webos_component.bbclass b/meta/classes/webos_component.bbclass new file mode 100644 index 0000000000..e29bdf46d9 --- /dev/null +++ b/meta/classes/webos_component.bbclass @@ -0,0 +1,13 @@ +# Copyright (c) 2012-2013 LG Electronics, Inc. +# +# webos_component +# +# This class is to be inherited by the recipe for every component developed by +# Palm that has had any do_*() task code required for its standalone Ubuntu desktop +# build to work moved to be in its CMakeLists/Makefile and is able to support +# having the filesystem layout rooted at /opt/webos. +# + +inherit webos_fs_layout + +WEBOS_SYSTEM_BUS_SKIP_DO_TASKS = "1" diff --git a/meta/classes/webos_configure_manifest.bbclass b/meta/classes/webos_configure_manifest.bbclass new file mode 100644 index 0000000000..f2278f9c02 --- /dev/null +++ b/meta/classes/webos_configure_manifest.bbclass @@ -0,0 +1,330 @@ +# Copyright (c) 2015-2018 LG Electronics, Inc. + +WEBOS_SYSTEM_BUS_MANIFEST_TYPE ??= "PACKAGE" + +inherit webos_filesystem_paths + +def webos_configure_manifest_template(): + manifest = {} + manifest["id"] = "" + manifest["version"] = "1.0.0" + + return manifest + +def webos_configure_manifest_warn(d, message): + pn = d.getVar("BPN", True) + bb.warn("webos_configure_manifest: warning in package: %s, with message: %s" % (pn, message)) + +def webos_configure_manifest_lookup_files_by_ext(d, dir_var, ext): + ret = [] + + dst = d.getVar("D", True) + rel_dir = d.getVar(dir_var, True) + abs_dir = dst + rel_dir + + if not os.path.exists(abs_dir): + return ret + + for f in os.listdir(abs_dir): + if f.endswith(ext): + ret.append(os.path.join(rel_dir, f)) + + return sorted(ret) + +def webos_configure_manifest_lookup_file_by_name(d, dir_name, srv_name): + dst = d.getVar("D", True) + rel_dir = d.getVar(dir_name, True) + abs_dir = dst + rel_dir + + if not os.path.exists(abs_dir): + return None + + for f in os.listdir(abs_dir): + if srv_name in f: + return os.path.join(rel_dir, f) + + return None + +def webos_configure_manifest_find_file_by_name_or_pn(d, dirpath, name, ext): + f = webos_configure_manifest_lookup_file_by_name(d, dirpath, name + ext) + return f + +def webos_configure_manifest_service(d): + import os.path + + dirs = [ "webos_sysbus_servicedir", "webos_sysbus_pubservicesdir", "webos_sysbus_prvservicesdir" ] + + def generate_manifests(d, dirpath): + found_srvs = webos_configure_manifest_lookup_files_by_ext(d, dirpath, ".service") + + manifests = [] + for srv in found_srvs: + srv_name = os.path.splitext(os.path.basename(srv))[0] + + manifest = webos_configure_manifest_template() + manifest["id"] = srv_name + manifest["serviceFiles"] = [srv] + + role = None + if "pub" in dirpath: + role = webos_configure_manifest_find_file_by_name_or_pn(d, "webos_sysbus_pubrolesdir", srv_name, ".role.json") + if role: manifest["roleFilesPub"] = [role] + elif "prv" in dirpath: + role = webos_configure_manifest_find_file_by_name_or_pn(d, "webos_sysbus_prvrolesdir", srv_name, ".role.json") + if role: manifest["roleFilesPrv"] = [role] + else: + role = webos_configure_manifest_find_file_by_name_or_pn(d, "webos_sysbus_rolesdir", srv_name, ".role.json") + if role: manifest["roleFiles"] = [role] + + provides = webos_configure_manifest_find_file_by_name_or_pn(d, "webos_sysbus_apipermissionsdir", srv_name, ".api.json") + if provides: manifest["apiPermissionFiles"] = [provides] + + requires = webos_configure_manifest_find_file_by_name_or_pn(d, "webos_sysbus_permissionsdir", srv_name, ".perm.json") + if requires: manifest["clientPermissionFiles"] = [requires] + + if role: + manifests.append(manifest) + else: + webos_configure_manifest_warn(d, "Can not distinguish role file for service %s" % srv_name) + + return manifests + + manifests = generate_manifests(d, dirs[0]) + if len(manifests) != 0: + return manifests + + manifests_pub = generate_manifests(d, dirs[1]) # public directory + manifests_prv = generate_manifests(d, dirs[2]) # private direcotry + + # merge public and private to one manifest + manifests = [] + + # some packages don't provide both files + for manifest_pub in manifests_pub: + manifest = webos_configure_manifest_template() + manifest["id"] = manifest_pub["id"] + + if "serviceFiles" in manifest_pub: + manifest["serviceFiles"] = manifest_pub["serviceFiles"] + if "roleFilesPub" in manifest_pub: + manifest["roleFilesPub"] = manifest_pub["roleFilesPub"] + + manifests.append(manifest) + + for manifest_prv in manifests_prv: + manifest = None + for manifest in manifests: + if manifest["id"] == manifest_prv["id"]: + break + + if manifest is None: + # There is not any public manifest, generate new + manifest = webos_configure_manifest_template() + manifest["id"] = manifest_prv["id"] + manifests.append(manifest) + + if "serviceFiles" in manifest_prv: + if "serviceFiles" in manifest: + manifest["serviceFiles"].extend(manifest_prv["serviceFiles"]) + else: + manifest["serviceFiles"] = manifest_prv["serviceFiles"] + + if "roleFilesPrv" in manifest_prv: + manifest["roleFilesPrv"] = manifest_prv["roleFilesPrv"] + + return manifests + +def webos_configure_manifest_comment_remover(text): + import re + + def replacer(match): + s = match.group(0) + return "" if s.startswith('/') else s + + pattern = re.compile(r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', re.DOTALL | re.MULTILINE) + return re.sub(pattern, replacer, text) + +def webos_configure_manifest_application_from_appinfo(d, app_info_file): + import json + import os.path + + manifest = webos_configure_manifest_template() + + with open(app_info_file, "r") as f: + app_info = json.loads(webos_configure_manifest_comment_remover(f.read())) + + + def is_valid_version(version): + """ + This function checks that string is valid version string + according to semver.org. + """ + import re + pattern = re.compile("^(\d+\.\d+\.\d+)" + "(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?" + "(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$") + return re.match(pattern, version) + + manifest["id"] = app_info["id"] + manifest["version"] = app_info["version"] + + if not is_valid_version(manifest["version"]): + webos_configure_manifest_warn(d, "Incompatible version string found in %s" % app_info_file) + + dst = d.getVar("D", True) + + # Possible behaviuors: + # 1. There is native or native_builtin type + # 1.1. The role is merged to service file + # 1.2. The role is installed in place + # 2. There is not native or native_builtin type, role files are generated by webos_app_configure_security + if "native" in app_info["type"]: + def warn_mismatch(d, dirpath): + files = webos_configure_manifest_lookup_files_by_ext(d, dirpath, ".json") + if len(files) == 0: + return False + + webos_configure_manifest_warn(d, "Can not determinate role file for application %s" % manifest["id"]) + webos_configure_manifest_warn(d, "Possible name mismatch required %s but found %s" + % (manifest["id"], ', '.join(files))) + + return True + + role_file = webos_configure_manifest_find_file_by_name_or_pn(d, "webos_sysbus_rolesdir", app_info["id"], ".json") + if role_file: + manifest["roleFile"] = [role_file] + + provides = webos_configure_manifest_find_file_by_name_or_pn(d, "webos_sysbus_apipermissionsdir", app_info["id"], ".json") + if provides: manifest["apiPermissionFiles"]= [provides] + + requires = webos_configure_manifest_find_file_by_name_or_pn(d, "webos_sysbus_permissionsdir", app_info["id"], ".json") + if requires: manifest["clientPermissionFiles"] = [requires] + return manifest + + if warn_mismatch(d, "webos_sysbus_rolesdir"): + return None + + role_file_pub = webos_configure_manifest_find_file_by_name_or_pn(d, "webos_sysbus_pubrolesdir", app_info["id"], ".json") + role_file_prv = webos_configure_manifest_find_file_by_name_or_pn(d, "webos_sysbus_prvrolesdir", app_info["id"], ".json") + + if not role_file_pub and not role_file_prv: + warn_mismatch(d, "webos_sysbus_pubrolesdir") + warn_mismatch(d, "webos_sysbus_prvrolesdir") + return None + + if role_file_pub: manifest["roleFilesPub"] = [role_file_pub] + if role_file_prv: manifest["roleFilesPrv"] = [role_file_prv] + else: + role_dir_rel = d.getVar("webos_sysbus_rolesdir", True) + role_file = os.path.join(role_dir_rel, manifest["id"] + ".app.json") + if not os.path.exists(dst + role_file): + webos_configure_manifest_warn(d, "Can not determinate role file for application %s" % manifest["id"]) + return None + + perm_dir = d.getVar("webos_sysbus_permissionsdir", True) + perm_file = os.path.join(perm_dir, manifest["id"] + ".app.json") + if not os.path.exists(dst + perm_file): + webos_configure_manifest_warn(d, "Can not determinate client permissions file for application %s" % manifest["id"]) + return None + + manifest["roleFiles"] = [role_file] + manifest["clientPermissionFiles"] = [perm_file] + + return manifest + +def webos_configure_manifest_application(d): + import os + + manifests = [] + def get_immediate_subdirectories(root): + return [name for name in os.listdir(root) + if os.path.isdir(os.path.join(root, name))] + + dst = d.getVar("D", True) + app_dir = dst + d.getVar("webos_applicationsdir", True) + if not os.path.exists(app_dir): + return manifests + + apps_dir = get_immediate_subdirectories(app_dir) + if len(apps_dir) == 0: + webos_configure_manifest_warn(d, "There aren't any app in application dir") + + for app in apps_dir: + app_info_file = os.path.join(app_dir, os.path.join(app, 'appinfo.json')) + + if not os.path.exists(app_info_file): + # ignore application template + if app_dir == d.getVar("BPN", True) and len(apps_dir) != 1: + webos_configure_manifest_warn(d, "There is no application info for %s" % app) + continue + + manifest = webos_configure_manifest_application_from_appinfo(d, app_info_file) + if not manifest is None: + manifests.append(manifest) + return manifests + +def webos_configure_manifest_package(d): + import os + + pn = d.getVar("BPN", True) + + manifest = webos_configure_manifest_template() + + manifest["id"] = pn + + role = webos_configure_manifest_lookup_files_by_ext(d, "webos_sysbus_rolesdir", ".json") + if role: manifest["roleFiles"] = role + + role_pub = webos_configure_manifest_lookup_files_by_ext(d, "webos_sysbus_pubrolesdir", ".json") + if role_pub: manifest["roleFilesPub"] = role_pub + + role_prv = webos_configure_manifest_lookup_files_by_ext(d, "webos_sysbus_prvrolesdir", ".json") + if role_prv: manifest["roleFilesPrv"] = role_prv + + srv = [] + srv.extend(webos_configure_manifest_lookup_files_by_ext(d, "webos_sysbus_servicedir", ".service")) + srv.extend(webos_configure_manifest_lookup_files_by_ext(d, "webos_sysbus_pubservicesdir", ".service")) + srv.extend(webos_configure_manifest_lookup_files_by_ext(d, "webos_sysbus_prvservicesdir", ".service")) + if srv: manifest["serviceFiles"] = srv + + provides = webos_configure_manifest_lookup_files_by_ext(d, "webos_sysbus_apipermissionsdir", ".json") + if provides: manifest["apiPermissionFiles"] = provides + + requires = webos_configure_manifest_lookup_files_by_ext(d, "webos_sysbus_permissionsdir", ".json") + if requires: manifest["clientPermissionFiles"] = requires + + return [manifest] + +fakeroot python do_configure_manifest() { + import os, json + + manifests = [] + + manifest_type = d.getVar("WEBOS_SYSTEM_BUS_MANIFEST_TYPE", True) + if manifest_type == "SERVICE": + manifests.extend(webos_configure_manifest_service(d)) + elif manifest_type == "APPLICATION": + manifests.extend(webos_configure_manifest_application(d)) + elif manifest_type == "PACKAGE": + manifests.extend(webos_configure_manifest_package(d)) + elif manifest_type == "PASS": + return + else: + webos_configure_manifest_warn(d, "Unrecognized manifest type %s" % manifest_type) + + if len(manifests) == 0: + webos_configure_manifest_warn(d, "No manifests were configured") + return + + man_dir = d.getVar("D", True) + d.getVar("webos_sysbus_manifestsdir", True) + if not os.path.exists(man_dir): + os.makedirs(man_dir) + + for manifest in manifests: + name = os.path.join(man_dir, manifest["id"] + ".manifest.json") + with open(name, "w+") as f: + json.dump(manifest, f, indent = 4, sort_keys = False) + f.write("\n") +} + +addtask configure_manifest after do_install do_configure_security before do_package diff --git a/meta/classes/webos_core_os_dep.bbclass b/meta/classes/webos_core_os_dep.bbclass new file mode 100644 index 0000000000..a48ab09c5d --- /dev/null +++ b/meta/classes/webos_core_os_dep.bbclass @@ -0,0 +1,8 @@ +# Copyright (c) 2012-2013 LG Electronics, Inc. +# +# webos_core_os_dep +# +# This class is to be inherited by the recipe for every component is dependent +# on the core OS at build time. +# + diff --git a/meta/classes/webos_daemon.bbclass b/meta/classes/webos_daemon.bbclass new file mode 100644 index 0000000000..412393f76d --- /dev/null +++ b/meta/classes/webos_daemon.bbclass @@ -0,0 +1,10 @@ +# Copyright (c) 2012-2013 LG Electronics, Inc. +# +# webos_daemon +# +# This class is to be inherited by the recipe for every component that installs +# a daemon. +# + +# We expect all daemons will use pkgconfig when building. +inherit webos_pkgconfig diff --git a/meta/classes/webos_distro_dep.bbclass b/meta/classes/webos_distro_dep.bbclass new file mode 100644 index 0000000000..e9952655d4 --- /dev/null +++ b/meta/classes/webos_distro_dep.bbclass @@ -0,0 +1,10 @@ +# Copyright (c) 2015 LG Electronics, Inc. +# +# webos_distro_dep +# +# This class is to be inherited by the recipe for every component that depends +# on DISTRO at build time. +# + +# Append this to EXTRA_OEMAKE to allow your makefile be DISTRO-dependent: +WEBOS_EXTRA_OEMAKE_DISTRO_DEP = "DISTRO=${DISTRO}" diff --git a/meta/classes/webos_distro_variant_dep.bbclass b/meta/classes/webos_distro_variant_dep.bbclass new file mode 100644 index 0000000000..0222708b4e --- /dev/null +++ b/meta/classes/webos_distro_variant_dep.bbclass @@ -0,0 +1,23 @@ +# Copyright (c) 2014-2018 LG Electronics, Inc. +# +# webos_distro_variant_dep +# +# This class is to be inherited by the recipe for every component that depends +# on WEBOS_TARGET_DISTRO_VARIANT or WEBOS_DISTRO_NAME_SUFFIX at build time. +# When different from the default ("normal"), WEBOS_TARGET_DISTRO_VARIANT is +# set in MACHINE.conf and WEBOS_DISTRO_NAME_SUFFIX is set in +# distro/include/<DISTRO>-<WEBOS_TARGET_DISTRO_VARIANT>.inc . +# +# Inheriting this class arranges for two overrides to be added that are selected +# ahead of "<DISTRO>": +# - "distrovariant-<WEBOS_TARGET_DISTRO_VARIANT>", which is meant to be used when +# an override applies to all DISTRO-s that have a particular variant. +# - "<DISTRO>-<WEBOS_TARGET_DISTRO_VARIANT>", which is meant to be used when an +# override applies to a particular DISTRO with that variant. +# +# "distrovariant-<WEBOS_TARGET_DISTRO_VARIANT>" is selected ahead of +# "<DISTRO>-<WEBOS_TARGET_DISTRO_VARIANT>". + + +# Append this to EXTRA_OEMAKE to allow your makefile be distro variant-dependent: +WEBOS_EXTRA_OEMAKE_DISTRO_VARIANT_DEP = "WEBOS_TARGET_DISTRO_VARIANT=${WEBOS_TARGET_DISTRO_VARIANT}" diff --git a/meta/classes/webos_enhanced_submissions.bbclass b/meta/classes/webos_enhanced_submissions.bbclass new file mode 100644 index 0000000000..e4ad2b856d --- /dev/null +++ b/meta/classes/webos_enhanced_submissions.bbclass @@ -0,0 +1,309 @@ +# Copyright (c) 2012-2018 LG Electronics, Inc. +# +# webos_enhanced_submissions +# +# Parse a WEBOS_VERSION in the following format: +# +# <component-version>-<enhanced-submission> +# +# where <enhanced-submission> is of the form: +# +# <submission>_<40-character-SHA-1>[;branch=<branch>] +# +# setting WEBOS_COMPONENT_VERSION, WEBOS_SUBMISSION, WEBOS_GIT_PARAM_TAG, +# WEBOS_GIT_TAG, WEBOS_GIT_PARAM_BRANCH, WEBOS_SRCREV, SRCREV, and PV. +# +# The default tag name is the webOS convention for submission tags, i.e., +# they are of the form: +# submissions/<decimal-integer> (default branch: "master") +# or, when the submission is from some permanent branch: +# submissions/<name>.<decimal-integer> (default branch: "@<name>") +# where <decimal-integer> does not contain leading zeros. +# +# <name> is the branch name without leading '@' and can have following forms: +# <decimal-integer> when the branch was created from submissions/<decimal-integer>. +# <decimal-integer>.<codename> when the branch was also created from +# submissions/<decimal-integer> tag, but for some specific <codename> release. +# <decimal-integer>.<codename>.<decimal-integer> is used for multiple levels of +# branched submissions, e.g. NN.<codename>.MM.PP is PP-th submission along the +# @NN.<codename>.MM branch. +# +# The default branch name value can be overriden by "branch" parameter in WEBOS_VERSION +# or by setting WEBOS_GIT_PARAM_BRANCH. +# +# The default tag name can be overriden by setting WEBOS_GIT_PARAM_TAG. +# +# WEBOS_SUBMISSION '0' has special meaning to disable check +# that selected SHA-1 is matching with submissions tag +# +# There is limited support for recipes with multiple git repositories in SRC_URI. +# Exactly one of them needs to have empty 'name' parameter or 'name' parameter with +# value 'main' and this one will get SRCREV set and verified by this bbclass. + +inherit webos_submissions + +def webos_enhsub_get_srcrev(d, webos_v): + webos_srcrev = webos_version_get_srcrev(webos_v) + webos_submission = d.getVar('WEBOS_SUBMISSION', True) + # submission 0 means that we're using: + # a) AUTOREV + # b) SHA-1 possibly not included in any tag or branch + # c) something else (like reference to a Gerrit review) + # + # a) and b) should be set in SRCREV + # c) should be set in WEBOS_GIT_PARAM_TAG with WEBOS_GIT_TAG enabled and let git ls-remote resolve it + # Another way to handle c) is to override WEBOS_GIT_TAG directly with ";tag=<ref>" + if webos_submission == '0': + # return only valid SRCREV or "AUTOINC", otherwise "INVALID" + if webos_srcrev == "AUTOINC" or not (len(webos_srcrev) != 40 or (False in [c in "abcdef0123456789" for c in webos_srcrev])): + return webos_srcrev + else: + return "INVALID" + if webos_srcrev == None or len(webos_srcrev) != 40 or (False in [c in "abcdef0123456789" for c in webos_srcrev]): + file = d.getVar('FILE', True) + webos_git_repo_tag = d.getVar('WEBOS_GIT_REPO_TAG', True) or "submissions/%s" % webos_submission + bb.fatal(("%s: WEBOS_VERSION needs to end with _<SHA-1> where " + + "<SHA-1> is the 40-character identifier of '%s' tag") + % (file, webos_git_repo_tag)) + # only valid SRCREVs at this point + return webos_srcrev + +def webos_enhsub_get_tag(d, webos_v): + webos_submission = d.getVar('WEBOS_SUBMISSION', True) + webos_git_repo_tag = d.getVar('WEBOS_GIT_REPO_TAG', True) or "submissions/%s" % webos_submission + return webos_git_repo_tag + +# Set WEBOS_SRCREV to value from WEBOS_VERSION. +WEBOS_SRCREV = "${@webos_enhsub_get_srcrev(d, '${WEBOS_VERSION}')}" + +# we don't include SRCPV in PV, so we have to manually include SRCREVs in do_fetch vardeps +do_fetch[vardeps] += "SRCREV_main SRCREV" +SRCREV = "${WEBOS_SRCREV}" +SRCREV_main = "${WEBOS_SRCREV}" + +# append WEBOS_PV_SUFFIX to PV when you're using 0 as WEBOS_SUBMISSION to make it clear which SHA-1 was built +WEBOS_PV_SUFFIX = "+gitr${SRCPV}" + +# srcrev is mandatory and enough, don't put tag= in SRC_URI +# to reenable you need to set WEBOS_GIT_TAG to ";tag=${WEBOS_GIT_PARAM_TAG}" +WEBOS_GIT_PARAM_TAG = "${@webos_enhsub_get_tag(d, '${WEBOS_VERSION}')}" +WEBOS_GIT_TAG = "" + +WEBOS_GIT_PARAM_BRANCH = "${@webos_version_get_branch('${WEBOS_VERSION}')}" + +# When SRCREV isn't SHA-1 show error +do_fetch[prefuncs] += "webos_enhsub_srcrev_sanity_check" + +# '0' in 'webos_submission' is used with AUTOREV or SHA-1 without matching tag +# show non-fatal ERROR to make sure that it's not accidentally merged in master +python webos_enhsub_srcrev_sanity_check() { + srcrev = d.getVar('SRCREV', True) + webos_submission = d.getVar('WEBOS_SUBMISSION', True) + if webos_submission == '0': + webos_version = d.getVar('WEBOS_VERSION', True) + pn = d.getVar('PN', True) + file = d.getVar('FILE', True) + msg = "WEBOS_VERSION '%s' for recipe '%s' (file '%s') contains submission 0, which indicates using AUTOREV or SHA-1 without matching tag and cannot be used in official builds." % (webos_version, pn, file) + package_qa_handle_error("webos-enh-sub-autorev-error", msg, d) + elif (len(srcrev) != 40 or (False in [c in "abcdef0123456789" for c in srcrev])): + file = d.getVar('FILE', True) + bb.error("%s: SRCREV needs to contain 40-character SHA1" % file) +} + +# When both SRCREV and WEBOS_SUBMISSION are defined check that they correspond +# This only compares tag and SHA-1 in local checkout (without using git ls-remote) +# This check is executed only when do_fetch is executed, that means that if someone +# moves the tag in remote repository, we won't notice it until do_fetch is re-executed. +do_unpack[postfuncs] += "submission_sanity_check" +python submission_sanity_check() { + def webos_enhsub_remote_update(d, u, pn, checkout): + """ Runs git remote update to fetch newly added tags or updated branches in case one of the checks fails + It runs git remote update twice, first in DL_DIR (e.g. downloads/git2/github.com.openwebos.librolegen/) + then in actuall checkout in WORKDIR, because we're already in do_unpack task and sanity checks are + executed in WORKDIR. + This isn't as efficient as the implementation in newer bitbake, because PREMIRROR tarballs aren't + recreated after this git remote update, so local builds will fetch the tarball and also run own + git remote update until PREMIRROR tarball is updated by fetching even newer SRCREV. + """ + bb.debug(2, "Running git remote update for pn '%s', checkout '%s'" % (pn, checkout)) + fetcher = bb.fetch2.Fetch([u], d) + localpath = fetcher.localpath(u) + bb.warn("Fetcher accessing the network, because sanity check failed %s, %s" % (u, localpath)) + cmd = "cd %s && git remote update" % (localpath) + try: + output = bb.fetch.runfetchcmd(cmd, d, quiet=True) + except bb.fetch2.FetchError: + msg = "Unable to update '%s' checkout for recipe '%s'" % (localpath, pn) + package_qa_handle_error("webos-enh-sub-error", msg, d) + # and the same in WORKDIR + cmd = "cd %s && git remote update" % (checkout) + try: + output = bb.fetch.runfetchcmd(cmd, d, quiet=True) + except bb.fetch2.FetchError: + msg = "Unable to update '%s' checkout for recipe '%s'" % (checkout, pn) + package_qa_handle_error("webos-enh-sub-error", msg, d) + + + def webos_enhsub_tag_sanity_check(d, fetcher, u, pn, tag_param, rev, webos_git_repo_tag, checkout, file, first=True): + """ Checks that tag: + 1) exists + 2) is annotated (not lightweight) + 3) uniq + 4) matches with selected SRCREV + """ + bb.debug(2, "sanity check for tag in pn '%s', tag_param '%s', rev '%s', webos_git_repo_tag '%s', checkout '%s'" % (pn, tag_param, rev, webos_git_repo_tag, checkout)) + cmd = "cd %s && git tag -l 2>/dev/null | grep '^%s$' | wc -l" % (checkout, webos_git_repo_tag) + tag_exists = bb.fetch.runfetchcmd(cmd, d).strip() + if tag_exists != "1": + if first: + webos_enhsub_remote_update(d, u, pn, checkout) + webos_enhsub_tag_sanity_check(d, fetcher, u, pn, tag_param, rev, webos_git_repo_tag, checkout, file, False) + return + else: + localpath = fetcher.localpath(u) + msg = "The tag '%s' for recipe '%s' (file '%s') doesn't exist in local checkout of SHA-1 '%s'. It's possible that the tag already exists in a remote repository, but your local checkout (or checkout downloaded as a tarball from PREMIRROR) contains the requested SHA-1 without a tag assigned to it (this cannot happen with annotated tags, because they have their own SHA-1 which either exists or not). Please update your checkout in %s by executing git fetch --tags and run again." % (webos_git_repo_tag, pn, file, rev, localpath) + package_qa_handle_error("webos-enh-sub-error", msg, d) + return + # for annotated tags there are 2 SHA-1s and we don't care which one is used (same source) + # $ git show-ref -d --tags 0.5 + # 70fb05fd340ab342c5132dc8bfa174dbe6c9d330 refs/tags/0.5 + # 215f9c884d0139c93feea940d255dc3575678218 refs/tags/0.5^{} + # prefix with 'refs/tags/' so that partial tags aren't matched, e.g. librolegen: + # $ git show-ref -d --tags 18 + # cbedc69733f65cd2f498787a621c014e219d38ab refs/tags/submissions/18 + # 9040954a24115b05219e7dd459dcf91ad05cc739 refs/tags/submissions/18^{} + # $ git show-ref -d --tags refs/tags/18 + # <nothing> + cmd = "cd %s && git show-ref -d --tags refs/tags/%s" % (checkout, webos_git_repo_tag) + tag_srcrevs = bb.fetch.runfetchcmd(cmd, d).strip().split('\n') + found_srcrev = False + if len(tag_srcrevs) > 2: + msg = "The reference refs/tags/%s is matching more than 2 entries for recipe '%s' (file '%s'):\n%s" % (webos_git_repo_tag, pn, file, '\n'.join(tag_srcrevs)) + package_qa_handle_error("webos-enh-sub-error", msg, d) + if len(tag_srcrevs) == 1: + if first: + webos_enhsub_remote_update(d, u, pn, checkout) + webos_enhsub_tag_sanity_check(d, fetcher, u, pn, tag_param, rev, webos_git_repo_tag, checkout, file, False) + return + else: + msg = "The tag '%s' for recipe '%s' (file '%s') is lightweight tag, please use annotated tag in next submission" % (webos_git_repo_tag, pn, file) + package_qa_handle_error("webos-enh-sub-error", msg, d) + for tag_srcrev in tag_srcrevs: + (sha, name) = tag_srcrev.split() + if sha == rev: + found_srcrev = True + if tag_srcrev != tag_srcrevs[0] or tag_srcrev.find("^{}") == len(tag_srcrev) - 3: + msg = "The tag '%s' for recipe '%s' (file '%s') is annotated, but WEBOS_VERSION '%s' is using SHA-1 of last commit included, not of the tag itself '%s'" % (webos_git_repo_tag, pn, file, webos_version, tag_srcrevs[0].split()[0]) + package_qa_handle_error("webos-enh-sub-error", msg, d) + + if not found_srcrev: + if first: + webos_enhsub_remote_update(d, u, pn, checkout) + webos_enhsub_tag_sanity_check(d, fetcher, u, pn, tag_param, rev, webos_git_repo_tag, checkout, file, False) + return + else: + if len(tag_srcrevs) < 1: + msg = "The SHA-1 '%s' defined in WEBOS_VERSION for recipe '%s' (file '%s') doesn't match with tag '%s', tag couldn't be found in refs/tags/" % (rev, pn, file, webos_git_repo_tag) + package_qa_handle_error("webos-enh-sub-error", msg, d) + elif len(tag_srcrevs) == 1: + msg = "The SHA-1 '%s' defined in WEBOS_VERSION for recipe '%s' (file '%s') doesn't match with tag '%s', which is seen as SHA-1 '%s'" % (rev, pn, file, webos_git_repo_tag, tag_srcrevs[0].split()[0]) + package_qa_handle_error("webos-enh-sub-error", msg, d) + else: + msg = "The SHA-1 '%s' defined in WEBOS_VERSION for recipe '%s' (file '%s') doesn't match with tag '%s', which is seen as SHA-1s:\n%s" % (rev, pn, file, webos_git_repo_tag, '\n'.join(tag_srcrevs)) + package_qa_handle_error("webos-enh-sub-error", msg, d) + + def webos_enhsub_branch_sanity_check(d, u, fetcher, branch_in_webos_version, branch_in_src_uri, pn, file, checkout, rev, first=True): + """ Checks that selected SRCREV is included in selected branch + duplicates bitbake's git fetcher functionality added in + http://git.openembedded.org/bitbake/commit/?id=89abfbc1953e3711d6c90aff793ee622c22609b1 + http://git.openembedded.org/bitbake/commit/?id=31467c0afe0346502fcd18bd376f23ea76a27d61 + http://git.openembedded.org/bitbake/commit/?id=f594cb9f5a18dd0ab2342f96ffc6dba697b35f65 + """ + bb.debug(2, "sanity check for branch in pn '%s', branch_in_webos_version '%s', branch_in_src_uri '%s', rev '%s', checkout '%s'" % (pn, branch_in_webos_version, branch_in_src_uri, rev, checkout)) + if branch_in_src_uri != branch_in_webos_version: + msg = "Branch is set in WEBOS_VERSION '%s' for recipe '%s' (file '%s') as well as in SRC_URI '%s' and they don't match" % (branch_in_webos_version, pn, file, branch_in_src_uri) + package_qa_handle_error("webos-enh-sub-error", msg, d) + cmd = "cd %s && git branch -a --contains %s --list origin/%s 2> /dev/null | wc -l" % (checkout, rev, branch_in_webos_version) + try: + output = bb.fetch.runfetchcmd(cmd, d, quiet=True) + except bb.fetch2.FetchError: + msg = "Unable to check if SHA-1 '%s' defined in WEBOS_VERSION for recipe '%s' (file '%s') is included in branch '%s'" % (rev, pn, file, branch) + package_qa_handle_error("webos-enh-sub-error", msg, d) + if len(output.split()) > 1: + msg = "Unable to check if SHA-1 '%s' defined in WEBOS_VERSION for recipe '%s' (file '%s') is included in branch '%s', unexpected output from '%s': '%s'" % (rev, pn, file, branch_in_webos_version, cmd, output) + package_qa_handle_error("webos-enh-sub-error", msg, d) + if output.split()[0] == "0": + if first: + webos_enhsub_remote_update(d, u, pn, checkout) + webos_enhsub_branch_sanity_check(d, u, fetcher, branch_in_webos_version, branch_in_src_uri, pn, file, checkout, rev, False) + return + else: + msg = "Revision '%s' defined in WEBOS_VERSION for recipe '%s' (file '%s') isn't included in branch '%s'" % (rev, pn, file, branch_in_webos_version) + package_qa_handle_error("webos-enh-sub-error", msg, d) + + src_uri = (d.getVar('SRC_URI', True) or "").split() + if len(src_uri) == 0: + return + + externalsrc = d.getVar('EXTERNALSRC', True) or "" + if len(externalsrc) != 0: + return + + found_first = False + workdir = d.getVar('WORKDIR', True) + pn = d.getVar('PN', True) + file = d.getVar('FILE', True) + fetcher = bb.fetch.Fetch(src_uri, d) + urldata = fetcher.ud + autoinc_templ = 'AUTOINC+' + for u in urldata: + tag_param = urldata[u].parm['tag'] if 'tag' in urldata[u].parm else None + name_param = urldata[u].parm['name'] if 'name' in urldata[u].parm else 'main' + if urldata[u].type == 'git' and name_param == 'main': + if found_first: + msg = "webos_enhanced_submission bbclass has limited support for recipes with multiple git repos in SRC_URI. They have to have different 'name' parameter and the one which points to repository with submissions tag should have 'name=main'. Recipe '%s' (file '%s') has multiple git repos with 'main' name or without names" % (pn, file) + package_qa_handle_error("webos-enh-sub-warning", msg, d) + break + found_first = True + destsuffix_param = urldata[u].parm['destsuffix'] if 'destsuffix' in urldata[u].parm else 'git' + webos_version = d.getVar('WEBOS_VERSION', True) + srcrev = d.getVar('SRCREV', True) + name = urldata[u].parm['name'] if 'name' in urldata[u].parm else 'default' + try: + rev = urldata[u].method.sortable_revision(urldata[u], d, name) + except TypeError: + # support old bitbake versions + rev = urldata[u].method.sortable_revision(u, urldata[u], d, name) + # Clean this up when we next bump bitbake version + if type(rev) != str: + autoinc, rev = rev + elif rev.startswith(autoinc_templ): + rev = rev[len(autoinc_templ):] + + webos_git_repo_tag = d.getVar('WEBOS_GIT_REPO_TAG', True) + webos_submission = d.getVar('WEBOS_SUBMISSION', True) + default_webos_git_repo_tag = "submissions/%s" % webos_submission + if not srcrev: + # Recipe needs to have SRCREV set one way or another + # it could be in WEBOS_VERSION, from AUTOREV or by explicit SRCREV assignment + msg = "Recipe '%s' (file '%s') doesn't contain SRCREV" % (pn, file) + package_qa_handle_error("webos-enh-sub-error", msg, d) + if not webos_git_repo_tag: + webos_git_repo_tag = default_webos_git_repo_tag + elif webos_git_repo_tag == default_webos_git_repo_tag: + msg = "Don't set WEBOS_GIT_REPO_TAG when the component is using default scheme 'submissions/${WEBOS_SUBMISSION}' in recipe '%s' (file '%s')" % (pn, file) + package_qa_handle_error("webos-enh-sub-error", msg, d) + checkout = "%s/%s" % (workdir, destsuffix_param) + + # '0' in 'webos_submission' is used with AUTOREV -> so don't check AUTOREV against submissions/0 tag + if webos_submission != '0' and webos_git_repo_tag and rev: + webos_enhsub_tag_sanity_check(d, fetcher, u, pn, tag_param, rev, webos_git_repo_tag, checkout, file) + + if not 'nobranch' in urldata[u].parm or urldata[u].parm['nobranch'] != "1": + branch_in_src_uri = urldata[u].parm['branch'] if 'branch' in urldata[u].parm else 'master' + branch_in_webos_version = d.getVar('WEBOS_GIT_PARAM_BRANCH', True) + webos_enhsub_branch_sanity_check(d, u, fetcher, branch_in_webos_version, branch_in_src_uri, pn, file, checkout, rev) + if not found_first: + msg = "Recipe '%s' (file '%s') doesn't have git repository without 'name' parameter or with 'name=main' in SRC_URI, webos_enhanced_submission bbclass shouldn't be inherited here (it has nothing to do)" % (pn, file) + package_qa_handle_error("webos-enh-sub-warning", msg, d) +} diff --git a/meta/classes/webos_filesystem_paths.bbclass b/meta/classes/webos_filesystem_paths.bbclass new file mode 100644 index 0000000000..b8865f5b08 --- /dev/null +++ b/meta/classes/webos_filesystem_paths.bbclass @@ -0,0 +1,162 @@ +# Copyright (c) 2012-2018 LG Electronics, Inc. + +# +# Variables invented by webOS for standard locations +# + +webos_bootdir = "${base_prefix}/boot" +webos_browserpluginsdir = "${libdir}/BrowserPlugins" +webos_defaultconfdir = "${sysconfdir}/default" +webos_execstatedir = "${localstatedir}/lib" +webos_fontsdir = "${datadir}/fonts" +webos_homedir = "${base_prefix}/home" +webos_firmwaredir = "${base_libdir}/firmware" +webos_logdir = "${localstatedir}/log" +webos_mediadir = "${base_prefix}/media" +webos_mntdir = "${base_prefix}/mnt" +# Discourage use of ${libdir}/pkgconfig by not providing a variable for it. +webos_pkgconfigdir = "${datadir}/pkgconfig" +webos_preservedtmpdir = "${localstatedir}/tmp" +# Having a Qt plugins directory is standard, but the value used by webOS OSE isn't. +webos_qtpluginsdir = "${libdir}/qt5/plugins" +webos_runtimeinfodir = "${localstatedir}/run" +webos_srcdir = "${prefix}/src" +webos_udevscriptsdir = "${base_libdir}/udev" +webos_upstartconfdir = "${sysconfdir}/event.d" + + +# +# Variables for webOS additions to the filesystem hierarchy +# + +# Increment this every time values for the variables below change. But +# don't increment if merely adding a new variable for an existing location. +WEBOS_FILESYSTEM_LAYOUT_VERSION = "1" + +webos_prefix = "${prefix}/palm" +webos_localstatedir = "${localstatedir}/palm" +webos_sysconfdir = "${sysconfdir}/palm" + +# The /palm/ subdirectories have been deliberately left as literals. +webos_accttemplatesdir = "${prefix}/palm/public/accounts" +# This is the location of webOS applications, both JS and native. There is a +# subdirectory tree for each application that is named using its complete name. +webos_applicationsdir = "${prefix}/palm/applications" +webos_frameworksdir = "${prefix}/palm/frameworks" +webos_keysdir = "${prefix}/palm/data" +# This is the location of the pre-installed catalog apps IPKs +webos_picapkgdir = "${webos_mntdir}/pica" +# This is the location of webOS application plugins. There is a subdirectory for +# each application that is named using the final field of its complete name. +webos_pluginsdir = "${prefix}/palm/plugins" +# This is the location of the trees for JS services; the files for native (dynamic) +# services are located under sbindir, libdir, etc. as if they were Linux daemons. +webos_servicesdir = "${prefix}/palm/services" +webos_smartkeydatadir = "${prefix}/palm/smartkey" +webos_soundsdir = "${prefix}/palm/sounds" +webos_sysmgrdir = "${prefix}/palm/sysmgr" + +# Note that everything under localstatedir is erased by a NYX_SYSTEM_ERASE_VAR +# erasure. +webos_db8datadir = "${localstatedir}/db" +webos_filecachedir = "${localstatedir}/file-cache" +webos_preferencesdir = "${localstatedir}/preferences" + +webos_sysbus_prefix = "${datadir}" +webos_sysbus_datadir = "${webos_sysbus_prefix}/luna-service2" +webos_sysbus_dyndatadir = "${localstatedir}/luna-service2" +webos_sysbus_devdatadir = "${localstatedir}/luna-service2-dev" +webos_sysbus_apipermissionsdir = "${webos_sysbus_datadir}/api-permissions.d" +webos_sysbus_dynapipermissionsdir = "${webos_sysbus_dyndatadir}/api-permissions.d" +webos_sysbus_devapipermissionsdir = "${webos_sysbus_devdatadir}/api-permissions.d" +webos_sysbus_containersdir = "${webos_sysbus_datadir}/containers.d" +webos_sysbus_permissionsdir = "${webos_sysbus_datadir}/client-permissions.d" +webos_sysbus_dynpermissionsdir = "${webos_sysbus_dyndatadir}/client-permissions.d" +webos_sysbus_devpermissionsdir = "${webos_sysbus_devdatadir}/client-permissions.d" +webos_sysbus_rolesdir = "${webos_sysbus_datadir}/roles.d" +webos_sysbus_dynrolesdir = "${webos_sysbus_dyndatadir}/roles.d" +webos_sysbus_devrolesdir = "${webos_sysbus_devdatadir}/roles.d" +webos_sysbus_servicedir = "${webos_sysbus_datadir}/services.d" +webos_sysbus_dynservicedir = "${webos_sysbus_dyndatadir}/services.d" +webos_sysbus_devservicesdir = "${webos_sysbus_devdatadir}/services.d" +webos_sysbus_manifestsdir = "${webos_sysbus_datadir}/manifests.d" +webos_sysbus_dynmanifestsdir = "${webos_sysbus_dyndatadir}/manifests.d" +webos_sysbus_devmanifestsdir = "${webos_sysbus_devdatadir}/manifests.d" +webos_sysbus_groupsdir = "${webos_sysbus_datadir}/groups.d" + +# Legacy sysbus locations +webos_sysbus_pubservicesdir = "${webos_sysbus_prefix}/dbus-1/services" +webos_sysbus_prvservicesdir = "${webos_sysbus_prefix}/dbus-1/system-services" +webos_sysbus_pubrolesdir = "${webos_sysbus_prefix}/ls2/roles/pub" +webos_sysbus_prvrolesdir = "${webos_sysbus_prefix}/ls2/roles/prv" +webos_sysbus_dynpubservicesdir = "${localstatedir}/palm/ls2/services/pub" +webos_sysbus_dynprvservicesdir = "${localstatedir}/palm/ls2/services/prv" +webos_sysbus_dynpubrolesdir = "${localstatedir}/palm/ls2/roles/pub" +webos_sysbus_dynprvrolesdir = "${localstatedir}/palm/ls2/roles/prv" +webos_sysbus_devpubservicesdir = "${localstatedir}/palm/ls2-dev/services/pub" +webos_sysbus_devprvservicesdir = "${localstatedir}/palm/ls2-dev/services/prv" +webos_sysbus_devpubrolesdir = "${localstatedir}/palm/ls2-dev/roles/pub" +webos_sysbus_devprvrolesdir = "${localstatedir}/palm/ls2-dev/roles/prv" + +webos_sysmgr_datadir = "${libdir}/luna" +webos_sysmgr_localstatedir = "${localstatedir}/luna" + +webos_cryptofsdir = "${webos_mediadir}/cryptofs" + +# Everything under this tree is erased by a NYX_SYSTEM_ERASE_VAR erasure. +webos_browserstoragedir = "${webos_cryptofsdir}/.browser" + +# This is the tree for components downloaded from the app catalog; everything +# under this tree is erased by a NYX_SYSTEM_ERASE_VAR erasure. +webos_downloadeddir = "${webos_cryptofsdir}/apps" +# The old name for webos_downloadeddir +webos_appstoragedir = "${webos_downloadeddir}" +webos_downloaded_applicationsdir = "${webos_downloadeddir}/usr/palm/applications" +# The old name for webos_downloaded_applicationsdir +webos_installedappsdir = "${webos_downloaded_applicationsdir}" +webos_downloaded_frameworksdir = "${webos_downloadeddir}/usr/palm/frameworks" +webos_downloaded_pluginsdir = "${webos_downloadeddir}/usr/palm/plugins" +webos_downloaded_servicesdir = "${webos_downloadeddir}/usr/palm/services" + +# The specs for webos_execstatedir apply to this location with the additional +# constraint that everything under this tree persists a NYX_SYSTEM_ERASE_VAR +# erasure. It is only deleted by a NYX_SYSTEM_ERASE_ALL erasure. +webos_persistentstoragedir = "${webos_cryptofsdir}/data" + +# db8 database use this directory to store mediadb database. +# mediadb database store results of fileindexer and contain information +# about media files. Potentially this db can be big +webos_db8mediadir = "${webos_persistentstoragedir}/db8/mediadb" + +# On devices that support it, this tree is externally mountable as (USB) mass +# storage. Applications that want their data to be visible in this manner should +# store them here instead of under webos_persistentstoragedir. This tree is +# erased by NYX_SYSTEM_ERASE_MEDIA. +webos_mountablestoragedir = "${webos_mediadir}/internal" +# The old name for webos_mountablestoragedir +webos_localstoragedir = "${webos_mountablestoragedir}" + +# This is the root of the tree that is accessible to developers who log into a +# device with ssh when it is in developer mode. It is where their side-loaded +# (webOS and native) apps will be installed for debugging. Everything +# under this tree is erased by a NYX_SYSTEM_ERASE_DEVELOPER erasure. +webos_developerdir = "${webos_mediadir}/developer" + +# Unit test executables and other test scripts or executables are installed, +# if at all, under ${webos_testsdir}/${PN} +webos_testsdir = "/opt/webos/tests" + +# This tree contains subdirectories of various types of customization data +webos_customizationdir = "${prefix}/palm/customization" + +# This directory is shared by the emulator for network mounting by its host OS +webos_emulatorshareddir = "${webos_mediadir}/shared" + +# The presence of this file indicates that First Use has been completed. +webos_firstusesentinelfile = "${webos_sysmgr_localstatedir}/preferences/ran-firstuse" + +# Note that everything under localstatedir is erased by a NYX_SYSTEM_ERASE_VAR erasure. +webos_crashddir = "${webos_logdir}/crashd" + +# Path to file which indicate failure to init settingsservice +webos_settingsservice_errorsentinelfile = "${webos_localstatedir}/settingsservice_critical_error" diff --git a/meta/classes/webos_fs_layout.bbclass b/meta/classes/webos_fs_layout.bbclass new file mode 100644 index 0000000000..d38e4bdc12 --- /dev/null +++ b/meta/classes/webos_fs_layout.bbclass @@ -0,0 +1,15 @@ +# Copyright (c) 2012-2013 LG Electronics, Inc. +# +# webos_fs_layout +# +# This class alters the filesystem layout to be root under /opt/webos. It is +# intended that this only be inherited by webos_component, webos_upstream_from_repo, +# and webos_upstream_with_patches. +# + +# XXX Not ready to activate this +#export base_prefix = "/opt/webos" +#export prefix = "/opt/webos/usr" +#export sysconfdir = "/opt/webos/etc" +#export localstatedir = "/opt/webos/var" +#export servicedir = "/opt/webos/srv" diff --git a/meta/classes/webos_library.bbclass b/meta/classes/webos_library.bbclass new file mode 100644 index 0000000000..17df3d99ae --- /dev/null +++ b/meta/classes/webos_library.bbclass @@ -0,0 +1,11 @@ +# Copyright (c) 2012-2013 LG Electronics, Inc. +# +# webos_library +# +# This class is to be inherited by the recipe for every component that installs a +# library. +# + +# We expect all libraries will use pkgconfig when building and will install +# pkgconfig (.pc) files. +inherit webos_pkgconfig diff --git a/meta/classes/webos_lttng.bbclass b/meta/classes/webos_lttng.bbclass new file mode 100644 index 0000000000..b984135224 --- /dev/null +++ b/meta/classes/webos_lttng.bbclass @@ -0,0 +1,21 @@ +# Copyright (c) 2013 LG Electronics, Inc. +# +# webos_lttng +# +# This class is to be inherited by the recipe for any component that +# uses LTTng tracing. +# +# Each recipe is responsible for setting a compilation flag to enable +# its own LTTng tracepoints based on the value of WEBOS_LTTNG_ENABLED. + +# LTTng is disabled by default. To enable, add: +# WEBOS_LTTNG_ENABLED = "1" +# to your webos-local.conf or the location of your choice. +WEBOS_LTTNG_ENABLED ??= "0" +# Only enable LTTng for target components +WEBOS_LTTNG_ENABLED_class-native = "0" +WEBOS_LTTNG_ENABLED_class-nativesdk = "0" + +# Use _append so that WEBOS_LTTNG_ENABLED is evaluated during finalization so that the overrides effectual. +DEPENDS_append = "${@ ' lttng-ust' if '${WEBOS_LTTNG_ENABLED}' == '1' else ''}" +RDEPENDS_${PN}_append = "${@ ' lttng-tools lttng-modules babeltrace' if '${WEBOS_LTTNG_ENABLED}' == '1' else ''}" diff --git a/meta/classes/webos_machine_dep.bbclass b/meta/classes/webos_machine_dep.bbclass new file mode 100644 index 0000000000..edb5e47fdc --- /dev/null +++ b/meta/classes/webos_machine_dep.bbclass @@ -0,0 +1,19 @@ +# Copyright (c) 2012-2016 LG Electronics, Inc. +# +# webos_machine_dep +# +# This class is to be inherited by the recipe for every component that depends +# on MACHINE at build time. +# + +PACKAGE_ARCH = "${MACHINE_ARCH}" + +# Uncomment to allow all PACKAGE_ARCH-s variants to be built in the same tree. +# (Note that the OE 2011.03 bitbake.conf defines WORKDIR to effectively prepend +# "${PACKAGE_ARCH}-${TARGET_VENDOR}-${TARGET_OS}/" for all PACKAGE_ARCH-s, i.e. +# there are separate subdirectories instead of suffixes.) +# WORKDIR_append = "-${PACKAGE_ARCH}" + +# Append this to EXTRA_OEMAKE to allow your makefile be MACHINE-dependent: +WEBOS_MACHINE ?= "${MACHINE}" +WEBOS_EXTRA_OEMAKE_MACHINE_DEP = "MACHINE=${WEBOS_MACHINE}" diff --git a/meta/classes/webos_machine_impl_dep.bbclass b/meta/classes/webos_machine_impl_dep.bbclass new file mode 100644 index 0000000000..45017332de --- /dev/null +++ b/meta/classes/webos_machine_impl_dep.bbclass @@ -0,0 +1,19 @@ +# Copyright (c) 2012-2013 LG Electronics, Inc. +# +# webos_machine_impl_dep +# +# This class is to be inherited by the recipe for every component that depends +# on the "machine implementation" at build time. + +# If there are MACHINE-s with different "machine implementations" but with the +# same TUNE_PKGARCH, they will have the same package name unless PACKAGE_ARCH +# is set to MACHINE_ARCH. XXX Is there a better way to handle this? +PACKAGE_ARCH = "${MACHINE_ARCH}" + +# Allow the use of WEBOS_TARGET_MACHINE_IMPL overrides. It's checked after +# what's set by the machine architecture .inc file, which is checked after +# MACHINE. WEBOS_EXTRA_MACHINEOVERRIDES is deliberately assigned to and not +# appended to or prepended to so that the order of inherit statements will not +# affect the order of what's in MACHINEOVERRIDES. + +WEBOS_EXTRA_MACHINEOVERRIDES = "${WEBOS_TARGET_MACHINE_IMPL}:" diff --git a/meta/classes/webos_pkgconfig.bbclass b/meta/classes/webos_pkgconfig.bbclass new file mode 100644 index 0000000000..c408fc9a45 --- /dev/null +++ b/meta/classes/webos_pkgconfig.bbclass @@ -0,0 +1,11 @@ +# Copyright (c) 2012-2013 LG Electronics, Inc. +# +# webos_pkgconfig +# +# This class is to be inherited by the recipe for every component that uses +# pkgconfig when building or installs a pkgconfig (.pc) file. This usually +# happens implicitly by inheriting from webos_library, webos_program, +# or webos_daemon. +# + +inherit pkgconfig diff --git a/meta/classes/webos_pmlog_config.bbclass b/meta/classes/webos_pmlog_config.bbclass new file mode 100644 index 0000000000..e4e282afb2 --- /dev/null +++ b/meta/classes/webos_pmlog_config.bbclass @@ -0,0 +1,8 @@ +# Copyright (c) 2014 LG Electronics, Inc. +# +# webos_pmlog_config + +# This class is to be inherited by pmloglib and pmlogdaemon recipes +# + +EXTRA_OECMAKE += "-DENABLE_LOGGING:BOOL=YES" diff --git a/meta/classes/webos_prerelease_dep.bbclass b/meta/classes/webos_prerelease_dep.bbclass new file mode 100644 index 0000000000..59d4af3659 --- /dev/null +++ b/meta/classes/webos_prerelease_dep.bbclass @@ -0,0 +1,7 @@ +# Copyright (c) 2013 LG Electronics, Inc. +# +# webos_prerelease_dep +# +# This class is to be inherited by the recipe for every component that depends +# on WEBOS_DISTRO_PRERELEASE value at build time. +# diff --git a/meta/classes/webos_program.bbclass b/meta/classes/webos_program.bbclass new file mode 100644 index 0000000000..7320047f19 --- /dev/null +++ b/meta/classes/webos_program.bbclass @@ -0,0 +1,10 @@ +# Copyright (c) 2012-2013 LG Electronics, Inc. +# +# webos_program +# +# This class is to be inherited by the recipe for every component that installs +# a console program. +# + +# We expect all programs will use pkgconfig when building. +inherit webos_pkgconfig diff --git a/meta/classes/webos_public_repo.bbclass b/meta/classes/webos_public_repo.bbclass new file mode 100644 index 0000000000..1cd3597fad --- /dev/null +++ b/meta/classes/webos_public_repo.bbclass @@ -0,0 +1,19 @@ +# Copyright (c) 2012-2018 LG Electronics, Inc. +# +# webos_public_repo +# +# This class is to be inherited by the recipe for every component that has (or +# will have) a public webOS OSE repo. +# + +# The default repo name is the "base" component name (no -native, etc.) +WEBOS_REPO_NAME ??= "${BPN}" + +WEBOS_GIT_PARAM_BRANCH ?= "master" +WEBOS_GIT_BRANCH ?= ";branch=${WEBOS_GIT_PARAM_BRANCH}" +# Default is empty but webos_enhanced_submissions.bbclass will always set the value +WEBOS_GIT_PARAM_TAG ?= "" +WEBOS_GIT_TAG ?= ";tag=${WEBOS_GIT_PARAM_TAG}" + +WEBOSOSE_GIT_REPO ?= "git://github.com/webosose" +WEBOSOSE_GIT_REPO_COMPLETE ?= "${WEBOSOSE_GIT_REPO}/${WEBOS_REPO_NAME}${WEBOS_GIT_TAG}${WEBOS_GIT_BRANCH}" diff --git a/meta/classes/webos_qmake5.bbclass b/meta/classes/webos_qmake5.bbclass new file mode 100644 index 0000000000..38165a181f --- /dev/null +++ b/meta/classes/webos_qmake5.bbclass @@ -0,0 +1,78 @@ +# Copyright (c) 2013-2018 LG Electronics, Inc. + +inherit qmake5 +inherit webos_filesystem_paths + +# These are used in the luna-sysmgr recipe +export QT_CONFIGURE_PREFIX_PATH = "${OE_QMAKE_PATH_PREFIX}" +export QT_CONFIGURE_HEADERS_PATH = "${OE_QMAKE_PATH_QT_HEADERS}" +export QT_CONFIGURE_LIBRARIES_PATH = "${OE_QMAKE_PATH_LIBS}" +export QT_CONFIGURE_BINARIES_PATH = "${OE_QMAKE_PATH_EXTERNAL_HOST_BINS}" + +# This is used in the webappmanager recipes +export STAGING_INCDIR + +# Set webOS specific locations for .pr* files to access +EXTRA_QMAKEVARS_PRE += "\ + WEBOS_STAGING_INCDIR=${STAGING_INCDIR} \ +" +# Used by mkspecs/features/webos-variables.prf +EXTRA_QMAKEVARS_PRE += "\ + WEBOS_INSTALL_BINS=${bindir} \ + WEBOS_INSTALL_LIBS=${libdir} \ + WEBOS_INSTALL_HEADERS=${includedir}/ \ + WEBOS_INSTALL_QML=${OE_QMAKE_PATH_QML} \ + WEBOS_INSTALL_QTPLUGINSDIR=${webos_qtpluginsdir} \ + WEBOS_INSTALL_WEBOS_APPLICATIONSDIR=${webos_applicationsdir} \ + WEBOS_PREFERENCESDIR=${webos_preferencesdir} \ + WEBOS_INSTALL_ROOT=${base_prefix} \ +" +# webos-variables.prf is using default value of ${prefix}, but here we use ${OE_QMAKE_PATH_PREFIX} +EXTRA_QMAKEVARS_PRE += "\ + WEBOS_INSTALL_PREFIX=${OE_QMAKE_PATH_PREFIX} \ + WEBOS_INSTALL_DATADIR=${datadir} \ + WEBOS_INSTALL_SYSCONFDIR=${sysconfdir} \ + WEBOS_INSTALL_SYSBUS_DATADIR=${sysbus_datadir} \ + WEBOS_INSTALL_UPSTARTCONFDIR=${webos_upstartconfdir} \ +" +# webos-variables.prf is using default value of webos_sysbus_servicesdir +# but the rest of the system is using singular servicedir +# webosSet(WEBOS_INSTALL_SYSBUS_SERVICESDIR, $$(webos_sysbus_servicesdir), $$WEBOS_INSTALL_SYSBUS_DATADIR/services.d) +# meta-webos/classes/webos_filesystem_paths.bbclass:webos_sysbus_servicedir = "${webos_sysbus_datadir}/services.d" +# Set both here from webos_sysbus_servicedir until PLAT-9971 is fixed +EXTRA_QMAKEVARS_PRE += "\ + WEBOS_INSTALL_SYSBUS_SERVICEDIR=${webos_sysbus_servicedir} \ + WEBOS_INSTALL_SYSBUS_SERVICESDIR=${webos_sysbus_servicedir} \ + WEBOS_INSTALL_SYSBUS_PUBSERVICESDIR=${webos_sysbus_pubservicesdir} \ + WEBOS_INSTALL_SYSBUS_PRVSERVICESDIR=${webos_sysbus_prvservicesdir} \ + WEBOS_INSTALL_SYSBUS_ROLESDIR=${webos_sysbus_rolesdir} \ + WEBOS_INSTALL_SYSBUS_PUBROLESDIR=${webos_sysbus_pubrolesdir} \ + WEBOS_INSTALL_SYSBUS_PRVROLESDIR=${webos_sysbus_prvrolesdir} \ + WEBOS_INSTALL_SYSBUS_APIDIR=${webos_sysbus_apipermissionsdir} \ + WEBOS_INSTALL_SYSBUS_PERMDIR=${webos_sysbus_permissionsdir} \ + WEBOS_INSTALL_SYSBUS_GROUPDIR=${webos_sysbus_groupsdir} \ +" + +# this value is exported in do_configure, so that project file can select MACHINE_NAME +WEBOS_QMAKE_MACHINE_ACTUAL ?= "${MACHINE}" +WEBOS_QMAKE_MACHINE ?= "${WEBOS_QMAKE_MACHINE_ACTUAL}" +# this value is defined only for make through EXTRA_OEMAKE +WEBOS_QMAKE_TARGET ?= "" + +# add only when WEBOS_QMAKE_MACHINE is defined (by default it equals MACHINE) +EXPORT_WEBOS_QMAKE_MACHINE += "${@ 'export MACHINE=${WEBOS_QMAKE_MACHINE}' if d.getVar('WEBOS_QMAKE_MACHINE', True) != '' and bb.data.inherits_class('webos_machine_dep', d) and not bb.data.inherits_class('native', d) else '' }" +EXPORT_WEBOS_QMAKE_MACHINE[vardepvalue] = "${EXPORT_WEBOS_QMAKE_MACHINE}" + +# add only when WEBOS_QMAKE_TARGET is defined (by default it's empty) +EXPORT_WEBOS_QMAKE_TARGET = "${@ 'MACHINE=${WEBOS_QMAKE_TARGET}' if d.getVar('WEBOS_QMAKE_TARGET', True) != '' and bb.data.inherits_class('webos_machine_dep', d) and not bb.data.inherits_class('native', d) else '' }" +EXPORT_WEBOS_QMAKE_TARGET[vardepvalue] = "${EXPORT_WEBOS_QMAKE_TARGET}" + +EXTRA_OEMAKE += "${EXPORT_WEBOS_QMAKE_TARGET}" + +# Add the the native tool in the paths as some project require rcc +# to be available +WEBOS_EXTRA_PATH .= "${OE_QMAKE_PATH_EXTERNAL_HOST_BINS}:" + +do_configure_prepend() { + ${EXPORT_WEBOS_QMAKE_MACHINE} +} diff --git a/meta/classes/webos_qmllint.bbclass b/meta/classes/webos_qmllint.bbclass new file mode 100644 index 0000000000..7e19305e3d --- /dev/null +++ b/meta/classes/webos_qmllint.bbclass @@ -0,0 +1,31 @@ +# Copyright (c) 2017 LG Electronics, Inc. +# +# QML syntax verifier +# + +DEPENDS_append = " qtdeclarative-native libxml2-native" + +inherit qmake5_paths + +do_compile_prepend () { + bbnote "Verify QML syntax(step 1): .qml or .js files stored as qresource" + find ${S} -type f -name "*.qrc" | while read qrc; do + local _dirname_=$(dirname $qrc) + ${STAGING_BINDIR_NATIVE}/xmllint --xpath '//RCC/qresource/file' $qrc | sed 's/<file>//g' | sed 's/<\/file>/\n/g' | grep -E "*.qml$|*.js$" | while read file; do + if [ -f "$_dirname_/$file" ]; then + bbnote "Inspecting $_dirname_/$file" + ${STAGING_DIR_NATIVE}${OE_QMAKE_PATH_QT_BINS}/qmllint "$_dirname_/$file" + fi + done + done + bbnote "Done verifying QML syntax(step 1), no errors detected" +} + +do_install_append () { + bbnote "Verify QML syntax(step 2): .qml or .js files to be installed" + find ${D} -type f -name "*.qml" -o -name "*.js" | while read file; do + bbnote "Inspecting $file" + ${STAGING_DIR_NATIVE}${OE_QMAKE_PATH_QT_BINS}/qmllint "$file" + done + bbnote "Done verifying QML syntax(step 2), no errors detected" +} diff --git a/meta/classes/webos_submissions.bbclass b/meta/classes/webos_submissions.bbclass new file mode 100644 index 0000000000..1a77c54aec --- /dev/null +++ b/meta/classes/webos_submissions.bbclass @@ -0,0 +1,36 @@ +# Copyright (c) 2012-2013 LG Electronics, Inc. +# +# webos_submissions +# +# Parse a WEBOS_VERSION in the following format: +# +# <component-version>-<submission> +# +# setting WEBOS_COMPONENT_VERSION, WEBOS_SUBMISSION, and PV. +# + +inherit webos_version + +# When WEBOS_VERSION isn't defined show error +do_fetch[prefuncs] += "webos_submissions_version_sanity_check" + +python webos_submissions_version_sanity_check() { + webos_version = d.getVar('WEBOS_VERSION', True) + webos_component_version = d.getVar('WEBOS_COMPONENT_VERSION', True) + pv = d.getVar('PV', True) + file = d.getVar('FILE', True) + src_uri = d.getVar('SRC_URI', True) + if not webos_version or webos_version == '0': + bb.fatal("%s: WEBOS_VERSION needs to be defined for recipes inheriting webos_submissions or webos_enhanced_submissions" % file) + if not webos_component_version or webos_component_version == '0': + bb.fatal("%s: WEBOS_VERSION needs contain WEBOS_COMPONENT_VERSION different from '0'" % file) + if not pv or pv == '0': + bb.fatal("%s: WEBOS_VERSION needs contain PV different from '0'" % file) + if src_uri.find('git://') != -1 and not bb.data.inherits_class('webos_enhanced_submissions', d): + bb.fatal("%s: inherit webos_enhanced_submissions when the recipe uses git:// in SRC_URI" % file) +} + +WEBOS_VERSION ?= "0" +PV = "${@webos_version_get_pv('${WEBOS_VERSION}')}" +WEBOS_COMPONENT_VERSION = "${@webos_version_get_component_version('${WEBOS_VERSION}')}" +WEBOS_SUBMISSION = "${@webos_version_get_submission('${WEBOS_VERSION}')}" diff --git a/meta/classes/webos_system_bus.bbclass b/meta/classes/webos_system_bus.bbclass new file mode 100644 index 0000000000..7cfca3f559 --- /dev/null +++ b/meta/classes/webos_system_bus.bbclass @@ -0,0 +1,100 @@ +# Copyright (c) 2012-2018 LG Electronics, Inc. +# +# webos_system_bus + +# This class is to be inherited by the recipe for every component that offers +# Luna System Bus services. +# +# Variables that control this bbclass's behavior: +# +# WEBOS_SYSTEM_BUS_FILES_LOCATION +# - The location of the system bus files to be installed. Defaults to +# ${S}/service. Set to "" to skip. +# +# WEBOS_SYSTEM_BUS_SKIP_DO_TASKS +# - If "1", all do_*() tasks or additions to them defined in this bbclass are +# skipped. +# + +inherit webos_configure_manifest +inherit webos_filesystem_paths + +webos_system_bus_install_files () { + local _LS_PRV_DIR="${D}$1" # destination directory for private hub files + local _LS_PUB_DIR="${D}$2" # destination directory for public hub files + local _LS_PRV_FILE="$3" # match string for private hub files + local _LS_PUB_FILE="$4" # match string for public hub files + local _LS_TREE="$5" # tree under which to search for the files + local i + + _LS_PUB=`find $_LS_TREE -name "$_LS_PUB_FILE"` + _LS_PRV=`find $_LS_TREE -name "$_LS_PRV_FILE"` + + if [ ${#_LS_PUB[@]} -ne 0 ]; then + install -d $_LS_PUB_DIR + fi + + for i in $_LS_PUB; do + _LS_PUB_DEST=`basename $i .pub` + bbnote "PUBLIC: $_LS_PUB_DIR/$_LS_PUB_DEST" + install -v -m 0644 $i $_LS_PUB_DIR/$_LS_PUB_DEST + done + + if [ ${#_LS_PRV[@]} -ne 0 ]; then + install -d $_LS_PRV_DIR + fi + + for i in $_LS_PRV; do + _LS_PRV_DEST=`basename $i .prv` + bbnote "PRIVATE: $_LS_PRV_DIR/$_LS_PRV_DEST" + install -v -m 0644 $i $_LS_PRV_DIR/$_LS_PRV_DEST + done +} + +# - Can't assume our current directory is still ${S} +# - Default to the pre webOS OSE location (because it's intended everything in +# webOS OSE is not require installation by the recipe). +WEBOS_SYSTEM_BUS_FILES_LOCATION ?= "${S}/service" + +do_install_append () { + # Only want WEBOS_SYSTEM_BUS_SKIP_DO_TASKS to be expanded by bitbake => single quotes + if [ '${WEBOS_SYSTEM_BUS_SKIP_DO_TASKS}' != 1 ]; then + local tree=${WEBOS_SYSTEM_BUS_FILES_LOCATION} + + if [ -n "$tree" -a -d "$tree" ]; then + webos_system_bus_install_files ${webos_sysbus_prvservicesdir} ${webos_sysbus_pubservicesdir} "*.service.prv" "*.service.pub" "$tree" + webos_system_bus_install_files ${webos_sysbus_prvrolesdir} ${webos_sysbus_pubrolesdir} "*.json.prv" "*.json.pub" "$tree" + + # If the files don't have .prv/.pub suffixes, then the same file is meant to be used for both (and there's no suffix to be removed) + webos_system_bus_install_files ${webos_sysbus_prvservicesdir} ${webos_sysbus_pubservicesdir} "*.service" "*.service" "$tree" + webos_system_bus_install_files ${webos_sysbus_prvrolesdir} ${webos_sysbus_pubrolesdir} "*.json" "*.json" "$tree" + + bbwarn "$pkgname: Installing roles and services files from bitbake is deprecated - use cmake, qmake, etc." + fi + fi +} + +WEBOS_SYSTEM_BUS_DIRS_LEGACY += " \ + ${webos_sysbus_prvservicesdir} \ + ${webos_sysbus_pubservicesdir} \ + ${webos_sysbus_prvrolesdir} \ + ${webos_sysbus_pubrolesdir} \ +" + +WEBOS_SYSTEM_BUS_DIRS += " \ + ${webos_sysbus_rolesdir} \ + ${webos_sysbus_servicedir} \ + ${webos_sysbus_permissionsdir} \ + ${webos_sysbus_apipermissionsdir} \ + ${webos_sysbus_groupsdir} \ + ${webos_sysbus_manifestsdir} \ +" + +FILES_${PN} += "${WEBOS_SYSTEM_BUS_DIRS_LEGACY} ${WEBOS_SYSTEM_BUS_DIRS}" + +sysroot_stage_dirs_append() { + # $to is 2nd parameter passed to sysroot_stage_dir, e.g. ${SYSROOT_DESTDIR} passed from sysroot_stage_all + for dir in ${WEBOS_SYSTEM_BUS_DIRS_LEGACY} ${WEBOS_SYSTEM_BUS_DIRS}; do + rm -rf $to$dir + done +} diff --git a/meta/classes/webos_test_provider.bbclass b/meta/classes/webos_test_provider.bbclass new file mode 100644 index 0000000000..1223d50af8 --- /dev/null +++ b/meta/classes/webos_test_provider.bbclass @@ -0,0 +1,45 @@ +# Copyright (c) 2014-2018 LG Electronics, Inc. +# +# webos_test_provider +# +# This class is to be inherited by every recipe whose component is able to build +# and install unit- or other test scripts based on the build variables +# WEBOS_CONFIG_BUILD_TESTS and WEBOS_CONFIG_INSTALL_TESTS. +# +# For components which also inherit from the webos_cmake bbclass, it adds the +# following defines to their CMake command lines. +# +# -DWEBOS_CONFIG_BUILD_TESTS:BOOL=<TRUE or FALSE> +# -DWEBOS_CONFIG_INSTALL_TESTS:BOOL=<TRUE or FALSE> +# +# By definition, WEBOS_CONFIG_INSTALL_TESTS implies WEBOS_CONFIG_BUILD_TESTS +# so either one will cause tests to be built. +# + +# Bring in the ptest functionality and packages etc. +inherit ptest +inherit webos_filesystem_paths + +# (Weakly) set default values for both control variables to ensure they are defined +# +# As the tests are placed in their own package, which may or may not be included in +# a particular image, set the default so that they are always built (i.e. available +# for inclusion). + +WEBOS_CONFIG_BUILD_TESTS[type] = "boolean" +WEBOS_CONFIG_BUILD_TESTS ??= "${PTEST_ENABLED}" +WEBOS_CONFIG_INSTALL_TESTS[type] = "boolean" +WEBOS_CONFIG_INSTALL_TESTS ??= "${PTEST_ENABLED}" + +# Pass the control variableis into CMake (will have no effect if component does not use CMake) +EXTRA_OECMAKE += "-DWEBOS_CONFIG_BUILD_TESTS:BOOL=${@ 'TRUE' if oe.data.typed_value('WEBOS_CONFIG_BUILD_TESTS',d) or oe.data.typed_value('WEBOS_CONFIG_INSTALL_TESTS',d) else 'FALSE' }" +EXTRA_OECMAKE += "-DWEBOS_CONFIG_INSTALL_TESTS:BOOL=${@ 'TRUE' if oe.data.typed_value('WEBOS_CONFIG_INSTALL_TESTS',d) else 'FALSE' }" + +# Ensure tests are installed if they are in the correct place +FILES_${PN}-ptest += "${webos_testsdir}/${BPN}" + +# Bring in the g-lib test runner, as something is bound to use it +RDEPENDS_${PN}-ptest += "glib-2.0-utils" + +# Also, add an RDEPENDS on ptest-runner - saves adding it to a packagegroup +RDEPENDS_${PN}-ptest += "ptest-runner" diff --git a/meta/classes/webos_version.bbclass b/meta/classes/webos_version.bbclass new file mode 100644 index 0000000000..5c19ea7cb4 --- /dev/null +++ b/meta/classes/webos_version.bbclass @@ -0,0 +1,63 @@ +# Copyright (c) 2013-2014 LG Electronics, Inc. +# +# webos_version +# +# Functions to parse the fields of a WEBOS_VERSION, which have the following format: +# +# <component-version>-<submission>[_<40-character-revision-hash>[;branch=<branch>]] +# + +# PV is the first underscore-separated field in WEBOS_VERSION, +# i.e., it includes the submission. If there is no WEBOS_VERSION +# setting, '0' will be returned. +def webos_version_get_pv(wv): + if not wv: + return '0' + split_wv = wv.split(';branch=') + return split_wv[0].split('_')[0] + +# The component version is PV with the last hyphen-separated field +# removed; i.e., it does not include the submission. +def webos_version_get_component_version(wv): + pv = webos_version_get_pv(wv) + split_pv = pv.split('-') + if len(split_pv) == 1: + # If there's no submission, then the component version can't + # contain a hyphen + return split_pv[0] + return "-".join(split_pv[:-1]) + +# The submission is the last hyphen-separated field in PV. +# If there is no hyphen in PV setting, '0' will be returned. +def webos_version_get_submission(wv): + pv = webos_version_get_pv(wv) + split_pv = pv.split('-') + if len(split_pv) == 1: + # If there no hyphen, that means there's no submission + return '0' + return split_pv[-1] + +# The revision-hash (SRCREV) is the second underscore-separated field in +# WEBOS_VERSION. Returns "INVALID" if the field is absent. +def webos_version_get_srcrev(wv): + split_wv = wv.split(';branch=') + split_wv = split_wv[0].split('_') + if len(split_wv) == 1: + return "INVALID" # this is default SRCREV value from bitbake.conf + return split_wv[1] + +# The branch is optional parameter, last in WEBOS_VERSION after ;branch= +# when not specified it will use @<name> when WEBOS_VERSION is in +# <name>.NN format (contains at least one dot) and "master" in all other cases. +def webos_version_get_branch(wv): + split_wv = wv.split(';branch=') + if len(split_wv) == 1: + submission = webos_version_get_submission(wv) + # Assume <name>.NN format (NN is submission number, @<name> is branch name) + split_submission = submission.rsplit('.', 1) + if len(split_submission) > 1: + return "@%s" % (split_submission[0]) + else: + # otherwise it's simply a submission along the master branch + return "master" + return split_wv[1] |