From e6b429450114917eb321b5dbcd826fbbf08816c9 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Tue, 9 Dec 2025 23:30:00 +0700 Subject: [PATCH] Update python to use host recipe as bootstrap --- Cargo.lock | 4 +- recipes/dev/python312/recipe.toml | 76 +++++++--------------- recipes/dev/python312/redox.patch | 62 +++++++----------- recipes/libs/ncursesw/recipe.toml | 6 +- recipes/libs/ncursesw/redox.patch | 12 ---- recipes/libs/readline/recipe.toml | 7 +- recipes/tools/bzip2/recipe.toml | 14 ++-- recipes/wip/libs/other/libuuid/recipe.toml | 2 + recipes/wip/libs/other/libuuid/redox.patch | 13 ++++ 9 files changed, 79 insertions(+), 117 deletions(-) delete mode 100644 recipes/libs/ncursesw/redox.patch diff --git a/Cargo.lock b/Cargo.lock index b95ef921..617dc20c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -911,8 +911,8 @@ dependencies = [ [[package]] name = "redox-pkg" -version = "0.2.8" -source = "git+https://gitlab.redox-os.org/redox-os/pkgutils.git#6ed6a265cbe9abaf9d747e700f72cad9cea5a5d0" +version = "0.2.9" +source = "git+https://gitlab.redox-os.org/redox-os/pkgutils.git#78b50760a3ee6c6752d47ec6f3511cd28b5d70de" dependencies = [ "anyhow", "ignore", diff --git a/recipes/dev/python312/recipe.toml b/recipes/dev/python312/recipe.toml index f7759afa..67cc6d40 100644 --- a/recipes/dev/python312/recipe.toml +++ b/recipes/dev/python312/recipe.toml @@ -1,5 +1,6 @@ [source] -tar = "https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tar.xz" +tar = "https://www.python.org/ftp/python/3.12.12/Python-3.12.12.tar.xz" +blake3 = "29636fdae3e0ee8d0fe585e528c9376fe43876f5f3f0f7892140567946fd907b" patches = [ "redox.patch" ] @@ -11,7 +12,6 @@ dependencies = [ "libffi", "libuuid", "openssl3", - "ncurses", "ncursesw", "readline", "sqlite3", @@ -19,63 +19,35 @@ dependencies = [ "xz", "zstd", ] +dev-dependencies = [ + "host:python312" +] script = """ DYNAMIC_INIT -# Build host python3 -mkdir -p host -pushd host -#TODO: easier way to build for host? -HOST_ENV=( - env - --unset=AR - --unset=AS - --unset=CC - --unset=CFLAGS - --unset=CPPFLAGS - --unset=CXX - --unset=GNU_TARGET - --unset=LD - --unset=LDFLAGS - --unset=NM - --unset=OBJCOPY - --unset=OBJDUMP - --unset=PKG_CONFIG - --unset=PKG_CONFIG_ALLOW_CROSS - --unset=PKG_CONFIG_FOR_BUILD - --unset=PKG_CONFIG_LIBDIR - --unset=PKG_CONFIG_PATH - --unset=PKG_CONFIG_SYSROOT_DIR - --unset=PREFIX_RUSTFLAGS - --unset=RANLIB - --unset=READELF - --unset=STRIP - --unset=TARGET -) -"${HOST_ENV[@]}" "${COOKBOOK_CONFIGURE}" --prefix="${PWD}/usr" -"${HOST_ENV[@]}" "${COOKBOOK_MAKE}" -j"${COOKBOOK_MAKE_JOBS}" -"${HOST_ENV[@]}" "${COOKBOOK_MAKE}" altinstall -popd - export PYTHONDONTWRITEBYTECODE=1 ARCH="${TARGET%%-*}" -# Packages are considerably larger because of this issue -# https://gitlab.redox-os.org/redox-os/relibc/-/issues/227 -export MODULE_BUILDTYPE=static +if [ "$TARGET" != "$COOKBOOK_HOST_TARGET" ]; then + COOKBOOK_CONFIGURE_FLAGS=( + --prefix=/usr + --disable-ipv6 + --host=${GNU_TARGET} + --build="$ARCH" + --with-build-python="${COOKBOOK_TOOLCHAIN}/usr/bin/python3.12" + --with-ensurepip=install + --disable-test-modules + ac_cv_file__dev_ptmx=no + ac_cv_file__dev_ptc=no + ) +else + COOKBOOK_CONFIGURE_FLAGS=(--prefix=/usr) +fi -COOKBOOK_CONFIGURE_FLAGS=( - --prefix=/usr - --enable-shared - --disable-ipv6 - --host=${GNU_TARGET} - --build="$ARCH" - --with-build-python="${PWD}/host/usr/bin/python3.12" - --with-ensurepip=install - --disable-test-modules - ac_cv_file__dev_ptmx=no - ac_cv_file__dev_ptc=no -) +if [ "${COOKBOOK_DYNAMIC}" != "1" ]; then + export MODULE_BUILDTYPE=static + COOKBOOK_CONFIGURE_FLAGS+=( --enable-shared ) +fi cookbook_configure """ diff --git a/recipes/dev/python312/redox.patch b/recipes/dev/python312/redox.patch index 9ead63c5..a0cfe4a5 100644 --- a/recipes/dev/python312/redox.patch +++ b/recipes/dev/python312/redox.patch @@ -1,7 +1,7 @@ diff -ruwN source/configure source-new/configure ---- source/configure 2023-10-02 05:48:14.000000000 -0600 -+++ source-new/configure 2025-09-28 13:44:57.914820310 -0600 -@@ -4276,6 +4276,9 @@ +--- source/configure 2025-10-09 18:07:00.000000000 +0700 ++++ source-new/configure 2025-12-09 22:14:30.781035339 +0700 +@@ -4283,6 +4283,9 @@ *-*-wasi) ac_sys_system=WASI ;; @@ -11,7 +11,7 @@ diff -ruwN source/configure source-new/configure *) # for now, limit cross builds to known configurations MACHDEP="unknown" -@@ -4300,6 +4303,7 @@ +@@ -4307,6 +4310,7 @@ case $MACHDEP in aix*) MACHDEP="aix";; linux*) MACHDEP="linux";; @@ -19,7 +19,7 @@ diff -ruwN source/configure source-new/configure cygwin*) MACHDEP="cygwin";; darwin*) MACHDEP="darwin";; '') MACHDEP="unknown";; -@@ -4311,7 +4315,7 @@ +@@ -4327,7 +4331,7 @@ if test "$cross_compiling" = yes; then case "$host" in @@ -28,7 +28,7 @@ diff -ruwN source/configure source-new/configure case "$host_cpu" in arm*) _host_cpu=arm -@@ -6746,6 +6750,7 @@ +@@ -6762,6 +6766,7 @@ #undef cris #undef fr30 #undef linux @@ -36,7 +36,7 @@ diff -ruwN source/configure source-new/configure #undef hppa #undef hpux #undef i386 -@@ -6891,6 +6896,18 @@ +@@ -6907,6 +6912,18 @@ # endif #elif defined(__gnu_hurd__) i386-gnu @@ -55,7 +55,7 @@ diff -ruwN source/configure source-new/configure #elif defined(__APPLE__) darwin #elif defined(__VXWORKS__) -@@ -7488,7 +7505,7 @@ +@@ -7507,7 +7524,7 @@ PY3LIBRARY=libpython3.so fi ;; @@ -64,8 +64,8 @@ diff -ruwN source/configure source-new/configure LDLIBRARY='libpython$(LDVERSION).so' BLDLIBRARY='-L. -lpython$(LDVERSION)' RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} -@@ -12753,7 +12770,7 @@ - Emscripten|WASI) +@@ -12815,7 +12832,7 @@ + Emscripten*|WASI*) LDSHARED='$(CC) -shared' LDCXXSHARED='$(CXX) -shared';; - Linux*|GNU*|QNX*|VxWorks*|Haiku*) @@ -73,7 +73,7 @@ diff -ruwN source/configure source-new/configure LDSHARED='$(CC) -shared' LDCXXSHARED='$(CXX) -shared';; FreeBSD*) -@@ -12839,7 +12856,7 @@ +@@ -12901,7 +12918,7 @@ else CCSHARED="+z"; fi;; Linux-android*) ;; @@ -82,7 +82,7 @@ diff -ruwN source/configure source-new/configure Emscripten*|WASI*) if test "x$enable_wasm_dynamic_linking" = xyes then : -@@ -12877,7 +12894,7 @@ +@@ -12939,7 +12956,7 @@ LINKFORSHARED="-Wl,-E -Wl,+s";; # LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";; Linux-android*) LINKFORSHARED="-pie -Xlinker -export-dynamic";; @@ -92,8 +92,8 @@ diff -ruwN source/configure source-new/configure Darwin/*) LINKFORSHARED="$extra_undefs -framework CoreFoundation" diff -ruwN source/Include/pyport.h source-new/Include/pyport.h ---- source/Include/pyport.h 2023-10-02 05:48:14.000000000 -0600 -+++ source-new/Include/pyport.h 2025-09-28 13:44:57.916856922 -0600 +--- source/Include/pyport.h 2025-10-09 18:07:00.000000000 +0700 ++++ source-new/Include/pyport.h 2025-12-09 22:14:30.781035339 +0700 @@ -684,7 +684,7 @@ # error "Py_TRACE_REFS ABI is not compatible with release and debug ABI" #endif @@ -104,8 +104,8 @@ diff -ruwN source/Include/pyport.h source-new/Include/pyport.h // See _Py_GetLocaleEncoding(), PyUnicode_DecodeLocale() // and PyUnicode_EncodeLocale(). diff -ruwN source/Modules/_cryptmodule.c source-new/Modules/_cryptmodule.c ---- source/Modules/_cryptmodule.c 2023-10-02 05:48:14.000000000 -0600 -+++ source-new/Modules/_cryptmodule.c 2025-09-28 13:44:57.917139387 -0600 +--- source/Modules/_cryptmodule.c 2025-10-09 18:07:00.000000000 +0700 ++++ source-new/Modules/_cryptmodule.c 2025-12-09 22:14:30.781035339 +0700 @@ -38,13 +38,7 @@ /*[clinic end generated code: output=0512284a03d2803c input=0e8edec9c364352b]*/ { @@ -121,9 +121,9 @@ diff -ruwN source/Modules/_cryptmodule.c source-new/Modules/_cryptmodule.c return PyErr_SetFromErrno(PyExc_OSError); } diff -ruwN source/Modules/posixmodule.c source-new/Modules/posixmodule.c ---- source/Modules/posixmodule.c 2023-10-02 05:48:14.000000000 -0600 -+++ source-new/Modules/posixmodule.c 2025-09-28 13:44:57.918070573 -0600 -@@ -2610,8 +2610,7 @@ +--- source/Modules/posixmodule.c 2025-10-09 18:07:00.000000000 +0700 ++++ source-new/Modules/posixmodule.c 2025-12-09 22:14:30.781035339 +0700 +@@ -2695,8 +2695,7 @@ #ifdef HAVE_FSTATAT if ((dir_fd != DEFAULT_DIR_FD) || !follow_symlinks) { if (HAVE_FSTATAT_RUNTIME) { @@ -133,7 +133,7 @@ diff -ruwN source/Modules/posixmodule.c source-new/Modules/posixmodule.c } else { fstatat_unavailable = 1; -@@ -3083,8 +3082,6 @@ +@@ -3186,8 +3185,6 @@ if (HAVE_FACCESSAT_RUNTIME) { int flags = 0; @@ -142,7 +142,7 @@ diff -ruwN source/Modules/posixmodule.c source-new/Modules/posixmodule.c if (effective_ids) flags |= AT_EACCESS; result = faccessat(dir_fd, path->narrow, mode, flags); -@@ -3369,8 +3366,7 @@ +@@ -3472,8 +3469,7 @@ * support dir_fd and follow_symlinks=False. (Hopefully.) * Until then, we need to be careful what exception we raise. */ @@ -152,7 +152,7 @@ diff -ruwN source/Modules/posixmodule.c source-new/Modules/posixmodule.c /* * But wait! We can't throw the exception without allowing threads, * and we can't do that in this nested scope. (Macro trickery, sigh.) -@@ -3747,8 +3743,7 @@ +@@ -3850,8 +3846,7 @@ #ifdef HAVE_FCHOWNAT if ((dir_fd != DEFAULT_DIR_FD) || (!follow_symlinks)) { if (HAVE_FCHOWNAT_RUNTIME) { @@ -162,7 +162,7 @@ diff -ruwN source/Modules/posixmodule.c source-new/Modules/posixmodule.c } else { fchownat_unsupported = 1; } -@@ -14598,8 +14593,7 @@ +@@ -14727,8 +14722,7 @@ #ifdef HAVE_FSTATAT if (HAVE_FSTATAT_RUNTIME) { Py_BEGIN_ALLOW_THREADS @@ -173,8 +173,8 @@ diff -ruwN source/Modules/posixmodule.c source-new/Modules/posixmodule.c } else diff -ruwN source/Modules/resource.c source-new/Modules/resource.c ---- source/Modules/resource.c 2023-10-02 05:48:14.000000000 -0600 -+++ source-new/Modules/resource.c 2025-09-28 13:44:57.919295094 -0600 +--- source/Modules/resource.c 2025-10-09 18:07:00.000000000 +0700 ++++ source-new/Modules/resource.c 2025-12-09 22:14:30.781035339 +0700 @@ -216,7 +216,7 @@ { struct rlimit rl; @@ -202,15 +202,3 @@ diff -ruwN source/Modules/resource.c source-new/Modules/resource.c PyErr_SetString(PyExc_ValueError, "invalid resource specified"); return NULL; -diff -ruwN source/Modules/timemodule.c source-new/Modules/timemodule.c ---- source/Modules/timemodule.c 2023-10-02 05:48:14.000000000 -0600 -+++ source-new/Modules/timemodule.c 2025-09-28 13:45:28.513234796 -0600 -@@ -1494,7 +1494,7 @@ - - #elif defined(HAVE_CLOCK_GETTIME) && \ - defined(CLOCK_PROCESS_CPUTIME_ID) && \ -- !defined(__EMSCRIPTEN__) && !defined(__wasi__) -+ !defined(__EMSCRIPTEN__) && !defined(__wasi__) && !defined(__redox__) - #define HAVE_THREAD_TIME - - #if defined(__APPLE__) && defined(__has_attribute) && __has_attribute(availability) diff --git a/recipes/libs/ncursesw/recipe.toml b/recipes/libs/ncursesw/recipe.toml index a697aabe..80eee827 100644 --- a/recipes/libs/ncursesw/recipe.toml +++ b/recipes/libs/ncursesw/recipe.toml @@ -1,9 +1,5 @@ [source] -tar = "https://ftp.gnu.org/gnu/ncurses/ncurses-6.4.tar.gz" -blake3 = "0d1c9fdf53c0ca4bd66ba707d49a079d2dd6f5a960cdec74a56e29952c4ffe73" -patches = [ - "redox.patch" -] +same_as = "../ncurses" [build] template = "custom" diff --git a/recipes/libs/ncursesw/redox.patch b/recipes/libs/ncursesw/redox.patch deleted file mode 100644 index b446db16..00000000 --- a/recipes/libs/ncursesw/redox.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -ruwN source/configure source-new/configure ---- source/configure 2022-11-06 04:13:26.000000000 +0700 -+++ source-new/configure 2025-09-17 21:14:28.163192730 +0700 -@@ -6386,7 +6386,7 @@ - fi - cf_cv_rm_so_locs=yes - ;; -- (linux*|gnu*|k*bsd*-gnu) -+ (linux*|gnu*|k*bsd*-gnu|redox*) - if test "$DFT_LWR_MODEL" = "shared" && test -n "$LD_RPATH_OPT" ; then - LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)" - LOCAL_LDFLAGS2="$LOCAL_LDFLAGS" diff --git a/recipes/libs/readline/recipe.toml b/recipes/libs/readline/recipe.toml index 35a30f59..82eb522b 100644 --- a/recipes/libs/readline/recipe.toml +++ b/recipes/libs/readline/recipe.toml @@ -13,6 +13,9 @@ dependencies = [ script = """ DYNAMIC_INIT cookbook_configure -ln -s "libhistory.so.7" "${COOKBOOK_STAGE}"/usr/lib/libhistory.so -ln -s "libreadline.so.7" "${COOKBOOK_STAGE}"/usr/lib/libreadline.so +OS=$(echo "${TARGET}" | cut -d - -f3) +if [ "${OS}" = "redox" ]; then + ln -s "libhistory.so.7" "${COOKBOOK_STAGE}"/usr/lib/libhistory.so + ln -s "libreadline.so.7" "${COOKBOOK_STAGE}"/usr/lib/libreadline.so +fi """ diff --git a/recipes/tools/bzip2/recipe.toml b/recipes/tools/bzip2/recipe.toml index 5c73235a..b7fdd383 100644 --- a/recipes/tools/bzip2/recipe.toml +++ b/recipes/tools/bzip2/recipe.toml @@ -11,10 +11,10 @@ DYNAMIC_INIT # The static lib is preferred according to the README because it's faster rsync -av --delete "${COOKBOOK_SOURCE}/" ./ "${COOKBOOK_MAKE}" -j"${COOKBOOK_MAKE_JOBS}" \ - AR="${TARGET}-ar" \ - CC="${CC_WRAPPER} ${TARGET}-gcc" \ + AR="${AR}" \ + CC="${CC}" \ + RANLIB="${RANLIB}" \ PREFIX="${COOKBOOK_STAGE}" \ - RANLIB="${TARGET}-ranlib" \ install # However, distros distribute libbz2 as well so we'll support it too @@ -24,10 +24,10 @@ rsync -av --delete "${COOKBOOK_SOURCE}/" ./ # This DOES NOT build/clobber the binaries already built above "${COOKBOOK_MAKE}" -f Makefile-libbz2_so \ -j"${COOKBOOK_MAKE_JOBS}" \ - AR="${TARGET}-ar" \ - CC="${CC_WRAPPER} ${TARGET}-gcc" \ - PREFIX="${COOKBOOK_STAGE}" \ - RANLIB="${TARGET}-ranlib" + AR="${AR}" \ + CC="${CC}" \ + RANLIB="${RANLIB}" \ + PREFIX="${COOKBOOK_STAGE}" cp -av libbz2.so* "${COOKBOOK_STAGE}/lib" ln -sr "${COOKBOOK_STAGE}/lib/libbz2.so.1.0" "${COOKBOOK_STAGE}/lib/libbz2.so.1" diff --git a/recipes/wip/libs/other/libuuid/recipe.toml b/recipes/wip/libs/other/libuuid/recipe.toml index 8a9947f9..2ea2e5b5 100644 --- a/recipes/wip/libs/other/libuuid/recipe.toml +++ b/recipes/wip/libs/other/libuuid/recipe.toml @@ -1,7 +1,9 @@ [source] tar = "https://sourceforge.net/projects/libuuid/files/libuuid-1.0.3.tar.gz/download" +blake3 = "ac6582304401d2be6e5db4570c0d9d6d1500f12c918591a05066679bb2e41e55" patches = [ "redox.patch" ] + [build] template = "configure" diff --git a/recipes/wip/libs/other/libuuid/redox.patch b/recipes/wip/libs/other/libuuid/redox.patch index 1ede79c4..2e7a5f9c 100644 --- a/recipes/wip/libs/other/libuuid/redox.patch +++ b/recipes/wip/libs/other/libuuid/redox.patch @@ -40,6 +40,19 @@ diff -ruwN source/configure source-new/configure version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no +diff -ruwN source/gen_uuid.c source-new/gen_uuid.c +--- source/gen_uuid.c 2014-08-12 04:07:18.000000000 -0400 ++++ source-new/gen_uuid.c 2025-12-09 10:49:12.580466005 -0500 +@@ -59,9 +59,7 @@ + #include + #endif + #include +-#ifdef HAVE_SYS_FILE_H + #include +-#endif + #ifdef HAVE_SYS_IOCTL_H + #include + #endif diff -ruwN source/randutils.c source-new/randutils.c --- source/randutils.c 2014-08-12 15:07:18.000000000 +0700 +++ source-new/randutils.c 2025-09-19 21:11:57.907659403 +0700