From 344c2f97025c6504ec986600498121bb83aaeb8f Mon Sep 17 00:00:00 2001 From: Samuli Piippo Date: Fri, 2 Mar 2018 13:08:39 +0200 Subject: Split meta-boot2qt layer Move distro specific recipes to own layer and leave only new recipes and bbclasses to meta-boot2qt layer. This makes it easier to include meta-boot2qt to your own distro layer to get access e.g., QDB and QBSP recipes that might be useful even without boot2qt distro. Task-number: QTBUG-65871 Change-Id: I6c353774dd1668b00f2d05aa262ad866b90bdef6 Reviewed-by: Timo Aarnipuro --- .../recipes-core/initramfs-basic/files/init.sh | 102 +++++++++++++ .../recipes-core/initramfs-basic/init-basic.bb | 43 ++++++ .../initramfs-basic/initramfs-basic.bb | 50 +++++++ meta-boot2qt/recipes-core/ostree/ostree.bb | 86 +++++++++++ ...llow-updating-files-in-the-boot-directory.patch | 161 +++++++++++++++++++++ .../Create-firmware-convenience-symlinks.patch | 126 ++++++++++++++++ .../ostree/ostree/Mount-boot-partition.patch | 60 ++++++++ ...nt-pull-progress-also-when-not-on-console.patch | 94 ++++++++++++ .../Support-for-booting-without-initramfs.patch | 131 +++++++++++++++++ .../Workaround-the-SIGCHLD-handler-issue.patch | 54 +++++++ .../ostree/deploy-add-karg-none-argument.patch | 62 ++++++++ ...epare-root-enabler-for-simpler-kernel-arg.patch | 54 +++++++ ...oot-add-bootdir-to-the-generated-uEnv.txt.patch | 52 +++++++ ...around-gtkdocize-configure-issue-in-autog.patch | 26 ++++ 14 files changed, 1101 insertions(+) create mode 100644 meta-boot2qt/recipes-core/initramfs-basic/files/init.sh create mode 100644 meta-boot2qt/recipes-core/initramfs-basic/init-basic.bb create mode 100644 meta-boot2qt/recipes-core/initramfs-basic/initramfs-basic.bb create mode 100644 meta-boot2qt/recipes-core/ostree/ostree.bb create mode 100644 meta-boot2qt/recipes-core/ostree/ostree/Allow-updating-files-in-the-boot-directory.patch create mode 100644 meta-boot2qt/recipes-core/ostree/ostree/Create-firmware-convenience-symlinks.patch create mode 100644 meta-boot2qt/recipes-core/ostree/ostree/Mount-boot-partition.patch create mode 100644 meta-boot2qt/recipes-core/ostree/ostree/Print-pull-progress-also-when-not-on-console.patch create mode 100644 meta-boot2qt/recipes-core/ostree/ostree/Support-for-booting-without-initramfs.patch create mode 100644 meta-boot2qt/recipes-core/ostree/ostree/Workaround-the-SIGCHLD-handler-issue.patch create mode 100644 meta-boot2qt/recipes-core/ostree/ostree/deploy-add-karg-none-argument.patch create mode 100644 meta-boot2qt/recipes-core/ostree/ostree/ostree-prepare-root-enabler-for-simpler-kernel-arg.patch create mode 100644 meta-boot2qt/recipes-core/ostree/ostree/u-boot-add-bootdir-to-the-generated-uEnv.txt.patch create mode 100644 meta-boot2qt/recipes-core/ostree/ostree/workaround-gtkdocize-configure-issue-in-autog.patch (limited to 'meta-boot2qt/recipes-core') diff --git a/meta-boot2qt/recipes-core/initramfs-basic/files/init.sh b/meta-boot2qt/recipes-core/initramfs-basic/files/init.sh new file mode 100644 index 0000000..3db235b --- /dev/null +++ b/meta-boot2qt/recipes-core/initramfs-basic/files/init.sh @@ -0,0 +1,102 @@ +#!/bin/sh + +PATH=/sbin:/bin:/usr/sbin:/usr/bin +ROOT_MOUNT="/sysroot/" +ROOT_DEVICE="" + +early_setup() { + + mkdir -p /proc + mkdir -p /sys + mount -t proc proc /proc + mount -t sysfs sysfs /sys + mount -t devtmpfs none /dev + + mkdir -p /run + mkdir -p /var/run +} + +read_args() { + + for arg in $(cat /proc/cmdline); do + value=$(echo ${arg} | cut -s -f2- -d '=') + case $arg in + root=*) + root=$value + ;; + debugshell*) + if [ -z "$value" ]; then + shelltimeout=30 + else + shelltimeout=$value + fi + ;; + esac + done + + if [ -z "$root" ] ; then + debug_shell "No root= specified via kernel command line." + else + case $root in + LABEL=*) + label=${root#LABEL=} + ;; + *) + debug_shell "This init script only supports root=LABEL=* for specifying root file system, but root=$root was provided." + ;; + esac + fi +} + +mount_rootfs() { + + mkdir -p $ROOT_MOUNT + mount $ROOT_DEVICE $ROOT_MOUNT + mount -n --move /proc $ROOT_MOUNT/proc + mount -n --move /sys $ROOT_MOUNT/sys + mount -n --move /dev $ROOT_MOUNT/dev + + exec switch_root $ROOT_MOUNT /sbin/init || debug_shell "Couldn't switch_root." +} + +switch_real_root() { + + echo "Searching for media..." + C=0 + while true + do + + rootfs=$(findfs LABEL=$label) + if [ -n "$rootfs" ] ; then + ROOT_DEVICE=$rootfs + mount_rootfs + fi + + # don't wait for more than $shelltimeout seconds, if it's set + if [ -n "$shelltimeout" ]; then + echo -n " " $(( $shelltimeout - $C )) + if [ $C -ge $shelltimeout ]; then + debug_shell "Cannot find root file system." + fi + C=$(( C + 1 )) + fi + + sleep 1 + done +} + +debug_shell() { + + echo ${1} + echo "Dropping to a shell." + exec sh +} + +main() { + + early_setup + read_args + switch_real_root +} + +main diff --git a/meta-boot2qt/recipes-core/initramfs-basic/init-basic.bb b/meta-boot2qt/recipes-core/initramfs-basic/init-basic.bb new file mode 100644 index 0000000..25039e7 --- /dev/null +++ b/meta-boot2qt/recipes-core/initramfs-basic/init-basic.bb @@ -0,0 +1,43 @@ +############################################################################ +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the Boot to Qt meta layer. +## +## $QT_BEGIN_LICENSE:GPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 or (at your option) any later version +## approved by the KDE Free Qt Foundation. The licenses are as published by +## the Free Software Foundation and appearing in the file LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################ + +SUMMARY = "Simple init script that mounts root filesystem by label." +LICENSE = "The-Qt-Company-DCLA-2.1" +LIC_FILES_CHKSUM = "file://${QT_LICENSE};md5=80e06902b5f0e94ad0a78ee4f7fcb74b" +SRC_URI = "file://init.sh" + +S = "${WORKDIR}" + +do_install () { + install -m 0755 ${WORKDIR}/init.sh ${D}/init +} + +inherit allarch + +FILES_${PN} += "/init" diff --git a/meta-boot2qt/recipes-core/initramfs-basic/initramfs-basic.bb b/meta-boot2qt/recipes-core/initramfs-basic/initramfs-basic.bb new file mode 100644 index 0000000..31388d3 --- /dev/null +++ b/meta-boot2qt/recipes-core/initramfs-basic/initramfs-basic.bb @@ -0,0 +1,50 @@ +############################################################################ +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the Boot to Qt meta layer. +## +## $QT_BEGIN_LICENSE:GPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 or (at your option) any later version +## approved by the KDE Free Qt Foundation. The licenses are as published by +## the Free Software Foundation and appearing in the file LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################ + +DESCRIPTION = "Basic initramfs image. Useful as a template for more advanced functionality." +LICENSE = "The-Qt-Company-DCLA-2.1" +LIC_FILES_CHKSUM = "file://${QT_LICENSE};md5=80e06902b5f0e94ad0a78ee4f7fcb74b" + +# findfs from busybox fails to do its jobs, the full version from util-linux-findfs works fine +PACKAGE_INSTALL = "init-basic busybox util-linux-findfs ${ROOTFS_BOOTSTRAP_INSTALL}" + +# Do not pollute the initramfs image with rootfs features +IMAGE_FEATURES = "" + +export IMAGE_BASENAME = "initramfs-basic" +IMAGE_LINGUAS = "" + +IMAGE_FSTYPES = "cpio.gz" +inherit core-image + +IMAGE_ROOTFS_SIZE = "8192" +IMAGE_ROOTFS_EXTRA_SPACE = "0" + +BAD_RECOMMENDATIONS += "busybox-syslog" + diff --git a/meta-boot2qt/recipes-core/ostree/ostree.bb b/meta-boot2qt/recipes-core/ostree/ostree.bb new file mode 100644 index 0000000..e4c8076 --- /dev/null +++ b/meta-boot2qt/recipes-core/ostree/ostree.bb @@ -0,0 +1,86 @@ +############################################################################ +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the Boot to Qt meta layer. +## +## $QT_BEGIN_LICENSE:GPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 or (at your option) any later version +## approved by the KDE Free Qt Foundation. The licenses are as published by +## the Free Software Foundation and appearing in the file LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################ + +SUMMARY = "Shared library with a reference command line tool for managing bootable, immutable, versioned filesystem trees." + +LICENSE = "LGPL-2.1" +LIC_FILES_CHKSUM = "file://COPYING;md5=5f30f0716dfdd0d91eb439ebec522ec2" + +inherit autotools pkgconfig systemd + +SRC_URI = " \ + git://github.com/ostreedev/ostree.git \ + file://Mount-boot-partition.patch \ + file://ostree-prepare-root-enabler-for-simpler-kernel-arg.patch \ + file://deploy-add-karg-none-argument.patch \ + file://Support-for-booting-without-initramfs.patch \ + file://Allow-updating-files-in-the-boot-directory.patch \ + file://u-boot-add-bootdir-to-the-generated-uEnv.txt.patch \ + file://Create-firmware-convenience-symlinks.patch \ + file://Print-pull-progress-also-when-not-on-console.patch \ + file://Workaround-the-SIGCHLD-handler-issue.patch \ + file://workaround-gtkdocize-configure-issue-in-autog.patch \ + " + +SRCREV = "8ece4d6d51bdbe3e41ab318259276bb83e553aa0" + +S = "${WORKDIR}/git" + +DEPENDS = "glib-2.0 glib-2.0-native e2fsprogs gpgme attr libsoup-2.4 libassuan xz systemd" +# Bash is needed by the shipped dracut module. This dracut module is used to generate initramfs image. +# The production image do not require bash for proper working. +RDEPENDS_${PN} += "bash" +RRECOMMENDS_${PN} += "gnupg" + +PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}" +PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_unitdir}/system/,,," + +SYSTEMD_SERVICE_${PN} = "ostree-prepare-root.service ostree-remount.service" +FILES_${PN} += "${systemd_unitdir}/system/ \ + ${libdir}/dracut/" + +EXTRA_OECONF = "--with-dracut \ + --without-selinux \ + --without-libarchive \ + --with-builtin-grub2-mkconfig \ + --enable-rofiles-fuse=no \ + --enable-gtk-doc-html=no \ + --enable-man=no \ + --with-soup \ + --with-static-prepare-root \ + --disable-otmpfile \ + --enable-introspection=no \ + --enable-libsoup-client-certs" + +do_configure_prepend() { + cd ${S} + # Update submodules and workaround bugs. + env NOCONFIGURE=1 ./autogen.sh + cd - +} diff --git a/meta-boot2qt/recipes-core/ostree/ostree/Allow-updating-files-in-the-boot-directory.patch b/meta-boot2qt/recipes-core/ostree/ostree/Allow-updating-files-in-the-boot-directory.patch new file mode 100644 index 0000000..d416543 --- /dev/null +++ b/meta-boot2qt/recipes-core/ostree/ostree/Allow-updating-files-in-the-boot-directory.patch @@ -0,0 +1,161 @@ +From cc31c80658a90cf1b13fdf9fe8b6dde1cc9a0d24 Mon Sep 17 00:00:00 2001 +From: Gatis Paeglis +Date: Mon, 22 Aug 2016 11:32:16 +0200 +Subject: [PATCH 1/3] Allow updating files in the /boot directory + +This patch adds support for copying (or hardlinking on +single partition systems) all files from the deployment's +/usr/lib/ostree-boot directory to the relevant +/boot/ostree/$os-$bootcsum/ directory. This feature can +be enabled by 'touch .ostree-bootcsumdir-source' in +/usr/lib/ostree-boot. +--- + src/libostree/ostree-sysroot-deploy.c | 101 +++++++++++++++++++++++++++++++--- + 1 file changed, 94 insertions(+), 7 deletions(-) + +diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c +index a05ca30..f34e3f3 100644 +--- a/src/libostree/ostree-sysroot-deploy.c ++++ b/src/libostree/ostree-sysroot-deploy.c +@@ -165,12 +165,31 @@ dirfd_copy_attributes_and_xattrs (int src_parent_dfd, + } + + static gboolean ++hardlink_or_copy_dir_recurse (int src_parent_dfd, ++ int dest_parent_dfd, ++ const char *name, ++ gboolean hardlink, ++ GCancellable *cancellable, ++ GError **error); ++ ++static gboolean + copy_dir_recurse (int src_parent_dfd, + int dest_parent_dfd, + const char *name, + GCancellable *cancellable, + GError **error) + { ++ return hardlink_or_copy_dir_recurse (src_parent_dfd, dest_parent_dfd, name, FALSE, cancellable, error); ++} ++ ++static gboolean ++hardlink_or_copy_dir_recurse (int src_parent_dfd, ++ int dest_parent_dfd, ++ const char *name, ++ gboolean hardlink, ++ GCancellable *cancellable, ++ GError **error) ++{ + g_auto(GLnxDirFdIterator) src_dfd_iter = { 0, }; + glnx_fd_close int dest_dfd = -1; + struct dirent *dent; +@@ -210,17 +229,27 @@ copy_dir_recurse (int src_parent_dfd, + + if (S_ISDIR (child_stbuf.st_mode)) + { +- if (!copy_dir_recurse (src_dfd_iter.fd, dest_dfd, dent->d_name, +- cancellable, error)) ++ if (!hardlink_or_copy_dir_recurse (src_dfd_iter.fd, dest_dfd, dent->d_name, ++ hardlink, cancellable, error)) + return FALSE; + } + else + { +- if (!glnx_file_copy_at (src_dfd_iter.fd, dent->d_name, &child_stbuf, +- dest_dfd, dent->d_name, +- GLNX_FILE_COPY_OVERWRITE, +- cancellable, error)) +- return FALSE; ++ if (hardlink) ++ { ++ if (!hardlink_or_copy_at (src_dfd_iter.fd, dent->d_name, ++ dest_dfd, dent->d_name, ++ cancellable, error)) ++ return FALSE; ++ } ++ else ++ { ++ if (!glnx_file_copy_at (src_dfd_iter.fd, dent->d_name, &child_stbuf, ++ dest_dfd, dent->d_name, ++ GLNX_FILE_COPY_OVERWRITE, ++ cancellable, error)) ++ return FALSE; ++ } + } + } + +@@ -1301,6 +1330,7 @@ install_deployment_kernel (OstreeSysroot *sysroot, + g_autofree char *version_key = NULL; + g_autofree char *ostree_kernel_arg = NULL; + g_autofree char *options_key = NULL; ++ g_auto(GLnxDirFdIterator) dfd_iter = { 0, }; + GString *title_key; + __attribute__((cleanup(_ostree_kernel_args_cleanup))) OstreeKernelArgs *kargs = NULL; + const char *val; +@@ -1367,6 +1397,63 @@ install_deployment_kernel (OstreeSysroot *sysroot, + } + } + ++ if (fstatat (tree_boot_dfd, ".ostree-bootcsumdir-source", &stbuf, 0) == 0) ++ { ++ if (!glnx_dirfd_iterator_init_at (tree_boot_dfd, ".", FALSE, &dfd_iter, error)) ++ goto out; ++ ++ while (TRUE) ++ { ++ struct dirent *dent; ++ ++ if (!glnx_dirfd_iterator_next_dent (&dfd_iter, &dent, cancellable, error)) ++ goto out; ++ if (dent == NULL) ++ break; ++ ++ /* Skip special files - vmlinuz-* and initramfs-* are handled separately */ ++ if (g_str_has_prefix (dent->d_name, "vmlinuz-") || g_str_has_prefix (dent->d_name, "initramfs-")) ++ continue; ++ ++ if (fstatat (bootcsum_dfd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW) != 0) ++ { ++ if (errno != ENOENT) ++ { ++ glnx_set_prefix_error_from_errno (error, "fstatat %s", dent->d_name); ++ goto out; ++ } ++ ++ if (fstatat (dfd_iter.fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW) != 0) ++ { ++ glnx_set_error_from_errno (error); ++ goto out; ++ } ++ ++ if (S_ISDIR (stbuf.st_mode)) ++ { ++ if (!hardlink_or_copy_dir_recurse (tree_boot_dfd, bootcsum_dfd, dent->d_name, ++ TRUE, cancellable, error)) ++ goto out; ++ } ++ else ++ { ++ if (!hardlink_or_copy_at (tree_boot_dfd, dent->d_name, ++ bootcsum_dfd, dent->d_name, ++ cancellable, error)) ++ goto out; ++ } ++ } ++ } ++ } ++ else ++ { ++ if (errno != ENOENT) ++ { ++ glnx_set_prefix_error_from_errno (error, "fstatat %s", ".ostree-bootcsumdir-source"); ++ goto out; ++ } ++ } ++ + if (fstatat (deployment_dfd, "usr/lib/os-release", &stbuf, 0) != 0) + { + if (errno != ENOENT) +-- +2.7.4 + diff --git a/meta-boot2qt/recipes-core/ostree/ostree/Create-firmware-convenience-symlinks.patch b/meta-boot2qt/recipes-core/ostree/ostree/Create-firmware-convenience-symlinks.patch new file mode 100644 index 0000000..656887d --- /dev/null +++ b/meta-boot2qt/recipes-core/ostree/ostree/Create-firmware-convenience-symlinks.patch @@ -0,0 +1,126 @@ +From c4df63488b9e09a9aa69e32ea5c0671c9dc50c9d Mon Sep 17 00:00:00 2001 +From: Gatis Paeglis +Date: Wed, 24 Aug 2016 12:29:38 +0200 +Subject: [PATCH] Create firmware convenience symlinks. + +Later this could be moved into utils or a similar +location, if other boot loader backends will need +this functionality. +--- + src/libostree/ostree-bootloader-uboot.c | 93 ++++++++++++++++++++++++++++++++- + 1 file changed, 92 insertions(+), 1 deletion(-) + +diff --git a/src/libostree/ostree-bootloader-uboot.c b/src/libostree/ostree-bootloader-uboot.c +index 22251da..26a3127 100644 +--- a/src/libostree/ostree-bootloader-uboot.c ++++ b/src/libostree/ostree-bootloader-uboot.c +@@ -62,6 +62,97 @@ _ostree_bootloader_uboot_get_name (OstreeBootloader *bootloader) + return "U-Boot"; + } + ++/* It is common for firmware to search / on the boot partition for additional ++ * files that are required for booting. It can be difficult to change this search ++ * logic if it is hardcoded somewhere low in the stack or is in a read-only memory. ++ * This issue can be solved by system builders by creating a convenience symlink: ++ * ++ * cd sysroot/boot ++ * ln -s loader/second-stage-bootloader second-stage-bootloader ++ * ++ * This function will make sure that loader/second-stage-bootloader points to the ++ * correct target file version. This function does nothing if boot/ does not contain ++ * symlink files pointing into the loader/ directory. ++ */ ++static gboolean ++create_firmware_convenience_symlinks (OstreeBootloaderUboot *self, ++ char *bootcsum_dir, ++ int bootversion, ++ GCancellable *cancellable, ++ GError **error) ++{ ++ glnx_fd_close int loader_dfd = -1; ++ glnx_fd_close int boot_dfd = -1; ++ g_autofree char *loader_dir = NULL; ++ g_auto(GLnxDirFdIterator) dfd_iter = { 0, }; ++ ++ loader_dir = g_strdup_printf ("boot/loader.%d/", bootversion); ++ if (!glnx_opendirat (self->sysroot->sysroot_fd, loader_dir, FALSE, &loader_dfd, error)) ++ return FALSE; ++ if (!glnx_opendirat (self->sysroot->sysroot_fd, "boot", FALSE, &boot_dfd, error)) ++ return FALSE; ++ if (!glnx_dirfd_iterator_init_take_fd (dup (boot_dfd), &dfd_iter, error)) ++ return FALSE; ++ ++ while (TRUE) { ++ struct dirent *dent; ++ struct stat stbuf; ++ ++ if (!glnx_dirfd_iterator_next_dent (&dfd_iter, &dent, cancellable, error)) ++ return FALSE; ++ if (dent == NULL) ++ break; ++ ++ if (fstatat (dfd_iter.fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW) != 0) ++ { ++ if (errno == ENOENT) ++ continue; ++ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "fstatat"); ++ return FALSE; ++ } ++ ++ if (S_ISLNK(stbuf.st_mode)) ++ { ++ char path_buffer[PATH_MAX]; ++ g_autofree char *symlink_target = NULL; ++ symlink_target = glnx_readlinkat_malloc (boot_dfd, dent->d_name, cancellable, error); ++ ++ if (g_str_has_prefix (symlink_target, "loader/")) ++ { ++ if (g_strcmp0 (dent->d_name, "uEnv.txt") == 0) ++ continue; ++ ++ snprintf (path_buffer, sizeof(path_buffer), "%s/%s", bootcsum_dir, dent->d_name); ++ if (faccessat (boot_dfd, path_buffer + 1, F_OK, AT_SYMLINK_NOFOLLOW) == -1) ++ { ++ /* This bootcsum dir does not contain the final target, do nothing. */ ++ if (errno == ENOENT) ++ continue; ++ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "faccessat"); ++ return FALSE; ++ } ++ ++ /* Cleanup from stray symlinks. This can happend when the previous deployment was ++ interrupted and no cleanup routines were run before restaring the deployment. */ ++ if (unlinkat (loader_dfd, dent->d_name, 0) == -1 && errno != ENOENT) ++ { ++ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "unlinkat"); ++ return FALSE; ++ } ++ /* Complete the link chain to the current boot file version. */ ++ snprintf (path_buffer, sizeof(path_buffer), "..%s/%s", bootcsum_dir, dent->d_name); ++ if (symlinkat (path_buffer, loader_dfd, dent->d_name) == -1) ++ { ++ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "symlinkat"); ++ return FALSE; ++ } ++ } ++ } ++ } ++ ++ return TRUE; ++} ++ + static gboolean + create_config_from_boot_loader_entries (OstreeBootloaderUboot *self, + int bootversion, +@@ -138,7 +229,7 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self, + } + } + +- return TRUE; ++ return create_firmware_convenience_symlinks (self, bootdir, bootversion, cancellable, error); + } + + static gboolean +-- +2.7.4 + diff --git a/meta-boot2qt/recipes-core/ostree/ostree/Mount-boot-partition.patch b/meta-boot2qt/recipes-core/ostree/ostree/Mount-boot-partition.patch new file mode 100644 index 0000000..a81f731 --- /dev/null +++ b/meta-boot2qt/recipes-core/ostree/ostree/Mount-boot-partition.patch @@ -0,0 +1,60 @@ +From 33642082578946fdc73ade8b78c05ba8d8521652 Mon Sep 17 00:00:00 2001 +From: Gatis Paeglis +Date: Mon, 7 Mar 2016 15:17:34 +0100 +Subject: [PATCH] ostree: Mount boot partition from user space + +In the current approach we assumed that boot/ + +- is on a separate boot partition +- boot partition is right before rootfs partition +- rootfs parition is provided as a *device node* +- has "ext2" filesystem (mount shell cmd tries to + auto detect FS type, mount system call does not.) + +The new approch does not assume any of the above, and +moves this logic from early user space (initramfs) to +user space. Initramfs by design should be used only to +prepare the rootfs, other tasks should be done later. +--- + src/switchroot/ostree-remount.c | 19 ++++++++++++++++++- + 1 file changed, 18 insertions(+), 1 deletion(-) + +diff --git a/src/switchroot/ostree-remount.c b/src/switchroot/ostree-remount.c +index b8d3a96..33f2645 100644 +--- a/src/switchroot/ostree-remount.c ++++ b/src/switchroot/ostree-remount.c +@@ -77,7 +77,7 @@ maybe_mount_tmpfs_on_var (void) + int + main(int argc, char *argv[]) + { +- const char *remounts[] = { "/sysroot", "/etc", "/home", "/root", "/tmp", "/var", NULL }; ++ const char *remounts[] = { "/sysroot", "/etc", "/home", "/root", "/tmp", "/var", "/boot", NULL }; + struct stat stbuf; + int i; + +@@ -117,5 +117,22 @@ main(int argc, char *argv[]) + + maybe_mount_tmpfs_on_var (); + ++ /* ostree-prepare-root mounts boot/ if it is on the same partition as root filesystem. ++ * If boot/ is not mounted, then it must be on a different partition. Try to mount ++ * filesystem where LABEL=boot-ostree. ++ */ ++ if (!(lstat ("/boot/loader", &stbuf) == 0 && S_ISLNK (stbuf.st_mode))) ++ { ++ /* mount the real boot parition over the deployment's boot directory */ ++ const char *mount_cmd="mount LABEL=boot-ostree /boot"; ++ FILE *fp = popen (mount_cmd, "w"); ++ if (fp == NULL) ++ { ++ perrorv ("popen failed for: %s", mount_cmd); ++ exit (EXIT_FAILURE); ++ } ++ pclose (fp); ++ } ++ + exit (EXIT_SUCCESS); + } +-- +2.7.0 + diff --git a/meta-boot2qt/recipes-core/ostree/ostree/Print-pull-progress-also-when-not-on-console.patch b/meta-boot2qt/recipes-core/ostree/ostree/Print-pull-progress-also-when-not-on-console.patch new file mode 100644 index 0000000..f8e7324 --- /dev/null +++ b/meta-boot2qt/recipes-core/ostree/ostree/Print-pull-progress-also-when-not-on-console.patch @@ -0,0 +1,94 @@ +From b24d691d968bca608142882b453e98ed5ee267e9 Mon Sep 17 00:00:00 2001 +From: Gatis Paeglis +Date: Thu, 29 Sep 2016 11:46:59 +0200 +Subject: [PATCH] Print pull progress also when not on console + +glnx_console_text is smart enough: + +"On a tty, print to the console @text followed by an ASCII art + progress bar whose percentage is @percentage. If stdout is not a + tty, a more basic line by line change will be printed." + +Otherwise, when pulling a lot of data, we do not get any feedback +in a GUI application for a significant amount of time. +--- + src/ostree/ot-admin-builtin-switch.c | 3 +-- + src/ostree/ot-admin-builtin-upgrade.c | 3 +-- + src/ostree/ot-builtin-pull-local.c | 3 +-- + src/ostree/ot-builtin-pull.c | 12 ++++-------- + 4 files changed, 7 insertions(+), 14 deletions(-) + +diff --git a/src/ostree/ot-admin-builtin-switch.c b/src/ostree/ot-admin-builtin-switch.c +index 895538a..7f1d6dd 100644 +--- a/src/ostree/ot-admin-builtin-switch.c ++++ b/src/ostree/ot-admin-builtin-switch.c +@@ -126,8 +126,7 @@ ot_admin_builtin_switch (int argc, char **argv, GCancellable *cancellable, GErro + { g_auto(GLnxConsoleRef) console = { 0, }; + glnx_console_lock (&console); + +- if (console.is_tty) +- progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console); ++ progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console); + + /* Always allow older...there's not going to be a chronological + * relationship necessarily. +diff --git a/src/ostree/ot-admin-builtin-upgrade.c b/src/ostree/ot-admin-builtin-upgrade.c +index 81f9bb6..8147b4f 100644 +--- a/src/ostree/ot-admin-builtin-upgrade.c ++++ b/src/ostree/ot-admin-builtin-upgrade.c +@@ -109,8 +109,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, GCancellable *cancellable, GErr + { g_auto(GLnxConsoleRef) console = { 0, }; + glnx_console_lock (&console); + +- if (console.is_tty) +- progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console); ++ progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console); + + if (opt_allow_downgrade) + upgraderpullflags |= OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_ALLOW_OLDER; +diff --git a/src/ostree/ot-builtin-pull-local.c b/src/ostree/ot-builtin-pull-local.c +index 5401a28..f2f5b21 100644 +--- a/src/ostree/ot-builtin-pull-local.c ++++ b/src/ostree/ot-builtin-pull-local.c +@@ -159,8 +159,7 @@ ostree_builtin_pull_local (int argc, char **argv, GCancellable *cancellable, GEr + g_variant_builder_add (&builder, "{s@v}", "depth", + g_variant_new_variant (g_variant_new_int32 (opt_depth))); + +- if (console.is_tty) +- progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console); ++ progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console); + + opts = g_variant_ref_sink (g_variant_builder_end (&builder)); + if (!ostree_repo_pull_with_options (repo, src_repo_uri, +diff --git a/src/ostree/ot-builtin-pull.c b/src/ostree/ot-builtin-pull.c +index 99b2593..78686b3 100644 +--- a/src/ostree/ot-builtin-pull.c ++++ b/src/ostree/ot-builtin-pull.c +@@ -242,20 +242,16 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError ** + + if (!opt_dry_run) + { +- if (console.is_tty) +- progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console); ++ progress = ostree_async_progress_new_and_connect (ostree_repo_pull_default_console_progress_changed, &console); + } + else + { + progress = ostree_async_progress_new_and_connect (dry_run_console_progress_changed, NULL); + } + +- if (console.is_tty) +- { +- signal_handler_id = g_signal_connect (repo, "gpg-verify-result", +- G_CALLBACK (gpg_verify_result_cb), +- &console); +- } ++ signal_handler_id = g_signal_connect (repo, "gpg-verify-result", ++ G_CALLBACK (gpg_verify_result_cb), ++ &console); + + if (!ostree_repo_pull_with_options (repo, remote, g_variant_builder_end (&builder), + progress, cancellable, error)) +-- +2.7.4 + diff --git a/meta-boot2qt/recipes-core/ostree/ostree/Support-for-booting-without-initramfs.patch b/meta-boot2qt/recipes-core/ostree/ostree/Support-for-booting-without-initramfs.patch new file mode 100644 index 0000000..4ec137f --- /dev/null +++ b/meta-boot2qt/recipes-core/ostree/ostree/Support-for-booting-without-initramfs.patch @@ -0,0 +1,131 @@ +From a31c9083870fd934e242cc9cc56fdd39ad0a42cb Mon Sep 17 00:00:00 2001 +From: Gatis Paeglis +Date: Wed, 24 Aug 2016 12:00:14 +0200 +Subject: [PATCH 3/4] Support for booting without initramfs + +Previously when initramfs-* was not found in a deployment's +boot directory, it was assumed that rootfs is prepared for +ostree booting by a kernel patch. + +With this patch, the behaviour changes to be - if initramfs-* +is not found, assume that system is using a static +ostree-prepare-root as init process. Booting without initramfs +is a common use case on embedded systems. This approach is +also more convenient, than having to patch the kernel. +--- + Makefile-switchroot.am | 3 +++ + configure.ac | 8 ++++++++ + src/boot/grub2/ostree-grub-generator | 8 +++++--- + src/libostree/ostree-sysroot-deploy.c | 18 +++++++++++++----- + 4 files changed, 29 insertions(+), 8 deletions(-) + +diff --git a/Makefile-switchroot.am b/Makefile-switchroot.am +index ef837ce..70a6de7 100644 +--- a/Makefile-switchroot.am ++++ b/Makefile-switchroot.am +@@ -29,6 +29,9 @@ libswitchroot_mountutil_la_SOURCES = \ + ostree_prepare_root_SOURCES = src/switchroot/ostree-prepare-root.c + ostree_prepare_root_LDADD = libswitchroot-mountutil.la + ostree_prepare_root_CFLAGS = $(AM_CFLAGS) -Isrc/switchroot ++if BUILDOPT_STATIC_PREPARE_ROOT ++ostree_prepare_root_LDFLAGS = --static ++endif + + ostree_remount_SOURCES = src/switchroot/ostree-remount.c + ostree_remount_LDADD = libswitchroot-mountutil.la +diff --git a/configure.ac b/configure.ac +index 4831bcc..97f3112 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -294,6 +294,13 @@ AS_IF([test x$with_grub2_mkconfig_path = x], [ + ],[GRUB2_MKCONFIG=$with_grub2_mkconfig_path]) + AC_DEFINE_UNQUOTED([GRUB2_MKCONFIG_PATH], ["$GRUB2_MKCONFIG"], [The system grub2-mkconfig executible name]) + ++AC_ARG_WITH(static-prepare-root, ++ AS_HELP_STRING([--with-static-prepare-root], ++ [Build static version of the 'ostree-prepare-root' binary. Useful when ++ using 'ostree-prepare-root' as the init (PID 1) process. (default: no)]),, ++ [with_static_prepare_root=no]) ++AM_CONDITIONAL(BUILDOPT_STATIC_PREPARE_ROOT, test x$with_static_prepare_root = xyes) ++ + dnl for tests + AS_IF([test "x$found_introspection" = xyes], [ + AC_PATH_PROG(GJS, [gjs]) +@@ -327,6 +334,7 @@ echo " + libarchive (parse tar files directly): $with_libarchive + static deltas: yes (always enabled now) + O_TMPFILE: $enable_otmpfile ++ static ostree-prepare-root $with_static_prepare_root + man pages (xsltproc): $enable_man + api docs (gtk-doc): $enable_gtk_doc + gjs-based tests: $have_gjs +diff --git a/src/boot/grub2/ostree-grub-generator b/src/boot/grub2/ostree-grub-generator +index 5673b26..ceca806 100644 +--- a/src/boot/grub2/ostree-grub-generator ++++ b/src/boot/grub2/ostree-grub-generator +@@ -28,7 +28,7 @@ entries_path=$(dirname $new_grub2_cfg)/entries + + read_config() + { +- config_file=${entries_path}/${1} ++ config_file=${1} + title="" + initrd="" + options="" +@@ -62,11 +62,13 @@ read_config() + populate_menu() + { + boot_prefix="${OSTREE_BOOT_PARTITION}" +- for config in $(ls ${entries_path}); do ++ for config in $(ls $entries_path/*.conf); do + read_config ${config} + menu="${menu}menuentry '${title}' {\n" + menu="${menu}\t linux ${boot_prefix}${linux} ${options}\n" +- menu="${menu}\t initrd ${boot_prefix}${initrd}\n" ++ if [ -n "${initrd}" ] ; then ++ menu="${menu}\t initrd ${boot_prefix}${initrd}\n" ++ fi + menu="${menu}}\n\n" + done + # The printf command seems to be more reliable across shells for special character (\n, \t) evaluation +diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c +index a05ca30..c0a0347 100644 +--- a/src/libostree/ostree-sysroot-deploy.c ++++ b/src/libostree/ostree-sysroot-deploy.c +@@ -1458,20 +1458,28 @@ install_deployment_kernel (OstreeSysroot *sysroot, + ostree_bootconfig_parser_set (bootconfig, "linux", boot_relpath); + } + ++ val = ostree_bootconfig_parser_get (bootconfig, "options"); ++ kargs = _ostree_kernel_args_from_string (val); ++ + if (dest_initramfs_name) + { + g_autofree char * boot_relpath = g_strconcat ("/", bootcsumdir, "/", dest_initramfs_name, NULL); + ostree_bootconfig_parser_set (bootconfig, "initrd", boot_relpath); + } +- +- val = ostree_bootconfig_parser_get (bootconfig, "options"); ++ else ++ { ++ g_autofree char *prepare_root_arg = NULL; ++ prepare_root_arg = g_strdup_printf ("init=/ostree/boot.%d/%s/%s/%d/usr/lib/ostree/ostree-prepare-root", ++ new_bootversion, osname, bootcsum, ++ ostree_deployment_get_bootserial (deployment)); ++ _ostree_kernel_args_replace_take (kargs, g_steal_pointer (&prepare_root_arg)); ++ } + + ostree_kernel_arg = g_strdup_printf ("ostree=/ostree/boot.%d/%s/%s/%d", + new_bootversion, osname, bootcsum, + ostree_deployment_get_bootserial (deployment)); +- kargs = _ostree_kernel_args_from_string (val); +- _ostree_kernel_args_replace_take (kargs, ostree_kernel_arg); +- ostree_kernel_arg = NULL; ++ _ostree_kernel_args_replace_take (kargs, g_steal_pointer (&ostree_kernel_arg)); ++ + options_key = _ostree_kernel_args_to_string (kargs); + ostree_bootconfig_parser_set (bootconfig, "options", options_key); + +-- +2.7.4 + diff --git a/meta-boot2qt/recipes-core/ostree/ostree/Workaround-the-SIGCHLD-handler-issue.patch b/meta-boot2qt/recipes-core/ostree/ostree/Workaround-the-SIGCHLD-handler-issue.patch new file mode 100644 index 0000000..ece69b8 --- /dev/null +++ b/meta-boot2qt/recipes-core/ostree/ostree/Workaround-the-SIGCHLD-handler-issue.patch @@ -0,0 +1,54 @@ +From c7cf5cb80c57423e707d87013050c6f9cc6f6d37 Mon Sep 17 00:00:00 2001 +From: Gatis Paeglis +Date: Tue, 18 Oct 2016 12:19:57 +0200 +Subject: [PATCH] Workaround the SIGCHLD handler issue + +REF: https://bugreports.qt.io/browse/QTBUG-56338 +--- + src/libostree/ostree-bootloader-grub2.c | 30 ++++++++++++++++++++++-------- + 1 file changed, 22 insertions(+), 8 deletions(-) + +diff --git a/src/libostree/ostree-bootloader-grub2.c b/src/libostree/ostree-bootloader-grub2.c +index f3dc8e1..2c60b80 100644 +--- a/src/libostree/ostree-bootloader-grub2.c ++++ b/src/libostree/ostree-bootloader-grub2.c +@@ -380,14 +380,28 @@ _ostree_bootloader_grub2_write_config (OstreeBootloader *bootloader, + + Upstream is fixed though. + */ +- proc = g_subprocess_launcher_spawn (launcher, error, +- grub_exec, "-o", +- gs_file_get_path_cached (new_config_path), +- NULL); +- +- if (!g_subprocess_wait_check (proc, cancellable, error)) +- goto out; +- ++ //proc = g_subprocess_launcher_spawn (launcher, error, ++ // grub_exec, "-o", ++ // gs_file_get_path_cached (new_config_path), ++ // NULL); ++ ++ //if (!g_subprocess_wait_check (proc, cancellable, error)) ++ // goto out; ++ { ++ // REF: https://bugreports.qt.io/browse/QTBUG-56338 ++ // We do not use the chroot (grub2_child_setup) code path, so we do not ++ // care about GSubprocessLauncher and the custom envvars passed to it. ++ const char *cmd = glnx_strjoina (grub_exec, " -o ", gs_file_get_path_cached (new_config_path)); ++ FILE *fp = popen(cmd, "r"); ++ if (!fp) { ++ glnx_set_prefix_error_from_errno (error, "popen (%s)", cmd); ++ goto out; ++ } ++ if (pclose(fp) == -1) { ++ glnx_set_prefix_error_from_errno (error, "pclose (%s)", cmd); ++ goto out; ++ } ++ } + /* Now let's fdatasync() for the new file */ + { glnx_fd_close int new_config_fd = open (gs_file_get_path_cached (new_config_path), O_RDONLY | O_CLOEXEC); + if (new_config_fd < 0) +-- +2.7.4 + diff --git a/meta-boot2qt/recipes-core/ostree/ostree/deploy-add-karg-none-argument.patch b/meta-boot2qt/recipes-core/ostree/ostree/deploy-add-karg-none-argument.patch new file mode 100644 index 0000000..5eaf68f --- /dev/null +++ b/meta-boot2qt/recipes-core/ostree/ostree/deploy-add-karg-none-argument.patch @@ -0,0 +1,62 @@ +From 9ca3a2cc64bc709649d0d756fa715aaef807dca8 Mon Sep 17 00:00:00 2001 +From: Gatis Paeglis +Date: Fri, 12 Aug 2016 11:51:04 +0200 +Subject: [PATCH 2/4] deploy: add --karg-none argument + +If the current deployment has "rootwait root=/dev/sda2", +but the new deployment does not need "rootwait" anymore, +there is no way to clear this arg at the moment (as opposed +to "karg=root=", which overrides any earlier argument with +the same name). With "--karg-none" users can now clear all +the previous args and set new "root=": + +ostree admin deploy --karg-none --karg=root=LABEL=rootfs +--- + src/ostree/ot-admin-builtin-deploy.c | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/src/ostree/ot-admin-builtin-deploy.c b/src/ostree/ot-admin-builtin-deploy.c +index c66c9b3..420efa3 100644 +--- a/src/ostree/ot-admin-builtin-deploy.c ++++ b/src/ostree/ot-admin-builtin-deploy.c +@@ -38,6 +38,7 @@ static char **opt_kernel_argv_append; + static gboolean opt_kernel_proc_cmdline; + static char *opt_osname; + static char *opt_origin_path; ++static gboolean opt_kernel_arg_none; + + static GOptionEntry options[] = { + { "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Use a different operating system root than the current one", "OSNAME" }, +@@ -46,6 +47,7 @@ static GOptionEntry options[] = { + { "karg-proc-cmdline", 0, 0, G_OPTION_ARG_NONE, &opt_kernel_proc_cmdline, "Import current /proc/cmdline", NULL }, + { "karg", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kernel_argv, "Set kernel argument, like root=/dev/sda1; this overrides any earlier argument with the same name", "NAME=VALUE" }, + { "karg-append", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kernel_argv_append, "Append kernel argument; useful with e.g. console= that can be used multiple times", "NAME=VALUE" }, ++ { "karg-none", 0, 0, G_OPTION_ARG_NONE, &opt_kernel_arg_none, "Do not import kernel arguments", NULL }, + { NULL } + }; + +@@ -77,6 +79,12 @@ ot_admin_builtin_deploy (int argc, char **argv, GCancellable *cancellable, GErro + goto out; + } + ++ if (opt_kernel_proc_cmdline && opt_kernel_arg_none) ++ { ++ ot_util_usage_error (context, "Can't specify both --karg-proc-cmdline and --karg-none", error); ++ goto out; ++ } ++ + refspec = argv[1]; + + if (!ostree_sysroot_load (sysroot, cancellable, error)) +@@ -135,7 +143,7 @@ ot_admin_builtin_deploy (int argc, char **argv, GCancellable *cancellable, GErro + if (!_ostree_kernel_args_append_proc_cmdline (kargs, cancellable, error)) + goto out; + } +- else if (merge_deployment) ++ else if (merge_deployment && !opt_kernel_arg_none) + { + OstreeBootconfigParser *bootconfig = ostree_deployment_get_bootconfig (merge_deployment); + g_auto(GStrv) previous_args = g_strsplit (ostree_bootconfig_parser_get (bootconfig, "options"), " ", -1); +-- +2.7.4 + diff --git a/meta-boot2qt/recipes-core/ostree/ostree/ostree-prepare-root-enabler-for-simpler-kernel-arg.patch b/meta-boot2qt/recipes-core/ostree/ostree/ostree-prepare-root-enabler-for-simpler-kernel-arg.patch new file mode 100644 index 0000000..2800618 --- /dev/null +++ b/meta-boot2qt/recipes-core/ostree/ostree/ostree-prepare-root-enabler-for-simpler-kernel-arg.patch @@ -0,0 +1,54 @@ +From d183819e6e7bdc7a9476542cbef384285f592f3f Mon Sep 17 00:00:00 2001 +From: Gatis Paeglis +Date: Fri, 12 Aug 2016 08:50:29 +0200 +Subject: [PATCH 1/4] ostree-prepare-root: enabler for simpler kernel arg + +With the current approach, when ostree-prepare-root is used +on the kernel command line as init=, it always assumes that +the next value in the argument list is a path to the sysroot. +The code for falling back to a default path (if none is provided), +would only work if init= is the last arg in the argument list. +We can not rely on that and have to explicitly provide the +path to the sysroot. Which defeats the purpose of a default +path selection code. + +To keep command line neater assume that sysroot is on / when +using ostree-prepare-root as init. This probably is what most +people want anyways. Also _ostree_kernel_args* API assumes +that args are space separated list. Which is problematic for: +"init=${ostree}/usr/lib/ostree/ostree-prepare-root /" as it +gets split in two. +--- + src/switchroot/ostree-prepare-root.c | 15 ++++++++++++--- + 1 file changed, 12 insertions(+), 3 deletions(-) + +diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c +index 895b2e5..449fc33 100644 +--- a/src/switchroot/ostree-prepare-root.c ++++ b/src/switchroot/ostree-prepare-root.c +@@ -199,10 +199,19 @@ main(int argc, char *argv[]) + char srcpath[PATH_MAX]; + struct stat stbuf; + +- if (argc < 2) +- root_mountpoint = "/"; ++ if (getpid() == 1) ++ { ++ root_mountpoint = "/"; ++ } + else +- root_mountpoint = argv[1]; ++ { ++ if (argc < 2) ++ { ++ fprintf (stderr, "usage: ostree-prepare-root SYSROOT\n"); ++ exit (EXIT_FAILURE); ++ } ++ root_mountpoint = argv[1]; ++ } + + root_mountpoint = realpath (root_mountpoint, NULL); + deploy_path = resolve_deploy_path (root_mountpoint); +-- +2.7.4 + diff --git a/meta-boot2qt/recipes-core/ostree/ostree/u-boot-add-bootdir-to-the-generated-uEnv.txt.patch b/meta-boot2qt/recipes-core/ostree/ostree/u-boot-add-bootdir-to-the-generated-uEnv.txt.patch new file mode 100644 index 0000000..e8c8f16 --- /dev/null +++ b/meta-boot2qt/recipes-core/ostree/ostree/u-boot-add-bootdir-to-the-generated-uEnv.txt.patch @@ -0,0 +1,52 @@ +From 8323c038733522f7f31fefc8921b7c1760416638 Mon Sep 17 00:00:00 2001 +From: Gatis Paeglis +Date: Mon, 22 Aug 2016 15:52:21 +0200 +Subject: [PATCH 3/3] u-boot: add 'bootdir' to the generated uEnv.txt + +When doing a full copy of: + +$deployment/usr/lib/ostree-boot -> /boot/ostree/$os-$bootcsum/ + +U-Boot bootscript can use the 'bootdir' to find, for example, +the Device Tree (dtb) file, as in: + +load ${dtype} ${disk}:${bootpart} ${a_fdt} ${bootdir}${dtbname} + +Or u-boot external bootscript: + +load ${dtype} ${disk}:${bootpart} ${a_scr} ${bootdir}${scriptname} + +It could also be possible to point 'bootdir' directly to the +$deployment/usr/lib/ostree-boot, but this would add unnecessary +restrictions on what file system can be used for rootfs as u-boot, +for example, can not read from BTRFS. So having +bootdir=/boot/ostree/$os-$bootcsum/ is a better approach here, as +/boot can be on a separate partition with its own file system type. +--- + src/libostree/ostree-bootloader-uboot.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/libostree/ostree-bootloader-uboot.c b/src/libostree/ostree-bootloader-uboot.c +index f95ea84..0786626 100644 +--- a/src/libostree/ostree-bootloader-uboot.c ++++ b/src/libostree/ostree-bootloader-uboot.c +@@ -72,6 +72,7 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self, + g_autoptr(GPtrArray) boot_loader_configs = NULL; + OstreeBootconfigParser *config; + const char *val; ++ g_autofree char *bootdir = NULL; + + if (!_ostree_sysroot_read_boot_loader_configs (self->sysroot, bootversion, &boot_loader_configs, + cancellable, error)) +@@ -88,6 +89,8 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self, + return FALSE; + } + g_ptr_array_add (new_lines, g_strdup_printf ("kernel_image=%s", val)); ++ bootdir = strndup (val, strrchr(val, '/') - val); ++ g_ptr_array_add (new_lines, g_strdup_printf ("bootdir=%s/", bootdir)); + + val = ostree_bootconfig_parser_get (config, "initrd"); + if (val) +-- +2.7.4 + diff --git a/meta-boot2qt/recipes-core/ostree/ostree/workaround-gtkdocize-configure-issue-in-autog.patch b/meta-boot2qt/recipes-core/ostree/ostree/workaround-gtkdocize-configure-issue-in-autog.patch new file mode 100644 index 0000000..5f19007 --- /dev/null +++ b/meta-boot2qt/recipes-core/ostree/ostree/workaround-gtkdocize-configure-issue-in-autog.patch @@ -0,0 +1,26 @@ +From 0b6711e10d36060d80962472c892c60e8a403422 Mon Sep 17 00:00:00 2001 +From: Mikko Gronoff +Date: Thu, 2 Feb 2017 13:38:54 +0200 +Subject: [PATCH] ostree: workaround gtkdocize configure issue in autogen.sh + +Building meta-boot2qt morty branch content with poky 2.2.1 causes +build break in ostree autogen.sh. Called gtkdocize script uses wrong +docdir thus causing error trying to remove gtk-doc.make in wrong +location +--- + autogen.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/autogen.sh b/autogen.sh +index 0f32089..f473fdc 100755 +--- a/autogen.sh ++++ b/autogen.sh +@@ -25,7 +25,7 @@ EXTRA_DIST = + CLEANFILES = + EOF + else +- gtkdocize ++ gtkdocize --docdir $srcdir --srcdir $srcdir + fi + + cd $olddir -- cgit v1.2.3-54-g00ecf