This commit is contained in:
2026-07-10 15:11:51 +08:00
parent 8bfcf23bc2
commit da17239d7d
148 changed files with 2542 additions and 4873 deletions
+69 -27
View File
@@ -1,38 +1,80 @@
#!/usr/bin/env bash
##makedesc: Install git (latest)
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
title
set -eo pipefail
require make
installed() { command -v "$1" >/dev/null 2>&1; }
if installed git; then
if [ -d "$HOME/install/git" ]; then
cd "$HOME/install/git" && \
git pull
else
clone "https://github.com/git/git.git" "$HOME/install/git" --depth=1 --single-branch && \
cd "$HOME/install/git"
require() {
local missing=()
for pkg in "$@"; do
installed "$pkg" || missing+=("$pkg")
done
if [ ${#missing[@]} -gt 0 ]; then
if [ "$(uname -s)" = "Darwin" ]; then
if installed brew; then
brew install "${missing[@]}"
else
echo "ERROR: Missing: ${missing[*]}. Install manually or use brew." >&2
exit 1
fi
else
sudo apt install -y "${missing[@]}"
fi
fi
sudo make prefix=/usr/local all && \
sudo make prefix=/usr/local install
else
require wget
mkdir -p "$HOME/install/git"
download "https://github.com/git/git/archive/master.zip" "/tmp/git.zip" && \
unzip -oq "/tmp/git.zip" -d "$HOME/install/git" && \
rm /tmp/git.zip && \
cd "$HOME/install/git/git-master" && \
sudo make prefix=/usr/local all && \
sudo make prefix=/usr/local install && \
cd - && \
rm -rf git && \
clone "https://github.com/git/git.git" "$HOME/install/git" --depth=1 --single-branch
fi
}
[ $? = 0 ] && {
download() {
if installed wget; then
wget -q --show-progress "$1" -O "$2"
else
curl -fsSL "$1" -o "$2"
fi
}
clone_quick() {
git clone --depth=1 --single-branch "$@"
}
install() {
echo
success "git installed!"
echo "==============================================="
echo "Installing git"
echo "==============================================="
echo
require make
if installed git; then
if [ -d "$HOME/install/git" ]; then
cd "$HOME/install/git"
git pull
else
clone_quick "https://github.com/git/git.git" "$HOME/install/git"
cd "$HOME/install/git"
fi
sudo make prefix=/usr/local all
sudo make prefix=/usr/local install
else
require wget unzip
mkdir -p "$HOME/install/git"
download "https://github.com/git/git/archive/master.zip" "/tmp/git.zip"
unzip -oq "/tmp/git.zip" -d "$HOME/install/git"
rm /tmp/git.zip
cd "$HOME/install/git/git-master"
sudo make prefix=/usr/local all
sudo make prefix=/usr/local install
cd -
rm -rf git
clone_quick "https://github.com/git/git.git" "$HOME/install/git"
fi
echo
echo "Finish!"
git --version
echo
}
case "$1" in
*) install ;;
esac