Skip to content

Instantly share code, notes, and snippets.

@kuoe0
Last active July 25, 2024 06:58
Show Gist options
  • Save kuoe0/6620246 to your computer and use it in GitHub Desktop.
Save kuoe0/6620246 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 <[email protected]>
# 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
@cwzsquare
Copy link

如果在dpkg-buildpackage -rfakeroot -b编译过程中出现 dpkg-buildpackage: error: failed to sign... 的错误,参考此处 ,修改成 dpkg-buildpackage -uc -us -rfakeroot -b 重新继续编译即可

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment