-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix(main/boost): prepend $TERMUX_PREFIX to all absolute /tmp paths
#25827
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
Conversation
|
Dunno if this matters in os_file_functions.hpp their sanity check on buffer size is set to 5u: "/tmp" length plus null character. Dunno if you'd want to add the length of TERMUX_PREFIX to that. I noticed that but didn't fix it in my patch as it wasn't used by supercollider. In my patch) I just replaced /tmp with a call to std::filesystem::temp_directory_path().string() which first tries env variables like TMPDIR one of which is set on Termux and works. If no such env var was set it'd default to /tmp, I didn't fix that, your fix to boost does probably. Well that's all I have to say dunno if it matters. |
859c65d to
4dd3cfc
Compare
Wow thank you, you are right and I didn't notice that at all. Now I've changed it to ensure the size of the destination buffer is always correct, and otherwise return |
I'd like to make a note here that, technically, in Termux, we use and deploy upstream Android's official Since we don't actually patch or recompile this (at least currently), if I guess that if there is someone who wants to have the option of using Termux Generally, I think it makes the most sense to assume that Termux packages will be installed in a writable folder |
|
Ok, assuming that this PR fixes the problem sufficiently for your PR |
In my opinion, just from what I would guess, probably the plugin will work if it's recompiled targeting the Termux versions of everything, and if it wasn't recompiled, it would probably only work on GNU/Linux, Windows etc. if it was only tested on official builds of SuperCollider that already exist. but if you realize that ends up being a problem, please let me know anything else you find out about it. |
Tried to build this PR but it wouldn't let me: Oh I'm sure it'll work, simple change which already worked with the patch I did. This PR is more robust on top of that.
On the bundled boost problem a SuperCollider dev read my concern there and said it wasn't a problem and not to worry about it, using Termux's boost will be fine. My paraphrase of his words. Thank you for the fix! |
- Fixes a problem explained here (that `boost` lacks needed `/tmp` path patches) termux#25025 - Methodology to find paths to prepend: - Ignore all folders named `doc` - Ignore all folders named `test` - Find them using `grep -rn $TERMUX_PKG_SRCDIR -e '"/tmp' -e 'data/local/tmp'` - Ignore codepaths that don't compile for Android (`#ifndef __ANDROID__`) - Try to calculate the code behavior to make sure every patched instance is a true absolute path (and not a path subcomponent that could be appended to a longer path) - Dependency of termux#25826
- Because it does not modify any files owned by any packages that are not `boost` or one of its subpackages
4dd3cfc to
f32a36f
Compare
There have been a series of people who made decisions about which packages are safe to build on-device before me, but unfortunately, my personal methodology for determining whether a package is safe to build on-device or not does not line up with the methodology that others used for many packages that have existed for a long time. The result has been:
Since the exact methodology others use has never been clearly documented beyond "it is unsafe to build on-device if it removes files in $TERMUX_PREFIX" (which I believe is a flawed methodology if not amended by additional conditions, and could explain why I believe that if asked), I am going to use this situation as an opportunity to apply my own methodology to the on-device build safety status of so that hopefully if others read this and either agree, or disagree, or have additional criteria to add, we can have a conversation about what the correct methodology for determining whether to mark a package as unsafe for on-device building should be. Below is the full process I have used to re-evaluate the on-device build safety status of pkg upgrade
pkg install apt-file
apt-file update
# data point 1: gather proof through apt-file search that all files removed
# during build.sh are ONLY provided by the package being built
# or one of its subpackages.
apt-file search 'lib/libboost' | grep -v glibc
apt-file search 'include/boost' | grep -v glibc
pkg install boost-headers boost-static boost # install package and all subpackages
pkg install python # install all build dependencies of the package
git clone https://github.com/termux/termux-packages.git
cd termux-packages
# temporarily exclude folders named '.git' from the build-package.sh system
git apply -v << 'EOF'
--- a/scripts/build/termux_step_copy_into_massagedir.sh
+++ b/scripts/build/termux_step_copy_into_massagedir.sh
@@ -2,6 +2,6 @@ termux_step_copy_into_massagedir() {
local DEST="$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX_CLASSICAL"
mkdir -p "$DEST"
# Copy files changed during the build into massagedir in order to massage them
- tar -C "$TERMUX_PREFIX_CLASSICAL" -N "$TERMUX_BUILD_TS_FILE" --exclude='tmp' -cf - . | \
+ tar -C "$TERMUX_PREFIX_CLASSICAL" -N "$TERMUX_BUILD_TS_FILE" --exclude='tmp' --exclude='.git' -cf - . | \
tar -C "$DEST" -xf -
}
EOF
# remove the on-device build safety condition to perform the test
git apply -v << 'EOF'
--- a/packages/boost/build.sh
+++ b/packages/boost/build.sh
@@ -16,14 +16,6 @@ TERMUX_PKG_BREAKS="libboost-python (<= 1.65.1-2), boost-dev"
TERMUX_PKG_REPLACES="libboost-python (<= 1.65.1-2), boost-dev"
TERMUX_PKG_BUILD_IN_SRC=true
-termux_step_pre_configure() {
- # Certain packages are not safe to build on device because their
- # build.sh script deletes specific files in $TERMUX_PREFIX.
- if $TERMUX_ON_DEVICE_BUILD; then
- termux_error_exit "Package '$TERMUX_PKG_NAME' is not safe for on-device builds."
- fi
-}
-
termux_step_make_install() {
CXXFLAGS+=" -std=c++14"
EOF
scripts/setup-termux.sh
cd $PREFIX
git init
git add .
git commit -m "tmp"
cd -
./build-package.sh -I -f boost
cd $PREFIX
# data point 2: gather real-world proof through manipulation of the capabilities
# of the `git` command that actually building the package on-device does NOT
# modify any files that are not provided by the package being built or one of
# its subpackages.
git status
# clean up
rm -rf $PREFIX/.gitAnnotated Results: .../files/usr $ git status
Refresh index: 100% (280649/280649), done.
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: include/boost/interprocess/detail/os_file_functions.hpp # boost-headers
modified: include/boost/interprocess/detail/shared_dir_helpers.hpp # boost-headers
modified: lib/libboost_atomic.a # boost-static
modified: lib/libboost_atomic.so # boost
modified: lib/libboost_charconv.a # boost-static
modified: lib/libboost_charconv.so # boost
modified: lib/libboost_chrono.a # boost-static
modified: lib/libboost_chrono.so # boost
modified: lib/libboost_container.a # boost-static
modified: lib/libboost_container.so # boost
modified: lib/libboost_context.a # boost-static
modified: lib/libboost_context.so # boost
modified: lib/libboost_contract.a # boost-static
modified: lib/libboost_contract.so # boost
modified: lib/libboost_coroutine.a # boost-static
modified: lib/libboost_coroutine.so # boost
modified: lib/libboost_date_time.a # boost-static
modified: lib/libboost_date_time.so # boost
modified: lib/libboost_exception.a # boost-static
modified: lib/libboost_fiber.a # boost-static
modified: lib/libboost_fiber.so # boost
modified: lib/libboost_filesystem.a # boost-static
modified: lib/libboost_filesystem.so # boost
modified: lib/libboost_graph.a # boost-static
modified: lib/libboost_graph.so # boost
modified: lib/libboost_iostreams.a # boost-static
modified: lib/libboost_iostreams.so # boost
modified: lib/libboost_json.a # boost-static
modified: lib/libboost_json.so # boost
modified: lib/libboost_locale.a # boost-static
modified: lib/libboost_locale.so # boost
modified: lib/libboost_log.a # boost-static
modified: lib/libboost_log.so # boost
modified: lib/libboost_log_setup.a # boost-static
modified: lib/libboost_log_setup.so # boost
modified: lib/libboost_math_c99.a # boost-static
modified: lib/libboost_math_c99.so # boost
modified: lib/libboost_math_c99f.a # boost-static
modified: lib/libboost_math_c99f.so # boost
modified: lib/libboost_math_c99l.a # boost-static
modified: lib/libboost_math_c99l.so # boost
modified: lib/libboost_math_tr1.a # boost-static
modified: lib/libboost_math_tr1.so # boost
modified: lib/libboost_math_tr1f.a # boost-static
modified: lib/libboost_math_tr1f.so # boost
modified: lib/libboost_math_tr1l.a # boost-static
modified: lib/libboost_math_tr1l.so # boost
modified: lib/libboost_nowide.a # boost-static
modified: lib/libboost_nowide.so # boost
modified: lib/libboost_prg_exec_monitor.a # boost-static
modified: lib/libboost_prg_exec_monitor.so # boost
modified: lib/libboost_process.a # boost-static
modified: lib/libboost_process.so # boost
modified: lib/libboost_program_options.a # boost-static
modified: lib/libboost_program_options.so # boost
modified: lib/libboost_python312.a # boost-static
modified: lib/libboost_python312.so # boost
modified: lib/libboost_random.a # boost-static
modified: lib/libboost_random.so # boost
modified: lib/libboost_regex.a # boost-static
modified: lib/libboost_regex.so # boost
modified: lib/libboost_serialization.a # boost-static
modified: lib/libboost_serialization.so # boost
modified: lib/libboost_system.a # boost-static
modified: lib/libboost_system.so # boost
modified: lib/libboost_test_exec_monitor.a # boost-static
modified: lib/libboost_thread.a # boost-static
modified: lib/libboost_thread.so # boost
modified: lib/libboost_timer.a # boost-static
modified: lib/libboost_timer.so # boost
modified: lib/libboost_type_erasure.a # boost-static
modified: lib/libboost_type_erasure.so # boost
modified: lib/libboost_unit_test_framework.a # boost-static
modified: lib/libboost_unit_test_framework.so
modified: lib/libboost_url.a # boost-static
modified: lib/libboost_url.so # boost
modified: lib/libboost_wave.a # boost-static
modified: lib/libboost_wave.so # boost
modified: lib/libboost_wserialization.a # boost-static
modified: lib/libboost_wserialization.so # boost
modified: lib/python3.12/__pycache__/platform.cpython-312.pyc # will be handled by PR #23652
Untracked files:
(use "git add <file>..." to include in what will be committed)
lib/cmake/boost_numpy-1.87.0/libboost_numpy-variant-shared-py3.12.cmake # prefix pollution (safe) (ask me if you need an explanation what this means)
lib/cmake/boost_numpy-1.87.0/libboost_numpy-variant-static-py3.12.cmake # prefix pollution (safe) (ask me if you need an explanation what this means)
lib/libboost_numpy312.a # prefix pollution (safe) (ask me if you need an explanation what this means)
lib/libboost_numpy312.so # prefix pollution (safe) (ask me if you need an explanation what this means)
tmp/build-package-call-building-packages-list-2025-08-27-17.41.16.284 # tmp files are temporary
tmp/build-package-call-built-packages-list-2025-08-27-17.41.16.180 # tmp files are temporary
no changes added to commit (use "git add" and/or "git commit -a")Based on my evaluation shown above, I have determined that according to my personal methodology, (you don't need to run any of the extra commands I sent in the above explanation ^^^ those are just my recorded proof of how people checking my work can calculate that |
|
Awesome! I'll be away from internet till Saturday so don't wait on me. Using git to track things like that is clever. I did notice that building on device appeared to not use package management. I wanted to point out the checkinstall utility if you hadn't heard of it. It was removed from Debian repos for being unmaintained but there were patches I found somewhere, mailing list or forum (dunno), and was able to keep using it in future Debian releases. |
This comment was marked as resolved.
This comment was marked as resolved.
It's a bit complicated to explain, but yes, you get the idea of how Termux packages work! some details from my perspective:
Unfortunately, the reason why termux-packages/packages/emacs/build.sh Line 103 in a5b6f7c
In order to make |
Fixes a problem explained here (that
boostlacks needed/tmppath patches) addpkg(main/supercollider): 3.14.0 #25025Methodology to find paths to prepend:
doctestgrep -rn $TERMUX_PKG_SRCDIR -e '"/tmp' -e 'data/local/tmp'#ifndef __ANDROID__)Dependency of addpkg(main/supercollider): 3.14.0 #25826
Enable on-device building because it does not modify any files owned by any packages that are not
boostor one of its subpackages