Skip to content

Commit 6b13d18

Browse files
committed
build git ourselves
1 parent 85efbd9 commit 6b13d18

File tree

2 files changed

+57
-29
lines changed

2 files changed

+57
-29
lines changed

docker/build_scripts/build.sh

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ DEVTOOLS_HASH=a8ebeb4bed624700f727179e6ef771dafe47651131a00a78b342251415646acc
1919
# https://github.com/NixOS/patchelf/commit/2a9cefd7d637d160d12dc7946393778fa8abbc58
2020
PATCHELF_VERSION=2a9cefd7d637d160d12dc7946393778fa8abbc58
2121
PATCHELF_HASH=12da4727f09be42ae0b54878e1b8e86d85cb7a5b595731cdc1a0a170c4873c6d
22-
CURL_ROOT=curl-7.57.0
23-
# https://github.com/Homebrew/homebrew-core/blob/e3a8622111ecefe444194cade5cca3c69165e26c/Formula/curl.rb#L6
24-
CURL_HASH=c92fe31a348eae079121b73884065e600c533493eb50f1f6cee9c48a3f454826
22+
CURL_ROOT=curl_7.52.1
23+
CURL_HASH=a8984e8b20880b621f61a62d95ff3c0763a3152093a9f9ce4287cfd614add6ae
2524
AUTOCONF_ROOT=autoconf-2.69
2625
AUTOCONF_HASH=954bd69b391edc12d6a4a51a2dd1476543da5c6bbf05a95b59dc0dd6fd4c2969
2726
AUTOMAKE_ROOT=automake-1.15
@@ -31,6 +30,8 @@ LIBTOOL_HASH=e3bd4d5d3d025a36c21dd6af7ea818a2afcd4dfc1ea5a17b39d7854bcd0c06e3
3130
SQLITE_AUTOCONF_VERSION=sqlite-autoconf-3210000
3231
# Homebrew saw the same hash: https://github.com/Homebrew/homebrew-core/blob/e3a8622111ecefe444194cade5cca3c69165e26c/Formula/sqlite.rb#L6
3332
SQLITE_AUTOCONF_HASH=d7dd516775005ad87a57f428b6f86afd206cb341722927f104d3f0cf65fbbbe3
33+
GIT_ROOT=2.16.2
34+
GIT_HASH=cbdc2398204c7b7bed64f28265870aabe40dd3cd5c0455f7d315570ad7f7f5c8
3435

3536
# Dependencies for compiling Python that we want to remove from
3637
# the final image after compiling Python
@@ -64,26 +65,38 @@ source $MY_DIR/build_utils.sh
6465
yum -y update
6566

6667
# EPEL support
67-
yum -y install wget curl
68+
yum -y install wget
6869
# https://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
6970
cp $MY_DIR/epel-release-5-4.noarch.rpm .
7071
check_sha256sum epel-release-5-4.noarch.rpm $EPEL_RPM_HASH
7172

7273
# Dev toolset (for LLVM and other projects requiring C++11 support)
73-
curl -fsSLO http://people.centos.org/tru/devtools-2/devtools-2.repo
74+
wget -q http://people.centos.org/tru/devtools-2/devtools-2.repo
7475
check_sha256sum devtools-2.repo $DEVTOOLS_HASH
7576
mv devtools-2.repo /etc/yum.repos.d/devtools-2.repo
7677
rpm -Uvh --replacepkgs epel-release-5*.rpm
7778
rm -f epel-release-5*.rpm
7879

7980
# Development tools and libraries
80-
yum -y install bzip2 make git patch unzip bison yasm diffutils \
81+
yum -y install bzip2 make patch unzip bison yasm diffutils \
8182
automake which file cmake28 \
8283
kernel-devel-`uname -r` \
84+
expat-devel gettext \
8385
devtoolset-2-binutils devtoolset-2-gcc \
8486
devtoolset-2-gcc-c++ devtoolset-2-gcc-gfortran \
8587
${PYTHON_COMPILE_DEPS}
8688

89+
# Build an OpenSSL for both curl and the Pythons. We'll delete this at the end.
90+
build_openssl $OPENSSL_ROOT $OPENSSL_HASH
91+
# Install curl so we can have TLS 1.2 in this ancient container.
92+
build_curl $CURL_ROOT $CURL_HASH
93+
hash -r
94+
curl --version
95+
curl-config --features
96+
97+
# Install a git we link against OpenSSL so that we can use TLS 1.2
98+
build_git $GIT_ROOT $GIT_HASH
99+
87100
# Install newest autoconf
88101
build_autoconf $AUTOCONF_ROOT $AUTOCONF_HASH
89102
autoconf --version
@@ -109,8 +122,7 @@ rm -rf $SQLITE_AUTOCONF_VERSION*
109122
# Compile the latest Python releases.
110123
# (In order to have a proper SSL module, Python is compiled
111124
# against a recent openssl [see env vars above], which is linked
112-
# statically. We delete openssl afterwards.)
113-
build_openssl $OPENSSL_ROOT $OPENSSL_HASH
125+
# statically.
114126
mkdir -p /opt/python
115127
build_cpythons $CPYTHON_VERSIONS
116128

@@ -129,14 +141,7 @@ ln -s $($PY36_BIN/python -c 'import certifi; print(certifi.where())') \
129141
# Dockerfiles:
130142
export SSL_CERT_FILE=/opt/_internal/certs.pem
131143

132-
# Install newest curl
133-
build_curl $CURL_ROOT $CURL_HASH
134-
rm -rf /usr/local/include/curl /usr/local/lib/libcurl* /usr/local/lib/pkgconfig/libcurl.pc
135-
hash -r
136-
curl --version
137-
curl-config --features
138-
139-
# Now we can delete our built SSL
144+
# Now we can delete our built OpenSSL headers/static libs since we've linked everything we need
140145
rm -rf /usr/local/ssl
141146

