From a2489ba8f680a921ec3e7b71ccb6bf99b583b0a0 Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Fri, 5 Dec 2025 14:48:13 +0800 Subject: [PATCH] Step3: enhanced with coreutiles. Signed-off-by: Chen Wang --- Makefile | 4 ++ build.sh | 3 +- ...001-coreutils-mcel-port-to-uClibc-ng.patch | 35 +++++++++++++ package/coreutils/make.sh | 49 +++++++++++++++++++ source.sh | 1 + 5 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 package/coreutils/0001-coreutils-mcel-port-to-uClibc-ng.patch create mode 100755 package/coreutils/make.sh diff --git a/Makefile b/Makefile index 47af9e2..0e06411 100644 --- a/Makefile +++ b/Makefile @@ -74,5 +74,9 @@ sysvinit: @./package/libxcrypt/make.sh || exit 1 @./package/sysvinit/make.sh || exit 1 +.PHONY: coreutils +coreutils: + @./package/coreutils/make.sh || exit 1 + clean: rm -rf output/ diff --git a/build.sh b/build.sh index 2f4d8e9..bf78175 100755 --- a/build.sh +++ b/build.sh @@ -9,5 +9,6 @@ make opensbi || exit 1 make linux || exit 1 make busybox || exit 1 make sysvinit || exit 1 +make coreutils || exit 1 make before-target-image || exit 1 -make rebuild-target-image || exit 1 \ No newline at end of file +make rebuild-target-image || exit 1 diff --git a/package/coreutils/0001-coreutils-mcel-port-to-uClibc-ng.patch b/package/coreutils/0001-coreutils-mcel-port-to-uClibc-ng.patch new file mode 100644 index 0000000..7639509 --- /dev/null +++ b/package/coreutils/0001-coreutils-mcel-port-to-uClibc-ng.patch @@ -0,0 +1,35 @@ +From c4e923a98f34fe5f5ec3b49543e90716ec2a45fc Mon Sep 17 00:00:00 2001 +From: Jean-Michel Hautbois +Date: Tue, 24 Sep 2024 18:08:31 +0200 +Subject: [PATCH] coreutils: mcel: port to uClibc-ng +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Problem reported by Waldemar Brodkorb in: +https://lists.gnu.org/r/bug-gnulib/2024-08/msg00130.html +* lib/mcel.h (mcel_scan): Don't treat uClibc-ng like glibc. + +Upstream: https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=9765bc796b3e6ceaa7a10ba07c9c2f1e272a4249 +Signed-off-by: Jean-Michel Hautbois +--- + lib/mcel.h | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/lib/mcel.h b/lib/mcel.h +index f6f006c..dca4d08 100644 +--- a/lib/mcel.h ++++ b/lib/mcel.h +@@ -221,7 +221,8 @@ mcel_scan (char const *p, char const *lim) + + /* An initial mbstate_t; initialization optimized for some platforms. + For details about these and other platforms, see wchar.in.h. */ +-#if defined __GLIBC__ && 2 < __GLIBC__ + (2 <= __GLIBC_MINOR__) ++#if (defined __GLIBC__ && 2 < __GLIBC__ + (2 <= __GLIBC_MINOR__) \ ++ && !defined __UCLIBC__) + /* Although only a trivial optimization, it's worth it for GNU. */ + mbstate_t mbs; mbs.__count = 0; + #elif (defined __FreeBSD__ || defined __DragonFly__ || defined __OpenBSD__ \ +-- +2.39.2 + diff --git a/package/coreutils/make.sh b/package/coreutils/make.sh new file mode 100755 index 0000000..b5d6691 --- /dev/null +++ b/package/coreutils/make.sh @@ -0,0 +1,49 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=coreutils +PKGVERSION=9.5 +PKGSOURCE_DIR=coreutils +PKGSOURCE=coreutils-9.5.tar.xz +PKGURL=http://mirrors.ustc.edu.cn/gnu/coreutils/coreutils-9.5.tar.xz + +PKGBUILDNAME=${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +step_start patch +TAR="tar" PATH=${HOST_DIR}/bin:$PATH ${PROJECT_DIR}/support/scripts/apply-patches.sh ${PKGBUILD_DIR} ${PROJECT_DIR}/package/${PKGNAME} \*.patch +step_end patch autotools + +step_start configure +(cd ${PKGBUILD_DIR} && rm -rf config.cache && eval "${TARGET_CONFIGURE_OPTS} CXX=no ac_cv_lbl_unaligned_fail=yes ac_cv_func_mmap_fixed_mapped=yes ac_cv_func_memcmp_working=yes ac_cv_have_decl_malloc=yes gl_cv_func_malloc_0_nonnull=yes ac_cv_func_malloc_0_nonnull=yes ac_cv_func_calloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes lt_cv_sys_lib_search_path_spec=\"\" ac_cv_c_bigendian=no ac_cv_c_restrict=no ac_cv_func_chown_works=yes ac_cv_func_fstatat=yes ac_cv_func_getdelim=yes ac_cv_func_getgroups=yes ac_cv_func_getgroups_works=yes ac_cv_func_getloadavg=no ac_cv_func_strnlen_working=yes ac_cv_have_decl_strerror_r=yes ac_cv_have_decl_strnlen=yes ac_cv_lib_getloadavg_getloadavg=no ac_cv_lib_util_getloadavg=no ac_fsusage_space=yes ac_use_included_regex=no am_cv_func_working_getline=yes fu_cv_sys_stat_statfs2_bsize=yes gl_cv_func_getcwd_null=yes gl_cv_func_getcwd_path_max=yes gl_cv_func_link_follows_symlink=no gl_cv_func_lstat_dereferences_slashed_symlink=yes gl_cv_func_re_compile_pattern_working=yes gl_cv_func_svid_putenv=yes gl_cv_func_working_mkstemp=yes gl_cv_func_working_utimes=yes gl_cv_macro_MB_CUR_MAX_good=yes gl_cv_have_proc_uptime=yes utils_cv_localtime_cache=no PERL=missing MAKEINFO=true INSTALL_PROGRAM=/usr/bin/install CONFIG_SITE=/dev/null ./configure --target=${GNU_TARGET_NAME} --host=${GNU_TARGET_NAME} --build=x86_64-pc-linux-gnu --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --localstatedir=/var --program-prefix=\"\" --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --with-xmlto=no --with-fop=no --disable-dependency-tracking --enable-ipv6 --disable-nls --disable-static --enable-shared --disable-rpath --disable-single-binary --disable-acl --disable-xattr --disable-libcap --without-selinux") +step_end configure + +step_start build +eval "${TARGET_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-target +eval "${TARGET_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} DESTDIR=${TARGET_DIR} install -C ${PKGBUILD_DIR}" +COREUTILS_BIN_PROGS="base64 cat chgrp chmod chown cp date dd df dir echo false \ + kill link ln ls mkdir mknod mktemp mv nice printenv pwd rm rmdir \ + vdir sleep stty sync touch true uname join" +for f in ${COREUTILS_BIN_PROGS} ; do + mv ${TARGET_DIR}/usr/bin/${f} ${TARGET_DIR}/bin +done +ln -fs test ${TARGET_DIR}/usr/bin/[ +mv ${TARGET_DIR}/usr/bin/chroot ${TARGET_DIR}/usr/sbin +step_end install-target + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/source.sh b/source.sh index 860e6c6..8598114 100755 --- a/source.sh +++ b/source.sh @@ -30,3 +30,4 @@ export ONLY_DOWNLOAD=y ./package/gettext-tiny/make-host.sh || exit 1 ./package/libxcrypt/make.sh || exit 1 ./package/sysvinit/make.sh || exit 1 +./package/coreutils/make.sh || exit 1