fix git.sh 2

experimental
Anthony Axenov 2022-01-09 17:26:27 +08:00
parent 7f8f9ddc27
commit d175b6ee3b
Signed by: anthony
GPG Key ID: EA9EC32FF7CCD4EC
1 changed files with 12 additions and 7 deletions

View File

@ -1,24 +1,29 @@
#!/bin/bash #!/bin/bash
echo echo
echo "===============================================" echo "==============================================="
echo "Installing git..." echo "Installing git (latest)..."
echo "===============================================" echo "==============================================="
echo echo
installed() { installed() {
command -v "$1" >/dev/null 2>&1 command -v "$1" >/dev/null 2>&1
} }
ENVDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
! installed make && sudo apt install -y make
! installed curl && sudo apt install -y curl
if installed git; then if installed git; then
[ ! -d "/usr/src/git" ] && sudo git clone https://github.com/git/git.git --depth=1 /usr/src/git sudo rm -rf /usr/src/git
sudo git clone https://github.com/git/git.git --depth=1 /usr/src/git
sudo chown -R $USER: /usr/src/git sudo chown -R $USER: /usr/src/git
cd /usr/src/git/ cd /usr/src/git/
sudo make prefix=/usr/local all sudo make prefix=/usr/local all
sudo make prefix=/usr/local install sudo make prefix=/usr/local install
else else
sudo wget https://github.com/git/git/archive/master.zip -O /usr/src/git.zip wget https://github.com/git/git/archive/master.zip -O /tmp/git.zip
sudo unzip /usr/src/git.zip -d /usr/src/git sudo unzip -q /tmp/git.zip -d /usr/src/git
sudo rm -f /usr/src/git.zip rm /tmp/git.zip
cd /usr/src/git/git-master cd /usr/src/git/git-master
sudo make prefix=/usr/local all sudo make prefix=/usr/local all
sudo make prefix=/usr/local install sudo make prefix=/usr/local install
@ -27,6 +32,6 @@ else
sudo git clone https://github.com/git/git.git --depth=1 /usr/src/git sudo git clone https://github.com/git/git.git --depth=1 /usr/src/git
sudo chown -R $USER: /usr/src/git sudo chown -R $USER: /usr/src/git
fi fi
ENVDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" cd -
cp "$ENVDIR"/dotfiles/.gitconfig $HOME/.gitconfig cp "$ENVDIR"/dotfiles/.gitconfig $HOME/.gitconfig
git --version git --version