SVN从源码构建

本文讲解SVN从源码的构建流程,和其中遇到的一些问题。

在install依赖库的时候通过configure --prefix指定install路径,其他项目引用依赖库的时候--with-来指定依赖库的install路径。

详细命令

apr

1
2
3
4
wget http://mirror.bit.edu.cn/apache//apr/apr-1.7.0.tar.gz
./buildconf
./configure --prefix=/root/subversion_build/third/apr
make -j5 && make install

apr-util

1
2
3
4
5
wget http://mirror.bit.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
./buildconf --with-apr=../apr-1.7.0
./configure --prefix=/root/subversion_build/third/apr-util --with-apr=/root/subversion_build/third/apr/
yum install expat-devel
make -j5 && make install

qlite

1
2
3
wget http://www.sqlite.org/2017/sqlite-autoconf-3210000.tar.gz
./configure --prefix=/root/subversion_build/third/sqlite
make -j5 && make install

scons

1
2
wget http://prdownloads.sourceforge.net/scons/scons-2.5.0.tar.gz
python setup.py install

openssl

1
2
3
4
wget https://www.openssl.org/source/old/1.0.1/openssl-1.0.1u.tar.gz
./config --prefix=/root/subversion_build/third/openssl -fPIC no-gost
make depend
make install

serf

serf主要是为了提供http方式的checkout
serf编译会有问题,需要参考本文做一些修改

1
2
3
4
5
6
wget https://www.apache.org/dist/serf/serf-1.3.9.tar.bz2
sed -i 's/OPENSSL_VERSION_NUMBER >= 0x10100000L/OPENSSL_VERSION_NUMBER >= 0x10100000L \&\& !defined(LIBRESSL_VERSION_NUMBER)/' buckets/ssl_buckets.c
sed -i 's/OPENSSL_VERSION_NUMBER >= 0x10100000L/OPENSSL_VERSION_NUMBER >= 0x10100000L \&\& !defined(LIBRESSL_VERSION_NUMBER)/' test/server/test_sslserver.c
scons -c
scons PREFIX=/usr/local/serf APR=/root/subversion_build/third/apr/bin/apr-1-config APU=/root/subversion_build/third/apr-util/bin/apu-1-config OPENSSL=/root/subversion_build/third/openssl/
scons install

subversion

这里需要将openss和serf加到PKG_CONFIG_PATH里面,否则会导致configure失败。
此外,还有可能出现expat缺失的问题,这个最好不要从源码编译了,因为--with-expat的配置有点麻烦。我们可以直接下载expact-devel包即可。

1
2
3
export PKG_CONFIG_PATH=/usr/local/serf/lib/pkgconfig:/root/subversion_build/third/openssl/lib/pkgconfig
./configure --with-apr=/root/subversion_build/third/apr --with-apr-util=/root/subversion_build/third/apr-util/ --with-sqlite=/root/subversion_build/third/sqlite --with-lz4=internal --with-utf8proc=internal --with-serf=/usr/local/serf --enable-mod-activation
make -j5 && make install

如果出现

1
2
# svn --version
svn: error while loading shared libraries: libserf-1.so.1: cannot open shared object file: No such file or directory

1
ln -s /usr/local/serf/lib/libserf-1.so.1.3.0 /usr/lib64/libserf-1.so.1

注意pkg-config返回错误码,而不是打印,所以最好加上--print-errors获取错误,如

1
/usr/bin/pkg-config /usr/local/serf/lib/pkgconfig/serf-1.pc  --exists --print-errors