Skip to content

Instantly share code, notes, and snippets.

@cgwalters
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgwalters/22c2ce00fa65271112b8 to your computer and use it in GitHub Desktop.
Save cgwalters/22c2ce00fa65271112b8 to your computer and use it in GitHub Desktop.
From fc1eede8883bdad29eaaf0fd6d4bdfc5797e5d93 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Fri, 12 Jun 2015 15:42:29 -0400
Subject: [PATCH] Add two backported patches
First is a critical issue upstream in 7.1.2.
Second is also a breakage specific to Anaconda.
---
...0001-sysroot-Close-sysroot-fd-in-finalize.patch | 27 +++++++
.../sysroot-sort-returned-bootloader-configs.patch | 89 ++++++++++++++++++++++
SPECS/ostree.spec | 10 ++-
3 files changed, 125 insertions(+), 1 deletion(-)
create mode 100644 SOURCES/0001-sysroot-Close-sysroot-fd-in-finalize.patch
create mode 100644 SOURCES/sysroot-sort-returned-bootloader-configs.patch
diff --git a/SOURCES/0001-sysroot-Close-sysroot-fd-in-finalize.patch b/SOURCES/0001-sysroot-Close-sysroot-fd-in-finalize.patch
new file mode 100644
index 0000000..0905db9
--- /dev/null
+++ b/SOURCES/0001-sysroot-Close-sysroot-fd-in-finalize.patch
@@ -0,0 +1,27 @@
+From f08cb802ea1b02c874fd71a0672c28b49e890d49 Mon Sep 17 00:00:00 2001
+From: Colin Walters <walters@verbum.org>
+Date: Sun, 19 Apr 2015 15:25:05 -0400
+Subject: [PATCH] sysroot: Close sysroot fd in finalize
+
+Just noticed this while I was going to add another one there.
+---
+ src/libostree/ostree-sysroot.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c
+index b18c6b7..6255803 100644
+--- a/src/libostree/ostree-sysroot.c
++++ b/src/libostree/ostree-sysroot.c
+@@ -66,6 +66,9 @@ ostree_sysroot_finalize (GObject *object)
+ g_clear_object (&self->sepolicy);
+ g_clear_object (&self->repo);
+
++ if (self->sysroot_fd != -1)
++ (void) close (self->sysroot_fd);
++
+ G_OBJECT_CLASS (ostree_sysroot_parent_class)->finalize (object);
+ }
+
+--
+1.8.3.1
+
diff --git a/SOURCES/sysroot-sort-returned-bootloader-configs.patch b/SOURCES/sysroot-sort-returned-bootloader-configs.patch
new file mode 100644
index 0000000..57fa308
--- /dev/null
+++ b/SOURCES/sysroot-sort-returned-bootloader-configs.patch
@@ -0,0 +1,89 @@
+From 3300ee6259d191199f96b5f4e04ccfded3d11b86 Mon Sep 17 00:00:00 2001
+From: Colin Walters <walters@verbum.org>
+Date: Tue, 26 May 2015 18:46:47 -0400
+Subject: sysroot: Sort returned boot loader configs
+
+I haven't done a full dig through the history, but it seems quite
+possible right now we've been relying on inode enumeration
+order for generating bootloader configuration.
+
+Most of the time, newer inodes (i.e. later written files) will win.
+But that's obviously not reliable.
+
+Fix this by sorting the returned configuration internally.
+
+diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c
+index ebcb632..f12ebc5 100644
+--- a/src/libostree/ostree-sysroot.c
++++ b/src/libostree/ostree-sysroot.c
+@@ -361,6 +361,35 @@ _ostree_sysroot_read_current_subbootversion (OstreeSysroot *self,
+ return ret;
+ }
+
++static gint
++compare_boot_loader_configs (OstreeBootconfigParser *a,
++ OstreeBootconfigParser *b)
++{
++ const char *a_version = ostree_bootconfig_parser_get (a, "version");
++ const char *b_version = ostree_bootconfig_parser_get (b, "version");
++
++ if (a_version && b_version)
++ {
++ int r = strverscmp (a_version, b_version);
++ /* Reverse */
++ return -r;
++ }
++ else if (a_version)
++ return -1;
++ else
++ return 1;
++}
++
++static int
++compare_loader_configs_for_sorting (gconstpointer a_pp,
++ gconstpointer b_pp)
++{
++ OstreeBootconfigParser *a = *((OstreeBootconfigParser**)a_pp);
++ OstreeBootconfigParser *b = *((OstreeBootconfigParser**)b_pp);
++
++ return compare_boot_loader_configs (a, b);
++}
++
+ gboolean
+ _ostree_sysroot_read_boot_loader_configs (OstreeSysroot *self,
+ int bootversion,
+@@ -427,6 +456,9 @@ _ostree_sysroot_read_boot_loader_configs (OstreeSysroot *self,
+ }
+ }
+
++ /* Callers expect us to give them a sorted array */
++ g_ptr_array_sort (ret_loader_configs, compare_loader_configs_for_sorting);
++
+ done:
+ gs_transfer_out_value (out_loader_configs, &ret_loader_configs);
+ ret = TRUE;
+@@ -706,19 +738,8 @@ compare_deployments_by_boot_loader_version_reversed (gconstpointer a_pp,
+ OstreeDeployment *b = *((OstreeDeployment**)b_pp);
+ OstreeBootconfigParser *a_bootconfig = ostree_deployment_get_bootconfig (a);
+ OstreeBootconfigParser *b_bootconfig = ostree_deployment_get_bootconfig (b);
+- const char *a_version = ostree_bootconfig_parser_get (a_bootconfig, "version");
+- const char *b_version = ostree_bootconfig_parser_get (b_bootconfig, "version");
+-
+- if (a_version && b_version)
+- {
+- int r = strverscmp (a_version, b_version);
+- /* Reverse */
+- return -r;
+- }
+- else if (a_version)
+- return -1;
+- else
+- return 1;
++
++ return compare_boot_loader_configs (a_bootconfig, b_bootconfig);
+ }
+
+ /**
+--
+cgit v0.10.2
+
diff --git a/SPECS/ostree.spec b/SPECS/ostree.spec
index 1294365..40fdf88 100644
--- a/SPECS/ostree.spec
+++ b/SPECS/ostree.spec
@@ -1,10 +1,18 @@
Summary: Tool for managing bootable, immutable filesystem trees
Name: ostree
Version: 2015.6
-Release: 2.atomic%{?dist}
+Release: 2.atomic%{?dist}.2
#VCS: git:git://git.gnome.org/ostree
Source0: http://ftp.gnome.org/pub/GNOME/sources/ostree/%{version}/ostree-%{version}.tar.xz
Source1: 91-ostree.preset
+### CentOS specific patches
+# We carry this one as it's a critical bug in upstream
+Patch0: sysroot-sort-returned-bootloader-configs.patch
+# This one is necessary - also a bug in upstream that
+# we hit but upstream didn't because they haven't rebuilt anaconda
+# with a newer ostree
+Patch1: 0001-sysroot-Close-sysroot-fd-in-finalize.patch
+###
License: LGPLv2+
URL: http://live.gnome.org/OSTree
--
1.8.3.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment