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

builder-context: Write a gitignore file into the state-dir #620

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

alatiera
Copy link
Contributor

Unless specified, state-dir is placed on the current path, which is usually the source directory of the project.

Write a .gitignore file to make sure that both the state-dir never gets checked out into git and that all the tooling will ignore it and avoid indexing it.

Inpired by meson's gitignore file in the build directories.

Retro-actively discovered the same change in flatpak-build init 1

@alatiera alatiera force-pushed the alatiera/gitignore branch 2 times, most recently from e757114 to 577a827 Compare October 15, 2024 23:11
src/builder-context.c Outdated Show resolved Hide resolved
src/builder-context.c Outdated Show resolved Hide resolved
@alatiera
Copy link
Contributor Author

alatiera commented Nov 6, 2024

Indeed, hit the footguns. I guess that's why everyone is using g_file_replace_contents even for supposedly simple things? Should I just make it a one liner g_file_replace_contents and give up on the If you change or delete it, it won't be recreated. part, it would match the code in flatpak itself anyway.

@TingPing
Copy link
Member

TingPing commented Nov 6, 2024

Yes that sounds fine to me.

@alatiera
Copy link
Contributor Author

alatiera commented Nov 6, 2024

(pushed but want to test it again)

@alatiera
Copy link
Contributor Author

alatiera commented Nov 6, 2024

Yea the current version did break something.

(/home/alatiera/Projects/flatpak-builder/_builddir_vscode/src/flatpak-builder:34220): GLib-CRITICAL **: 23:46:01.803: g_file_set_contents_full: assertion 'error == NULL || *error == NULL' failed

Thread 1 "flatpak-builder" received signal SIGTRAP, Trace/breakpoint trap.
_g_log_abort (breakpoint=<optimized out>) at ../glib/gmessages.c:426
426         G_BREAKPOINT ();
(gdb) bt
#0  _g_log_abort (breakpoint=<optimized out>) at ../glib/gmessages.c:426
#1  g_logv (log_domain=0x7ffff7f0d00e "GLib", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffdac0)
    at ../glib/gmessages.c:1273
#2  0x00007ffff7eb1b3b in g_log
    (log_domain=log_domain@entry=0x7ffff7f0d00e "GLib", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7ffff7f0f2ec "%s: assertion '%s' failed") at ../glib/gmessages.c:1315
#3  0x00007ffff7eb2c4d in g_return_if_fail_warning
    (log_domain=log_domain@entry=0x7ffff7f0d00e "GLib", pretty_function=pretty_function@entry=0x7ffff7f1eb70 <__func__.17> "g_file_set_contents_full", expression=expression@entry=0x7ffff7f127f0 "error == NULL || *error == NULL") at ../glib/gmessages.c:3055
#4  0x00007ffff7e910f2 in g_file_set_contents_full
    (filename=0x5555555e7250 "/home/alatiera/Projects/flatpak-builder/.flatpak-builder/checksums/x86_64-test-runtime.json", contents=contents@entry=0x5555555dd0f0 "7109820d75e46b6c85799365dbc67797583c15d259666e0b889e258185e67e3f", length=length@entry=-1, flags=flags@entry=(G_FILE_SET_CONTENTS_CONSISTENT | G_FILE_SET_CONTENTS_ONLY_EXISTING), mode=mode@entry=438, error=error@entry=0x7fffffffdd50)
    at ../glib/gfileutils.c:1337
#5  0x00007ffff7e91447 in g_file_set_contents
    (filename=<optimized out>, contents=contents@entry=0x5555555dd0f0 "7109820d75e46b6c85799365dbc67797583c15d259666e0b889e258185e67e3f", length=length@entry=-1, error=error@entry=0x7fffffffdd50) at ../glib/gfileutils.c:1253
#6  0x000055555556ac6f in builder_context_set_checksum_for
    (self=self@entry=0x5555555dcb90 [BuilderContext], name=name@entry=0x5555555da580 "test-runtime.json", checksum=checksum@entry=0x5555555dd0f0 "7109820d75e46b6c85799365dbc67797583c15d259666e0b889e258185e67e3f", error=error@entry=0x7fffffffdd50)
    at ../src/builder-context.c:553
#7  0x000055555556569c in main (argc=<optimized out>, argv=<optimized out>) at ../src/builder-main.c:824

@alatiera
Copy link
Contributor Author

alatiera commented Nov 6, 2024

Nvm, fixed, was missing the clear_error

Unless specified, state-dir is placed on the current path,
which is usually the source directory of the project.

Write a .gitignore file to make sure that both the state-dir
never gets checked out into git and that all the tooling
will ignore it and avoid indexing it.

Inpired by meson's gitignore file in the build directories.

Retro-actively discovered the same change in flatpak-build init [1]

[1]: flatpak/flatpak@a62f8cf
Copy link
Member

@TingPing TingPing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(pushed but want to test it again)

LGTM, let me know if its ready to merge.

@alatiera
Copy link
Contributor Author

alatiera commented Nov 8, 2024

Good to go, just fixed a typo yday

@TingPing TingPing merged commit 3b96885 into flatpak:main Nov 8, 2024
3 of 5 checks passed
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.

2 participants