8000 install.sh: with a symlinked state directory, archive beside the link's target and restore onto it · Issue #3862 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

install.sh: with a symlinked state directory, archive beside the link's target and restore onto it #3862

Done

Description

@agent-137

Situation

People often keep Minimal's state directory on another disk through a symbolic link: ~/.local/state/minimal -> /Volumes/big/minimal. On macOS that directory holds the VM data volume, which can grow to 256 GiB. scripts/install.sh at main, from #3848 (gominimal/inbox#1330), mishandles this layout in two ways.

1. The archive lands on the wrong disk.

  • archive_box_state copies the contents of the resolved state into archive_dest="$box_state.<version>" (install.sh:1350-1356), which is beside the link, on the link's disk.
  • The copy therefore crosses filesystems, so the cp -c or --reflink clone can never work and the copy is always a full one.
  • The space check measures the link's disk (df -Pk "${box_state%/*}", :1376), not the data's.

2. The way back restores onto the wrong disk.

  • The R2.6 refusal (refuse_over_0_8_state, :1272) prints mv <state> <state>.0.8 && mv <newest copy> <state>, with <state> being the link.
  • That renames the link aside, and renames the copy (on the home disk) into the link's place.
  • The 0.7 state comes back as a plain directory on the home disk. The 0.8 data stays on the other disk, behind a link that is now named <state>.0.8.

Work

Resolve the state directory once, with cd -P and pwd -P. Call the result <target>. When it differs from $box_state (a link):

The archive goes beside the target, on the data's disk.

  • archive_dest="<target>.<version>", with the same .<t0> and .<t0>.<pid> suffixes when that name is taken.
  • The clone is tried there, and the space check runs df -Pk on <target>'s parent.
  • The closing card names that path.

The refusal's restore acts on the target and keeps the link.

  • The printed line becomes mv <target> <target>.0.8 && mv <newest copy beside target> <target>, with the same free-name rule for <target>.0.8.
  • Both moves are renames on one filesystem. The link itself is never moved.
  • The newest-copy search looks beside <target> first, then beside the link, which is where fix: install.sh archives the box state on a 0.7 to 0.8 upgrade, refuses 0.7.x over 0.8 state, and #3848's archives landed. It names the newest by modification time and counts the others, as now.
  • A copy found only beside the link is named with a cp into a new directory beside <target>, then the rename. The printed line must not mv across filesystems.

When the state directory is not a link, the behaviour is unchanged.

Tests (scripts/install_test.sh)

  • The archive with a symlinked state: an upgrade from a stub 0.7.3 over minimal -> <other dir>/minimal makes <other dir>/minimal.0.7.3, a real directory whose contents match. The link is unchanged.
  • The refusal with a symlinked state: the printed restore line names <other dir>/minimal, not the link. Running it leaves the link in place and pointing at the restored 0.7 state.
  • A pre-fix: install.sh archives the box state on a 0.7 to 0.8 upgrade, refuses 0.7.x over 0.8 state, and #3848 archive beside the link: it is found, and the printed steps copy it beside the target, then rename it.
  • A plain state directory: the output is the same as before. The existing cases cover this.

The installer spec 07 gets the same change: R5.7's archive location and R2.6's restore line, for a symlinked state directory.

Refs gominimal/inbox#1330, #3845, #3848, #3844.

Activity

  1. added
    priority:should-have
    release:0.8.0
    on Nov 28, 2026
  2. agent-137 commented on Nov 28, 2026

    @agent-137
    MemberAuthor

    Fixed by #3867 (D3862, task #3866), merged as d3bafd0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:should-haverelease:0.8.0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0