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

Pass system version to bundle install hooks #1368

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

Conversation

obbardc
Copy link
Contributor

@obbardc obbardc commented Mar 21, 2024

Pass installed system version to bundle install-check hook script.

Fixes: #531

(This has been collecting dust downstream for a while now; time to get it upstreamed)

launcher = g_subprocess_launcher_new(G_SUBPROCESS_FLAGS_STDERR_PIPE);

g_subprocess_launcher_setenv(launcher, "RAUC_SYSTEM_COMPATIBLE", r_context()->config->system_compatible, TRUE);
g_subprocess_launcher_setenv(launcher, "RAUC_SYSTEM_VARIANT", r_context()->config->system_variant ?: "", TRUE);
g_subprocess_launcher_setenv(launcher, "RAUC_SYSTEM_VERSION", system_version ?: "", TRUE);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jluebbe suggests it would be better to include this in prepare_environment.

Copy link
Member

Choose a reason for hiding this comment

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

By now, that part was factored out to add_system_environment, which you could use in run_bundle_hook.


g_assert_nonnull(manifest->hook_name);

hook_name = g_build_filename(bundledir, manifest->hook_name, NULL);

g_message("Running bundle hook %s", hook_cmd);

/* Pass the version of the currently running slot to the hook script */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This (4 year old!) logic is a bit awful, but it seems to work.

Pass installed system version to bundle install-check hook script.

Fixes: rauc#531
Signed-off-by: Christopher Obbard <[email protected]>
@obbardc obbardc force-pushed the wip/obbardc/pass-system-version-to-handler-hooks branch from 80730ae to b4d2558 Compare March 21, 2024 19:31
/* Pass the version of the currently running slot to the hook script */
s = find_config_slot_by_device(r_context()->config, r_context()->bootslot);
if (s) {
load_slot_status(s);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the wrong API, from an older version of RAUC. I will fix it.

@jluebbe
Copy link
Member

jluebbe commented Mar 28, 2024

As mentioned in #531 (comment), RAUC_SYSTEM_VERSION would be a misleading name. Each slot remembers the bundle version which was installed to it last, so there are potentially multiple versions (one per slot).

If I understood your request correctly, you need the version of the currently booted slot. With the info suggested in the linked comment, you could do something like this:

eval CURRENT_VERSION=\$RAUC_SLOT_BUNDLE_VERSION_${RAUC_BOOTED_SLOT_IDX}

Alternatively I'd also be fine with exporting a RAUC_BOOT_SLOT_BUNDLE_VERSION with that value.

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.

Pass running system version to handler/hooks
2 participants