Skip to content

feat(builder): auto-compile GSettings schemas during build#1740

Open
123123213weqw wants to merge 1 commit into
OpenAtom-Linyaps:masterfrom
123123213weqw:wangyue/issue-679
Open

feat(builder): auto-compile GSettings schemas during build#1740
123123213weqw wants to merge 1 commit into
OpenAtom-Linyaps:masterfrom
123123213weqw:wangyue/issue-679

Conversation

@123123213weqw

Copy link
Copy Markdown
Contributor

Summary

Resolves #679.

Applications that depend on gsettings require a compiled gschemas.compiled binary in share/glib-2.0/schemas to function at runtime. Until now linglong only ran glib-compile-schemas at install time (OSTreeRepo::updateSharedInfo), which forced the tool to be present on every end-user machine.

This PR makes ll-builder automatically compile GSettings schemas at build time so the compiled binary is shipped inside the package.

Changes

  • misc/libexec/linglong/builder/helper/compile-schemas.sh (new) — helper script that:
    • Does nothing when $PREFIX/share/glib-2.0/schemas does not exist (no overhead for apps without gsettings).
    • Skips with a warning when glib-compile-schemas is unavailable.
    • Otherwise runs glib-compile-schemas on the schemas directory.
  • misc/CMakeLists.txt — registers the new script in configure_files and the install(PROGRAMS …) list (kept in sorted order alongside the other builder helpers).
  • libs/linglong/src/linglong/builder/linglong_builder.cpp (generateEntryScript) — appends compile-schemas.sh to the POST BUILD PROCESS section of the generated entry.sh, immediately after the user build script and optional symbol stripping. The call runs unconditionally (not gated on skipStripSymbols).

How it works

During ll-builder build, the generated entry script now ends with:

# POST BUILD PROCESS
<builder-helper>/symbols-strip.sh   # only when strip is enabled
<builder-helper>/compile-schemas.sh  # always; no-op without schemas

The script runs inside the build container where glib-compile-schemas is part of the glib development packages, so no extra host dependency is introduced.

Verification

  • bash -n compile-schemas.sh — syntax OK.
  • Manual functional tests:
    • No schemas dir → exit 0, no output.
    • Schemas dir exists, glib-compile-schemas missing → warning on stderr, exit 0.
    • Schemas dir exists, glib-compile-schemas present → gschemas.compiled created, exit 0.
  • git diff --check — no whitespace errors.

Full CMake build and CTest could not be executed in this environment (no compiler toolchain installed); the change is limited to a new shell script, two CMake list entries, and a three-line C++ edit that follows existing patterns.

Applications that depend on gsettings require a compiled
gschemas.compiled binary in share/glib-2.0/schemas to function at
runtime. Previously linglong only ran glib-compile-schemas at install
time (OSTreeRepo::updateSharedInfo), which means the tool had to be
present on every end-user machine.
Add a compile-schemas.sh builder helper that runs glib-compile-schemas
on $PREFIX/share/glib-2.0/schemas as part of the POST BUILD PROCESS
section of the generated entry.sh, right after the user build script
and symbol stripping. This ships the compiled schemas inside the
package so glib-compile-schemas is no longer required at install time.
The script is a no-op when no schemas directory exists and gracefully
skips (with a warning) when glib-compile-schemas is unavailable, so
packages without gsettings dependencies are unaffected.
Closes OpenAtom-Linyaps#679

Signed-off-by: 王越 <1939455790@qq.com>
@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 123123213weqw

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

Hi @123123213weqw. Thanks for your PR.

I'm waiting for a OpenAtom-Linyaps member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces automatic compilation of GSettings schemas during the build process by adding a new helper script, compile-schemas.sh, and integrating it into the post-build process. Feedback suggests optimizing the helper script to check for the actual presence of .gschema.xml files before verifying the existence of glib-compile-schemas, which prevents false-positive warnings when no schemas are present.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +14 to +16
if [ ! -d "$schema_dir" ]; then
exit 0
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

If the $schema_dir directory exists but contains no .gschema.xml files, running glib-compile-schemas is unnecessary and might trigger warnings or errors. Furthermore, if glib-compile-schemas is missing, a false-positive warning will be printed even if there are no schemas to compile.

We can use Bash's nullglob to check if there are actually any .gschema.xml files present before proceeding.

Suggested change
if [ ! -d "$schema_dir" ]; then
exit 0
fi
if [ ! -d "$schema_dir" ]; then
exit 0
fi
shopt -s nullglob
schemas=("$schema_dir"/*.gschema.xml)
if [ ${#schemas[@]} -eq 0 ]; then
exit 0
fi

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...linglong/src/linglong/builder/linglong_builder.cpp 0.00% 2 Missing ⚠️
Files with missing lines Coverage Δ
...linglong/src/linglong/builder/linglong_builder.cpp 8.70% <0.00%> (-0.01%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

需要调用glib-compile-schemas

2 participants