Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switchroot: Fix regression for separately mounted /var #1668

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/switchroot/ostree-prepare-root.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,17 @@ main(int argc, char *argv[])
if (chdir (deploy_path) < 0)
err (EXIT_FAILURE, "failed to chdir to deploy_path");

/* Default to true, but in the systemd case, default to false because it's handled by
* ostree-system-generator. */
bool mount_var = true;
/* In the systemd case, this is handled by ostree-system-generator by default */
#ifndef HAVE_SYSTEMD_AND_LIBMOUNT
/* file in /run can override that behaviour */
if (lstat (INITRAMFS_MOUNT_VAR, &stbuf) < 0)
mount_var = false;
#ifdef HAVE_SYSTEMD_AND_LIBMOUNT
mount_var = false;
#endif

/* file in /run can override the default behaviour so that we definitely mount /var */
if (lstat (INITRAMFS_MOUNT_VAR, &stbuf) == 0)
mount_var = true;

/* Link to the deployment's /var */
if (mount_var && mount ("../../var", "var", NULL, MS_MGC_VAL|MS_BIND, NULL) < 0)
err (EXIT_FAILURE, "failed to bind mount ../../var to var");
Expand Down
1 change: 1 addition & 0 deletions tests/installed/destructive-ansible.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
when: use_git_build
- import_tasks: tasks/query-host.yml
- import_tasks: destructive/staged-deploy.yml
- import_tasks: destructive/var-mount.yml
13 changes: 13 additions & 0 deletions tests/installed/destructive/var-mount.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://github.com/ostreedev/ostree/issues/1667
- name: Set up /var as a mountpoint
shell: |
set -xeuo pipefail
cp -a /var /sysroot/myvar
touch /sysroot/myvar/somenewfile
echo '/sysroot/myvar /var none bind 0 0' >> /etc/fstab
- include_tasks: ../tasks/reboot.yml
- name: Check that /var mountpoint worked
shell: |
set -xeuo pipefail
systemctl status var.mount
test -f /var/somenewfile
4 changes: 4 additions & 0 deletions tests/installed/playbook-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ dn=$(cd $(dirname $0) && pwd)
if ! test -d build; then
mkdir -p build
(cd build && ${dn}/../../ci/build-rpm.sh)
else
# XXX: we should invalidate based on `git describe` or something
echo "NOTE: Re-using prebuilt RPMs:"
find build -name '*.rpm'
fi

# https://fedoraproject.org/wiki/CI/Tests
Expand Down
3 changes: 3 additions & 0 deletions tests/installed/tasks/install-git.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
synchronize: src=build/x86_64/ dest=/root/x86_64/ archive=yes
- name: Install RPMs
shell: rpm-ostree override replace /root/x86_64/*.rpm
# Regenerate to make sure new ostree binaries also make it to the initrd
- name: Regenerate initramfs
shell: rpm-ostree initramfs --enable
- import_tasks: ../tasks/reboot.yml
- import_tasks: ../tasks/query-host.yml
- command: ostree --version
Expand Down