Skip to content

Commit 856bd2c

Browse files
committed
bump(main/fish): 4.0.0
- build ctermid - add custom libc crate patch for 32bit android builds - backport FindRust.cmake rustup fix This backports: fish-shell/fish-shell@b38551d Co-authored-by: Jia Yuan Lo <jylo06g@gmail.com> Co-authored-by: Yaksh Bariya <yakshbari4@gmail.com> Co-authored-by: Robert Kirkman <misternumberone@live.com> Co-authored-by: AminurAlam <64137875+AminurAlam@users.noreply.github.com>
1 parent f202463 commit 856bd2c

14 files changed

+393
-176
lines changed

packages/fish/CMakeLists.txt.patch

Lines changed: 0 additions & 23 deletions
This file was deleted.

packages/fish/Cargo.toml.patch

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- a/Cargo.toml
2+
+++ b/Cargo.toml
3+
@@ -31,7 +31,7 @@
4+
bitflags = "2.5.0"
5+
errno = "0.3.0"
6+
lazy_static = "1.4.0"
7+
-libc = "0.2.155"
8+
+libc = "0.2.170"
9+
# lru pulls in hashbrown by default, which uses a faster (though less DoS resistant) hashing algo.
10+
# disabling default features uses the stdlib instead, but it doubles the time to rewrite the history
11+
# files as of 22 April 2024.

packages/fish/WIFSTOPPED.patch

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/fish/apt-autocompletion-sources-paths.patch

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
From b38551dde9daaab501b4f20d5d16a65bef9fa43f Mon Sep 17 00:00:00 2001
2+
From: Peter Ammon <rf@fishshell.com>
3+
Date: Wed, 5 Mar 2025 21:37:21 -0800
4+
Subject: [PATCH] Drag FindRust.cmake back into the land of the living
5+
6+
rustup has changed its output for 'rustup toolchain list --verbose`.
7+
Teach FindRust.cmake about it, so that it may shamble on.
8+
9+
This was reported against BSD and also affects macOS and ALSO affects Linux; our
10+
CI just doesn't have a new enough rustup. Anyways we can't have nice things.
11+
---
12+
cmake/FindRust.cmake | 11 ++++++++---
13+
1 file changed, 8 insertions(+), 3 deletions(-)
14+
15+
diff --git a/cmake/FindRust.cmake b/cmake/FindRust.cmake
16+
index cf68c4e27a21..493104accad5 100644
17+
--- a/cmake/FindRust.cmake
18+
+++ b/cmake/FindRust.cmake
19+
@@ -306,18 +306,23 @@ if (Rust_RESOLVE_RUSTUP_TOOLCHAINS)
20+
set(_DISCOVERED_TOOLCHAINS_VERSION "")
21+
22+
foreach(_TOOLCHAIN_RAW ${_TOOLCHAINS_RAW})
23+
- if (_TOOLCHAIN_RAW MATCHES "([a-zA-Z0-9\\._\\-]+)[ \t\r\n]?(\\(default\\) \\(override\\)|\\(default\\)|\\(override\\))?[ \t\r\n]+(.+)")
24+
+ # We're going to try to parse the output of `rustup toolchain list --verbose`.
25+
+ # We expect output like this:
26+
+ # stable-random-toolchain-junk (parenthesized-random-stuff-like-active-or-default) /path/to/toolchain/blah/more-blah
27+
+ # In the following regex, we capture the toolchain name, any parenthesized stuff, and then the path.
28+
+ message(STATUS "Parsing toolchain: ${_TOOLCHAIN_RAW}")
29+
+ if (_TOOLCHAIN_RAW MATCHES "([^\t ]+)[\t ]*(\\(.*\\))?[\t ]*(.+)")
30+
set(_TOOLCHAIN "${CMAKE_MATCH_1}")
31+
set(_TOOLCHAIN_TYPE "${CMAKE_MATCH_2}")
32+
33+
set(_TOOLCHAIN_PATH "${CMAKE_MATCH_3}")
34+
set(_TOOLCHAIN_${_TOOLCHAIN}_PATH "${CMAKE_MATCH_3}")
35+
36+
- if (_TOOLCHAIN_TYPE MATCHES ".*\\(default\\).*")
37+
+ if (_TOOLCHAIN_TYPE MATCHES "default")
38+
set(_TOOLCHAIN_DEFAULT "${_TOOLCHAIN}")
39+
endif()
40+
41+
- if (_TOOLCHAIN_TYPE MATCHES ".*\\(override\\).*")
42+
+ if (_TOOLCHAIN_TYPE MATCHES "override")
43+
set(_TOOLCHAIN_OVERRIDE "${_TOOLCHAIN}")
44+
endif()
45+

