From 0578449c428bb9ecbe40d00a4687902a04746285 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 21 Mar 2016 22:06:13 -0400 Subject: [PATCH] sysroot: Support /boot on / for syslinux and uboot People making smaller operating systems, particularly things like cloud images, don't need to have /boot as a separate partition. --- Makefile-tests.am | 1 + src/libostree/ostree-bootloader-grub2.c | 1 + src/libostree/ostree-bootloader-syslinux.c | 14 +++-- src/libostree/ostree-bootloader-uboot.c | 22 ++++---- src/libostree/ostree-bootloader.c | 10 ++-- src/libostree/ostree-bootloader.h | 2 + src/libostree/ostree-sysroot-deploy.c | 47 ++++++++++++++++ tests/admin-test.sh | 2 + tests/boot_on_root_bind_mount.mountinfo | 27 +++++++++ tests/boot_on_root_no_bind.mountinfo | 28 ++++++++++ tests/boot_partition.mountinfo | 41 ++++++++++++++ .../test-admin-deploy-syslinux-bootonslash.sh | 55 +++++++++++++++++++ 12 files changed, 231 insertions(+), 19 deletions(-) create mode 100644 tests/boot_on_root_bind_mount.mountinfo create mode 100644 tests/boot_on_root_no_bind.mountinfo create mode 100644 tests/boot_partition.mountinfo create mode 100755 tests/test-admin-deploy-syslinux-bootonslash.sh diff --git a/Makefile-tests.am b/Makefile-tests.am index 284dc76f73..39bc1315f1 100644 --- a/Makefile-tests.am +++ b/Makefile-tests.am @@ -89,6 +89,7 @@ _installed_or_uninstalled_test_scripts = \ tests/test-admin-upgrade-unconfigured.sh \ tests/test-admin-upgrade-endoflife.sh \ tests/test-admin-deploy-syslinux.sh \ + tests/test-admin-deploy-syslinux-bootonslash.sh \ tests/test-admin-deploy-2.sh \ tests/test-admin-deploy-karg.sh \ tests/test-admin-deploy-switch.sh \ diff --git a/src/libostree/ostree-bootloader-grub2.c b/src/libostree/ostree-bootloader-grub2.c index f0d348092e..c82559b0f2 100644 --- a/src/libostree/ostree-bootloader-grub2.c +++ b/src/libostree/ostree-bootloader-grub2.c @@ -320,6 +320,7 @@ grub2_child_setup (gpointer user_data) static gboolean _ostree_bootloader_grub2_write_config (OstreeBootloader *bootloader, int bootversion, + const char *boot_path_on_disk, GCancellable *cancellable, GError **error) { diff --git a/src/libostree/ostree-bootloader-syslinux.c b/src/libostree/ostree-bootloader-syslinux.c index 8b09a861b2..686f17383d 100644 --- a/src/libostree/ostree-bootloader-syslinux.c +++ b/src/libostree/ostree-bootloader-syslinux.c @@ -65,6 +65,7 @@ static gboolean append_config_from_loader_entries (OstreeBootloaderSyslinux *self, gboolean regenerate_default, int bootversion, + const char *boot_path_on_disk, GPtrArray *new_lines, GCancellable *cancellable, GError **error) @@ -89,15 +90,15 @@ append_config_from_loader_entries (OstreeBootloaderSyslinux *self, val = ostree_bootconfig_parser_get (config, "linux"); if (!val) return glnx_throw (error, "No \"linux\" key in bootloader config"); - g_ptr_array_add (new_lines, g_strdup_printf ("\tKERNEL %s", val)); + g_ptr_array_add (new_lines, g_strdup_printf ("\tKERNEL %s%s", boot_path_on_disk, val)); val = ostree_bootconfig_parser_get (config, "initrd"); if (val) - g_ptr_array_add (new_lines, g_strdup_printf ("\tINITRD %s", val)); + g_ptr_array_add (new_lines, g_strdup_printf ("\tINITRD %s%s", boot_path_on_disk, val)); val = ostree_bootconfig_parser_get (config, "devicetree"); if (val) - g_ptr_array_add (new_lines, g_strdup_printf ("\tDEVICETREE %s", val)); + g_ptr_array_add (new_lines, g_strdup_printf ("\tDEVICETREE %s%s", boot_path_on_disk, val)); val = ostree_bootconfig_parser_get (config, "options"); if (val) @@ -110,6 +111,7 @@ append_config_from_loader_entries (OstreeBootloaderSyslinux *self, static gboolean _ostree_bootloader_syslinux_write_config (OstreeBootloader *bootloader, int bootversion, + const char *boot_path_on_disk, GCancellable *cancellable, GError **error) { @@ -141,6 +143,7 @@ _ostree_bootloader_syslinux_write_config (OstreeBootloader *bootloader, { const char *line = *iter; gboolean skip = FALSE; + g_autofree char *nonostree_prefix = g_build_path ("/", boot_path_on_disk, "/ostree/", NULL); if (parsing_label && (line == NULL || !g_str_has_prefix (line, "\t"))) @@ -152,7 +155,7 @@ _ostree_bootloader_syslinux_write_config (OstreeBootloader *bootloader, /* If this is a non-ostree kernel, just emit the lines * we saw. */ - if (!g_str_has_prefix (kernel_arg, "/ostree/")) + if (!g_str_has_prefix (kernel_arg, nonostree_prefix)) { for (guint i = 0; i < tmp_lines->len; i++) { @@ -209,7 +212,8 @@ _ostree_bootloader_syslinux_write_config (OstreeBootloader *bootloader, regenerate_default = TRUE; if (!append_config_from_loader_entries (self, regenerate_default, - bootversion, new_lines, + bootversion, boot_path_on_disk, + new_lines, cancellable, error)) return FALSE; diff --git a/src/libostree/ostree-bootloader-uboot.c b/src/libostree/ostree-bootloader-uboot.c index 262681b1fd..f03002319a 100644 --- a/src/libostree/ostree-bootloader-uboot.c +++ b/src/libostree/ostree-bootloader-uboot.c @@ -105,10 +105,11 @@ append_system_uenv (OstreeBootloaderUboot *self, static gboolean create_config_from_boot_loader_entries (OstreeBootloaderUboot *self, - int bootversion, - GPtrArray *new_lines, - GCancellable *cancellable, - GError **error) + int bootversion, + const char *boot_path_on_disk, + GPtrArray *new_lines, + GCancellable *cancellable, + GError **error) { g_autoptr(GPtrArray) boot_loader_configs = NULL; OstreeBootconfigParser *config; @@ -134,11 +135,11 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self, "No \"linux\" key in bootloader config"); return FALSE; } - g_ptr_array_add (new_lines, g_strdup_printf ("kernel_image%s=%s", index_suffix, val)); + g_ptr_array_add (new_lines, g_strdup_printf ("kernel_image%s=%s%s", index_suffix, boot_path_on_disk, val)); val = ostree_bootconfig_parser_get (config, "initrd"); if (val) - g_ptr_array_add (new_lines, g_strdup_printf ("ramdisk_image%s=%s", index_suffix, val)); + g_ptr_array_add (new_lines, g_strdup_printf ("ramdisk_image%s=%s%s", index_suffix, boot_path_on_disk, val)); val = ostree_bootconfig_parser_get (config, "options"); if (val) @@ -155,9 +156,10 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self, static gboolean _ostree_bootloader_uboot_write_config (OstreeBootloader *bootloader, - int bootversion, - GCancellable *cancellable, - GError **error) + int bootversion, + const char *boot_path_on_disk, + GCancellable *cancellable, + GError **error) { OstreeBootloaderUboot *self = OSTREE_BOOTLOADER_UBOOT (bootloader); @@ -169,7 +171,7 @@ _ostree_bootloader_uboot_write_config (OstreeBootloader *bootloader, return FALSE; g_autoptr(GPtrArray) new_lines = g_ptr_array_new_with_free_func (g_free); - if (!create_config_from_boot_loader_entries (self, bootversion, new_lines, + if (!create_config_from_boot_loader_entries (self, bootversion, boot_path_on_disk, new_lines, cancellable, error)) return FALSE; diff --git a/src/libostree/ostree-bootloader.c b/src/libostree/ostree-bootloader.c index 87823f7ea5..e5b8337f92 100644 --- a/src/libostree/ostree-bootloader.c +++ b/src/libostree/ostree-bootloader.c @@ -53,14 +53,16 @@ _ostree_bootloader_get_name (OstreeBootloader *self) gboolean _ostree_bootloader_write_config (OstreeBootloader *self, - int bootversion, - GCancellable *cancellable, - GError **error) + int bootversion, + const char *boot_path_on_disk, + GCancellable *cancellable, + GError **error) { g_return_val_if_fail (OSTREE_IS_BOOTLOADER (self), FALSE); return OSTREE_BOOTLOADER_GET_IFACE (self)->write_config (self, bootversion, - cancellable, error); + boot_path_on_disk, + cancellable, error); } gboolean diff --git a/src/libostree/ostree-bootloader.h b/src/libostree/ostree-bootloader.h index a4793b08c8..b4ffe0a99a 100644 --- a/src/libostree/ostree-bootloader.h +++ b/src/libostree/ostree-bootloader.h @@ -44,6 +44,7 @@ struct _OstreeBootloaderInterface const char * (* get_name) (OstreeBootloader *self); gboolean (* write_config) (OstreeBootloader *self, int bootversion, + const char *boot_path_on_disk, GCancellable *cancellable, GError **error); gboolean (* is_atomic) (OstreeBootloader *self); @@ -61,6 +62,7 @@ const char *_ostree_bootloader_get_name (OstreeBootloader *self); gboolean _ostree_bootloader_write_config (OstreeBootloader *self, int bootversion, + const char *boot_path_on_disk, GCancellable *cancellable, GError **error); diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c index 0379735a4a..1ebf02a4ef 100644 --- a/src/libostree/ostree-sysroot-deploy.c +++ b/src/libostree/ostree-sysroot-deploy.c @@ -2042,6 +2042,49 @@ ostree_sysroot_write_deployments (OstreeSysroot *self, cancellable, error); } +/* Finds the path to /boot on the filesystem that /boot is actually stored on. + * If you have a dedicated boot partition this will probably be "". If it's + * stored on the root partition it will be "/boot". + * + * The path_out won't end with a "/". That means that "/" is represented at "" + */ +static gboolean +boot_find_path_on_disk(char** path_out, GError **error) +{ +#ifdef HAVE_LIBMOUNT + g_autoptr(libmnt_table) tb = mnt_new_table(); + g_assert (tb); + if (mnt_table_parse_mtab(tb, getenv("OSTREE_DEBUG_MOUNTINFO_FILE")) < 0) + return glnx_throw (error, "Failed to parse /proc/self/mountinfo"); + + const char *suffix = NULL; + struct libmnt_fs *fs = mnt_table_find_target(tb, "/boot", MNT_ITER_BACKWARD); + if (fs) + suffix = ""; + else + { + suffix = "boot"; + fs = mnt_table_find_target(tb, "/", MNT_ITER_BACKWARD); + if (!fs) + return glnx_throw (error, "libmount error: Can't find /"); + } + g_autofree char *path = g_build_path ("/", mnt_fs_get_root (fs), suffix, NULL); + if (strcmp(path, "/") == 0) + { + g_free (g_steal_pointer(&path)); + path = g_strdup(""); + } + + *path_out = g_steal_pointer(&path); + return TRUE; +#else /* !HAVE_LIBMOUNT */ + g_printerr ("warning: ostree compiled without libmount so we can't determine " + "whether /boot is its own partition. Assuming yes\n"); + *path_out = g_strdup(""); + return TRUE; +#endif /* HAVE_LIBMOUNT */ +} + /** * ostree_sysroot_write_deployments_with_options: * @self: Sysroot @@ -2239,7 +2282,11 @@ ostree_sysroot_write_deployments_with_options (OstreeSysroot *self, if (bootloader) { + g_autofree char *boot_path_on_disk = NULL; + if (!boot_find_path_on_disk (&boot_path_on_disk, error)) + goto out; if (!_ostree_bootloader_write_config (bootloader, new_bootversion, + boot_path_on_disk, cancellable, error)) { g_prefix_error (error, "Bootloader write config: "); diff --git a/tests/admin-test.sh b/tests/admin-test.sh index dafbc79b0a..c486692b18 100644 --- a/tests/admin-test.sh +++ b/tests/admin-test.sh @@ -42,6 +42,8 @@ assert_ostree_deployment_refs() { diff -u ostree-refs{-expected,}.txt } +export OSTREE_DEBUG_MOUNTINFO_FILE=${test_srcdir}/boot_partition.mountinfo + orig_mtime=$(stat -c '%.Y' sysroot/ostree/deploy) ${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime) diff --git a/tests/boot_on_root_bind_mount.mountinfo b/tests/boot_on_root_bind_mount.mountinfo new file mode 100644 index 0000000000..ccbae6dc79 --- /dev/null +++ b/tests/boot_on_root_bind_mount.mountinfo @@ -0,0 +1,27 @@ +13 14 179:1 / /sysroot rw,relatime shared:5 - ext4 /dev/root rw,data=ordered +14 1 179:1 /ostree/deploy/linux/deploy/61892bc01f9afdef900d7a7904fe934ac7fc8caf9befddc1faf0f6b4f179bf35.0 / rw,relatime shared:1 - ext4 /dev/root rw,data=ordered +15 14 179:1 /ostree/deploy/linux/var /var rw,relatime shared:2 - ext4 /dev/root rw,data=ordered +16 14 179:1 /boot /boot rw,relatime shared:3 - ext4 /dev/root rw,data=ordered +17 14 179:1 /ostree/deploy/linux/deploy/61892bc01f9afdef900d7a7904fe934ac7fc8caf9befddc1faf0f6b4f179bf35.0/usr /usr ro,relatime shared:4 - ext4 /dev/root rw,data=ordered +18 14 0:12 / /sys rw,nosuid,nodev,noexec,relatime shared:6 - sysfs sysfs rw +19 14 0:3 / /proc rw,nosuid,nodev,noexec,relatime shared:10 - proc proc rw +20 14 0:5 / /dev rw,nosuid shared:11 - devtmpfs devtmpfs rw,size=958480k,nr_inodes=181514,mode=755 +21 20 0:13 / /dev/shm rw,nosuid,nodev shared:12 - tmpfs tmpfs rw +22 20 0:10 / /dev/pts rw,nosuid,noexec,relatime shared:13 - devpts devpts rw,gid=5,mode=620,ptmxmode=000 +23 14 0:14 / /run rw,nosuid,nodev shared:14 - tmpfs tmpfs rw,mode=755 +24 23 0:15 / /run/lock rw,nosuid,nodev,noexec,relatime shared:15 - tmpfs tmpfs rw,size=5120k +25 18 0:16 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:7 - tmpfs tmpfs ro,mode=755 +26 25 0:17 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:8 - cgroup cgroup rw,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd +27 18 0:18 / /sys/fs/pstore rw,nosuid,nodev,noexec,relatime shared:9 - pstore pstore rw +28 25 0:19 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,freezer +29 25 0:20 / /sys/fs/cgroup/debug rw,nosuid,nodev,noexec,relatime shared:17 - cgroup cgroup rw,debug +30 25 0:21 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:18 - cgroup cgroup rw,cpuset +31 25 0:22 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:19 - cgroup cgroup rw,devices +32 25 0:23 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:20 - cgroup cgroup rw,memory +33 25 0:24 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:21 - cgroup cgroup rw,cpuacct,cpu +34 25 0:25 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:22 - cgroup cgroup rw,perf_event +35 19 0:26 / /proc/sys/fs/binfmt_misc rw,relatime shared:23 - autofs systemd-1 rw,fd=24,pgrp=1,timeout=0,minproto=5,maxproto=5,direct +36 20 0:11 / /dev/mqueue rw,relatime shared:24 - mqueue mqueue rw +37 14 0:27 / /tmp rw,nosuid,nodev shared:25 - tmpfs tmpfs rw +38 18 0:6 / /sys/kernel/debug rw,relatime shared:26 - debugfs debugfs rw +39 18 0:28 / /sys/fs/fuse/connections rw,relatime shared:27 - fusectl fusectl rw diff --git a/tests/boot_on_root_no_bind.mountinfo b/tests/boot_on_root_no_bind.mountinfo new file mode 100644 index 0000000000..7a24e8ce62 --- /dev/null +++ b/tests/boot_on_root_no_bind.mountinfo @@ -0,0 +1,28 @@ +19 25 0:18 / /sys rw,nosuid,nodev,noexec,relatime shared:7 - sysfs sysfs rw +20 25 0:4 / /proc rw,nosuid,nodev,noexec,relatime shared:12 - proc proc rw +21 25 0:6 / /dev rw,nosuid,relatime shared:2 - devtmpfs udev rw,size=3895676k,nr_inodes=973919,mode=755 +22 21 0:14 / /dev/pts rw,nosuid,noexec,relatime shared:3 - devpts devpts rw,gid=5,mode=620,ptmxmode=000 +23 25 0:19 / /run rw,nosuid,noexec,relatime shared:5 - tmpfs tmpfs rw,size=782788k,mode=755 +25 0 8:1 / / rw,relatime shared:1 - ext4 /dev/sda1 rw,errors=remount-ro,data=ordered +26 19 0:12 / /sys/kernel/security rw,nosuid,nodev,noexec,relatime shared:8 - securityfs securityfs rw +27 21 0:21 / /dev/shm rw,nosuid,nodev shared:4 - tmpfs tmpfs rw +28 23 0:22 / /run/lock rw,nosuid,nodev,noexec,relatime shared:6 - tmpfs tmpfs rw,size=5120k +29 19 0:23 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:9 - tmpfs tmpfs ro,mode=755 +30 29 0:24 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:10 - cgroup cgroup rw,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd +31 19 0:25 / /sys/fs/pstore rw,nosuid,nodev,noexec,relatime shared:11 - pstore pstore rw +32 29 0:26 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:13 - cgroup cgroup rw,memory +33 29 0:27 / /sys/fs/cgroup/net_cls,net_prio rw,nosuid,nodev,noexec,relatime shared:14 - cgroup cgroup rw,net_cls,net_prio +34 29 0:28 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,blkio +35 29 0:29 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,devices +36 29 0:30 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:17 - cgroup cgroup rw,cpu,cpuacct +37 29 0:31 / /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime shared:18 - cgroup cgroup rw,pids +38 29 0:32 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:19 - cgroup cgroup rw,cpuset +39 29 0:33 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:20 - cgroup cgroup rw,perf_event +40 29 0:34 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:21 - cgroup cgroup rw,freezer +41 29 0:35 / /sys/fs/cgroup/hugetlb rw,nosuid,nodev,noexec,relatime shared:22 - cgroup cgroup rw,hugetlb +42 21 0:17 / /dev/mqueue rw,relatime shared:23 - mqueue mqueue rw +43 19 0:7 / /sys/kernel/debug rw,relatime shared:24 - debugfs debugfs rw +44 20 0:36 / /proc/sys/fs/binfmt_misc rw,relatime shared:25 - autofs systemd-1 rw,fd=30,pgrp=1,timeout=0,minproto=5,maxproto=5,direct +45 21 0:37 / /dev/hugepages rw,relatime shared:26 - hugetlbfs hugetlbfs rw +46 19 0:38 / /sys/fs/fuse/connections rw,relatime shared:27 - fusectl fusectl rw +47 44 0:39 / /proc/sys/fs/binfmt_misc rw,relatime shared:28 - binfmt_misc binfmt_misc rw diff --git a/tests/boot_partition.mountinfo b/tests/boot_partition.mountinfo new file mode 100644 index 0000000000..67d0341324 --- /dev/null +++ b/tests/boot_partition.mountinfo @@ -0,0 +1,41 @@ +20 25 0:19 / /sys rw,nosuid,nodev,noexec,relatime shared:7 - sysfs sysfs rw +21 25 0:4 / /proc rw,nosuid,nodev,noexec,relatime shared:12 - proc proc rw +22 25 0:6 / /dev rw,nosuid,relatime shared:2 - devtmpfs udev rw,size=3860744k,nr_inodes=965186,mode=755 +23 22 0:20 / /dev/pts rw,nosuid,noexec,relatime shared:3 - devpts devpts rw,gid=5,mode=620,ptmxmode=000 +24 25 0:21 / /run rw,nosuid,noexec,relatime shared:5 - tmpfs tmpfs rw,size=774888k,mode=755 +25 0 253:0 / / rw,relatime shared:1 - ext4 /dev/mapper/sda2_crypt rw,discard,errors=remount-ro,data=ordered +26 20 0:7 / /sys/kernel/security rw,nosuid,nodev,noexec,relatime shared:8 - securityfs securityfs rw +27 22 0:22 / /dev/shm rw,nosuid,nodev shared:4 - tmpfs tmpfs rw +28 24 0:23 / /run/lock rw,nosuid,nodev,noexec,relatime shared:6 - tmpfs tmpfs rw,size=5120k +29 20 0:24 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:9 - tmpfs tmpfs ro,mode=755 +30 29 0:25 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:10 - cgroup cgroup rw,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd +31 20 0:26 / /sys/fs/pstore rw,nosuid,nodev,noexec,relatime shared:11 - pstore pstore rw +32 29 0:27 / /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime shared:13 - cgroup cgroup rw,pids +33 29 0:28 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:14 - cgroup cgroup rw,cpu,cpuacct +34 29 0:29 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,devices +35 29 0:30 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,freezer +36 29 0:31 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:17 - cgroup cgroup rw,cpuset +37 29 0:32 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:18 - cgroup cgroup rw,memory +38 29 0:33 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:19 - cgroup cgroup rw,perf_event +39 29 0:34 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:20 - cgroup cgroup rw,blkio +40 29 0:35 / /sys/fs/cgroup/net_prio rw,nosuid,nodev,noexec,relatime shared:21 - cgroup cgroup rw,net_prio +41 29 0:36 / /sys/fs/cgroup/net_cls rw,nosuid,nodev,noexec,relatime shared:22 - cgroup cgroup rw,net_cls +42 21 0:37 / /proc/sys/fs/binfmt_misc rw,relatime shared:23 - autofs systemd-1 rw,fd=27,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=11329 +45 22 0:18 / /dev/mqueue rw,relatime shared:24 - mqueue mqueue rw +44 20 0:8 / /sys/kernel/debug rw,relatime shared:25 - debugfs debugfs rw +43 22 0:38 / /dev/hugepages rw,relatime shared:26 - hugetlbfs hugetlbfs rw,pagesize=2M +46 24 0:39 / /run/rpc_pipefs rw,relatime shared:27 - rpc_pipefs sunrpc rw +78 25 8:1 / /boot rw,relatime shared:28 - ext4 /dev/sda1 rw,discard,data=ordered +76 25 0:41 / /var/lib/machines rw,relatime shared:29 - btrfs /dev/loop0 rw,space_cache,subvolid=5,subvol=/ +77 42 0:44 / /proc/sys/fs/binfmt_misc rw,relatime shared:30 - binfmt_misc binfmt_misc rw +364 25 253:0 /var/lib/docker/overlay /var/lib/docker/overlay rw,relatime shared:265 - ext4 /dev/mapper/sda2_crypt rw,discard,errors=remount-ro,data=ordered +373 24 0:47 / /run/user/119 rw,nosuid,nodev,relatime shared:281 - tmpfs tmpfs rw,size=774884k,mode=700,uid=119,gid=125 +432 24 0:49 / /run/user/1000 rw,nosuid,nodev,relatime shared:337 - tmpfs tmpfs rw,size=774884k,mode=700,uid=1000,gid=1000 +444 20 0:50 / /sys/fs/fuse/connections rw,relatime shared:346 - fusectl fusectl rw +219 432 0:46 / /run/user/1000/gvfs rw,nosuid,nodev,relatime shared:165 - fuse.gvfsd-fuse gvfsd-fuse rw,user_id=1000,group_id=1000 +331 364 0:48 / /var/lib/docker/overlay/741f11f50e29b137c7af05b6be3da324a9c433fdd1030c16ccebeb8966e60ca1/merged rw,relatime shared:266 - overlay overlay rw,lowerdir=/var/lib/docker/overlay/ef862e21c28aed5cedbe85c4bf68a95747506d968319bc0dc79a7d87c5aa89d9/root,upperdir=/var/lib/docker/overlay/741f11f50e29b137c7af05b6be3da324a9c433fdd1030c16ccebeb8966e60ca1/upper,workdir=/var/lib/docker/overlay/741f11f50e29b137c7af05b6be3da324a9c433fdd1030c16ccebeb8966e60ca1/work +334 25 0:51 / /var/lib/docker/containers/4d8f0d7e69fd9a2841af2c8c89ebab56bf808719a63c4a3568f5fa950e3c8f1d/shm rw,nosuid,nodev,noexec,relatime shared:241 - tmpfs shm rw,size=65536k +419 24 0:3 net:[4026532460] /run/docker/netns/5b425736aafb rw shared:247 - nsfs nsfs rw +61 364 0:59 / /var/lib/docker/overlay/20c8d8de0fe482e77a3f15dde232e73820757bf735c0abbfe113be1e83c41abd/merged rw,relatime shared:36 - overlay overlay rw,lowerdir=/var/lib/docker/overlay/847466c8b9a9592909c772f907a559eb38d9b3bfbbba46731623cb3a904cd34b/root,upperdir=/var/lib/docker/overlay/20c8d8de0fe482e77a3f15dde232e73820757bf735c0abbfe113be1e83c41abd/upper,workdir=/var/lib/docker/overlay/20c8d8de0fe482e77a3f15dde232e73820757bf735c0abbfe113be1e83c41abd/work +203 25 0:60 / /var/lib/docker/containers/4ce771ae12a0b56e3511828b5f4adc3cb3848d3443cc9f6a3c2478d15d882e73/shm rw,nosuid,nodev,noexec,relatime shared:89 - tmpfs shm rw,size=65536k +497 24 0:3 net:[4026532549] /run/docker/netns/75dae9022532 rw shared:256 - nsfs nsfs rw diff --git a/tests/test-admin-deploy-syslinux-bootonslash.sh b/tests/test-admin-deploy-syslinux-bootonslash.sh new file mode 100755 index 0000000000..b7a95358ea --- /dev/null +++ b/tests/test-admin-deploy-syslinux-bootonslash.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Copyright (C) 2016 Colin Walters +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +set -euo pipefail + +. $(dirname $0)/libtest.sh + +# Exports OSTREE_SYSROOT so --sysroot not needed. +setup_os_repository "archive-z2" "syslinux" + +echo "1..3" + +${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime + +# Override the default and say that /boot is not a partition +env OSTREE_DEBUG_MOUNTINFO_FILE=${test_srcdir}/boot_on_root_no_bind.mountinfo \ + ${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime + +assert_file_has_content sysroot/boot/syslinux/syslinux.cfg "KERNEL /boot/ostree/testos.*vmlinuz" +assert_file_has_content sysroot/boot/syslinux/syslinux.cfg "INITRD /boot/ostree/testos.*initramfs" + +echo "ok bootonslash - /boot not bind-mounted" + +# Same again, but with /boot bind-mounted from real / +env OSTREE_DEBUG_MOUNTINFO_FILE=${test_srcdir}/boot_on_root_bind_mount.mountinfo \ + ${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime + +assert_file_has_content sysroot/boot/syslinux/syslinux.cfg "KERNEL /boot/ostree/testos.*vmlinuz" +assert_file_has_content sysroot/boot/syslinux/syslinux.cfg "INITRD /boot/ostree/testos.*initramfs" + +echo "ok bootonslash - /boot bind-mounted" + +${CMD_PREFIX} ostree admin undeploy 0 + +OSTREE_DEBUG_MOUNTINFO_FILE=${test_srcdir}/boot_partition.mountinfo ${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime +assert_file_has_content sysroot/boot/syslinux/syslinux.cfg "KERNEL /ostree/testos.*vmlinuz" +assert_file_has_content sysroot/boot/syslinux/syslinux.cfg "INITRD /ostree/testos.*initramfs" + +echo "ok bootpartition"