4 Star 7 Fork 5

GiteeStudio / git-dist

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
git-dist.sh 2.93 KB
一键复制 编辑 原始数据 按行查看 历史
likui 提交于 2024-01-23 16:31 . update git to 2.43.0
#!/usr/bin/env bash
function download() {
local url="${1}"
local path="${2}"
curl -f --progress-bar --continue-at - --location --output "${path}" "${url}"
}
function installdeps() {
# shellcheck source=/dev/null
source /etc/os-release
if [[ "$ID" == "ubuntu" ]]; then
sudo apt-get install -y make libcurl4-gnutls-dev libexpat1-dev gettext libz-dev curl autoconf perl
fi
if [[ "$ID" == "debain" ]]; then
#statements
sudo apt-get install -y make libcurl4-gnutls-dev libexpat1-dev gettext libz-dev curl autoconf perl
fi
if [[ "$ID" == "centos" ]]; then
#statements
sudo yum install -y make curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc autoconf
fi
}
function checkdeps() {
echo "checking dependencies ..."
if [[ ! -f "/usr/lib/x86_64-linux-gnu/libcurl.a" ]]; then
#mybe not compile git
installdeps
fi
if ! hash make; then
installdeps
fi
}
function compilegit() {
local sourcedir="${1}"
local installdir="${2}"
cd "$sourcedir" || exit 1
echo "git sources: $sourcedir"
make configure
./configure --prefix="${installdir}"
if ! make; then
echo "unable compile"
exit 1
fi
sudo make install
}
checkdeps
readonly GIT_URL_BASE="https://github.com/git/git/archive"
readonly GIT_REMOTE_VERSION="https://gitee.com/oscstudio/git-dist/raw/master/version"
# URL: https://github.com/git/git/archive/$version.tar.gz
Xdirname=$(dirname "$0")
PrefixDir=$(
cd "$Xdirname"
pwd
) || exit 1
if [[ -f "${PrefixDir}/version" ]]; then
# shellcheck source=/dev/null
source "${PrefixDir}/version"
else
echo "fetch remote version"
curl -f --progress-bar --location --output /tmp/git-real-version "$GIT_REMOTE_VERSION"
if [[ ! -f "/tmp/git-real-version" ]]; then
echo -e "\\x1b[31munable download git version file\\x1b[0m"
exit 1
fi
# shellcheck source=/dev/null
source "/tmp/git-real-version"
fi
git_version="$GIT_REAL_VERSION"
echo "GIT_REAL_VERSION: $GIT_REAL_VERSION"
if [[ ! -d "/tmp/buildgit" ]]; then
#statements
mkdir -p "/tmp/buildgit"
fi
# https://github.com/git/git/archive/v2.19.0.tar.gz
GIT_TAR_URL="${GIT_URL_BASE}/v${git_version}.tar.gz"
GIT_TAR_PATH="/tmp/buildgit/git-${git_version}.tar.gz"
#https://github.com/git/git/archive/v2.13.2.tar.gz
echo "download: ${GIT_TAR_URL}"
if [[ ! -f $GIT_TAR_PATH ]]; then
download "${GIT_TAR_URL}" "${GIT_TAR_PATH}"
if [[ ! -f $GIT_TAR_PATH ]]; then
exit 1
fi
fi
# check sha256sum if GIT_GITHUB_HASH is matched
if [[ "x$GIT_GITHUB_HASH" != "x" ]]; then
echo "check $GIT_TAR_PATH sha256sum"
if sha256sum "$GIT_TAR_PATH" | grep "$GIT_GITHUB_HASH"; then
echo "$GIT_TAR_PATH sha256sum = $GIT_GITHUB_HASH"
else
echo "sha256sum does not match"
rm "$GIT_TAR_PATH"
exit 1
fi
fi
cd "/tmp/buildgit" || exit 1
echo "unpack ${GIT_TAR_PATH}"
tar -xf "${GIT_TAR_PATH}"
compilegit "/tmp/buildgit/git-$git_version" "/usr/local"
echo "complete install git"
echo "delete git source files"
rm -rf "/tmp/buildgit"
Shell
1
https://gitee.com/oscstudio/git-dist.git
git@gitee.com:oscstudio/git-dist.git
oscstudio
git-dist
git-dist
master

搜索帮助