Skip to content

builder-main: Prevent deleting state-dir, cwd or their parents with force-clean#668

Merged
swick merged 3 commits intomainfrom
bbhtt/prevent-delete
Sep 15, 2025
Merged

builder-main: Prevent deleting state-dir, cwd or their parents with force-clean#668
swick merged 3 commits intomainfrom
bbhtt/prevent-delete

Conversation

@bbhtt
Copy link
Contributor

@bbhtt bbhtt commented Sep 12, 2025

Fixes #475

I guess the question here is how much mistake should it prevent and how much is this a breaking change.

I think the spinoff state dir deletion case that I found makes sense and wouldn't really be a breaking change as that never worked without hanging. That also automatically solves the builddir being . case at least when --state-dir doesn't point to somewhere else.

I'm a bit unsure about the blocking the cwd case.

@bbhtt bbhtt force-pushed the bbhtt/prevent-delete branch 2 times, most recently from c5b8fb3 to b8841de Compare September 12, 2025 07:10
Deleting the state dir leaves flatpak-builder in an inconsistent hung
state by default as rofiles-fuse tries to recurse indefinitely when
resolving paths.

```
statx(AT_FDCWD, "/home/bbhtt/test/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/rofiles/rofiles-lLitmd/.flatpak-builder/cache/config", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW|AT_NO_AUTOMOUNT, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=67, ...}) = 0
[...]
```

This is reproducible when doing

```
flatpak-builder --state-dir ~/foobar ~/foobar --force-clean MANIFEST
```

or

```
flatpak-builder . --force-clean MANIFEST
```
Building in the current directory does not make sense and cwd
usually contains the manifest, files referenced in the manifest and
other files. Deleting all of them is destructive.

Also since state dir defaults to cwd/.flatpak-builder by default,
a deletion leads to the hung state described in the previous commit.

Fixes #475
@bbhtt bbhtt force-pushed the bbhtt/prevent-delete branch from b8841de to 77ab2e0 Compare September 12, 2025 07:23
@bbhtt bbhtt changed the title builder-main: Prevent deleting cwd or its parents with force-clean builder-main: Prevent deleting state-dir, cwd or their parents with force-clean Sep 12, 2025
@bbhtt
Copy link
Contributor Author

bbhtt commented Sep 12, 2025

I'm wondering whether to merge this for 1.4.x or wait for 1.5.0. At least the second commit is technically a breaking change, but maybe easily solvable. So maybe it is low impact...

I need to update the doc accordingly.

@bbhtt
Copy link
Contributor Author

bbhtt commented Sep 15, 2025

After thinking about it for a while, I think it's fine for 1.4.6. I couldn't find a use case which cannot be easily solved by adjusting DIRECTORY.

I updated the doc.

@swick swick merged commit 1302aa5 into main Sep 15, 2025
5 checks passed
@swick swick deleted the bbhtt/prevent-delete branch September 15, 2025 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: flatpak-builder is happy to delete the current directory

2 participants