From d18ed2a9aab915008288153b435b16d80fac69d2 Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Mon, 5 Oct 2026 15:07:08 +0900 Subject: [PATCH] build-gnu.sh: fetch tarball instead of git clone --- util/build-gnu.sh | 97 ++++------------------------------------------- 1 file changed, 7 insertions(+), 90 deletions(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 4e76a50..4cca2bf 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -11,84 +11,6 @@ export PROFILE path_UUTILS=${path_UUTILS:-${REPO_main_dir}} path_GNU="${path_GNU:-${path_UUTILS}/../gnu}" -retry_attempts() { - local attempts="${GNU_TAR_SETUP_ATTEMPTS:-3}" - local delay="${GNU_TAR_SETUP_RETRY_DELAY:-30}" - local description="${1}" - shift - local attempt=1 - local status=0 - - if [[ ! "${attempts}" =~ ^[1-9][0-9]*$ ]]; then - echo "GNU_TAR_SETUP_ATTEMPTS must be a positive integer, got: ${attempts}" >&2 - return 1 - fi - - if [[ ! "${delay}" =~ ^[1-9][0-9]*$ ]]; then - echo "GNU_TAR_SETUP_RETRY_DELAY must be a positive integer, got: ${delay}" >&2 - return 1 - fi - - while (( attempt <= attempts )); do - if "$@"; then - return 0 - else - status=$? - fi - - if (( attempt == attempts )); then - echo "Failed to ${description} after ${attempts} attempts." >&2 - return "${status}" - fi - - echo "Failed to ${description} (attempt ${attempt}/${attempts}); retrying in ${delay}s..." >&2 - sleep "${delay}" - attempt=$(( attempt + 1 )) - delay=$(( delay * 2 )) - done -} - -clone_gnu_tar() { - local attempts="${GNU_TAR_SETUP_ATTEMPTS:-3}" - local delay="${GNU_TAR_SETUP_RETRY_DELAY:-30}" - local attempt=1 - local status=0 - - if [[ ! "${attempts}" =~ ^[1-9][0-9]*$ ]]; then - echo "GNU_TAR_SETUP_ATTEMPTS must be a positive integer, got: ${attempts}" >&2 - return 1 - fi - - if [[ ! "${delay}" =~ ^[1-9][0-9]*$ ]]; then - echo "GNU_TAR_SETUP_RETRY_DELAY must be a positive integer, got: ${delay}" >&2 - return 1 - fi - - if [[ -e "${path_GNU}" ]]; then - echo "Cannot clone GNU tar: ${path_GNU} exists but is not a git checkout." >&2 - return 1 - fi - - while (( attempt <= attempts )); do - if git clone --recurse-submodules https://git.savannah.gnu.org/git/tar.git "${path_GNU}"; then - return 0 - else - status=$? - fi - - if (( attempt == attempts )); then - echo "Failed to clone GNU tar after ${attempts} attempts." >&2 - return "${status}" - fi - - echo "Failed to clone GNU tar (attempt ${attempt}/${attempts}); retrying in ${delay}s..." >&2 - rm -rf -- "${path_GNU}" - sleep "${delay}" - attempt=$(( attempt + 1 )) - delay=$(( delay * 2 )) - done -} - echo "Building uutils tar..." cd "${path_UUTILS}" cargo build --profile="${PROFILE}" --bin tarapp @@ -100,19 +22,14 @@ else fi # Symlink tarapp to tar so tests find it as 'tar' -ln -sf "${UU_BUILD_DIR}/tarapp" "${UU_BUILD_DIR}/tar" -echo "Created symlink ${UU_BUILD_DIR}/tar -> tarapp" +ln -svf "${UU_BUILD_DIR}/tarapp" "${UU_BUILD_DIR}/tar" -# Clone GNU tar if needed -if test ! -d "${path_GNU}/.git"; then - echo "Cloning GNU tar..." - clone_gnu_tar +# Extract GNU tar source if needed +if test ! -d "${path_GNU}/README"; then + echo "Extracting GNU tar..." + mkdir -p "${path_GNU}" cd "${path_GNU}" - git checkout v1.35 - retry_attempts "update GNU tar submodules" git submodule update --init --recursive - - # Bootstrap requires gnulib and generates the configure script - ./bootstrap --skip-po + curl -L https://ftpmirror.gnu.org/tar/tar-1.35.tar.xz | tar xJf - --strip-components=1 fi cd "${path_GNU}" @@ -124,4 +41,4 @@ if [ ! -f Makefile ]; then fi echo "Building GNU tar (for test suite)..." -make -j"$(nproc)" +make -j"$(nproc 2>/dev/null || echo 2)"