packages/fish/build.rs.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--- a/build.rs
2+
+++ b/build.rs
3+
@@ -96,7 +96,9 @@ fn detect_cfgs(target: &mut Target) {
4+
Ok(target.has_symbol("localeconv_l"))
5+
}),
6+
("FISH_USE_POSIX_SPAWN", &|target| {
7+
- Ok(target.has_header("spawn.h"))
8+
+ // the command 'fish -c "uname"', and most other uses of fish's -c argument,
9+
+ // are not working if this is enabled.
10+
+ Ok(false)
11+
}),
12+
("HAVE_PIPE2", &|target| {
13+
Ok(target.has_symbol("pipe2"))

packages/fish/build.sh

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,61 @@ TERMUX_PKG_HOMEPAGE=https://fishshell.com/
22
TERMUX_PKG_DESCRIPTION="The user-friendly command line shell"
33
TERMUX_PKG_LICENSE="GPL-2.0"
44
TERMUX_PKG_MAINTAINER="@termux"
5-
TERMUX_PKG_VERSION="3.7.1"
6-
TERMUX_PKG_REVISION=2
5+
TERMUX_PKG_VERSION="4.0.0"
76
TERMUX_PKG_SRCURL=https://github.com/fish-shell/fish-shell/releases/download/$TERMUX_PKG_VERSION/fish-${TERMUX_PKG_VERSION}.tar.xz
8-
TERMUX_PKG_SHA256=614c9f5643cd0799df391395fa6bbc3649427bb839722ce3b114d3bbc1a3b250
7+
TERMUX_PKG_SHA256=2fda5bd970357064d8d4c896e08285ba59965ca2a8c4829ca8a82bf3b89c69f3
98
TERMUX_PKG_AUTO_UPDATE=true
109
# fish calls 'tput' from ncurses-utils, at least when cancelling (Ctrl+C) a command line.
1110
# man is needed since fish calls apropos during command completion.
1211
TERMUX_PKG_DEPENDS="bc, libandroid-support, libandroid-spawn, libc++, ncurses, ncurses-utils, man, pcre2"
1312
TERMUX_PKG_BUILD_IN_SRC=true
1413
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
1514
-DBUILD_DOCS=OFF
15+
-DFISH_USE_SYSTEM_PCRE2=ON
16+
-DMAC_CODESIGN_ID=OFF
17+
-DWITH_GETTEXT=OFF
1618
"
1719

1820
termux_step_pre_configure() {
19-
# fish releases tarballs that conflict with the way the toolchain
20-
# currently is by putting a file in the tarball
21-
# named "version" (not visible directly in the source code on github,
22-
# generated by this code in fish's release workflow:
23-
# https://github.com/fish-shell/fish-shell/blob/master/build_tools/make_tarball.sh#L69 )
24-
# and, crucially, also placing the folder containing that file named "version"
25-
# in the include path of building fish (since right next to this in the same folder,
26-
# fish does have a file named "config.h" that it uses)
27-
# here is the upstream, conflicting instance of file in internal llvm
28-
# include path named "version" that is probably what propogates into the NDK's
29-
# equivalent file,
30-
# /home/builder/.termux-build/_cache/android-r27b-api-24-v1/sysroot/usr/include/c++/v1/version
31-
# https://github.com/llvm/llvm-project/blob/main/libcxx/include/version
32-
mv version fish_version
33-
find build_tools -type f -exec sed -i {} \
34-
-e 's/cat version/cat fish_version/g' \
35-
-e 's/test -f version/test -f fish_version/g' \;
36-
CXXFLAGS+=" $CPPFLAGS"
21+
termux_setup_cmake
22+
termux_setup_ninja
23+
termux_setup_rust
24+
25+
# FindRust.cmake auto pick thumbv7neon-linux-androideabi
26+
[[ "${TERMUX_ARCH}" == "arm" ]] && TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DCMAKE_ANDROID_ARM_MODE=ON"
27+
28+
# older than Android 8 dont have ctermid
29+
"${CC}" ${CPPFLAGS} ${CFLAGS} -c ${TERMUX_PKG_BUILDER_DIR}/ctermid.c
30+
"${AR}" cru libctermid.a ctermid.o
31+
32+
# cmake invokes rustc directly leaving CARGO_TARGET_*_RUSTFLAGS unused
33+
local -u env_host="${CARGO_TARGET_NAME//-/_}"
34+
export RUSTFLAGS=$(env | grep CARGO_TARGET_${env_host}_RUSTFLAGS | cut -d'=' -f2-)
35+
RUSTFLAGS+=" -C link-arg=-landroid-spawn"
36+
RUSTFLAGS+=" -L${TERMUX_PKG_BUILDDIR} -C link-arg=-l:libctermid.a"
37+
38+
: "${CARGO_HOME:=${HOME}/.cargo}"
39+
export CARGO_HOME
40+
41+
rm -rf "$CARGO_HOME"/registry/src/*/libc-*
42+
cargo fetch --target "${CARGO_TARGET_NAME}"
43+
44+
local libc p
45+
for libc in "${CARGO_HOME}"/registry/src/*/libc-*; do
46+
for p in "${TERMUX_PKG_BUILDER_DIR}"/libc-*.diff; do
47+
[[ -f "${p}" ]] && patch -p1 -d "${libc}" -i "${p}" || termux_error_exit "fish: failed to apply patch '$p'"
48+
done
49+
done
3750
}
3851

3952
termux_step_post_make_install() {
40-
cat >> $TERMUX_PREFIX/etc/fish/config.fish <<HERE
41-
function __fish_command_not_found_handler --on-event fish_command_not_found
42-
$TERMUX_PREFIX/libexec/termux/command-not-found \$argv[1]
43-
end
44-
HERE
53+
cat >> "$TERMUX_PREFIX/etc/fish/config.fish" <<-EOF
54+
function __fish_command_not_found_handler --on-event fish_command_not_found
55+
$TERMUX_PREFIX/libexec/termux/command-not-found \$argv[1]
56+
end
57+
EOF
58+
}
59+
60+
termux_step_post_massage() {
61+
rm -rf "$CARGO_HOME"/registry/src/*/libc-*
4562
}

packages/fish/create_manpage_completions.py.patch

Lines changed: 0 additions & 12 deletions
This file was deleted.

packages/fish/ctermid.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Copyright © 2005-2020 Rich Felker, et al.
3+
4+
Permission is hereby granted, free of charge, to any person obtaining
5+
a copy of this software and associated documentation files (the
6+
"Software"), to deal in the Software without restriction, including
7+
without limitation the rights to use, copy, modify, merge, publish,
8+
distribute, sublicense, and/or sell copies of the Software, and to
9+
permit persons to whom the Software is furnished to do so, subject to
10+
the following conditions:
11+
12+
The above copyright notice and this permission notice shall be
13+
included in all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
23+
24+
// redefine ctermid since ndk-patches/*/stdio.h.patch inline ctermid
25+
#define ctermid ctermid_orig
26+
#include <stdio.h>
27+
#include <string.h>
28+
#undef ctermid
29+
30+
char *ctermid(char *s)
31+
{
32+
return s ? strcpy(s, "/dev/tty") : "/dev/tty";
33+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
--- a/src/unix/linux_like/android/mod.rs
2+
+++ b/src/unix/linux_like/android/mod.rs
3+
@@ -54,6 +54,92 @@
4+
pub type posix_spawn_file_actions_t = *mut c_void;
5+
pub type posix_spawnattr_t = *mut c_void;
6+
7+
+pub const POSIX_SPAWN_USEVFORK: c_int = 64;
8+
+pub const POSIX_SPAWN_SETSID: c_int = 128;
9+
+
10+
+pub const POSIX_SPAWN_RESETIDS: c_int = 0x01;
11+
+pub const POSIX_SPAWN_SETPGROUP: c_int = 0x02;
12+
+pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x04;
13+
+pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x08;
14+
+pub const POSIX_SPAWN_SETSCHEDPARAM: c_int = 0x10;
15+
+pub const POSIX_SPAWN_SETSCHEDULER: c_int = 0x20;
16+
+
17+
+extern "C" {
18+
+ pub fn posix_spawn(
19+
+ pid: *mut crate::pid_t,
20+
+ path: *const c_char,
21+
+ file_actions: *const crate::posix_spawn_file_actions_t,
22+
+ attrp: *const crate::posix_spawnattr_t,
23+
+ argv: *const *mut c_char,
24+
+ envp: *const *mut c_char,
25+
+ ) -> c_int;
26+
+ pub fn posix_spawnp(
27+
+ pid: *mut crate::pid_t,
28+
+ file: *const c_char,
29+
+ file_actions: *const crate::posix_spawn_file_actions_t,
30+
+ attrp: *const crate::posix_spawnattr_t,
31+
+ argv: *const *mut c_char,
32+
+ envp: *const *mut c_char,
33+
+ ) -> c_int;
34+
+ pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int;
35+
+ pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int;
36+
+ pub fn posix_spawnattr_getsigdefault(
37+
+ attr: *const posix_spawnattr_t,
38+
+ default: *mut crate::sigset_t,
39+
+ ) -> c_int;
40+
+ pub fn posix_spawnattr_setsigdefault(
41+
+ attr: *mut posix_spawnattr_t,
42+
+ default: *const crate::sigset_t,
43+
+ ) -> c_int;
44+
+ pub fn posix_spawnattr_getsigmask(
45+
+ attr: *const posix_spawnattr_t,
46+
+ default: *mut crate::sigset_t,
47+
+ ) -> c_int;
48+
+ pub fn posix_spawnattr_setsigmask(
49+
+ attr: *mut posix_spawnattr_t,
50+
+ default: *const crate::sigset_t,
51+
+ ) -> c_int;
52+
+ pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int;
53+
+ pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int;
54+
+ pub fn posix_spawnattr_getpgroup(
55+
+ attr: *const posix_spawnattr_t,
56+
+ flags: *mut crate::pid_t,
57+
+ ) -> c_int;
58+
+ pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: crate::pid_t) -> c_int;
59+
+ pub fn posix_spawnattr_getschedpolicy(
60+
+ attr: *const posix_spawnattr_t,
61+
+ flags: *mut c_int,
62+
+ ) -> c_int;
63+
+ pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: c_int) -> c_int;
64+
+ pub fn posix_spawnattr_getschedparam(
65+
+ attr: *const posix_spawnattr_t,
66+
+ param: *mut crate::sched_param,
67+
+ ) -> c_int;
68+
+ pub fn posix_spawnattr_setschedparam(
69+
+ attr: *mut posix_spawnattr_t,
70+
+ param: *const crate::sched_param,
71+
+ ) -> c_int;
72+
+
73+
+ pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int;
74+
+ pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int;
75+
+ pub fn posix_spawn_file_actions_addopen(
76+
+ actions: *mut posix_spawn_file_actions_t,
77+
+ fd: c_int,
78+
+ path: *const c_char,
79+
+ oflag: c_int,
80+
+ mode: crate::mode_t,
81+
+ ) -> c_int;
82+
+ pub fn posix_spawn_file_actions_addclose(
83+
+ actions: *mut posix_spawn_file_actions_t,
84+
+ fd: c_int,
85+
+ ) -> c_int;
86+
+ pub fn posix_spawn_file_actions_adddup2(
87+
+ actions: *mut posix_spawn_file_actions_t,
88+
+ fd: c_int,
89+
+ newfd: c_int,
90+
+ ) -> c_int;
91+
+}
92+
+
93+
s! {
94+
pub struct stack_t {
95+
pub ss_sp: *mut c_void,

0 commit comments

Comments
 (0)