diff --git a/.gitmodules b/.gitmodules index c28fa40ae2..f5aa3a60b7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -35,3 +35,11 @@ [submodule "meta-security"] path = meta-security url = https://git.yoctoproject.org/git/meta-security +[submodule "meta-flatpak"] + path = meta-flatpak + url = https://github.com/klihub/meta-flatpak + branch = intel-iot-refkit/flatpak + ignore = untracked +[submodule "meta-gplv2"] + path = meta-gplv2 + url = https://git.yoctoproject.org/git/meta-gplv2 diff --git a/docker/build-project.sh b/docker/build-project.sh index f00fd31bd0..66370a78b1 100755 --- a/docker/build-project.sh +++ b/docker/build-project.sh @@ -82,6 +82,8 @@ if [ -z "$BUILD_TARGET" ]; then (REFKIT_CI_SDK_TARGETS) _sufx=":do_populate_sdk" ;; (REFKIT_CI_ESDK_TARGETS) _sufx=":do_populate_sdk_ext" ;; (REFKIT_CI_TEST_EXPORT_TARGETS) _sufx=":do_test_iot_export" ;; + (REFKIT_CI_FLATPAK_RUNTIME_TARGETS) _sufx="-flatpak-runtime:do_test_iot_export" ;; + (REFKIT_CI_FLATPAK_SDK_TARGETS) _sufx="-flatpak-sdk" ;; (*) continue;; esac for img in `grep ${ci_var} ${WORKSPACE}/refkit_ci_vars | perl -pe 's/.+="(.*)"/\1/g; s/[^ a-zA-Z0-9_-]//g'`; do diff --git a/meta-flatpak b/meta-flatpak new file mode 160000 index 0000000000..ccb6b12053 --- /dev/null +++ b/meta-flatpak @@ -0,0 +1 @@ +Subproject commit ccb6b12053af692fcf005e4a52d7c228ee190406 diff --git a/meta-gplv2 b/meta-gplv2 new file mode 160000 index 0000000000..de001bd6bf --- /dev/null +++ b/meta-gplv2 @@ -0,0 +1 @@ +Subproject commit de001bd6bfcec943d274b649c62be6848cc9c3e6 diff --git a/meta-refkit/classes/refkit-image.bbclass b/meta-refkit/classes/refkit-image.bbclass index 8c9e308b07..6b71a395c0 100644 --- a/meta-refkit/classes/refkit-image.bbclass +++ b/meta-refkit/classes/refkit-image.bbclass @@ -192,6 +192,9 @@ FEATURE_PACKAGES_tools-debug_append = " valgrind" FEATURE_PACKAGES_computervision = "packagegroup-computervision" FEATURE_PACKAGES_computervision-test = "packagegroup-computervision-test" +inherit ${@bb.utils.contains('DISTRO_FEATURES', 'flatpak', \ + 'flatpak-image', '', d)} + IMAGE_LINGUAS = " " LICENSE = "MIT" @@ -436,7 +439,11 @@ ROOTFS_POSTPROCESS_COMMAND += "refkit_image_patch_os_release; " # Instead we pre-configure some defaults in the image and can remove # the useless service. refkit_image_disable_firstboot () { - for i in /etc/systemd /lib/systemd /usr/lib/systemd /bin /usr/bin; do + SEARCH_DIRS='/etc/systemd /usr/lib/systemd /usr/bin' + if [ "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '1', '0', d)}" = "0" ]; then + SEARCH_DIRS=$SEARCH_DIRS' /lib/systemd /bin' + fi + for i in ${SEARCH_DIRS}; do d="${IMAGE_ROOTFS}$i" if [ -d "$d" ] && [ ! -h "$d" ]; then for e in $(find "$d" -name systemd-firstboot.service -o -name systemd-firstboot.service.d -o -name systemd-firstboot); do @@ -494,3 +501,43 @@ EOF fi } ROOTFS_POSTPROCESS_COMMAND += "refkit_image_system_serialgetty; " + +# Prepare the symlinks required for merged /usr at the time of rootfs creation. + +# The links created in rootfs are: +#/bin --> /usr/sbin +#/sbin --> /usr/sbin +#/lib --> /usr/lib +#/lib64 --> /usr/lib64 + +# We cannot make these symlinks as part of 'base-files' or some other package. +# Because at rootfs creation, installation of the package(say kernel) that +# depends on these root folders/links fails, if package manager installs this +# package prior to base-files. + +# These symbolic links in top level folder should present as long as +# - kerenl tools use /lib/{module,firmware} +# - shell scripts uses +#upstream commit waiting for review: +# http://lists.openembedded.org/pipermail/openembedded-core/2017-February/133151.html +create_merged_usr_symlinks() { + install -m 0755 -d ${IMAGE_ROOTFS}/${base_bindir} + install -m 0755 -d ${IMAGE_ROOTFS}/${base_sbindir} + install -m 0755 -d ${IMAGE_ROOTFS}/${base_libdir} + lnr ${IMAGE_ROOTFS}${base_bindir} ${IMAGE_ROOTFS}/bin + lnr ${IMAGE_ROOTFS}${base_sbindir} ${IMAGE_ROOTFS}/sbin + lnr ${IMAGE_ROOTFS}${base_libdir} ${IMAGE_ROOTFS}/${baselib} + + if [ "${nonarch_base_libdir}" != "${base_libdir}" ]; then + install -m 0755 -d ${IMAGE_ROOTFS}/${nonarch_base_libdir} + lnr ${IMAGE_ROOTFS}${nonarch_base_libdir} ${IMAGE_ROOTFS}/lib + fi + + # create base links for multilibs + multi_libdirs="${@d.getVar('MULTILIB_VARIANTS')}" + for d in $multi_libdirs; do + install -m 0755 -d ${IMAGE_ROOTFS}/${exec_prefix}/$d + lnr ${IMAGE_ROOTFS}/${exec_prefix}/$d ${IMAGE_ROOTFS}/$d + done +} +ROOTFS_PREPROCESS_COMMAND += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_symlinks; ', '',d)}" diff --git a/meta-refkit/conf/bblayers.conf.sample b/meta-refkit/conf/bblayers.conf.sample index 78dbbceb32..cb49d1139d 100644 --- a/meta-refkit/conf/bblayers.conf.sample +++ b/meta-refkit/conf/bblayers.conf.sample @@ -17,6 +17,8 @@ REFKIT_LAYERS = " \ ##OEROOT##/../meta-security-isafw \ ##OEROOT##/../meta-intel-realsense \ ##OEROOT##/../meta-clang \ + ##OEROOT##/../meta-flatpak \ + ##OEROOT##/../meta-gplv2 \ " # REFKIT_LAYERS += "##OEROOT##/../meta-openembedded/meta-efl" diff --git a/meta-refkit/conf/conf-notes.txt b/meta-refkit/conf/conf-notes.txt index 4b8b31140d..20199f89df 100644 --- a/meta-refkit/conf/conf-notes.txt +++ b/meta-refkit/conf/conf-notes.txt @@ -9,3 +9,11 @@ Common targets are: refkit-image-gateway (when building an image with tools and configuration for acting as an IoT sensor gateway) + +If you enable flatpak applications (see the comments in local.conf on how to +do this), you can build two additional image variants: + -flatpak-runtime flatpak-enabled version of + -flatpak-sdk flatpak SDK runtime (OSTree repo) for the above + +You can use a -flatpak-sdk image variant on your (flatpak-enabled) host +to build flatpaks for the -flatpak-runtime image variant. diff --git a/meta-refkit/conf/distro/include/refkit-ci.inc b/meta-refkit/conf/distro/include/refkit-ci.inc index ae19c4eea0..8cada832d7 100644 --- a/meta-refkit/conf/distro/include/refkit-ci.inc +++ b/meta-refkit/conf/distro/include/refkit-ci.inc @@ -47,6 +47,9 @@ require conf/distro/include/refkit-development.inc # If we can access /dev/kvm, then let's use it. QEMU_USE_KVM = "${@ 'intel-corei7-64 intel-core2-32 qemux86 qemux86-64' if os.access('/dev/kvm', os.R_OK|os.W_OK) else '' }" +# Enable flatpak application support. +require conf/distro/include/flatpak-applications.inc + REFKIT_VM_IMAGE_TYPES = "wic.xz wic.zip wic.bmap wic.xz.sha256sum" # @@ -72,6 +75,17 @@ REFKIT_CI_SDK_TARGETS="" # Uses the fully-populated image to ensure that the eSDK is as complete # as possible. REFKIT_CI_ESDK_TARGETS="" +# We'll automatically enable flatpak runtime/SDK support for the +# following targets if flatpak support is enabled (by commenting out +# the corresponding require above. +REFKIT_CI_FLATPAK_RUNTIME_TARGETS = " \ + ${@bb.utils.contains('DISTRO_FEATURES', 'flatpak', \ + 'refkit-image-minimal', '', d)} \ +" +REFKIT_CI_FLATPAK_SDK_TARGETS = " \ + ${@bb.utils.contains('DISTRO_FEATURES', 'flatpak', \ + 'refkit-image-minimal', '', d)} \ +" # Following targets would be executed with do_test_iot_export task REFKIT_CI_TEST_EXPORT_TARGETS="refkit-image-common refkit-image-computervision refkit-image-gateway" # Execute automatic tests for following images with corresponding diff --git a/meta-refkit/conf/distro/include/usrmerge.inc b/meta-refkit/conf/distro/include/usrmerge.inc new file mode 100644 index 0000000000..2ea85f2321 --- /dev/null +++ b/meta-refkit/conf/distro/include/usrmerge.inc @@ -0,0 +1,17 @@ + +#enable merged /usr +REFKIT_DEFAULT_DISTRO_FEATURES += "usrmerge" + +export base_bindir = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '${exec_prefix}/bin', '${base_prefix}/bin', d)}" +export base_sbindir = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '${exec_prefix}/sbin', '${base_prefix}/sbin', d)}" +export base_libdir = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '${exec_prefix}/${baselib}', '${base_prefix}/${baselib}', d)}" +export nonarch_base_libdir = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '${exec_prefix}/lib', '${base_prefix}/lib', d)}" + +#nativesdk +base_bindir_nativesdk = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '${bindir_nativesdk}', '/bin', d)}" +base_sbindir_nativesdk = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '${sbindir_nativesdk}', '/sbin', d)}" +base_libdir_nativesdk = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '${libdir_nativesdk}', '/lib', d)}" + +DISTRO_FEATURES_remove = " gobject-introspection-data" + + diff --git a/meta-refkit/conf/distro/refkit.conf b/meta-refkit/conf/distro/refkit.conf index 3fa00d36e1..93d1ed715a 100644 --- a/meta-refkit/conf/distro/refkit.conf +++ b/meta-refkit/conf/distro/refkit.conf @@ -356,3 +356,5 @@ INHERIT += "uninative" # necessary patch "net-tools: enable native and nativesdk variant" # is in OE-core): swtpm_setup.sh needs netstat command. DEPENDS_append_pn-swtpm-wrappers-native = " net-tools-native" + +require conf/distro/include/usrmerge.inc diff --git a/meta-refkit/conf/local.conf.sample b/meta-refkit/conf/local.conf.sample index 85c69550a6..8753e3c5ea 100644 --- a/meta-refkit/conf/local.conf.sample +++ b/meta-refkit/conf/local.conf.sample @@ -283,6 +283,21 @@ PACKAGE_DEBUG_SPLIT_STYLE = "debug-without-src" # #require conf/distro/include/refkit-production.inc +# If you'd like to enable support for flatpak applications and building +# flatpak SDK runtime repositories, which you can use on your flatpak- +# enabled host to build flatpak applications for a flatpak-enabled version +# of an image, enabled the require line below. You can build a flatpak- +# enabled version of an image by appending '-flatpak-runtime' to the image +# name. Simiarly you can build a flatpak SDK runtime for such an image +# by appending '-flatpak-sdk' to the image name. +# +# For instance, to build a flatpak-enabled version of the minimal image and +# a flatpak SDK runtime for it, use +# +# bitbake refkit-image-minimal-flatpak-runtime refkit-image-minimal-flatpak-sdk +# +#require conf/distro/include/flatpak-applications.inc + # systemd-bootchart is a useful tool to analyze and optimize a system # boot time. The tool is available in IoT Reference OS Kit and needs to be activated # by a kernel command-line parameter which requires to build a new diff --git a/meta-refkit/recipes-core/busybox/busybox_%.bbappend b/meta-refkit/recipes-core/busybox/busybox_%.bbappend index 9089d539f7..2234b2a0c1 100644 --- a/meta-refkit/recipes-core/busybox/busybox_%.bbappend +++ b/meta-refkit/recipes-core/busybox/busybox_%.bbappend @@ -9,3 +9,5 @@ RRECOMMENDS_${PN}_remove = "${PN}-syslog" SRC_URI_append = "\ file://refkit.cfg \ " + +RPROVIDES_${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '/bin/sh', '', d)}" diff --git a/meta-refkit/recipes-core/systemd/systemd_%.bbappend b/meta-refkit/recipes-core/systemd/systemd_%.bbappend index 160208686f..4cbc5cd667 100644 --- a/meta-refkit/recipes-core/systemd/systemd_%.bbappend +++ b/meta-refkit/recipes-core/systemd/systemd_%.bbappend @@ -2,3 +2,7 @@ # systemd-getty-generator (instead of the Yocto default # systemd-serialgetty that creates everything in do_install). PACKAGECONFIG_append = "serial-getty-generator" + +#usrmege supported changes +EXTRA_OECONF_append = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', ' --disable-split-usr', ' --enable-split-usr', d)}" +rootprefix = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '${exec_prefix}', '${base_prefix}', d)}" diff --git a/meta-refkit/recipes-extended/bash_%.bbappend b/meta-refkit/recipes-extended/bash_%.bbappend new file mode 100644 index 0000000000..29b2b8f4c9 --- /dev/null +++ b/meta-refkit/recipes-extended/bash_%.bbappend @@ -0,0 +1 @@ +RPROVIDES_${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '/bin/sh /bin/bash', '', d)}" diff --git a/meta-refkit/recipes-image/images/refkit-initramfs.bb b/meta-refkit/recipes-image/images/refkit-initramfs.bb index 0a269987b6..302f2591e7 100644 --- a/meta-refkit/recipes-image/images/refkit-initramfs.bb +++ b/meta-refkit/recipes-image/images/refkit-initramfs.bb @@ -67,3 +67,12 @@ IMA_EVM_ROOTFS_SIGNED = "-maxdepth 0 -false" IMA_EVM_ROOTFS_HASHED = "-maxdepth 0 -false" IMA_EVM_ROOTFS_CLASS = "${@bb.utils.contains('IMAGE_FEATURES', 'ima', 'ima-evm-rootfs', '',d)}" inherit ${IMA_EVM_ROOTFS_CLASS} + +create_merged_usr_links() { + mkdir -p ${IMAGE_ROOTFS}${libdir} ${IMAGE_ROOTFS}${bindir} ${IMAGE_ROOTFS}${sbindir} + lnr ${IMAGE_ROOTFS}${libdir} ${IMAGE_ROOTFS}/${baselib} + lnr ${IMAGE_ROOTFS}${bindir} ${IMAGE_ROOTFS}/bin + lnr ${IMAGE_ROOTFS}${sbindir} ${IMAGE_ROOTFS}/sbin +} +ROOTFS_PREPROCESS_COMMAND += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_links;', '', d)}" +