-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.sh
executable file
·63 lines (52 loc) · 2.35 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh
CDIR=$(pwd)
SRCDIR="${CDIR}/src"
NUMCORE=$(cat /proc/cpuinfo | grep -c cores)
export NUMCORE
rm -rf src
mkdir -p src
cd src
if [ ! -d "incubator-pagespeed-mod" ]; then
git clone -c advice.detachedHead=false --recursive https://github.com/apache/incubator-pagespeed-mod.git
cd incubator-pagespeed-mod
else
cd incubator-pagespeed-mod
git pull --recurse-submodules
fi
# Do a hard reset to the last working commit (before bazel got introduced)
git reset --hard 409bd76
# init and update all submodules (removed after #409bd76)
git submodule update --init --recursive --jobs=${NUMCORE} --force
# Fix conflict with gettid
# based on
# https://github.com/apache/incubator-pagespeed-mod/issues/2040
# https://github.com/tensorflow/tensorflow/issues/33758
sed -i 's/static long gettid/static long sys_gettid/g' third_party/grpc/src/src/core/lib/support/log_linux.c
sed -i -e 's/tid = gettid()/tid = sys_gettid()/g' third_party/grpc/src/src/core/lib/support/log_linux.c
sed -i 's/static intptr_t gettid/static intptr_t sys_gettid/g' third_party/grpc/src/src/core/lib/support/log_posix.c
sed -i -e 's/ gettid()/ sys_gettid()/g' third_party/grpc/src/src/core/lib/support/log_posix.c
# Apply some handpicked PR's from https://github.com/apache/incubator-pagespeed-mod/
for PR in `ls ${CDIR}/pr`
do
patch -p1 < ${CDIR}/pr/${PR}
done
# Add more jobs ($NUMCORE) to the make arguments
sed -i s/"MAKE_ARGS=(V=1 BUILDTYPE=\$buildtype)"/"MAKE_ARGS=(V=1 -j${NUMCORE} BUILDTYPE=\$buildtype)"/ install/build_psol.sh
# Fix log output, we run in docker so it should go to STDOUT
sed -i /"run_with_log log\/install_deps.log"/d install/build_psol.sh
sed -i s/"run_with_log log\/gyp.log"//g install/build_psol.sh
sed -i s/"run_with_log log\/psol_build.log"//g install/build_psol.sh
sed -i /"run_with_log \.\.\/\.\.\/log\/psol_automatic_build.log"/d install/build_psol.sh
# Build dockers and build psol from docker/bootstrap.sh
# jammy and higher have to go last, because of the sed for glibc functions in the docker
cd ${CDIR}
for DIST in focal bionic xenial trusty jammy
do
cp docker/Dockerfile-template docker/Dockerfile
sed -i s/OS/ubuntu-base/ docker/Dockerfile
sed -i s/DIST/${DIST}/ docker/Dockerfile
cd docker
docker build --no-cache -t eilandert/psol:${DIST} .
docker run --volume ${SRCDIR}:/usr/src eilandert/psol:${DIST}
cd ..
done