flatpak-builder icon indicating copy to clipboard operation
flatpak-builder copied to clipboard

Cache not used for 'dir' sources

Open sophie-h opened this issue 5 years ago • 4 comments

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

sophie-h avatar Jul 02 '20 13:07 sophie-h

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.

sophie-h avatar Jul 02 '20 21:07 sophie-h

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.

sophie-h avatar Jul 02 '20 22:07 sophie-h

Certainly one way to checksum a directory is to make an ostree commit of it.

mwleeds avatar Jul 02 '20 22:07 mwleeds

Trying to tackle this in https://github.com/flatpak/flatpak-builder/pull/575 while still keeping the current default.

abergmeier avatar Dec 18 '23 12:12 abergmeier