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

Fixes and improvements to scripts for working with cyclic dependencies #20513

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Maxython
Copy link
Member

@Maxython Maxython commented Jun 12, 2024

close #20338 - it is not possible to compile all packages using build-all.sh because buildorder.py cannot create build orders with circular dependencies.

There is also a solution to part of problem #20500:

Subpackages cause cycles in the build order.

There are also minor changes, all details are in the commit.

CC @tstein @TomJo2000

build-all.sh Show resolved Hide resolved
@Maxython Maxython force-pushed the fix-build-all branch 2 times, most recently from 9b5068d to 4317575 Compare June 13, 2024 14:35
@Maxython Maxython changed the title build-all.sh: fixes for working with cyclic dependencies Script improvements and fixes Jun 13, 2024
@Maxython Maxython force-pushed the fix-build-all branch 2 times, most recently from 59138be to c820cc0 Compare June 13, 2024 17:53
scripts/buildorder.py Outdated Show resolved Hide resolved
Copy link
Contributor

@tstein tstein left a comment

Choose a reason for hiding this comment

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

It took me an hour to review this and I'm still not clear on what the new behavior is. We should not merge this until the code and comments are clear enough that reading it in one pass leaves you with a truthy understanding of the build order computation.

(I think it's a mistake to keep hacking on this without stepping back to think about how this code should be and how your changes get us closer. Not trying to block, because I think it's possible to get this to a state where it's better to merge it than not, but then we should have that conversation right after this.)

scripts/build/termux_step_setup_variables.sh Outdated Show resolved Hide resolved
scripts/build/termux_step_setup_variables.sh Outdated Show resolved Hide resolved
scripts/build/termux_step_setup_variables.sh Outdated Show resolved Hide resolved
scripts/buildorder.py Outdated Show resolved Hide resolved
scripts/buildorder.py Outdated Show resolved Hide resolved
scripts/buildorder.py Outdated Show resolved Hide resolved
scripts/buildorder.py Show resolved Hide resolved
scripts/buildorder.py Outdated Show resolved Hide resolved
scripts/buildorder.py Outdated Show resolved Hide resolved
scripts/buildorder.py Outdated Show resolved Hide resolved
@agnostic-apollo

This comment was marked as off-topic.

@Maxython

This comment was marked as off-topic.

@agnostic-apollo

This comment was marked as off-topic.

@Maxython Maxython force-pushed the fix-build-all branch 5 times, most recently from 3dab149 to d46835f Compare June 17, 2024 15:23
@Maxython Maxython marked this pull request as ready for review June 17, 2024 15:23
@Maxython Maxython requested a review from Grimler91 June 17, 2024 15:23
build-all.sh Show resolved Hide resolved
scripts/buildorder.py Outdated Show resolved Hide resolved
scripts/buildorder.py Show resolved Hide resolved
scripts/buildorder.py Outdated Show resolved Hide resolved
scripts/buildorder.py Outdated Show resolved Hide resolved
scripts/buildorder.py Outdated Show resolved Hide resolved
@Maxython Maxython changed the title Script improvements and fixes Scripts fixe and improvement Jun 18, 2024
@Maxython Maxython changed the title Scripts fixe and improvement Fixes and improvements to scripts for working with cyclic dependencies Jun 18, 2024
@Maxython Maxython requested a review from TomJo2000 June 18, 2024 11:46
@Maxython Maxython force-pushed the fix-build-all branch 2 times, most recently from 6b39ff1 to 5890600 Compare June 18, 2024 14:26
Copy link
Member

@TomJo2000 TomJo2000 left a comment

Choose a reason for hiding this comment

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

Nice work Max.

scripts/buildorder.py Outdated Show resolved Hide resolved
scripts/buildorder.py Outdated Show resolved Hide resolved
scripts/buildorder.py Show resolved Hide resolved
scripts/buildorder.py Show resolved Hide resolved
@robertkirkman
Copy link
Contributor

robertkirkman commented Nov 3, 2024

Hello, I greatly appreciate the work that Maxython has done in this PR to enable the build-all.sh to begin building packages, rather than the current vanilla behavior of build-all.sh as it currently exists in the unmodified repo (which is to print a large error about "cyclic dependencies" and do nothing). I am not intending to be rude or belittling towards the quality of the code in this PR, on the contrary I would like to help it be as complete and useful a tool as possible to implement a functioning build-all.sh for use in the pinned issue until a time when the vanilla repository gets its own functioning build-all.sh implementation, whatever form that might end up taking, and this PR has served well for a very large amount of packages consecutively, without behaving too strangely for most of the process. I would just like to explain something that happens to me every time I attempt to build the libepoxy package currently using the command scripts/run-docker.sh ./build-package.sh libepoxy in any clone of the repository that has this PR applied to it. In the vanilla repository, these commands complete successfully:

docker container stop termux-package-builder
docker container rm termux-package-builder
docker image rm ghcr.io/termux/package-builder:latest
git clone https://github.com/termux/termux-packages.git
cd termux-packages/
scripts/run-docker.sh ./build-package.sh libepoxy

On the other hand, unfortunately, it appears that there might be a problem when using the same command in a clone of the repository that has this PR applied to it (with the exception of the glib package which conflicts currently, but seems unrelated and shouldn't impact this because glib is not a dependency of libepoxy)

docker container stop termux-package-builder
docker container rm termux-package-builder
docker image rm ghcr.io/termux/package-builder:latest
git clone https://github.com/termux/termux-packages.git
cd termux-packages/
curl https://patch-diff.githubusercontent.com/raw/termux/termux-packages/pull/20513.diff | git apply -v --exclude=packages/glib/build.sh
scripts/run-docker.sh ./build-package.sh libepoxy

since when I use those commands, I see this:

[7/13] Compiling C object src/libepoxy.so.p/dispatch_egl.c.o
FAILED: src/libepoxy.so.p/dispatch_egl.c.o 
aarch64-linux-android-clang -Isrc/libepoxy.so.p -Isrc -I../src/src -Iinclude -I../src/include -Iinclude/epoxy -I/data/data/com.termux/files/usr/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=gnu99 -Oz -g -fstack-protector-strong -Oz -fPIC -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast -Wold-style-definition -Wdeclaration-after-statement -Wunused -Wuninitialized -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Werror=implicit -Werror=nonnull -Werror=init-self -Werror=main -Werror=missing-braces -Werror=sequence-point -Werror=return-type -Werror=trigraphs -Werror=array-bounds -Werror=write-strings -Werror=address -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -fno-strict-aliasing -Wno-int-conversion -fvisibility=hidden -MD -MQ src/libepoxy.so.p/dispatch_egl.c.o -MF src/libepoxy.so.p/dispatch_egl.c.o.d -o src/libepoxy.so.p/dispatch_egl.c.o -c ../src/src/dispatch_egl.c
In file included from ../src/src/dispatch_egl.c:28:
In file included from ../src/src/dispatch_common.h:46:
../src/include/epoxy/glx.h:36:10: fatal error: 'X11/Xlib.h' file not found
   36 | #include <X11/Xlib.h>
      |          ^~~~~~~~~~~~
1 error generated.

It looks to me like the libx11 and libglvnd-dev build dependencies of libepoxy end up not being completely detected, causing them not to be installed when using the code from this PR, as opposed to the behavior of the vanilla repository where they are correctly built automatically before the libepoxy package is built. This can be confirmed by testing this command, which works in both the current vanilla repository, and the current repository with this PR applied to it.

scripts/run-docker.sh ./build-package.sh libx11 libglvnd libepoxy

I will troubleshoot this and try to find if there is any alternative or workaround possible to this situation in order to automatically detect the required dependencies at all times.

@Maxython Maxython force-pushed the fix-build-all branch 6 times, most recently from 0db2fc4 to c8325a0 Compare November 29, 2024 12:29
@Maxython Maxython force-pushed the fix-build-all branch 6 times, most recently from c45965f to c7976ec Compare December 9, 2024 14:14
@Maxython Maxython requested a review from TomJo2000 December 9, 2024 14:15
Copy link
Member

@TomJo2000 TomJo2000 left a comment

Choose a reason for hiding this comment

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

This review is only pertaining to commit c7976ec.

This is pretty much unreviewable.
843 lines changed in a single commit is one hell of a lot to ask.
The specific pieces I have commented on in this review are by no means exhaustive, but I do not have 2-3 hours to review one commit.
I may be coming back to this later and do more incremental review,
but the amount of nesting in the code makes it exceedingly difficult to follow.

Please consider inverting some of the deeply nested conditionals into guard clauses so they can be mentally discarded after they are passed.

build-package.sh Outdated Show resolved Hide resolved
build-package.sh Outdated Show resolved Hide resolved
build-package.sh Show resolved Hide resolved
scripts/build/termux_step_get_dependencies.sh Show resolved Hide resolved
@Maxython Maxython force-pushed the fix-build-all branch 2 times, most recently from 7e4fff3 to fa6bcc3 Compare December 9, 2024 21:31
- remove_char(var): removes unnecessary characters when parsing values
- parse_build_file_variable(path, var): returns the value of a variable from the specified source
- has_prefix_glibc(pkgname): checks if the package name has the prefix "glibc"
scripts/buildorder.py:
 - the algorithm of the function `generate_full_buildorder` has been changed, now it can work with cyclic dependencies
 - added new flag `-l` and function `get_list_cyclic_dependencies` which allows to find cyclic dependencies
 - for subpackages a new variable `depend_on_parent` has been added which allows disabling dependencies on the parent package (controlled via the variable `TERMUX_SUBPKG_DEPEND_ON_PARENT`)
 - updated logic of variable `only_installing`, now package dependency (with this variable) from variable `pkg_deps` will be used
 - added the ability to control the `only_installing` variable for subpackages via the `TERMUX_SUBPKG_DEPEND_ON_PARENT` variable
 - updated logic of the `recursive_dependencies` function, now only dependencies of the requested package will be returned during non-fast build
scripts/build/termux_step_get_dependencies.sh:
 - removed `-s` flag when compiling dependencies to fix cyclic dependencies
 - fixed running of `termux_download_repo_file` function when cyclic dependencies are detected
build-package.sh: the algorithm that launches the signing key settings has been changed, now it will be launched if the value from the `TERMUX_REPO_PACKAGE` variable and from `TERMUX_APP_PACKAGE` match
build-all.sh: removed default `-s` flag when compiling packages and added check for compiled packages
- added the ability to change the package format
- added library base check by package name
- the method of saving processes in the logo has been changed
Virtual packages are packages that are compiled and installed into the system, but are not assembled into a source package for package managers. One advantage of virtual packages is that they can use sources (including values from configured variables) from regular packages. This will allow us to easily create special virtual packages that will have to resolve cyclic dependencies in regular packages.

[no ci]
@Maxython
Copy link
Member Author

Please consider inverting some of the deeply nested conditionals into guard clauses so they can be mentally discarded after they are passed.

Perhaps some local functions could be created in some places, but is it worth it to make the code more readable? It is worth noting that the commit highlights a large number of changed lines due to new conditions added to large algorithms (but in essence they did not change that much) for the correct operation of the collector.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants