termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
12.79k stars 2.93k forks source link

[Bug]: Building package `glib` fails #20070

Open gouravkhunger opened 2 months ago

gouravkhunger commented 2 months ago

Problem description

The build for package glib fails with the error:

...
Installing /home/builder/.termux-build/glib/src/m4macros/gsettings.m4 to /data/data/com.termux/files/usr/opt/glib/cross/share/aclocal
Applying patch: gio-gdbusprivate.c.patch
Applying patch: gio-gkeyfilesettingsbackend.c.patch
Applying patch: gio-gnetworking.h.in.patch
Applying patch: gio-gunixmounts.c.patch
Applying patch: gio-xdgmime-xdgmime.c.patch
Applying patch: glib-gcharset.c.patch
Applying patch: glib-gspawn.c.patch
Applying patch: glib-gthread-posix.c.patch
Applying patch: glib-gthreadprivate.h.patch
Applying patch: glib-gtimezone.patch
Applying patch: glib-gtypes.h.patch
Applying patch: glib-gutils.c.patch
Applying patch: glib-tests-meson.build.patch
Applying patch: meson.build.patch
sed: can't read /data/data/com.termux/files/usr/lib/pkgconfig/gobject-introspection-1.0.pc: No such file or directory
Error: Process completed with exit code 2.

This seems to be introduced since 4ccbae1cec294cdf0c2dff25fc3a0227d493f456 in line:

https://github.com/termux/termux-packages/blob/4ccbae1cec294cdf0c2dff25fc3a0227d493f456/packages/glib/build.sh#L73-L74

On inspection, I found that the build system didn't download gobject-introspection for building even if it is defined in the TERMUX_PKG_BUILD_DEPENDS for glib:

https://github.com/termux/termux-packages/blob/bb4bdf2294cc22c4eb88ae1913421b8901def97d/packages/glib/build.sh#L10

Thus the file is missing.

What steps will reproduce the bug?

Build the package glib on master with command:

./scripts/run-docker.sh ./clean.sh
./scripts/run-docker.sh ./build-package.sh glib

Because gobject-introspection was not downloaded, I tried building it right before glib. But that resulted in an infinite pause:

./scripts/run-docker.sh ./build-package.sh gobject-introspection glib

But well, gobject-introspection depends on glib so maybe that caused the loop:

https://github.com/termux/termux-packages/blob/e6edae346502fb933dd3940ee78345afb6a2147e/packages/gobject-introspection/build.sh#L8

What is the expected behavior?

I am unable to replicate the successful builds as in termux workflow builds.

System information

N/A

Biswa96 commented 2 months ago

You have to follow some steps to bootstrap glib and gojbect-introspection (GI). See https://gitlab.gnome.org/GNOME/glib/-/blob/2.80.0/docs/reference/glib/building.md?ref_type=tags

  1. Build glib using -Dintrospection=disabled option.
  2. Build GI using glib from step1.
  3. Build glib with -Dintrospection=enabled using GI from step2.

I can try to add a bootstrap flag in glib or GI build script but I do not know how to check if glib is being bootstrapped. Otherwise, user has to pass the bootstrap flag manually.

gouravkhunger commented 2 months ago

@Biswa96 I understand, thank you! I get how termux uses the already built gobject-introspection package from past builds and thus the workflow succeeds.

But it would be really helpful to have these steps automated for cases where dependencies need rebuilding too. How about using TERMUX_FORCE_BUILD_DEPENDENCIES to use the option -Dintrospection=disabled first, and somehow run the logic for step 2. and 3. as you mentioned, right after the build is done.

I have started at PR that achieves the former in #20081. This makes the build pass. But to rebuild glib with -Dintrospection=enabled, I'll need some insight on how to dynamically add more packages to be built with specific parameters after the current one succeeds.

Maybe something could be added in the termux_step_post_make_install or termux_step_post_massage functions.

Biswa96 commented 2 months ago

I am not sure if TERMUX_FORCE_BUILD_DEPENDENCIES variable should be used. It is not documented and not used in any other build script. That variable is true when -F option is passed to build-package.sh. I would follow simple steps from Alpine Linux to replace the cyclic dependency https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/main/glib/APKBUILD (if feasible). Those steps would increase build time significantly.