Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for external dir hasher #575

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

abergmeier
Copy link

@abergmeier abergmeier commented Dec 18, 2023

Allows providing hash-cmd.
Protocol is that cmd will be executed and output will be used to calculate
dir checksum.
If program fails - it falls back to rebuilding.

@abergmeier abergmeier marked this pull request as draft December 18, 2023 10:05
@abergmeier abergmeier changed the title Initial support for external dir hasher Add support for external dir hasher Dec 18, 2023
Allows providing hash-cmd.
Protocol is that cmd will be executed and output will be used to calculate
dir checksum.
If program fails - it falls back to rebuilding.
@abergmeier
Copy link
Author

@alexlarsson Mind to have a look? Seems like you said that checksumming dir was "not possible". Not sure what you meant.

@TingPing
Copy link
Member

Can you give some real world examples of hash commands for an entire directory?

Also it is very common that a project uses a flatpak build dir inside of the same directory, which is impossible to say nothing changes, so maybe there should be a check for that.

@abergmeier
Copy link
Author

Can you give some real world examples of hash commands for an entire directory?

Also it is very common that a project uses a flatpak build dir inside of the same directory, which is impossible to say nothing changes, so maybe there should be a check for that.

I have most current experience with both Rust and Go. For both "a project uses a flatpak build dir inside of the same directory" is NOT an issue because they have either a very strict standard layout or mostly people adhere to best practices.

Thus the real world example for e.g. Golang would be:

build-options:
  env:
    GOBIN: /app/bin
    GOROOT: /usr/lib/sdk/golang
modules:
  - name: foo
    buildsystem: simple
    sources:
      - type: dir
        path: .
        hash-cmd: [go run ./cmd/dirhash cmd internal go.mod go.sum]
    build-commands: [
      "$GOROOT/bin/go build -C ./cmd/app -o foo",
      "install -Dm00755 gadget-app $FLATPAK_DEST/bin/foo",
    ]

dirhash here is a recursive hash program.
Following best-practices in Go, source can be found in directories cmd, internal and pkg only. Also the only files in the root can be go.*. Note also that you do not need to handle vendor directory since it is a direct consequence of go.sum.

@abergmeier
Copy link
Author

The general question though is whether it would not be better to have a hash for every build-command...

@TingPing
Copy link
Member

TingPing commented Dec 19, 2023

I don't think it should be per build-command. It is a departure from how f-b operates. Build commands aren't necessarily reproducible.

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.

None yet

2 participants