代码拉取完成,页面将自动刷新
同步操作将从 GiteeStudio/git-dist 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/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
# https://mirrors.kernel.org/pub/software/scm/git/git-2.22.0.tar.xz
readonly GIT_URL_BASE="https://mirrors.kernel.org/pub/software/scm/git"
#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://mirrors.edge.kernel.org/pub/software/scm/git/git-2.22.0.tar.xz
GIT_TAR_URL="${GIT_URL_BASE}/git-${git_version}.tar.xz"
GIT_TAR_PATH="/tmp/buildgit/git-${git_version}.tar.xz"
#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_KERNAL_HASH is matched
if [[ "x$GIT_KERNAL_HASH" != "x" ]]; then
echo "check $GIT_TAR_PATH sha256sum"
if sha256sum "$GIT_TAR_PATH" | grep "$GIT_KERNAL_HASH"; then
echo "$GIT_TAR_PATH sha256sum = $GIT_KERNAL_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"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。