Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions packages/fish/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ TERMUX_PKG_DESCRIPTION="The user-friendly command line shell"
TERMUX_PKG_LICENSE="GPL-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="4.0.2"
TERMUX_PKG_REVISION=1
TERMUX_PKG_REVISION=2
TERMUX_PKG_SRCURL=https://github.com/fish-shell/fish-shell/releases/download/$TERMUX_PKG_VERSION/fish-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_SHA256=6e1ecdb164285fc057b2f35acbdc20815c1623099e7bb47bbfc011120adf7e83
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.
TERMUX_PKG_DEPENDS="bc, libandroid-support, libandroid-spawn, libc++, ncurses, ncurses-utils, mandoc, pcre2"
TERMUX_PKG_DEPENDS="bc, libandroid-support, libc++, ncurses, ncurses-utils, mandoc, pcre2"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
-DBUILD_DOCS=OFF
Expand All @@ -35,19 +35,6 @@ termux_step_pre_configure() {
export RUSTFLAGS=$(env | grep CARGO_TARGET_${env_host}_RUSTFLAGS | cut -d'=' -f2-)
RUSTFLAGS+=" -C link-arg=-landroid-spawn"
RUSTFLAGS+=" -L${TERMUX_PKG_BUILDDIR} -C link-arg=-l:libctermid.a"

: "${CARGO_HOME:=${HOME}/.cargo}"
export CARGO_HOME

rm -rf "$CARGO_HOME"/registry/src/*/libc-*
cargo fetch --target "${CARGO_TARGET_NAME}"

local libc p
for libc in "${CARGO_HOME}"/registry/src/*/libc-*; do
for p in "${TERMUX_PKG_BUILDER_DIR}"/libc-*.diff; do
[[ -f "${p}" ]] && patch -p1 -d "${libc}" -i "${p}" || termux_error_exit "fish: failed to apply patch '$p'"
done
done
}

