Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
編譯採用 OpenSSL 的 APT,避免某些網路環境下發生 gnutls_handshake() failed 的情況!
#!/usr/bin/env bash
# =============================================================================
# FileName: Install_OpenSSL_APT.sh
# Desc: Build APT with OpenSSL and Install it
# Environment: Ubuntu 13.04 amd64
# Usage: ./Install_OpenSSL_APT.sh
# Author: KuoE0 <kuoe0.tw@gmail.com>
# HomePage: http://kuoe0.tw/
# Copyright: BSD License (C) 2013 KuoE0
# =============================================================================
work_path=/tmp/apt-openssl
if [ -d $work_path ]; then
sudo rm -rf $work_path
fi
mkdir $work_path
cd $work_path
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
echo -e "\x1b[33msudo apt-get source apt\x1b[0m"
sudo apt-get source apt
echo -e "\x1b[33msudo apt-get -y build-dep apt\x1b[0m"
sudo apt-get -y build-dep apt
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
echo -e "\x1b[33mbuild apt...\x1b[0m"
sudo dpkg-buildpackage -rfakeroot -b
cd $work_path
PKG_LIST=$(ls *.deb)
find $work_path -maxdepth 1 -name "*.deb" -exec sudo dpkg -i {} \;
# prevent to upgrade from APT
echo -e "\x1b[33mset to not upgrade them\x1b[0m"
for PKG in $PKG_LIST; do
PKG=$(echo $PKG | grep -o '^[^_]*')
# dpkg --get-selections | grep "$PKG" | head -n 1 | sed -e 's/install/hold/' | sudo dpkg --set-selections
dpkg --get-selections | grep "$PKG" | head -n 1 | sed -e 's/install/hold/' | sudo dpkg --set-selections
done
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
You can’t perform that action at this time.