Skip to content

Commit

Permalink
feat: support deploy when root is an overlayfs
Browse files Browse the repository at this point in the history
support deploy when root is an overlayfs

Log: support deploy when root is an overlayfs
  • Loading branch information
xml committed Aug 8, 2024
1 parent c1e3850 commit dfa5e6a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
ostree (2024.6-1deepin1) unstable; urgency=medium

* support deploy when root is an overlayfs

-- xiamengliang <[email protected]> Thu, 08 Aug 2024 14:25:11 +0800

ostree (2024.6-1) unstable; urgency=medium

* New upstream release
Expand Down
52 changes: 52 additions & 0 deletions debian/patches/deepin-deploy-when-root-is-overlay.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
--- a/src/libostree/ostree-sysroot.c
+++ b/src/libostree/ostree-sysroot.c
@@ -764,6 +764,33 @@
ostree_deployment_get_deployserial (deployment), key);
}

+static gboolean is_sysroot_booted_overlay(gchar* ostree) {
+ g_autofree gchar * txt;
+ g_file_get_contents("/proc/mounts", &txt,NULL,NULL);
+
+ gboolean is_sysroot_overlay = FALSE;
+ g_auto (GStrv) lines = g_strsplit (txt, "\n", -1);
+ for (char **iter = lines; *iter; iter++) {
+ const char *line = *iter;
+ g_auto (GStrv)items = g_strsplit_set (line, " ", 6);
+ if(g_strv_length (items) == 6 && \
+ g_str_equal(items[1], "/") && g_str_equal(items[2],"overlay")) {
+ g_auto (GStrv) opts = g_strsplit(items[3], ",", -1);
+ for (char **iter_opt = opts; *iter_opt; iter_opt++) {
+ if(g_str_has_prefix(*iter_opt, "upperdir=")) {
+ g_autofree gchar* upperdir = g_strdup((*iter_opt) + 9);
+ g_debug("upperdir=%s", upperdir);
+ if(g_str_has_suffix(upperdir, ostree)) {
+ is_sysroot_overlay = TRUE;
+ }
+ }
+ }
+ }
+ }
+
+ return is_sysroot_overlay;
+}
+
static gboolean
parse_deployment (OstreeSysroot *self, const char *boot_link, OstreeDeployment **out_deployment,
GCancellable *cancellable, GError **error)
@@ -835,12 +862,14 @@
else
g_debug ("Target rootdev key %s found", OTCORE_RUN_BOOTED_KEY_BACKING_ROOTDEVINO);

+ gboolean overlay_booted = is_sysroot_booted_overlay(deploy_basename);
+ g_debug("overlay_booted: %d", overlay_booted);
/* A bit ugly, we're assigning to a sysroot-owned variable from deep in
* this parsing code. But eh, if something fails the sysroot state can't
* be relied on anyways.
*/
is_booted_deployment
- = stbuf.st_dev == expected_root_dev && stbuf.st_ino == expected_root_inode;
+ = (stbuf.st_dev == expected_root_dev && stbuf.st_ino == expected_root_inode) || overlay_booted;
}

g_autoptr (OstreeDeployment) ret_deployment
1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
debian/Skip-test-pull-repeated-during-CI.patch
debian/test-sysroot-Skip-on-s390x-by-default.patch
debian/Skip-test-admin-deploy-uboot.sh-on-s390x.patch
deepin-deploy-when-root-is-overlay.patch

0 comments on commit dfa5e6a

Please sign in to comment.