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

lib/checkout: support filtering #1441

Closed
wants to merge 2 commits into from

Conversation

jlebon
Copy link
Member

@jlebon jlebon commented Feb 1, 2018

This is analogous to the filtering support for the commit API: we allow
library users to skip over checking out specific files. This is useful
in some tricky situations where we know that the files to be checked
out will conflict with existing files in subtle ways.

One such example is in rpm-ostree support for multilib. There, we want
to allow checking out a package onto an existing tree, but skipping over
files that are not coloured to our preferred value (e.g. not overwriting
an i686 version of ldconfig if we already have the x86_64 version).
See coreos/rpm-ostree#1227 for details.

gpointer unused_ptrs[5];
gpointer unused_ptrs[3];
OstreeRepoCheckoutFilter filter; /* Since: 2018.2 */
gpointer filter_user_data; /* Since: 2018.2 */
Copy link
Member Author

Choose a reason for hiding this comment

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

I can transform those two into a single object, similar to OstreeRepoCommitModifier, if we want to conserve pointers.

Copy link
Member

Choose a reason for hiding this comment

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

Eh, feels unlikely we keep adding a lot more functionality to checkout. If we do, I think I'd vote we add new high level APIs.

@jlebon
Copy link
Member Author

jlebon commented Feb 1, 2018

This will be used by coreos/rpm-ostree#1227. Marking as WIP for now for tests and initial feedback.

@jlebon jlebon added the WIP label Feb 1, 2018
if (state->path_buf)
g_string_truncate (state->path_buf, state->path_buf->len - n);
if (state->selabel_path_buf && !state->shared_path_buf)
g_string_truncate (state->selabel_path_buf, state->selabel_path_buf->len - n);
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that this mostly reverts #936. AFAICT, the algorithm before was good, there was just an off-by-one error to account for the added / when truncating after recursing into a subdir.

Copy link
Member

@cgwalters cgwalters Feb 5, 2018

Choose a reason for hiding this comment

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

Yeah, makes sense.

@jlebon
Copy link
Member Author

jlebon commented Feb 1, 2018

Added tests and split out some of the prep in #1442. Dropping WIP.

@jlebon jlebon removed the WIP label Feb 1, 2018
@jlebon jlebon changed the title WIP: add callback to checkout API lib/checkout: support filtering Feb 1, 2018
// If SELinux labeling is enabled, we need to keep track of the full path string

if (options->filter)
state.path_buf = new_canonicalized_path_buf (options->subpath);
Copy link
Member Author

Choose a reason for hiding this comment

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

We can switch this to / so that we call back with the subpath prefixed removed already. Hmm, yeah that feels more natural actually.

@jlebon jlebon force-pushed the pr/checkout-callback branch 2 times, most recently from 5eedb07 to 02dba1d Compare February 2, 2018 13:32
@jlebon
Copy link
Member Author

jlebon commented Feb 2, 2018

bot, retest this please

@rh-atomic-bot
Copy link

☔ The latest upstream changes (presumably 8174885) made this pull request unmergeable. Please resolve the merge conflicts.

This is analogous to the filtering support for the commit API: we allow
library users to skip over checking out specific files. This is useful
in some tricky situations where we *know* that the files to be checked
out will conflict with existing files in subtle ways.

One such example is in rpm-ostree support for multilib. There, we want
to allow checking out a package onto an existing tree, but skipping over
files that are not coloured to our preferred value (e.g. not overwriting
an i686 version of `ldconfig` if we already have the `x86_64` version).
See coreos/rpm-ostree#1227 for details.
@jlebon
Copy link
Member Author

jlebon commented Feb 5, 2018

This is ready for review!

if (state->selabel_path_buf)
if (state->path_buf)
g_string_free (state->path_buf, TRUE);
if (state->selabel_path_buf && !state->shared_path_buf)
Copy link
Member

Choose a reason for hiding this comment

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

We could also just check state->path_buf != state->selabel_path_buf and lose the boolean, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

True, done in ⬇️!

@cgwalters
Copy link
Member

@rh-atomic-bot r+ bb40284

@rh-atomic-bot
Copy link

⌛ Testing commit bb40284 with merge 6214811...

rh-atomic-bot pushed a commit that referenced this pull request Feb 5, 2018
This is analogous to the filtering support for the commit API: we allow
library users to skip over checking out specific files. This is useful
in some tricky situations where we *know* that the files to be checked
out will conflict with existing files in subtle ways.

One such example is in rpm-ostree support for multilib. There, we want
to allow checking out a package onto an existing tree, but skipping over
files that are not coloured to our preferred value (e.g. not overwriting
an i686 version of `ldconfig` if we already have the `x86_64` version).
See coreos/rpm-ostree#1227 for details.

Closes: #1441
Approved by: cgwalters
@rh-atomic-bot
Copy link

💥 Test timed out

@jlebon
Copy link
Member Author

jlebon commented Feb 6, 2018

@rh-atomic-bot retry

@rh-atomic-bot
Copy link

⌛ Testing commit bb40284 with merge ca9f18a...

rh-atomic-bot pushed a commit that referenced this pull request Feb 6, 2018
This is analogous to the filtering support for the commit API: we allow
library users to skip over checking out specific files. This is useful
in some tricky situations where we *know* that the files to be checked
out will conflict with existing files in subtle ways.

One such example is in rpm-ostree support for multilib. There, we want
to allow checking out a package onto an existing tree, but skipping over
files that are not coloured to our preferred value (e.g. not overwriting
an i686 version of `ldconfig` if we already have the `x86_64` version).
See coreos/rpm-ostree#1227 for details.

Closes: #1441
Approved by: cgwalters
@rh-atomic-bot
Copy link

💔 Test failed - status-atomicjenkins

@cgwalters
Copy link
Member

cgwalters commented Feb 6, 2018 via email

@rh-atomic-bot
Copy link

⌛ Testing commit bb40284 with merge 2e95e06...

@rh-atomic-bot
Copy link

☀️ Test successful - status-atomicjenkins
Approved by: cgwalters
Pushing 2e95e06 to master...

@jlebon jlebon deleted the pr/checkout-callback branch June 14, 2018 01: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.

None yet

3 participants