termux_step_post_make_install() {
Expand All @@ -60,7 +47,3 @@ termux_step_post_make_install() {
status test-feature keyboard-protocols && set -U fish_features no-keyboard-protocols
EOF
}

termux_step_post_massage() {
rm -rf "$CARGO_HOME"/registry/src/*/libc-*
}
59 changes: 59 additions & 0 deletions packages/fish/do-not-import-posix-spawn.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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?= <[email protected]>
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};
131 changes: 131 additions & 0 deletions packages/fish/force-d_ino-and-st_mode-types-on-32-bit-android.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
This fixes https://github.com/termux/termux-packages/issues/24741

To maintain:
keep the conditionally-compiled implementations of DirEntry and stat_mode_to_entry_type()
synchronized with their upstream counterparts that are developed for non-32-bit-Android platforms.
keep the S_IFIFO, etc. definitions synchronized with this file:
https://github.com/rust-lang/libc/blob/c1d2b8e055e29b239a308f10b38a6b6138711612/src/unix/linux_like/mod.rs#L563

This patch was not created by an automatic tool - unfortunately, it was created by manually typing the
syntax of the unified-diff format, in order to artifically extend the context of each hunk an
abnormal number of lines after the changed lines (but not before the changed lines).
The reason for this is so that if anything in the normal implementation of the blocks changes,
this patch is explicitly forced to fail so that the maintainer is reminded to make an equivalent change
in the implementation of the block for 32-bit Android. If another maintianer of this patch is not
familiar with manually writing the unified-diff format, this documentation might be helpful to
preserve this failsafe in future revisions of this patch:
https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html

--- a/src/wildcard.rs
+++ b/src/wildcard.rs
@@ -885,6 +885,9 @@ mod expander {
// Ensure we don't fall into a symlink loop.
// Ideally we would compare both devices and inodes, but devices require a stat call, so we
// use inodes exclusively.
+ #[cfg(all(target_os = "android", target_pointer_width = "32"))]
+ let mut visited_inodes: HashSet<u64> = HashSet::new();
+ #[cfg(not(all(target_os = "android", target_pointer_width = "32")))]
let mut visited_inodes: HashSet<libc::ino_t> = HashSet::new();

loop {
--- a/src/wutil/dir_iter.rs
+++ b/src/wutil/dir_iter.rs
@@ -26,26 +26,52 @@ pub enum DirEntryType {
whiteout, // whiteout (from BSD)
}

-/// An entry returned by DirIter.
+/// An entry returned by DirIter on 32-bit Android.
+#[cfg(all(target_os = "android", target_pointer_width = "32"))]
+#[derive(Clone)]
+pub struct DirEntry {
+ /// File name of this entry.
+ pub name: WString,
+
+ /// inode of this entry.
+ pub inode: u64,
+
+ // Device, inode pair for this entry, or none if not yet computed.
+ dev_inode: Cell<Option<DevInode>>,
+
+ // The type of the entry. This is initially none; it may be populated eagerly via readdir()
+ // on some filesystems, or later via stat(). If stat() fails, the error is silently ignored
+ // and the type is left as none(). Note this is an unavoidable race.
+ typ: Cell<Option<DirEntryType>>,
+
+ // whether this could be a link, false if we know definitively it isn't.
+ possible_link: Option<bool>,
+
+ // fd of the DIR*, used for fstatat().
+ dirfd: Rc<DirFd>,
+}
+
+/// An entry returned by DirIter on everything except 32-bit Android.
+#[cfg(not(all(target_os = "android", target_pointer_width = "32")))]
#[derive(Clone)]
pub struct DirEntry {
/// File name of this entry.
pub name: WString,

/// inode of this entry.
pub inode: libc::ino_t,

// Device, inode pair for this entry, or none if not yet computed.
dev_inode: Cell<Option<DevInode>>,

// The type of the entry. This is initially none; it may be populated eagerly via readdir()
// on some filesystems, or later via stat(). If stat() fails, the error is silently ignored
// and the type is left as none(). Note this is an unavoidable race.
typ: Cell<Option<DirEntryType>>,

// whether this could be a link, false if we know definitively it isn't.
possible_link: Option<bool>,

// fd of the DIR*, used for fstatat().
dirfd: Rc<DirFd>,
}
@@ -148,18 +174,44 @@ fn dirent_type_to_entry_type(dt: u8) -> Option<DirEntryType> {
}
}

+#[cfg(all(target_os = "android", target_pointer_width = "32"))]
+fn stat_mode_to_entry_type(m: u32) -> Option<DirEntryType> {
+ const S_IFIFO_32_bit_android: u32 = 0o1_0000;
+ const S_IFCHR_32_bit_android: u32 = 0o2_0000;
+ const S_IFBLK_32_bit_android: u32 = 0o6_0000;
+ const S_IFDIR_32_bit_android: u32 = 0o4_0000;
+ const S_IFREG_32_bit_android: u32 = 0o10_0000;
+ const S_IFLNK_32_bit_android: u32 = 0o12_0000;
+ const S_IFSOCK_32_bit_android: u32 = 0o14_0000;
+ const S_IFMT_32_bit_android: u32 = 0o17_0000;
+ match m & S_IFMT_32_bit_android {
+ S_IFIFO_32_bit_android => Some(DirEntryType::fifo),
+ S_IFCHR_32_bit_android => Some(DirEntryType::chr),
+ S_IFDIR_32_bit_android => Some(DirEntryType::dir),
+ S_IFBLK_32_bit_android => Some(DirEntryType::blk),
+ S_IFREG_32_bit_android => Some(DirEntryType::reg),
+ S_IFLNK_32_bit_android => Some(DirEntryType::lnk),
+ S_IFSOCK_32_bit_android => Some(DirEntryType::sock),
+ _ => {
+ // todo!("whiteout")
+ None
+ }
+ }
+}
+
+#[cfg(not(all(target_os = "android", target_pointer_width = "32")))]
fn stat_mode_to_entry_type(m: libc::mode_t) -> Option<DirEntryType> {
match m & S_IFMT {
S_IFIFO => Some(DirEntryType::fifo),
S_IFCHR => Some(DirEntryType::chr),
S_IFDIR => Some(DirEntryType::dir),
S_IFBLK => Some(DirEntryType::blk),
S_IFREG => Some(DirEntryType::reg),
S_IFLNK => Some(DirEntryType::lnk),
S_IFSOCK => Some(DirEntryType::sock),
_ => {
// todo!("whiteout")
None
}
}
}
95 changes: 0 additions & 95 deletions packages/fish/libc-src-unix-linux_like-android-mod.rs.diff

This file was deleted.

Loading