Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
編譯採用 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
@linnet8989

This comment has been minimized.

Copy link

linnet8989 commented Sep 24, 2018

分享点自己的经验:

sudo apt-get -y build-dep git # 这句有个sgml-data的依赖包装不上,最后手动从官网下载安装的(还有些install和网络代理方面的东西就不提了,没记住)

sudo dpkg-buildpackage -rfakeroot -b # 使用命令sudo update-alternatives --set fakeroot /usr/bin/fakeroot-tcp解决

find $work_path -maxdepth 1 -name "git_.deb" -exec sudo dpkg -i {} ; # 依赖的git-man得先装上,把"git_.deb"换成"git-man_*deb"跑一次解决依赖问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.