diff --git a/recipes/libgsystem/libgsystem.bb b/recipes/libgsystem/libgsystem.bb deleted file mode 100644 index 0e140551cdc645449e898adb00b97797787de425..0000000000000000000000000000000000000000 --- a/recipes/libgsystem/libgsystem.bb +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################ -## -## 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 = "LibGSystem is a GIO-based library, targeted primarily for use by operating system components." - -LICENSE = "LGPL-2.1" -LIC_FILES_CHKSUM = "file://COPYING;md5=5f30f0716dfdd0d91eb439ebec522ec2" - -inherit autotools pkgconfig - -SRC_URI = "gitsm://github.com/GNOME/libgsystem.git;protocol=git" -SRCREV = "86c24c181ec6c3ec334a39145efc022c3e744929" - -S = "${WORKDIR}/git" - -DEPENDS = "glib-2.0 attr libcap" - -do_configure_prepend() { - # Workaround a broken configure.ac. It should check first if GTK_DOC_CHECK - # macro is actually defined before trying to use it. For how-to see: - # https://developer.gnome.org/gtk-doc-manual/stable/settingup_autoconf.html.en - # We get a syntax error since we do not bundle gnome recipes that define this macro. - sed -i '/GTK_DOC_CHECK/d' ${S}/configure.ac -} diff --git a/recipes/ostree/ostree.bb b/recipes/ostree/ostree.bb index 39ee76c78ade49d9f71cba77ec47c3322660453a..c0ac11ae467e9832b82b1c42f0a06c586f578b27 100644 --- a/recipes/ostree/ostree.bb +++ b/recipes/ostree/ostree.bb @@ -35,19 +35,22 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=5f30f0716dfdd0d91eb439ebec522ec2" inherit autotools pkgconfig systemd SRC_URI = " \ - git://github.com/GNOME/ostree.git \ - file://Fix-enable_rofiles_fuse-no-build.patch \ + 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://u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch \ file://Create-firmware-convenience-symlinks.patch \ " -SRCREV = "v2016.5" +SRCREV = "77af6844d8330b31d58080076afb31e08974ce09" S = "${WORKDIR}/git" -DEPENDS = "glib-2.0 e2fsprogs gpgme attr libsoup-2.4 libgsystem libassuan xz" +DEPENDS = "glib-2.0 e2fsprogs gpgme attr libsoup-2.4 libassuan xz" # 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" @@ -68,6 +71,7 @@ EXTRA_OECONF = "--with-dracut \ --enable-gtk-doc-html=no \ --enable-man=no \ --with-soup \ + --with-static-prepare-root \ --enable-libsoup-client-certs" do_configure_prepend() { diff --git a/recipes/ostree/ostree/Allow-updating-files-in-the-boot-directory.patch b/recipes/ostree/ostree/Allow-updating-files-in-the-boot-directory.patch index ffcc77c8afd3e477f0072e27f90df837af3d69f3..d416543a79845936968bdc807bbb68a0f43f411d 100644 --- a/recipes/ostree/ostree/Allow-updating-files-in-the-boot-directory.patch +++ b/recipes/ostree/ostree/Allow-updating-files-in-the-boot-directory.patch @@ -1,34 +1,90 @@ -From 7f4549c6e94494460be06311c3a4d23ae684ab21 Mon Sep 17 00:00:00 2001 -From: Gatis Paeglis <gatis.paeglis@theqtcompany.com> -Date: Wed, 20 Apr 2016 13:58:27 +0200 -Subject: [PATCH 1/3] Allow updating files in the /boot directory. +From cc31c80658a90cf1b13fdf9fe8b6dde1cc9a0d24 Mon Sep 17 00:00:00 2001 +From: Gatis Paeglis <gatis.paeglis@qt.io> +Date: Mon, 22 Aug 2016 11:32:16 +0200 +Subject: [PATCH 1/3] Allow updating files in the /boot directory -Until now OSTree copied only the vmlinuz and initramfs -binaries to the boot/ directory (which in some setups -might be on a separate partition). This patch adds -support for copying other files from the deployment's -/boot directory to the real /boot. - -How this works: - -Ignore subdirectories, only files in root of the boot -directory are copied. There is overhead of copying files -to boot/, therefore the amount of files in boot/ should -be kept to the minimum and subdirectories shouldn't -really be necessary. - -Files in the boot/ directory are updated only with major -releases, when kernel/initramfs bootcsum changes. Files -that require frequent updates should not be stored here. +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 | 52 +++++++++++++++++++++++++++++++++++ - 1 file changed, 52 insertions(+) + 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 8877236..8cf080e 100644 +index a05ca30..f34e3f3 100644 --- a/src/libostree/ostree-sysroot-deploy.c +++ b/src/libostree/ostree-sysroot-deploy.c -@@ -1295,6 +1295,7 @@ install_deployment_kernel (OstreeSysroot *sysroot, +@@ -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; @@ -36,60 +92,66 @@ index 8877236..8cf080e 100644 GString *title_key; __attribute__((cleanup(_ostree_kernel_args_cleanup))) OstreeKernelArgs *kargs = NULL; const char *val; -@@ -1361,6 +1362,57 @@ install_deployment_kernel (OstreeSysroot *sysroot, +@@ -1367,6 +1397,63 @@ install_deployment_kernel (OstreeSysroot *sysroot, } } -+ -+ /* Copy other files that are stored in deployment's /usr/lib/ostree-boot. Lets keep this simple: -+ * -+ * - Ignore subdirectories. Only files in root of the /usr/lib/ostree-boot directory are copied. -+ * There is an overhead of copying files to boot/, therefore the amount of files in a deployment's -+ * usr/lib/ostree-boot should be kept to the minimum and subdirectories shouldn't really -+ * be necessary. -+ * -+ * - Files in /boot are updated only with major releases, when kernel/initramfs -+ * bootcsum changes. Files that require frequent updates should not be stored here. -+ */ -+ if (!glnx_dirfd_iterator_init_take_fd (dup (tree_boot_dfd), &dfd_iter, error)) -+ goto out; -+ -+ while (TRUE) ++ if (fstatat (tree_boot_dfd, ".ostree-bootcsumdir-source", &stbuf, 0) == 0) + { -+ struct dirent *dent; -+ -+ if (!glnx_dirfd_iterator_next_dent (&dfd_iter, &dent, cancellable, error)) ++ if (!glnx_dirfd_iterator_init_at (tree_boot_dfd, ".", FALSE, &dfd_iter, error)) + goto out; + -+ if (dent == NULL) -+ break; -+ -+ if (fstatat (dfd_iter.fd, dent->d_name, &stbuf, 0) != 0) ++ while (TRUE) + { -+ if (errno == ENOENT) -+ continue; -+ glnx_set_error_from_errno (error); -+ goto out; -+ } ++ struct dirent *dent; + -+ if (g_str_has_prefix (dent->d_name, "vmlinuz-") || g_str_has_prefix (dent->d_name, "initramfs-") -+ || !S_ISREG(stbuf.st_mode)) -+ continue; ++ if (!glnx_dirfd_iterator_next_dent (&dfd_iter, &dent, cancellable, error)) ++ goto out; ++ if (dent == NULL) ++ break; + -+ if (fstatat (bootcsum_dfd, dent->d_name, &stbuf, 0) != 0) -+ { -+ if (errno != ENOENT) ++ /* 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) + { -+ glnx_set_prefix_error_from_errno (error, "fstat %s", dent->d_name); -+ goto out; ++ 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; ++ } + } -+ if (!glnx_file_copy_at (tree_boot_dfd, dent->d_name, &stbuf, -+ bootcsum_dfd, dent->d_name, 0, -+ 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) { diff --git a/recipes/ostree/ostree/Create-firmware-convenience-symlinks.patch b/recipes/ostree/ostree/Create-firmware-convenience-symlinks.patch index 960367c6c64636404639816159b23b1b15ca5457..656887dddbc4cd429e29202988183d9c91b9ac5f 100644 --- a/recipes/ostree/ostree/Create-firmware-convenience-symlinks.patch +++ b/recipes/ostree/ostree/Create-firmware-convenience-symlinks.patch @@ -1,44 +1,42 @@ -From 310ddd84dc353d93a2cc118725b459dba643cf0b Mon Sep 17 00:00:00 2001 -From: Gatis Paeglis <gatis.paeglis@theqtcompany.com> -Date: Thu, 21 Apr 2016 16:54:05 +0200 -Subject: [PATCH 3/3] Create firmware convenience symlinks. +From c4df63488b9e09a9aa69e32ea5c0671c9dc50c9d Mon Sep 17 00:00:00 2001 +From: Gatis Paeglis <gatis.paeglis@qt.io> +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 | 97 ++++++++++++++++++++++++++++++++- - 1 file changed, 96 insertions(+), 1 deletion(-) + 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 9bcde9c..be5e8c5 100644 +index 22251da..26a3127 100644 --- a/src/libostree/ostree-bootloader-uboot.c +++ b/src/libostree/ostree-bootloader-uboot.c -@@ -66,6 +66,100 @@ _ostree_bootloader_uboot_get_name (OstreeBootloader *bootloader) +@@ -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 from the OS installer, by creating a symlink in the -+ * following way: ++ * 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 loader/. ++ * symlink files pointing into the loader/ directory. + */ +static gboolean -+create_firmware_convenience_symlinks (OstreeBootloaderUboot *self, ++create_firmware_convenience_symlinks (OstreeBootloaderUboot *self, + char *bootcsum_dir, + int bootversion, + GCancellable *cancellable, + GError **error) +{ -+ gboolean ret = FALSE; + glnx_fd_close int loader_dfd = -1; + glnx_fd_close int boot_dfd = -1; + g_autofree char *loader_dir = NULL; @@ -46,18 +44,18 @@ index 9bcde9c..be5e8c5 100644 + + loader_dir = g_strdup_printf ("boot/loader.%d/", bootversion); + if (!glnx_opendirat (self->sysroot->sysroot_fd, loader_dir, FALSE, &loader_dfd, error)) -+ goto out; ++ return FALSE; + if (!glnx_opendirat (self->sysroot->sysroot_fd, "boot", FALSE, &boot_dfd, error)) -+ goto out; ++ return FALSE; + if (!glnx_dirfd_iterator_init_take_fd (dup (boot_dfd), &dfd_iter, error)) -+ goto out; ++ return FALSE; + + while (TRUE) { + struct dirent *dent; + struct stat stbuf; + + if (!glnx_dirfd_iterator_next_dent (&dfd_iter, &dent, cancellable, error)) -+ goto out; ++ return FALSE; + if (dent == NULL) + break; + @@ -66,7 +64,7 @@ index 9bcde9c..be5e8c5 100644 + if (errno == ENOENT) + continue; + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "fstatat"); -+ goto out; ++ return FALSE; + } + + if (S_ISLNK(stbuf.st_mode)) @@ -87,44 +85,42 @@ index 9bcde9c..be5e8c5 100644 + if (errno == ENOENT) + continue; + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "faccessat"); -+ goto out; ++ return FALSE; + } + -+ /* In case 'ostree admin cleanup' was not run after an interrupted deployment */ ++ /* 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"); -+ goto out; ++ return FALSE; + } -+ /* Complete the link chain to the current boot file version */ ++ /* 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"); -+ goto out; ++ return FALSE; + } + } + } + } + -+ ret = TRUE; -+out: -+ return ret; ++ return TRUE; +} + static gboolean create_config_from_boot_loader_entries (OstreeBootloaderUboot *self, int bootversion, -@@ -130,7 +224,8 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self, +@@ -138,7 +229,7 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self, } } -- ret = TRUE; -+ ret = create_firmware_convenience_symlinks (self, bootdir, bootversion, cancellable, error); -+ - out: - return ret; +- return TRUE; ++ return create_firmware_convenience_symlinks (self, bootdir, bootversion, cancellable, error); } + + static gboolean -- 2.7.4 diff --git a/recipes/ostree/ostree/Fix-enable_rofiles_fuse-no-build.patch b/recipes/ostree/ostree/Fix-enable_rofiles_fuse-no-build.patch deleted file mode 100644 index 480fc2171aacc83581b893add863f60d47b73cf2..0000000000000000000000000000000000000000 --- a/recipes/ostree/ostree/Fix-enable_rofiles_fuse-no-build.patch +++ /dev/null @@ -1,40 +0,0 @@ -From b54643153cade28523cccee44fdddea2c94e0684 Mon Sep 17 00:00:00 2001 -From: Gatis Paeglis <gatis.paeglis@theqtcompany.com> -Date: Mon, 25 Apr 2016 13:57:03 +0200 -Subject: [PATCH] Fix --enable_rofiles_fuse=no build - ---- - Makefile.am | 2 ++ - configure.ac | 2 +- - 2 files changed, 3 insertions(+), 1 deletion(-) - -diff --git a/Makefile.am b/Makefile.am -index 488d4b6..e49b7c5 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -71,7 +71,9 @@ include Makefile-otutil.am - include Makefile-libostree.am - include Makefile-ostree.am - include Makefile-switchroot.am -+if BUILDOPT_FUSE - include src/rofiles-fuse/Makefile-inc.am -+endif - include Makefile-tests.am - include Makefile-boot.am - include Makefile-man.am -diff --git a/configure.ac b/configure.ac -index dca9f53..6af60e8 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -222,7 +222,7 @@ AC_ARG_ENABLE(rofiles-fuse, - [AS_HELP_STRING([--enable-rofiles-fuse], - [generate rofiles-fuse helper [default=yes]])],, - enable_rofiles_fuse=yes) --AS_IF([ test $enable_rofiles_fuse != xno ], [ -+AS_IF([ test x$enable_rofiles_fuse != xno ], [ - PKG_CHECK_MODULES(BUILDOPT_FUSE, $FUSE_DEPENDENCY) - ], [enable_rofiles_fuse=no]) - AM_CONDITIONAL(BUILDOPT_FUSE, test x$enable_rofiles_fuse = xyes) --- -2.7.4 - diff --git a/recipes/ostree/ostree/Support-for-booting-without-initramfs.patch b/recipes/ostree/ostree/Support-for-booting-without-initramfs.patch new file mode 100644 index 0000000000000000000000000000000000000000..4ec137fdf3189a0b76d497037787775253aee073 --- /dev/null +++ b/recipes/ostree/ostree/Support-for-booting-without-initramfs.patch @@ -0,0 +1,131 @@ +From a31c9083870fd934e242cc9cc56fdd39ad0a42cb Mon Sep 17 00:00:00 2001 +From: Gatis Paeglis <gatis.paeglis@qt.io> +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/recipes/ostree/ostree/deploy-add-karg-none-argument.patch b/recipes/ostree/ostree/deploy-add-karg-none-argument.patch new file mode 100644 index 0000000000000000000000000000000000000000..5eaf68f07c6a3f12cdad0961530dbb8257dd87a8 --- /dev/null +++ b/recipes/ostree/ostree/deploy-add-karg-none-argument.patch @@ -0,0 +1,62 @@ +From 9ca3a2cc64bc709649d0d756fa715aaef807dca8 Mon Sep 17 00:00:00 2001 +From: Gatis Paeglis <gatis.paeglis@qt.io> +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/recipes/ostree/ostree/ostree-prepare-root-enabler-for-simpler-kernel-arg.patch b/recipes/ostree/ostree/ostree-prepare-root-enabler-for-simpler-kernel-arg.patch new file mode 100644 index 0000000000000000000000000000000000000000..280061852e2e17321f4ddcce7eb577f9e0458156 --- /dev/null +++ b/recipes/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 <gatis.paeglis@qt.io> +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/recipes/ostree/ostree/u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch b/recipes/ostree/ostree/u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch index 501f8d4db3969760e2e2aaec9d2fdad251af6fa3..80677c7601552c86b017ec1790f0efd00e4aa11d 100644 --- a/recipes/ostree/ostree/u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch +++ b/recipes/ostree/ostree/u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch @@ -1,104 +1,76 @@ -From 86184e5a266b087ba222b03141b491241e27e284 Mon Sep 17 00:00:00 2001 -From: Gatis Paeglis <gatis.paeglis@theqtcompany.com> -Date: Thu, 21 Apr 2016 14:28:38 +0200 -Subject: [PATCH 2/3] u-boot: Merge ostree's and systems uEnv.txt +From 4d8648d35ba7fe60f428aab2240aa6044fb51c50 Mon Sep 17 00:00:00 2001 +From: Gatis Paeglis <gatis.paeglis@qt.io> +Date: Tue, 23 Aug 2016 14:32:35 +0200 +Subject: [PATCH 1/2] u-boot: Merge ostree's and systems uEnv.txt -This allow for simpler u-boot scripts and is a proper -fix for: https://bugzilla.gnome.org/show_bug.cgi?id=755787 +This is a proper fix for: +https://bugzilla.gnome.org/show_bug.cgi?id=755787 -With this patch admin can now: +With this patch, an admin (system builder) can now: 1) Edit /usr/lib/ostree-boot/uEnv.txt +2) Deploy the new tree. OSTree will append system's uEnv.txt + to the OSTree's managed uEnv.txt (loader/uEnv.txt). -2) Download the update to a target. And during the deploy - process OSTree will prepend its env (loader/uEnv.txt) - to the system's uEnv.txt +It is common for u-boot systems to read in an extra env +from external /uEnv.txt. The same file OSTree uses to pass +in its env. With this patch /uEnv.txt now contains OSTree's +env + custom env added by system builders. --- - src/libostree/ostree-bootloader-uboot.c | 41 ++++++++++++++++++++++++++++++--- - 1 file changed, 38 insertions(+), 3 deletions(-) + src/libostree/ostree-bootloader-uboot.c | 40 ++++++++++++++++++++++++++++++++- + 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/libostree/ostree-bootloader-uboot.c b/src/libostree/ostree-bootloader-uboot.c -index f67e9bd..9bcde9c 100644 +index f95ea84..5172477 100644 --- a/src/libostree/ostree-bootloader-uboot.c +++ b/src/libostree/ostree-bootloader-uboot.c -@@ -29,6 +29,10 @@ - #include "otutil.h" +@@ -95,7 +95,45 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self, - #include <string.h> -+#include <stdlib.h> -+#include <stdio.h> -+#include <unistd.h> -+#include <fcntl.h> - - struct _OstreeBootloaderUboot - { -@@ -69,13 +73,17 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self, - GCancellable *cancellable, - GError **error) - { -+ gboolean ret = FALSE; - g_autoptr(GPtrArray) boot_loader_configs = NULL; - OstreeBootconfigParser *config; - const char *val; -+ g_autofree char *bootdir = NULL; -+ g_autoptr(GFile) uenv_file = NULL; -+ char uenv_path[PATH_MAX]; - - if (!_ostree_sysroot_read_boot_loader_configs (self->sysroot, bootversion, &boot_loader_configs, - cancellable, error)) -- return FALSE; -+ goto out; - - /* U-Boot doesn't support a menu so just pick the first one since the list is ordered */ - config = boot_loader_configs->pdata[0]; -@@ -85,10 +93,13 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self, - { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - "No \"linux\" key in bootloader config"); -- return FALSE; -+ goto out; - } - 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) - g_ptr_array_add (new_lines, g_strdup_printf ("ramdisk_image=%s", val)); -@@ -97,7 +108,31 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self, + val = ostree_bootconfig_parser_get (config, "options"); if (val) - g_ptr_array_add (new_lines, g_strdup_printf ("bootargs=%s", val)); - -- return TRUE; -+ /* Append user's uEnv.txt if it exists */ -+ snprintf (uenv_path, sizeof(uenv_path), "boot/%s/uEnv.txt", bootdir); -+ uenv_file = g_file_get_child (self->sysroot->path, uenv_path); -+ if (g_file_query_exists (uenv_file, cancellable)) +- g_ptr_array_add (new_lines, g_strdup_printf ("bootargs=%s", val)); + { -+ g_autoptr(GInputStream) instream = NULL; -+ g_autoptr(GDataInputStream) datastream = NULL; -+ gsize len; -+ instream = (GInputStream*)g_file_read (uenv_file, cancellable, error); -+ if (!instream) -+ goto out; ++ glnx_fd_close int uenv_fd = -1; ++ g_autofree char* kargs = g_strdup (val); ++ const char *uenv_path = NULL; ++ const char *ostree_arg = NULL; + -+ datastream = g_data_input_stream_new (instream); -+ while (TRUE) ++ g_ptr_array_add (new_lines, g_strdup_printf ("bootargs=%s", val)); ++ ++ /* Append system's uEnv.txt, if it exists in $deployment/usr/lib/ostree-boot/ */ ++ ostree_arg = strtok (kargs, " "); ++ while (ostree_arg != NULL && !g_str_has_prefix (ostree_arg, "ostree=")) ++ ostree_arg = strtok (NULL, " "); ++ if (!ostree_arg) ++ { ++ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, ++ "No ostree= kernel argument found in boot loader configuration file"); ++ return FALSE; ++ } ++ uenv_path = glnx_strjoina (ostree_arg + strlen ("ostree=/"), "/usr/lib/ostree-boot/uEnv.txt"); ++ uenv_fd = openat (self->sysroot->sysroot_fd, uenv_path, O_CLOEXEC | O_RDONLY); ++ if (uenv_fd != -1) ++ { ++ char *uenv = glnx_fd_readall_utf8 (uenv_fd, NULL, cancellable, error); ++ if (!uenv) ++ { ++ glnx_set_prefix_error_from_errno (error, "%s", uenv_path); ++ return FALSE; ++ } ++ g_ptr_array_add (new_lines, uenv); ++ } ++ else + { -+ val = g_data_input_stream_read_line (datastream, &len, cancellable, error); -+ if (!val) -+ break; -+ g_ptr_array_add (new_lines, (char *)val); ++ if (errno != ENOENT) ++ { ++ glnx_set_prefix_error_from_errno (error, "%s", uenv_path); ++ return FALSE; ++ } + } + } -+ -+ ret = TRUE; -+out: -+ return ret; - } - static gboolean + return TRUE; + } -- 2.7.4 diff --git a/recipes/ostree/ostree/u-boot-add-bootdir-to-the-generated-uEnv.txt.patch b/recipes/ostree/ostree/u-boot-add-bootdir-to-the-generated-uEnv.txt.patch new file mode 100644 index 0000000000000000000000000000000000000000..e8c8f16150a806f7929c09340a20c3d44c649eda --- /dev/null +++ b/recipes/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 <gatis.paeglis@qt.io> +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 +