summaryrefslogtreecommitdiffstats
path: root/qt-ostree
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@qt.io>2016-08-05 13:45:05 +0200
committerGatis Paeglis <gatis.paeglis@qt.io>2016-08-24 13:50:42 +0000
commit202bcad2d975facdfe00d69ce0167a933fb32e27 (patch)
treed4f02cbddda794789c5255147c34313a2e7f0065 /qt-ostree
parentd238fcca176b20c11afc4267b1552c513f531c32 (diff)
build_ostree.sh: update revision
Change-Id: I4c1174970c26802df8ad58bbdb1df1a24d78bc4e Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'qt-ostree')
-rwxr-xr-xqt-ostree/build-ostree.sh44
-rw-r--r--qt-ostree/patches/Allow-updating-files-in-the-boot-directory.patch161
-rw-r--r--qt-ostree/patches/Create-firmware-convenience-symlinks.patch (renamed from qt-ostree/patches/ostree-Create-firmware-convenience-symlinks.patch)62
-rw-r--r--qt-ostree/patches/Support-for-booting-without-initramfs.patch131
-rw-r--r--qt-ostree/patches/deploy-add-karg-none-argument.patch62
-rw-r--r--qt-ostree/patches/ostree-Allow-updating-files-in-the-boot-directory.patch99
-rw-r--r--qt-ostree/patches/ostree-Fix-build-for-HAVE_LIBSOUP_CLIENT_CERTS.patch32
-rw-r--r--qt-ostree/patches/ostree-Fix-enable_rofiles_fuse-no-build.patch42
-rw-r--r--qt-ostree/patches/ostree-prepare-root-enabler-for-simpler-kernel-arg.patch54
-rw-r--r--qt-ostree/patches/ostree-u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch104
-rw-r--r--qt-ostree/patches/u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch76
-rw-r--r--qt-ostree/patches/u-boot-add-bootdir-to-the-generated-uEnv.txt.patch52
-rwxr-xr-xqt-ostree/qt-ostree2
13 files changed, 580 insertions, 341 deletions
diff --git a/qt-ostree/build-ostree.sh b/qt-ostree/build-ostree.sh
index caf7cd9..243bc7b 100755
--- a/qt-ostree/build-ostree.sh
+++ b/qt-ostree/build-ostree.sh
@@ -29,42 +29,28 @@
#############################################################################
set -e
set -x
+
# On Ubuntu 14.04 the following build dependecies needs to be installed:
# sudo apt-get install git autoconf gtk-doc-tools libattr1-dev libcap-dev libghc-gio-dev liblzma-dev \
# e2fslibs-dev libgpgme11-dev libsoup2.4-dev libarchive-dev
+
DIR=$(dirname $(readlink -f $0))
-OTA_LIBGSYSTEM_REF="v2015.2"
-OTA_OSTREE_REF="v2016.5"
+OTA_OSTREE_REF="77af6844d8330b31d58080076afb31e08974ce09"
PARALLEL=4
cd "${DIR}"
-rm -rf libgsystem-git ostree-git
-
-# Build libgsystem.
-# Note: There is an ongoing work in the ostree project to remove this dependency.
-git clone https://github.com/GNOME/libgsystem.git libgsystem-git
-cd libgsystem-git
-git checkout ${OTA_LIBGSYSTEM_REF}
-git submodule update --init
-./autogen.sh \
- --disable-shared \
- --enable-static \
- CFLAGS='-fPIC'
-
-make V=1 -j ${PARALLEL}
-export PKG_CONFIG_PATH=$PWD/src
-export LD_LIBRARY_PATH=$PWD/.libs
-cd -
+rm -rf ostree-git
-# Build OSTree.
git clone https://github.com/ostreedev/ostree.git ostree-git
cd ostree-git
git checkout ${OTA_OSTREE_REF}
-git am "${DIR}"/patches/ostree-Fix-enable_rofiles_fuse-no-build.patch
-git am "${DIR}"/patches/ostree-Allow-updating-files-in-the-boot-directory.patch
-git am "${DIR}"/patches/ostree-u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch
-git am "${DIR}"/patches/ostree-Create-firmware-convenience-symlinks.patch
-git am "${DIR}"/patches/ostree-Fix-build-for-HAVE_LIBSOUP_CLIENT_CERTS.patch
+git am "${DIR}"/patches/ostree-prepare-root-enabler-for-simpler-kernel-arg.patch
+git am "${DIR}"/patches/deploy-add-karg-none-argument.patch
+git am "${DIR}"/patches/Support-for-booting-without-initramfs.patch
+git am "${DIR}"/patches/Allow-updating-files-in-the-boot-directory.patch
+git am "${DIR}"/patches/u-boot-add-bootdir-to-the-generated-uEnv.txt.patch
+git am "${DIR}"/patches/u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch
+git am "${DIR}"/patches/Create-firmware-convenience-symlinks.patch
./autogen.sh \
--with-soup \
@@ -72,15 +58,11 @@ git am "${DIR}"/patches/ostree-Fix-build-for-HAVE_LIBSOUP_CLIENT_CERTS.patch
--enable-gtk-doc-html=no \
--enable-man=no \
--disable-shared \
- --enable-static \
- CFLAGS='-I../libgsystem-git/src -fPIC' \
- LDFLAGS='-Wl,-rpath,\$$ORIGIN/lib/'
+ --enable-static
make V=1 -j ${PARALLEL}
-unset PKG_CONFIG_PATH
-unset LD_LIBRARY_PATH
cd -
mv ostree-git/ostree .
strip ostree
-rm -rf libgsystem-git ostree-git
+rm -rf ostree-git
diff --git a/qt-ostree/patches/Allow-updating-files-in-the-boot-directory.patch b/qt-ostree/patches/Allow-updating-files-in-the-boot-directory.patch
new file mode 100644
index 0000000..d416543
--- /dev/null
+++ b/qt-ostree/patches/Allow-updating-files-in-the-boot-directory.patch
@@ -0,0 +1,161 @@
+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
+
+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/qt-ostree/patches/ostree-Create-firmware-convenience-symlinks.patch b/qt-ostree/patches/Create-firmware-convenience-symlinks.patch
index a91f11e..656887d 100644
--- a/qt-ostree/patches/ostree-Create-firmware-convenience-symlinks.patch
+++ b/qt-ostree/patches/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.3
+2.7.4
diff --git a/qt-ostree/patches/Support-for-booting-without-initramfs.patch b/qt-ostree/patches/Support-for-booting-without-initramfs.patch
new file mode 100644
index 0000000..4ec137f
--- /dev/null
+++ b/qt-ostree/patches/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/qt-ostree/patches/deploy-add-karg-none-argument.patch b/qt-ostree/patches/deploy-add-karg-none-argument.patch
new file mode 100644
index 0000000..5eaf68f
--- /dev/null
+++ b/qt-ostree/patches/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/qt-ostree/patches/ostree-Allow-updating-files-in-the-boot-directory.patch b/qt-ostree/patches/ostree-Allow-updating-files-in-the-boot-directory.patch
deleted file mode 100644
index e05c9cd..0000000
--- a/qt-ostree/patches/ostree-Allow-updating-files-in-the-boot-directory.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-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.
-
-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.
----
- src/libostree/ostree-sysroot-deploy.c | 52 +++++++++++++++++++++++++++++++++++
- 1 file changed, 52 insertions(+)
-
-diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c
-index 8877236..8cf080e 100644
---- a/src/libostree/ostree-sysroot-deploy.c
-+++ b/src/libostree/ostree-sysroot-deploy.c
-@@ -1295,6 +1295,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;
-@@ -1361,6 +1362,57 @@ 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)
-+ {
-+ struct dirent *dent;
-+
-+ if (!glnx_dirfd_iterator_next_dent (&dfd_iter, &dent, cancellable, error))
-+ goto out;
-+
-+ if (dent == NULL)
-+ break;
-+
-+ if (fstatat (dfd_iter.fd, dent->d_name, &stbuf, 0) != 0)
-+ {
-+ if (errno == ENOENT)
-+ continue;
-+ glnx_set_error_from_errno (error);
-+ goto out;
-+ }
-+
-+ if (g_str_has_prefix (dent->d_name, "vmlinuz-") || g_str_has_prefix (dent->d_name, "initramfs-")
-+ || !S_ISREG(stbuf.st_mode))
-+ continue;
-+
-+ if (fstatat (bootcsum_dfd, dent->d_name, &stbuf, 0) != 0)
-+ {
-+ if (errno != ENOENT)
-+ {
-+ glnx_set_prefix_error_from_errno (error, "fstat %s", dent->d_name);
-+ goto out;
-+ }
-+ if (!glnx_file_copy_at (tree_boot_dfd, dent->d_name, &stbuf,
-+ bootcsum_dfd, dent->d_name, 0,
-+ cancellable, error))
-+ goto out;
-+ }
-+ }
-+
-+
- if (fstatat (deployment_dfd, "usr/lib/os-release", &stbuf, 0) != 0)
- {
- if (errno != ENOENT)
---
-2.7.3
-
diff --git a/qt-ostree/patches/ostree-Fix-build-for-HAVE_LIBSOUP_CLIENT_CERTS.patch b/qt-ostree/patches/ostree-Fix-build-for-HAVE_LIBSOUP_CLIENT_CERTS.patch
deleted file mode 100644
index dd7dd56..0000000
--- a/qt-ostree/patches/ostree-Fix-build-for-HAVE_LIBSOUP_CLIENT_CERTS.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From 0efbf32e1bcd1cfe046df072cbbc32182cca29a7 Mon Sep 17 00:00:00 2001
-From: Gatis Paeglis <gatis.paeglis@theqtcompany.com>
-Date: Thu, 12 May 2016 11:44:35 +0200
-Subject: [PATCH] Fix build for HAVE_LIBSOUP_CLIENT_CERTS
-
----
- src/libostree/ostree-fetcher.c | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/src/libostree/ostree-fetcher.c b/src/libostree/ostree-fetcher.c
-index d7915ba..d54b7c7 100644
---- a/src/libostree/ostree-fetcher.c
-+++ b/src/libostree/ostree-fetcher.c
-@@ -273,6 +273,7 @@ session_thread_set_proxy_cb (ThreadClosure *thread_closure,
- proxy_uri, NULL);
- }
-
-+#ifdef HAVE_LIBSOUP_CLIENT_CERTS
- static void
- session_thread_set_tls_interaction_cb (ThreadClosure *thread_closure,
- gpointer data)
-@@ -288,6 +289,7 @@ session_thread_set_tls_interaction_cb (ThreadClosure *thread_closure,
- SOUP_SESSION_TLS_INTERACTION,
- interaction, NULL);
- }
-+#endif
-
- static void
- session_thread_set_tls_database_cb (ThreadClosure *thread_closure,
---
-2.7.4
-
diff --git a/qt-ostree/patches/ostree-Fix-enable_rofiles_fuse-no-build.patch b/qt-ostree/patches/ostree-Fix-enable_rofiles_fuse-no-build.patch
deleted file mode 100644
index 6ffd3e8..0000000
--- a/qt-ostree/patches/ostree-Fix-enable_rofiles_fuse-no-build.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-From ad0de186bb968cb25987d0118aa94552ca9dfc33 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
-
-Closes: #276
-Approved by: cgwalters
----
- 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.3
-
diff --git a/qt-ostree/patches/ostree-prepare-root-enabler-for-simpler-kernel-arg.patch b/qt-ostree/patches/ostree-prepare-root-enabler-for-simpler-kernel-arg.patch
new file mode 100644
index 0000000..2800618
--- /dev/null
+++ b/qt-ostree/patches/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/qt-ostree/patches/ostree-u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch b/qt-ostree/patches/ostree-u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch
deleted file mode 100644
index a14f716..0000000
--- a/qt-ostree/patches/ostree-u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch
+++ /dev/null
@@ -1,104 +0,0 @@
-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
-
-This allow for simpler u-boot scripts and is a proper
-fix for: https://bugzilla.gnome.org/show_bug.cgi?id=755787
-
-With this patch admin can now:
-
-1) Edit /usr/lib/ostree-boot/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
----
- src/libostree/ostree-bootloader-uboot.c | 41 ++++++++++++++++++++++++++++++---
- 1 file changed, 38 insertions(+), 3 deletions(-)
-
-diff --git a/src/libostree/ostree-bootloader-uboot.c b/src/libostree/ostree-bootloader-uboot.c
-index f67e9bd..9bcde9c 100644
---- a/src/libostree/ostree-bootloader-uboot.c
-+++ b/src/libostree/ostree-bootloader-uboot.c
-@@ -29,6 +29,10 @@
- #include "otutil.h"
-
- #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,
- 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_autoptr(GInputStream) instream = NULL;
-+ g_autoptr(GDataInputStream) datastream = NULL;
-+ gsize len;
-+ instream = (GInputStream*)g_file_read (uenv_file, cancellable, error);
-+ if (!instream)
-+ goto out;
-+
-+ datastream = g_data_input_stream_new (instream);
-+ while (TRUE)
-+ {
-+ val = g_data_input_stream_read_line (datastream, &len, cancellable, error);
-+ if (!val)
-+ break;
-+ g_ptr_array_add (new_lines, (char *)val);
-+ }
-+ }
-+
-+ ret = TRUE;
-+out:
-+ return ret;
- }
-
- static gboolean
---
-2.7.3
-
diff --git a/qt-ostree/patches/u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch b/qt-ostree/patches/u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch
new file mode 100644
index 0000000..80677c7
--- /dev/null
+++ b/qt-ostree/patches/u-boot-Merge-ostree-s-and-systems-uEnv.txt.patch
@@ -0,0 +1,76 @@
+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 is a proper fix for:
+https://bugzilla.gnome.org/show_bug.cgi?id=755787
+
+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).
+
+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 | 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 f95ea84..5172477 100644
+--- a/src/libostree/ostree-bootloader-uboot.c
++++ b/src/libostree/ostree-bootloader-uboot.c
+@@ -95,7 +95,45 @@ 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));
++ {
++ glnx_fd_close int uenv_fd = -1;
++ g_autofree char* kargs = g_strdup (val);
++ const char *uenv_path = NULL;
++ const char *ostree_arg = NULL;
++
++ 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
++ {
++ if (errno != ENOENT)
++ {
++ glnx_set_prefix_error_from_errno (error, "%s", uenv_path);
++ return FALSE;
++ }
++ }
++ }
+
+ return TRUE;
+ }
+--
+2.7.4
+
diff --git a/qt-ostree/patches/u-boot-add-bootdir-to-the-generated-uEnv.txt.patch b/qt-ostree/patches/u-boot-add-bootdir-to-the-generated-uEnv.txt.patch
new file mode 100644
index 0000000..e8c8f16
--- /dev/null
+++ b/qt-ostree/patches/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
+
diff --git a/qt-ostree/qt-ostree b/qt-ostree/qt-ostree
index 5917027..dd9f0bc 100755
--- a/qt-ostree/qt-ostree
+++ b/qt-ostree/qt-ostree
@@ -571,6 +571,8 @@ organize_boot_files()
mv ${KERNEL} ${BOOT_FILE_PATH}/vmlinuz-${KERNEL_VERSION}-${bootcsum}
cp ${INITRAMFS} ${BOOT_FILE_PATH}/initramfs-${KERNEL_VERSION}-${bootcsum}
+ touch ${BOOT_FILE_PATH}/.ostree-bootcsumdir-source
+
# Boot loader companions.
if [[ "${BOOTLOADER}" = "u-boot" && -n "${UBOOT_ENV_FILE}" ]] ; then
cp ${UBOOT_ENV_FILE} ${BOOT_FILE_PATH}/