Skip to content

Instantly share code, notes, and snippets.

@linnet8989
Forked from kuoe0/Install_OpenSSL_GIT.sh
Created September 24, 2018 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linnet8989/2d414040cff4761214d510925cd75169 to your computer and use it in GitHub Desktop.
Save linnet8989/2d414040cff4761214d510925cd75169 to your computer and use it in GitHub Desktop.
編譯採用 OpenSSL 的 git,避免某些網路環境下發生 gnutls_handshake() failed 的情況!
#!/usr/bin/env bash
# =============================================================================
# FileName: Install_OpenSSL_GIT.sh
# Desc: Build GIT with OpenSSL and Install it
# Environment: Ubuntu 13.04 amd64
# Usage: ./Install_OpenSSL_GIT.sh
# Author: KuoE0 <kuoe0.tw@gmail.com>
# HomePage: http://kuoe0.tw/
# Copyright: BSD License (C) 2013 KuoE0
# =============================================================================
work_path=/tmp/git-openssl
echo -e "\x1b[33msudo apt-get -y install build-essential fakeroot dpkg-dev\x1b[0m"
sudo apt-get -y install build-essential fakeroot dpkg-dev
mkdir $work_path
cd $work_path
echo -e "\x1b[33msudo apt-get source git\x1b[0m"
sudo apt-get source git
echo -e "\x1b[33msudo apt-get -y build-dep git\x1b[0m"
sudo apt-get -y build-dep git
echo -e "\x1b[33msudo apt-get -y install libcurl4-openssl-dev\x1b[0m"
sudo apt-get -y install libcurl4-openssl-dev
find . -name "*.dsc" | xargs sudo dpkg-source -x
dir=`find $work_path -maxdepth 1 -mindepth 1 -type d`
cd $dir
# replace gnutls with openssl
echo -e "\x1b[33mreplace gnutls with openssl\x1b[0m"
sudo sed --in-place 's/libcurl4-gnutls-dev/libcurl4-openssl-dev/g' debian/control
# remove TEST target
sudo sed --in-place '/TEST =test/d' debian/rules
echo -e "\x1b[33mbuild git...\x1b[0m"
sudo dpkg-buildpackage -rfakeroot -b
find $work_path -maxdepth 1 -name "git_*.deb" -exec sudo dpkg -i {} \;
echo -e "\x1b[33mset to not upgrade them\x1b[0m"
# prevent to upgrade from APT
dpkg --get-selections | grep git > $work_path/GIT
sed -e 's/install/hold/' $work_path/GIT | sudo dpkg --set-selections
cd /tmp
sudo rm -r $work_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment