From 3d420cd5774e0c51819d9973ba632cb5f71883ac Mon Sep 17 00:00:00 2001 From: Robert Kirkman Date: Sat, 27 Sep 2025 21:26:44 -0500 Subject: [PATCH] bump(main/fish): 4.1.0 - Fixes https://github.com/termux/termux-packages/issues/26707 - Revert https://github.com/fish-shell/fish-shell/commit/70bd49f61265c3a50c98d439fc77e13ef4409231 as planned and previously noted in https://github.com/termux/termux-packages/pull/26466 - After https://github.com/fish-shell/fish-shell/commit/eb4cec1fe25336d07aeed6f67f4bcd0f0cb2f8f0, `fix-import-when-posix-spawn-disabled.patch` is necessary to prevent compilation error `failed to resolve: use of undeclared type 'Pid'` - After https://github.com/fish-shell/fish-shell/commit/91ee45b0e172d2cc75b600505b6fefe9ecb01bd5, `revert-6644cc9.patch` is no longer necessary to prevent a compilation failure, and can be removed. - https://github.com/termux/termux-app/pull/4417 has been in [Termux 0.118.3](https://github.com/termux/termux-app/releases/tag/v0.118.3) for 4 months, meaning that `status test-feature keyboard-protocols && set -U fish_features no-keyboard-protocols` can be removed. --- packages/fish/Cargo.toml.patch | 8 +- packages/fish/build.sh | 9 +- packages/fish/do-not-import-posix-spawn.patch | 59 ------------- ...fix-import-when-posix-spawn-disabled.patch | 25 ++++++ packages/fish/revert-6644cc9.patch | 84 ------------------- packages/fish/revert-70bd49f.patch | 67 +++++++++++++++ 6 files changed, 100 insertions(+), 152 deletions(-) delete mode 100644 packages/fish/do-not-import-posix-spawn.patch create mode 100644 packages/fish/fix-import-when-posix-spawn-disabled.patch delete mode 100644 packages/fish/revert-6644cc9.patch create mode 100644 packages/fish/revert-70bd49f.patch diff --git a/packages/fish/Cargo.toml.patch b/packages/fish/Cargo.toml.patch index e6016504847ae7..14a5ef4e5a06c4 100644 --- a/packages/fish/Cargo.toml.patch +++ b/packages/fish/Cargo.toml.patch @@ -1,9 +1,9 @@ --- a/Cargo.toml +++ b/Cargo.toml -@@ -31,7 +31,7 @@ - bitflags = "2.5.0" - errno = "0.3.0" - lazy_static = "1.4.0" +@@ -18,7 +18,7 @@ fish-gettext-extraction = { path = "crates/gettext-extraction" } + fish-gettext-maps = { path = "crates/gettext-maps" } + fish-gettext-mo-file-parser = { path = "crates/gettext-mo-file-parser" } + fish-printf = { path = "crates/printf", features = ["widestring"] } -libc = "0.2.155" +libc = "0.2.170" # lru pulls in hashbrown by default, which uses a faster (though less DoS resistant) hashing algo. diff --git a/packages/fish/build.sh b/packages/fish/build.sh index d9fb03790697e4..2b61616d761b01 100644 --- a/packages/fish/build.sh +++ b/packages/fish/build.sh @@ -2,9 +2,9 @@ TERMUX_PKG_HOMEPAGE=https://fishshell.com/ TERMUX_PKG_DESCRIPTION="The user-friendly command line shell" TERMUX_PKG_LICENSE="GPL-2.0" TERMUX_PKG_MAINTAINER="@termux" -TERMUX_PKG_VERSION="4.0.8" +TERMUX_PKG_VERSION="4.1.0" TERMUX_PKG_SRCURL=https://github.com/fish-shell/fish-shell/releases/download/$TERMUX_PKG_VERSION/fish-${TERMUX_PKG_VERSION}.tar.xz -TERMUX_PKG_SHA256=7f779d13aa55d2fa3afc17364c61ab9edc16faa1eac5851badeffb4e73692240 +TERMUX_PKG_SHA256=07a76c67e161b9edc772e6f1d66ebead85d7056e86631d61577f9f9a529c4d9c TERMUX_PKG_AUTO_UPDATE=true # fish calls 'tput' from ncurses-utils, at least when cancelling (Ctrl+C) a command line. # man is needed since fish calls apropos during command completion. @@ -25,6 +25,8 @@ termux_step_pre_configure() { # FindRust.cmake auto pick thumbv7neon-linux-androideabi [[ "${TERMUX_ARCH}" == "arm" ]] && TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DCMAKE_ANDROID_ARM_MODE=ON" + TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DRust_CARGO_TARGET=$CARGO_TARGET_NAME" + # older than Android 8 dont have ctermid "${CC}" ${CPPFLAGS} ${CFLAGS} -c ${TERMUX_PKG_BUILDER_DIR}/ctermid.c "${AR}" cru libctermid.a ctermid.o @@ -41,8 +43,5 @@ termux_step_post_make_install() { function __fish_command_not_found_handler --on-event fish_command_not_found $TERMUX_PREFIX/libexec/termux/command-not-found \$argv[1] end - - # TODO: remove when https://github.com/termux/termux-app/pull/4417 gets released - status test-feature keyboard-protocols && set -U fish_features no-keyboard-protocols EOF } diff --git a/packages/fish/do-not-import-posix-spawn.patch b/packages/fish/do-not-import-posix-spawn.patch deleted file mode 100644 index bf945ab4e4a47d..00000000000000 --- a/packages/fish/do-not-import-posix-spawn.patch +++ /dev/null @@ -1,59 +0,0 @@ -Cherry-pick of https://github.com/fish-shell/fish-shell/commit/bbf678e7185fedce955587afbb23d83d37a87344 - -From bbf678e7185fedce955587afbb23d83d37a87344 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E9=80=B8?= -Date: Sat, 8 Mar 2025 02:09:45 +0800 -Subject: [PATCH] Reduce warnings when posix_spawn disabled. - ---- - src/exec.rs | 8 ++++++-- - src/fork_exec/mod.rs | 1 + - 2 files changed, 7 insertions(+), 2 deletions(-) - -diff --git a/src/exec.rs b/src/exec.rs -index 89b8b86f462b..ba961e456e5f 100644 ---- a/src/exec.rs -+++ b/src/exec.rs -@@ -12,6 +12,7 @@ use crate::common::{ - ScopeGuard, - }; - use crate::env::{EnvMode, EnvStack, Environment, Statuses, READ_BYTE_LIMIT}; -+#[cfg(FISH_USE_POSIX_SPAWN)] - use crate::env_dispatch::use_posix_spawn; - use crate::fds::make_fd_blocking; - use crate::fds::{make_autoclose_pipes, open_cloexec, PIPE_ERROR}; -@@ -34,10 +35,12 @@ use crate::null_terminated_array::{ - null_terminated_array_length, AsNullTerminatedArray, OwningNullTerminatedArray, - }; - use crate::parser::{Block, BlockId, BlockType, EvalRes, Parser}; -+#[cfg(FISH_USE_POSIX_SPAWN)] -+use crate::proc::Pid; - use crate::proc::{ - hup_jobs, is_interactive_session, jobs_requiring_warning_on_exit, no_exec, -- print_exit_warning_for_jobs, InternalProc, Job, JobGroupRef, Pid, ProcStatus, Process, -- ProcessType, TtyTransfer, -+ print_exit_warning_for_jobs, InternalProc, Job, JobGroupRef, ProcStatus, Process, ProcessType, -+ TtyTransfer, - }; - use crate::reader::{reader_run_count, restore_term_mode}; - use crate::redirection::{dup2_list_resolve_chain, Dup2List}; -@@ -447,6 +450,7 @@ fn launch_process_nofork(vars: &EnvStack, p: &Process) -> ! { - // To avoid the race between the caller calling tcsetpgrp() and the client checking the - // foreground process group, we don't use posix_spawn if we're going to foreground the process. (If - // we use fork(), we can call tcsetpgrp after the fork, before the exec, and avoid the race). -+#[cfg(FISH_USE_POSIX_SPAWN)] - fn can_use_posix_spawn_for_job(job: &Job, dup2s: &Dup2List) -> bool { - // Is it globally disabled? - if !use_posix_spawn() { -diff --git a/src/fork_exec/mod.rs b/src/fork_exec/mod.rs -index 2c10fccd5202..c0d0de46e2b9 100644 ---- a/src/fork_exec/mod.rs -+++ b/src/fork_exec/mod.rs -@@ -4,6 +4,7 @@ - - pub mod flog_safe; - pub mod postfork; -+#[cfg(FISH_USE_POSIX_SPAWN)] - pub mod spawn; - use crate::proc::Job; - use libc::{SIGINT, SIGQUIT}; diff --git a/packages/fish/fix-import-when-posix-spawn-disabled.patch b/packages/fish/fix-import-when-posix-spawn-disabled.patch new file mode 100644 index 00000000000000..88f0d975161a06 --- /dev/null +++ b/packages/fish/fix-import-when-posix-spawn-disabled.patch @@ -0,0 +1,25 @@ +Fixes this error: + +error[E0433]: failed to resolve: use of undeclared type `Pid` + --> src/exec.rs:753:15 + | +753 | p.set_pid(Pid::new(pid).unwrap()); + | ^^^ use of undeclared type `Pid` + | +help: consider importing this struct + | +6 + use crate::proc::Pid; + | + +after: https://github.com/fish-shell/fish-shell/commit/eb4cec1fe25336d07aeed6f67f4bcd0f0cb2f8f0 + +--- a/src/exec.rs ++++ b/src/exec.rs +@@ -33,7 +33,6 @@ use crate::libc::_PATH_BSHELL; + use crate::nix::{getpid, isatty}; + use crate::null_terminated_array::OwningNullTerminatedArray; + use crate::parser::{Block, BlockId, BlockType, EvalRes, Parser}; +-#[cfg(FISH_USE_POSIX_SPAWN)] + use crate::proc::Pid; + use crate::proc::{ + hup_jobs, is_interactive_session, jobs_requiring_warning_on_exit, no_exec, diff --git a/packages/fish/revert-6644cc9.patch b/packages/fish/revert-6644cc9.patch deleted file mode 100644 index 7b518f7e563e00..00000000000000 --- a/packages/fish/revert-6644cc9.patch +++ /dev/null @@ -1,84 +0,0 @@ -Reverts https://github.com/fish-shell/fish-shell/commit/6644cc9b0e29841e3d0a85fbc672a95c4a2fd000, -a NetBSD-related commit, -because it causes this compilation failure on Android: - -error[E0308]: mismatched types - --> src/path.rs:749:13 - | -748 | let remoteness = remoteness_via_statfs( - | --------------------- arguments to this function are incorrect -749 | libc::statfs, - | ^^^^^^^^^^^^ expected fn pointer, found fn item - | - = note: expected fn pointer `unsafe extern "C" fn(*const i8, _) -> _` - found fn item `unsafe extern "C" fn(*const u8, _) -> _ {libc::statfs}` - ---- a/src/path.rs -+++ b/src/path.rs -@@ -6,6 +6,8 @@ use crate::common::{wcs2osstring, wcs2zstring}; - use crate::env::{EnvMode, EnvStack, Environment}; - use crate::expand::{expand_tilde, HOME_DIRECTORY}; - use crate::flog::{FLOG, FLOGF}; -+#[cfg(not(target_os = "linux"))] -+use crate::libc::{MNT_LOCAL, ST_LOCAL}; - use crate::wchar::prelude::*; - use crate::wutil::{normalize_path, path_normalize_for_cd, waccess, wdirname, wstat}; - use errno::{errno, set_errno, Errno}; -@@ -709,49 +711,25 @@ fn path_remoteness(path: &wstr) -> DirRemoteness { - } - #[cfg(not(target_os = "linux"))] - { -- fn remoteness_via_statfs( -- statfn: unsafe extern "C" fn(*const i8, *mut StatFS) -> libc::c_int, -- flagsfn: fn(&StatFS) -> Flags, -- is_local_flag: u64, -- path: &std::ffi::CStr, -- ) -> DirRemoteness -- where -- u64: From, -- { -- if is_local_flag == 0 { -- return DirRemoteness::unknown; -- } -+ // ST_LOCAL is a flag to statvfs, which is itself standardized. -+ // In practice the only system to define it is NetBSD. -+ let local_flag = ST_LOCAL() | MNT_LOCAL(); -+ if local_flag != 0 { - let mut buf = MaybeUninit::uninit(); -- if unsafe { (statfn)(path.as_ptr(), buf.as_mut_ptr()) } < 0 { -+ if unsafe { libc::statfs(narrow.as_ptr(), buf.as_mut_ptr()) } < 0 { - return DirRemoteness::unknown; - } - let buf = unsafe { buf.assume_init() }; - // statfs::f_flag is hard-coded as 64-bits on 32/64-bit FreeBSD but it's a (4-byte) - // long on 32-bit NetBSD.. and always 4-bytes on macOS (even on 64-bit builds). - #[allow(clippy::useless_conversion)] -- if u64::from((flagsfn)(&buf)) & is_local_flag != 0 { -+ return if u64::from(buf.f_flags) & local_flag != 0 { - DirRemoteness::local - } else { - DirRemoteness::remote -- } -+ }; - } -- // ST_LOCAL is a flag to statvfs, which is itself standardized. -- // In practice the only system to define it is NetBSD. -- #[cfg(target_os = "netbsd")] -- let remoteness = remoteness_via_statfs( -- libc::statvfs, -- |stat: &libc::statvfs| stat.f_flag, -- crate::libc::ST_LOCAL(), -- &narrow, -- ); -- #[cfg(not(target_os = "netbsd"))] -- let remoteness = remoteness_via_statfs( -- libc::statfs, -- |stat: &libc::statfs| stat.f_flags, -- crate::libc::MNT_LOCAL(), -- &narrow, -- ); -- remoteness -+ DirRemoteness::unknown - } - } - diff --git a/packages/fish/revert-70bd49f.patch b/packages/fish/revert-70bd49f.patch new file mode 100644 index 00000000000000..0f88f7a999c95c --- /dev/null +++ b/packages/fish/revert-70bd49f.patch @@ -0,0 +1,67 @@ +Reverts https://github.com/fish-shell/fish-shell/commit/70bd49f61265c3a50c98d439fc77e13ef4409231, +because it causes this compilation failure on Android: + +error[E0432]: unresolved import `libc::confstr` + --> src/env/environment.rs:31:19 + | +31 | use libc::{c_int, confstr, uid_t, STDOUT_FILENO, _IONBF}; + | ^^^^^^^ no `confstr` in the root + +--- a/src/env/environment.rs ++++ b/src/env/environment.rs +@@ -28,7 +28,7 @@ use crate::wcstringutil::join_strings; + use crate::wutil::{fish_wcstol, wgetcwd, wgettext}; + use std::sync::atomic::Ordering; + +-use libc::{c_int, confstr, uid_t, STDOUT_FILENO, _IONBF}; ++use libc::{c_int, uid_t, STDOUT_FILENO, _IONBF}; + use once_cell::sync::{Lazy, OnceCell}; + use std::collections::HashMap; + use std::ffi::CStr; +@@ -569,7 +569,7 @@ fn setup_user(vars: &EnvStack) { + } + + pub(crate) static FALLBACK_PATH: Lazy<&[WString]> = Lazy::new(|| { +- use crate::libc::_CS_PATH; ++ use crate::libc::{confstr, _CS_PATH}; + // _CS_PATH: colon-separated paths to find POSIX utilities + let buf_size = unsafe { confstr(_CS_PATH(), std::ptr::null_mut(), 0) }; + Box::leak( +--- a/src/libc.c ++++ b/src/libc.c +@@ -21,6 +21,21 @@ uint64_t C_ST_LOCAL() { + #endif + } + ++// confstr + _CS_PATH is only available on macOS with rust's libc ++// we could just declare extern "C" confstr directly in Rust ++// that would panic if it failed to link, which C++ did not ++// therefore we define a backup, which just returns an error ++// which for confstr is 0 ++#if defined(_CS_PATH) ++#else ++size_t confstr(int name, char* buf, size_t size) { ++ UNUSED(name); ++ UNUSED(buf); ++ UNUSED(size); ++ return 0; ++} ++#endif ++ + int C_CS_PATH() { + #if defined(_CS_PATH) + return _CS_PATH; +--- a/src/libc.rs ++++ b/src/libc.rs +@@ -14,6 +14,11 @@ extern "C" { + } + + extern "C" { ++ pub(crate) fn confstr( ++ name: libc::c_int, ++ buf: *mut libc::c_char, ++ len: libc::size_t, ++ ) -> libc::size_t; + pub fn stdout_stream() -> *mut libc::FILE; + pub fn setlinebuf(stream: *mut libc::FILE); + }