Cache not used for 'dir' sources
Linux distribution and version
Debian 10
Flatpak-builder version
1.0.10
Flatpak version
1.2.5
Description of the problem
Source of type dir always leads to "Cache miss"
Steps to reproduce
app-id: org.example.App
runtime: org.gnome.Platform
sdk: org.gnome.Sdk
modules:
- name: file
buildsystem: simple
build-commands: [ echo file ]
sources:
- type: file
path: /etc/os-release
- name: dir
buildsystem: simple
build-commands: [ echo dir ]
sources:
- type: dir
path: ./
- name: git
buildsystem: simple
build-commands: [ echo git ]
sources:
- type: git
path: ./
result of second run
Cache hit for file, skipping build
Cache miss, checking out last cache hit
========================================================================
Building module dir in /tmp/test/.flatpak-builder/build/dir-1
========================================================================
Running: echo dir
dir
Committing stage build-dir to cache
========================================================================
Building module git in /tmp/test/.flatpak-builder/build/git-1
========================================================================
Already on 'master'
Running: echo git
git
Committing stage build-git to cache
Found this in the source code:
/* We can't realistically checksum a directory, so always rebuild */
builder_cache_checksum_random (cache);
Maybe this could be mentioned in the docs and I guess git might be a good alternative that could be recommend for some cases.
Actually, to me it doesn't sound that unrealistic to checksum a directory. Rebuilding dir sources is pretty annoying for CI. The GNOME CI for example seems to do all builds twice due to cache misses for dir sources.
Certainly one way to checksum a directory is to make an ostree commit of it.
Trying to tackle this in https://github.com/flatpak/flatpak-builder/pull/575 while still keeping the current default.