# Fix general bugs

postprocess:
  # See also https://github.com/openshift/os/blob/f6cde963ee140c02364674db378b2bc4ac42675b/common.yaml#L156
  # This one is undoes the effect of
  # # RHEL-only: Disable /tmp on tmpfs.
  #Wants=tmp.mount
  # in /usr/lib/systemd/system/basic.target
  # We absolutely must have tmpfs-on-tmp for multiple reasons,
  # but the biggest is that when we have composefs for / it's read-only,
  # and for units with ProtectSystem=full systemd clones / but needs
  # a writable place.
  - |
    #!/usr/bin/env bash
    set -xeuo pipefail
    mkdir -p /usr/lib/systemd/system/local-fs.target.wants
    if test '!' -f /usr/lib/systemd/system/local-fs.target.wants/tmp.mount; then
      ln -sf ../tmp.mount /usr/lib/systemd/system/local-fs.target.wants
    fi

    # See https://github.com/containers/bootc/issues/358
    # basically systemd-tmpfiles doesn't follow symlinks; ordinarily our
    # tmpfiles.d unit for `/var/roothome` is fine, but this actually doesn't
    # work if we want to use tmpfiles.d to write to `/root/.ssh` because
    # tmpfiles gives up on that before getting to `/var/roothome`.
    sed -ie 's, /root, /var/roothome,' /usr/lib/tmpfiles.d/provision.conf
    # Because /var/roothome is also defined in rpm-ostree-0-integration.conf
    # we need to delete /var/roothome
    sed -ie '/^d- \/var\/roothome /d' /usr/lib/tmpfiles.d/provision.conf