看来CentOS 5的存储库正在消失。这个问题中提到的大多数工具都不再在线,似乎没有Git或真正的旧版Git。下面是我用来从源代码构建OpenSSL,IDN2,PCRE,cURL和Git的脚本。无论是git://
和https://
协议将可用于克隆。
随着时间的流逝,档案名称将需要更新。例如,在撰写本文时,它openssl-1.0.2k.tar.gz
是1.0.2系列中的最新版本。
Dale Anderson使用RHEL存储库的答案目前看来不错,但它是一个相当老的版本。Red Hat提供了Git版本1.8,而下面的脚本从源代码构建了2.12。
#!/usr/bin/env bash
# OpenSSL installs into lib64/, while cURL installs into lib/
INSTALL_ROOT=/usr/local
INSTALL_LIB32="$INSTALL_ROOT/lib"
INSTALL_LIB64="$INSTALL_ROOT/lib64"
OPENSSL_TAR=openssl-1.0.2k.tar.gz
OPENSSL_DIR=openssl-1.0.2k
ZLIB_TAR=zlib-1.2.11.tar.gz
ZLIB_DIR=zlib-1.2.11
UNISTR_TAR=libunistring-0.9.7.tar.gz
UNISTR_DIR=libunistring-0.9.7
IDN2_TAR=libidn2-0.16.tar.gz
IDN2_DIR=libidn2-0.16
PCRE_TAR=pcre2-10.23.tar.gz
PCRE_DIR=pcre2-10.23
CURL_TAR=curl-7.53.1.tar.gz
CURL_DIR=curl-7.53.1
GIT_TAR=v2.12.2.tar.gz
GIT_DIR=git-2.12.2
###############################################################################
# I don't like doing this, but...
read -s -p "Please enter password for sudo: " SUDO_PASSWWORD
###############################################################################
echo
echo "********** zLib **********"
wget "http://www.zlib.net/$ZLIB_TAR" -O "$ZLIB_TAR"
if [[ "$?" -ne "0" ]]; then
echo "Failed to download zLib"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
rm -rf "$ZLIB_DIR" &>/dev/null
tar -xzf "$ZLIB_TAR"
cd "$ZLIB_DIR"
LIBS="-ldl -lpthread" ./configure --enable-shared --libdir="$INSTALL_LIB64"
if [[ "$?" -ne "0" ]]; then
echo "Failed to configure zLib"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
make -j 4
if [ "$?" -ne "0" ]; then
echo "Failed to build zLib"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
echo "$SUDO_PASSWWORD" | sudo -S make install
cd ..
###############################################################################
echo
echo "********** Unistring **********"
# https://savannah.gnu.org/bugs/?func=detailitem&item_id=26786
wget "https://ftp.gnu.org/gnu/libunistring/$UNISTR_TAR" --no-check-certificate -O "$UNISTR_TAR"
if [[ "$?" -ne "0" ]]; then
echo "Failed to download IDN"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
rm -rf "$UNISTR_DIR" &>/dev/null
tar -xzf "$UNISTR_TAR"
cd "$UNISTR_DIR"
LIBS="-ldl -lpthread" ./configure --enable-shared --libdir="$INSTALL_LIB64"
if [[ "$?" -ne "0" ]]; then
echo "Failed to configure IDN"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
make -j 4
if [ "$?" -ne "0" ]; then
echo "Failed to build IDN"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
echo "$SUDO_PASSWWORD" | sudo -S make install
cd ..
###############################################################################
echo
echo "********** IDN **********"
# https://savannah.gnu.org/bugs/?func=detailitem&item_id=26786
wget "https://alpha.gnu.org/gnu/libidn/$IDN2_TAR" --no-check-certificate -O "$IDN2_TAR"
if [[ "$?" -ne "0" ]]; then
echo "Failed to download IDN"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
rm -rf "$IDN2_DIR" &>/dev/null
tar -xzf "$IDN2_TAR"
cd "$IDN2_DIR"
LIBS="-ldl -lpthread" ./configure --enable-shared --libdir="$INSTALL_LIB64"
if [[ "$?" -ne "0" ]]; then
echo "Failed to configure IDN"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
make -j 4
if [ "$?" -ne "0" ]; then
echo "Failed to build IDN"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
echo "$SUDO_PASSWWORD" | sudo -S make install
cd ..
###############################################################################
echo
echo "********** OpenSSL **********"
wget "https://www.openssl.org/source/$OPENSSL_TAR" -O "$OPENSSL_TAR"
if [[ "$?" -ne "0" ]]; then
echo "Failed to download OpenSSL"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
rm -rf "$OPENSSL_DIR" &>/dev/null
tar -xzf "$OPENSSL_TAR"
cd "$OPENSSL_DIR"
# OpenSSL and enable-ec_nistp_64_gcc_12 option
IS_X86_64=$(uname -m 2>&1 | egrep -i -c "(amd64|x86_64)")
CONFIG=./config
CONFIG_FLAGS=(no-ssl2 no-ssl3 no-comp shared "-Wl,-rpath,$INSTALL_LIB64" --prefix="$INSTALL_ROOT" --openssldir="$INSTALL_ROOT")
if [[ "$IS_X86_64" -eq "1" ]]; then
CONFIG_FLAGS+=("enable-ec_nistp_64_gcc_128")
fi
"$CONFIG" "${CONFIG_FLAGS[@]}"
if [[ "$?" -ne "0" ]]; then
echo "Failed to configure OpenSSL"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
make depend
make -j 4
if [ "$?" -ne "0" ]; then
echo "Failed to build OpenSSL"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
echo "$SUDO_PASSWWORD" | sudo -S make install_sw
cd ..
###############################################################################
echo
echo "********** PCRE **********"
# https://savannah.gnu.org/bugs/?func=detailitem&item_id=26786
wget "https://ftp.pcre.org/pub/pcre//$PCRE_TAR" --no-check-certificate -O "$PCRE_TAR"
if [[ "$?" -ne "0" ]]; then
echo "Failed to download PCRE"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
rm -rf "$PCRE_DIR" &>/dev/null
tar -xzf "$PCRE_TAR"
cd "$PCRE_DIR"
make configure
CPPFLAGS="-I$INSTALL_ROOT/include" LDFLAGS="-Wl,-rpath,$INSTALL_LIB64 -L$INSTALL_LIB64" \
LIBS="-lidn2 -lz -ldl -lpthread" ./configure --enable-shared --enable-pcre2-8 --enable-pcre2-16 --enable-pcre2-32 \
--enable-unicode-properties --enable-pcregrep-libz --prefix="$INSTALL_ROOT" --libdir="$INSTALL_LIB64"
if [[ "$?" -ne "0" ]]; then
echo "Failed to configure PCRE"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
make all -j 4
if [ "$?" -ne "0" ]; then
echo "Failed to build PCRE"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
echo "$SUDO_PASSWWORD" | sudo -S make install
cd ..
###############################################################################
echo
echo "********** cURL **********"
# https://savannah.gnu.org/bugs/?func=detailitem&item_id=26786
wget "https://curl.haxx.se/download/$CURL_TAR" --no-check-certificate -O "$CURL_TAR"
if [[ "$?" -ne "0" ]]; then
echo "Failed to download cURL"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
rm -rf "$CURL_DIR" &>/dev/null
tar -xzf "$CURL_TAR"
cd "$CURL_DIR"
CPPFLAGS="-I$INSTALL_ROOT/include" LDFLAGS="-Wl,-rpath,$INSTALL_LIB64 -L$INSTALL_LIB64" \
LIBS="-lidn2 -lssl -lcrypto -lz -ldl -lpthread" \
./configure --enable-shared --with-ssl="$INSTALL_ROOT" --with-libidn2="$INSTALL_ROOT" --libdir="$INSTALL_LIB64"
if [[ "$?" -ne "0" ]]; then
echo "Failed to configure cURL"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
make -j 4
if [ "$?" -ne "0" ]; then
echo "Failed to build cURL"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
echo "$SUDO_PASSWWORD" | sudo -S make install
cd ..
###############################################################################
echo
echo "********** Git **********"
wget "https://github.com/git/git/archive/$GIT_TAR" -O "$GIT_TAR"
if [[ "$?" -ne "0" ]]; then
echo "Failed to download Git"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
rm -rf "$GIT_DIR" &>/dev/null
tar -xzf "$GIT_TAR"
cd "$GIT_DIR"
make configure
CPPFLAGS="-I$INSTALL_ROOT/include" LDFLAGS="-Wl,-rpath,$INSTALL_LIB64,-rpath,$INSTALL_LIB32 -L$INSTALL_LIB64 -L$INSTALL_LIB32" \
LIBS="-lidn2 -lssl -lcrypto -lz -ldl -lpthread" ./configure --with-openssl --with-curl --with-libpcre --prefix="$INSTALL_ROOT"
if [[ "$?" -ne "0" ]]; then
echo "Failed to configure Git"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
make all -j 4
if [ "$?" -ne "0" ]; then
echo "Failed to build Git"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
MAKE=make
MAKE_FLAGS=(install)
if [[ ! -z `which asciidoc 2>/dev/null | grep -v 'no asciidoc'` ]]; then
if [[ ! -z `which xmlto 2>/dev/null | grep -v 'no xmlto'` ]]; then
MAKE_FLAGS+=("install-doc" "install-html" "install-info")
fi
fi
echo "$SUDO_PASSWWORD" | sudo -S "$MAKE" "${MAKE_FLAGS[@]}"
cd ..
###############################################################################
echo
echo "********** Cleanup **********"
rm -rf "$OPENSSL_TAR $OPENSSL_DIR $UNISTR_TAR $UNISTR_DIR $CURL_TAR $CURL_DIR"
rm -rf "$PCRE_TAR $PCRE_DIR $ZLIB_TAR $ZLIB_DIR $IDN2_TAR $IDN2_DIR $GIT_TAR $GIT_DIR"
[[ "$0" = "$BASH_SOURCE" ]] && exit 0 || return 0