142147
# Install patchelf (latest with unreleased bug fixes)
@@ -152,6 +157,7 @@ ln -s $PY36_BIN/auditwheel /usr/local/bin/auditwheel
152157
# final image
153158
yum -y erase wireless-tools gtk2 libX11 hicolor-icon-theme \
154159
avahi freetype bitstream-vera-fonts \
160+
expat-devel gettext \
155161
${PYTHON_COMPILE_DEPS} > /dev/null 2>&1
156162
yum -y install ${MANYLINUX1_DEPS}
157163
yum -y clean all > /dev/null 2>&1

docker/build_scripts/build_utils.sh

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ PYTHON_DOWNLOAD_URL=https://www.python.org/ftp/python
66
# with the old versions of openssl and curl in Centos 5.11 hence the fallback
77
# to the ftp mirror:
88
OPENSSL_DOWNLOAD_URL=ftp://ftp.openssl.org/source
9-
# Ditto the curl sources
10-
# FIXME: This is about the only mirror that supports bootstrapping over a
11-
# broken version of curl. Unfortunately, we are hardcoding the directory used
12-
# to download the new version of curl.
13-
CURL_DOWNLOAD_URL=https://github.com/curl/curl/releases/download/curl-7_57_0
9+
# We had to switch to a debian mirror because we can't use TLS until we
10+
# bootstrap it with this curl + openssl
11+
CURL_DOWNLOAD_URL=http://deb.debian.org/debian/pool/main/c/curl
1412

1513
GET_PIP_URL=https://bootstrap.pypa.io/get-pip.py
1614

1715
AUTOCONF_DOWNLOAD_URL=http://ftp.gnu.org/gnu/autoconf
1816
AUTOMAKE_DOWNLOAD_URL=http://ftp.gnu.org/gnu/automake
1917
LIBTOOL_DOWNLOAD_URL=http://ftp.gnu.org/gnu/libtool
2018

19+
GIT_DOWNLOAD_URL=https://github.com/git/git/archive
20+
2121

2222
function check_var {
2323
if [ -z "$1" ]; then
@@ -113,7 +113,7 @@ function build_cpythons {
113113
function do_openssl_build {
114114
./config no-ssl2 no-shared -fPIC --prefix=/usr/local/ssl > /dev/null
115115
make > /dev/null
116-
make install > /dev/null
116+
make install_sw > /dev/null
117117
}
118118

119119

@@ -135,16 +135,37 @@ function build_openssl {
135135
local openssl_sha256=$2
136136
check_var ${openssl_sha256}
137137
check_var ${OPENSSL_DOWNLOAD_URL}
138-
curl -sSLO ${OPENSSL_DOWNLOAD_URL}/${openssl_fname}.tar.gz
138+
# Can't use curl here because we don't have it yet
139+
wget -q ${OPENSSL_DOWNLOAD_URL}/${openssl_fname}.tar.gz
139140
check_sha256sum ${openssl_fname}.tar.gz ${openssl_sha256}
140141
tar -xzf ${openssl_fname}.tar.gz
141142
(cd ${openssl_fname} && do_openssl_build)
142143
rm -rf ${openssl_fname} ${openssl_fname}.tar.gz
143144
}
144145

146+
function build_git {
147+
local git_fname=$1
148+
check_var ${git_fname}
149+
local git_sha256=$2
150+
check_var ${git_sha256}
151+
check_var ${GIT_DOWNLOAD_URL}
152+
curl -sSLO ${GIT_DOWNLOAD_URL}/v${git_fname}.tar.gz
153+
check_sha256sum v${git_fname}.tar.gz ${git_sha256}
154+
tar -xzf v${git_fname}.tar.gz
155+
(cd git-${git_fname} && do_git_build)
156+
rm -rf git-${git_fname} v${git_fname}.tar.gz
157+
}
158+
159+
function do_git_build {
160+
make LDFLAGS="-L/usr/local/ssl/lib -ldl" CFLAGS="-I/usr/local/ssl/include" > /dev/null
161+
make install > /dev/null
162+
}
163+
145164

146165
function do_curl_build {
147-
LIBS=-ldl ./configure --with-ssl --disable-shared > /dev/null
166+
# We do this shared to avoid obnoxious linker issues where git couldn't
167+
# link properly. If anyone wants to make this build statically go for it.
168+
LIBS=-ldl CFLAGS=-Wl,--exclude-libs,ALL ./configure --with-ssl --disable-static > /dev/null
148169
make > /dev/null
149170
make install > /dev/null
150171
}
@@ -156,11 +177,12 @@ function build_curl {
156177
local curl_sha256=$2
157178
check_var ${curl_sha256}
158179
check_var ${CURL_DOWNLOAD_URL}
159-
curl -sSLO ${CURL_DOWNLOAD_URL}/${curl_fname}.tar.bz2
160-
check_sha256sum ${curl_fname}.tar.bz2 ${curl_sha256}
161-
tar -jxf ${curl_fname}.tar.bz2
162-
(cd ${curl_fname} && do_curl_build)
163-
rm -rf ${curl_fname} ${curl_fname}.tar.bz2
180+
# Can't use curl here because we don't have it yet...we are building it.
181+
wget -q ${CURL_DOWNLOAD_URL}/${curl_fname}.orig.tar.gz
182+
check_sha256sum ${curl_fname}.orig.tar.gz ${curl_sha256}
183+
tar -zxf ${curl_fname}.orig.tar.gz
184+
(cd curl-* && do_curl_build)
185+
rm -rf curl-*
164186
}
165187

166188

0 commit comments

Comments
 (0)