Refactor toolchain packaging process by introducing package-toolchain.sh

- Replaced the packaging logic in build-toolchain.sh with a call to the new package-toolchain.sh script for better organization and maintainability.
- Added package-toolchain.sh to handle the stripping and archiving of the toolchain, including necessary checks for the installation directory and environment script.
- Updated README.md to document the addition of package-toolchain.sh for clarity on the build process.
This commit is contained in:
2026-04-06 15:09:07 +03:00
parent 082098c9ec
commit 8267e2e4da
3 changed files with 39 additions and 15 deletions

36
package-toolchain.sh Normal file
View File

@@ -0,0 +1,36 @@
#!/bin/bash
set -e
source "$(dirname "$0")/versions.sh"
TOP="$(pwd)"
TARGET="${1:-arm-uclinuxfdpiceabi}"
SUBARCH="${2:-armv7-m}"
INSTALL_DIR="${3:-${TOP}/build/install}"
if [ ! -d "${INSTALL_DIR}" ]; then
echo "Ошибка: директория установки не найдена: ${INSTALL_DIR}"
exit 1
fi
if [ ! -f "${TOP}/scripts/env.sh" ]; then
echo "Ошибка: файл окружения не найден: ${TOP}/scripts/env.sh"
exit 1
fi
echo "== Strip toolchain и упаковка =="
WDIR="$(mktemp -d)"
trap 'rm -rf "$WDIR"' EXIT
ARCHIVE_TOOLCHAIN_DIR="${WDIR}/${TARGET}"
mkdir -p "${ARCHIVE_TOOLCHAIN_DIR}"
cp -a "${INSTALL_DIR}"/* "${ARCHIVE_TOOLCHAIN_DIR}/"
cp -a "${TOP}/scripts/env.sh" "${WDIR}/env.sh"
find "${ARCHIVE_TOOLCHAIN_DIR}" -type f -executable -exec strip -p {} \; 2>/dev/null || true
ARCHIVE_NAME="toolset-jlv-${SUBARCH}-gcc${GCC_VER}-uclibc${UCLIBC_VER}.tar.xz"
tar -C "${WDIR}" --owner=0 --group=0 -cJf "${ARCHIVE_NAME}" "${TARGET}" "env.sh"
echo "Готово: ${ARCHIVE_NAME}"