[Linux/apt] 更新crosstool-ng版本

This commit is contained in:
2025-02-03 01:30:38 +08:00
parent c476f71722
commit bbdb691459
3 changed files with 83 additions and 31 deletions

View File

@@ -0,0 +1 @@
local

View File

@@ -1,39 +1,47 @@
#/bin/bash
export CROSSTOOL_NG_URL=http://crosstool-ng.org/download/crosstool-ng/
export CROSSTOOL_NG_FILENAME=crosstool-ng-1.26.0.tar.xz
export CROSSTOOL_NG_DIRNAME=crosstool-ng-1.26.0
export CROSSTOOL_NG_LOCAL_SRC_PATH=${HENVBOX_LOCAL_SRC_PATH}/crosstool-ng/
#检查是否在HEnvBox中
[ -d "${HENVBOX_ROOT_PATH}" ] || exit 1
shellcheck disable=SC2128 # ignore array expansion warning
if [ -n "${BASH_SOURCE-}" ]
then
self_path="${BASH_SOURCE}"
elif [ -n "${ZSH_VERSION-}" ]
then
self_path="${(%):-%x}"
else
exit 1
fi
# shellcheck disable=SC2169,SC2169,SC2039 # unreachable with 'dash'
if [[ "$OSTYPE" == "darwin"* ]]; then
# convert possibly relative path to absolute
script_dir="$(realpath_int "${self_path}")"
# resolve any ../ references to make the path shorter
script_dir="$(cd "${script_dir}" || exit 1; pwd)"
else
# convert to full path and get the directory name of that
script_name="$(readlink -f "${self_path}")"
script_dir="$(dirname "${script_name}")"
fi
function Download()
{
mkdir -p ${CROSSTOOL_NG_LOCAL_SRC_PATH}
pushd ${CROSSTOOL_NG_LOCAL_SRC_PATH}
wget --no-check-certificate -c -t 5 -O ${CROSSTOOL_NG_LOCAL_SRC_PATH}/${CROSSTOOL_NG_FILENAME} ${CROSSTOOL_NG_URL}/${CROSSTOOL_NG_FILENAME}
wget --no-check-certificate -c -t 5 -O ${CROSSTOOL_NG_LOCAL_SRC_PATH}/${CROSSTOOL_NG_FILENAME}.sha512 ${CROSSTOOL_NG_URL}/${CROSSTOOL_NG_FILENAME}.sha512
[ -f ${CROSSTOOL_NG_LOCAL_SRC_PATH}/${CROSSTOOL_NG_FILENAME} ] && [ -f ${CROSSTOOL_NG_LOCAL_SRC_PATH}/${CROSSTOOL_NG_FILENAME}.sha512 ] && sha512sum -c ${CROSSTOOL_NG_LOCAL_SRC_PATH}/${CROSSTOOL_NG_FILENAME}.sha512 && touch ${HENVBOX_LOCAL_STAMP_PATH}/download.${CROSSTOOL_NG_FILENAME}
popd 2> /dev/null >dev/null
}
#进入当前目录
pushd ${script_dir}
[ -f ${HENVBOX_LOCAL_STAMP_PATH}/download.${CROSSTOOL_NG_FILENAME} ] || Download
#进行编译
make -f crosstool-ng.mk install
function Compile()
{
pushd ${CROSSTOOL_NG_LOCAL_SRC_PATH}
[ -f ${HENVBOX_LOCAL_STAMP_PATH}/extract.${CROSSTOOL_NG_FILENAME} ] || tar -xvf ${CROSSTOOL_NG_FILENAME}
[ $? -eq 0 ] && touch ${HENVBOX_LOCAL_STAMP_PATH}/extract.${CROSSTOOL_NG_FILENAME}
if [ -f ${HENVBOX_LOCAL_STAMP_PATH}/extract.${CROSSTOOL_NG_FILENAME} ]
then
pushd ${CROSSTOOL_NG_LOCAL_SRC_PATH}/${CROSSTOOL_NG_DIRNAME}
./bootstrap
./configure --prefix=${HENVBOX_LOCAL_ROOT_PATH}
make install
[ $? -eq 0 ] && touch ${HENVBOX_LOCAL_STAMP_PATH}/compile.${CROSSTOOL_NG_FILENAME}
popd 2> /dev/null >dev/null
fi
popd 2> /dev/null >dev/null
}
#退出目录
popd
[ -f ${HENVBOX_LOCAL_STAMP_PATH}/download.${CROSSTOOL_NG_FILENAME} ] && [ -f ${HENVBOX_LOCAL_STAMP_PATH}/compile.${CROSSTOOL_NG_FILENAME} ] || Compile
#提示是否成功
if [ "$?" -eq "0" ]
then
echo 编译成功!
else
echo 编译失败!请手动重新调用安装脚本!
fi
#正常退出
exit 0

View File

@@ -0,0 +1,43 @@
include ${MAKEFILE_INCLUDE_DIR}/top.mk
HENVBOX_LOCAL_SRC_PATH ?= ${HENVBOX_LOCAL_ROOT_PATH}/src/
CROSSTOOL_NG_LOCAL_SRC_PATH ?= ${HENVBOX_LOCAL_SRC_PATH}/crosstool-ng-git
CROSSTOOL_NG_LOCAL_SRC_URL ?= https://github.com/crosstool-ng/crosstool-ng.git
.PHONY: prepare_dir download_git_repository configure_ct_ng build_ct_ng install_ct_ng clean_ct_ng
prepare_dir:
mkdir -p ${CROSSTOOL_NG_LOCAL_SRC_PATH}
prepare_step += prepare_dir
download_git_repository:
if [ ! -e ${CROSSTOOL_NG_LOCAL_SRC_PATH}/.git/config ]; then cd "${CROSSTOOL_NG_LOCAL_SRC_PATH}" && git init && git remote add origin ${CROSSTOOL_NG_LOCAL_SRC_URL}; fi;
cd "${CROSSTOOL_NG_LOCAL_SRC_PATH}" && git fetch && git checkout -f master
download_step += download_git_repository
configure_ct_ng:
if [ ! -e ${CROSSTOOL_NG_LOCAL_SRC_PATH}/configure ]; then cd "${CROSSTOOL_NG_LOCAL_SRC_PATH}" && ${CROSSTOOL_NG_LOCAL_SRC_PATH}/bootstrap; fi;
cd "${CROSSTOOL_NG_LOCAL_SRC_PATH}" && ${CROSSTOOL_NG_LOCAL_SRC_PATH}/configure --prefix="${HENVBOX_LOCAL_ROOT_PATH}"
configure_step+= configure_ct_ng
build_ct_ng:
cd "${CROSSTOOL_NG_LOCAL_SRC_PATH}" && ${MAKE}
build_step+= build_ct_ng
install_ct_ng:
cd "${CROSSTOOL_NG_LOCAL_SRC_PATH}" && ${MAKE} install
install_step+= install_ct_ng
clean_ct_ng:
cd "${CROSSTOOL_NG_LOCAL_SRC_PATH}" && git clean -x -f -d
clean_step+= clean_ct_ng
include ${MAKEFILE_INCLUDE_DIR}/bottom.mk