This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

构建打包

如何准备构建 PostgreSQL rpm/deb 扩展包的环境,以及重要扩展的构建打包方式。

1 - 虚拟机构建环境

如何制备构建 Pigsty 扩展所需的虚拟机环境:EL 8/9,Debian12,Ubuntu22。

准备虚拟机

想要在 EL / Debian 环境下构建 PGML RPM 包,需要准备虚拟机环境,Pigsty 提供 ext.yml 模板,用于准备构建所需的虚拟机环境

cd pigsty
make build
./node.yml -i conf/build/ext.yml -t node_repo,node_pkg

在该配置下,Pigsty 默认提供 EL8,EL9,Debian12,Ubuntu22 四台虚拟机,并安装构建所需的依赖软件包。


代理服务器

如果您的网络条件不佳,最好配置一个 HTTP 代理,例如,假设你的本地环境中,有一台可用的代理服务器: http://192.168.0.106:8118(需要换成你自己的地址)。那么 EL 环境下的环境变量配置如下:

PROXY=http://192.168.0.107:8118
export HTTP_PROXY=${PROXY}
export HTTPS_PROXY=${PROXY}
export ALL_PROXY=${PROXY}
export NO_PROXY="localhost,127.0.0.1,10.0.0.0/8,192.168.0.0/16,*.pigsty,*.aliyun.com,mirrors.*,*.myqcloud.com,*.tsinghua.edu.cn"
alias build="HTTPS_PROXY=${PROXY} cargo pgrx package -v"

编辑 ~/.ssh/config 文件,添加代理配置,让 Github git 克隆走 HTTPS 代理(可选):

Host github.com
    Hostname ssh.github.com
    Port 443
    User git

如果以下命令可以成功执行,说明 github 代理配置成功:


快捷别名

EL 环境下,可以使用以下 Alias 便捷地切换 PG 环境:

alias pg17="export PATH=/usr/pgsql-17/bin:~/.cargo/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
alias pg16="export PATH=/usr/pgsql-16/bin:~/.cargo/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
alias pg15="export PATH=/usr/pgsql-15/bin:~/.cargo/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
alias pg14="export PATH=/usr/pgsql-14/bin:~/.cargo/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
alias pg13="export PATH=/usr/pgsql-13/bin:~/.cargo/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
alias pg12="export PATH=/usr/pgsql-12/bin:~/.cargo/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"

而 Debian / Ubuntu 环境下则使用以下的 Alias:

alias pg17="export PATH=/usr/lib/postgresql/17/bin:~/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin;"
alias pg16="export PATH=/usr/lib/postgresql/16/bin:~/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin;"
alias pg15="export PATH=/usr/lib/postgresql/15/bin:~/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin;"
alias pg14="export PATH=/usr/lib/postgresql/14/bin:~/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin;"
alias pg13="export PATH=/usr/lib/postgresql/13/bin:~/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin;"
alias pg12="export PATH=/usr/lib/postgresql/12/bin:~/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin;"

安装构建工具链

在 EL 8 / EL 9 环境中,还需要额外安装 'Development Tools' 组件。其中,EL8 因为依赖错漏问题,需要添加 --nobest 选项才能完成安装。

sudo yum groupinstall --nobest -y 'Development Tools';
rpmdev-setuptree  # 在当前用户家目录下创建 rpmbuild 目录

2 - 准备 rust 与 pgrx

编译 Rust 扩展需要安装 Rust 与 pgrx ,这里是配置说明与扩展编译的清单与手册。

安装Rust

如果需要构建 Rust 扩展,需要安装 rustpgrx

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"

安装 pgrx,注意 版本

cargo install --locked cargo-pgrx@${PGRX_VER-'0.12.7'} # <--- 
cargo install --locked cargo-pgrx@${PGRX_VER-'0.11.3'}
cargo install --locked cargo-pgrx@${PGRX_VER-'0.10.2'}
cargo pgrx init
配置 Rust Cargo 使用中国镜像(可选)
mkdir -vp ${CARGO_HOME:-$HOME/.cargo};
cat > ${CARGO_HOME:-$HOME/.cargo}/config << EOF
[source.crates-io]
replace-with = 'mirror'

[source.mirror]
registry = "sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/"
EOF
env RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup rustup install stable


Rust扩展清单

Vendor Name Version PGRX License PG Ver Deps
Supabase pg_graphql v1.5.9 v0.12.5 Apache-2.0 17,16,15
Supabase pg_jsonschema v0.3.2 v0.12.5 Apache-2.0 17,16,15,14,13,12
Supabase wrappers v0.4.3 v0.12.6 Apache-2.0 17,16,15,14
TimescaleDB vectorscale v0.3.0 v0.12.5 PostgreSQL 17,16,15,14,13,12
kelvich pg_tiktoken v0.0.1 v0.12.6 Apache-2.0 16,15,14,13,12
PostgresML pgml v2.9.3 v0.11.3 MIT 16,15,14
Tembo pg_vectorize v0.17.0 v0.11.3 PostgreSQL 16,15,14 pgmq, pg_cron
Tembo pg_later v0.1.1 v0.11.3 PostgreSQL 16,15,14,13 pgmq
kaspermarstal plprql v0.1.0 v0.11.3 Apache-2.0 16,15,14,13,12
VADOSWARE pg_idkit v0.2.3 v0.12.5 Apache-2.0 17,16,15,14,13,12
pgsmcrypto pgsmcrypto v0.1.0 v0.12.6 MIT 17,16,15,14,13,12
rustprooflabs pgdd v0.5.2 v0.10.2 MIT 16,15,14,13,12
CrunchyData pg_parquet v0.1.0 v0.12.6 PostgreSQL 17, 16

下载并构建Rust扩展

cd ~;
cd ~; git clone --recursive [email protected]:postgresml/postgresml.git  ; cd ~/postgresml     && git checkout v2.9.3
cd ~; git clone [email protected]:supabase/pg_graphql.git                ; cd ~/pg_graphql     #&& git checkout v1.5.8             
cd ~; git clone [email protected]:supabase/pg_jsonschema.git             ; cd ~/pg_jsonschema  #&& git checkout v0.3.2       
cd ~; git clone [email protected]:supabase/wrappers.git                  ; cd ~/wrappers       && git checkout v0.4.3               
cd ~; git clone [email protected]:Vonng/pgsmcrypto.git                   ; cd ~/pgsmcrypto
cd ~; git clone [email protected]:Vonng/pg_tiktoken.git                  ; cd ~/pg_tiktoken
cd ~; git clone [email protected]:VADOSWARE/pg_idkit.git                 ; cd ~/pg_idkit       && git checkout v0.2.4             
cd ~; git clone [email protected]:timescale/pgvectorscale.git            ; cd ~/pgvectorscale  && git checkout 0.4.0                    

cd ~; git clone [email protected]:tembo-io/pg_vectorize.git              ; cd ~/pg_vectorize   && git checkout v0.18.3 
cd ~; git clone [email protected]:tembo-io/pg_later.git                  ; cd ~/pg_later       && git checkout v0.1.3           
cd ~; git clone [email protected]:kaspermarstal/plprql.git               ; cd ~/plprql         && git checkout v1.0.0
cd ~; git clone [email protected]:rustprooflabs/pgdd.git                 ; cd ~/pgdd           && git checkout 0.5.2

cd ~; [email protected]:CrunchyData/pg_parquet.git                       ; cd ~/pg_parquet     && git checkout 0.1.0

#cd ~; git clone [email protected]:tembo-io/pgmq.git                      ; cd ~/pgmq           && git checkout v1.2.1 #v1.3.3
#cd ~; git clone --recursive https://github.com/paradedb/paradedb.git  ; cd ~/paradedb       && git checkout v0.8.6
#cd ~/paradedb;     cargo update

您可以使用扩展别名,批量构建 Rust 扩展:

# pgrx 0.12.6
cd ~/pg_graphql;                  pg17 build; pg16 build; pg15 build; pg14 build;  
cd ~/pg_jsonschema;               pg17 build; pg16 build; pg15 build; pg14 build; pg13 build; pg12 build; 
cd ~/wrappers/wrappers;           pg17 build; pg16 build; pg15 build; pg14 build;
cd ~/pgsmcrypto;                  pg17 build; pg16 build; pg15 build; pg14 build; pg13 build; pg12 build; 
cd ~/pg_tiktoken;                 pg17 build; pg16 build; pg15 build; pg14 build; pg13 build; pg12 build; 
cd ~/pg_idkit;                    pg17 build; pg16 build; pg15 build; pg14 build; pg13 build; pg12 build; 
export RUSTFLAGS="-C target-feature=+avx2,+fma"
cd ~/pgvectorscale/pgvectorscale; pg17 build; pg16 build; pg15 build; pg14 build; pg13 build; 

# pgrx 0.11.3
cd ~/plprql/plprql;               pg16 build; pg15 build; pg14 build; pg13 build; pg12 build;
cd ~/pg_later;                    pg16 build; pg15 build; pg14 build; pg13 build; 
cd ~/pg_vectorize/extension;      pg16 build; pg15 build; pg14 build;
 
# pgrx 0.10.2
cd ~/pgdd;                        pg17 build; pg16 build; pg15 build; pg14 build; pg13 build; pg12 build; 

cd ~/pg_parquet;                  pg17 build; pg16 build;
cd ~/pg_polyline;                 pg17 build; pg16 build; pg15 build; pg14 build; pg13 build; pg12 build; 
cd ~/pg_explain_ui;               pg17 build; pg16 build; pg15 build; pg14 build; pg13 build; pg12 build; 
cd ~/pg_cardano;                  pg17 build; pg16 build; pg15 build; pg14 build; pg13 build; pg12 build; 
cd ~/pg_base58;                   pg17 build; pg16 build; pg15 build; pg14 build; pg13 build; pg12 build; 
cd ~/pg_summarize;                pg17 build; pg16 build; pg15 build; pg14 build; pg13 build; pg12 build; 

3 - PGML 构建指南

构建库内机器学习扩展 PostgresML 需要一些额外的配置

构建 PGML

构建 PostgresML 是相当麻烦的工作,下面是在 EL8 与 EL9 上构建 PGML 的教程。

首先,根据 RPM 构建环境 的说明,配置好 环境与代理,安装 rustpgrx,特别注意 pgml 使用的 pgrx 版本号

准备Python3

安装 Python,并设置为默认版本:

sudo yum install python3.11 python3.11-devel python3-virtualenv openssl openssl-devel cmake pkg-config libomp libomp-devel openblas* llvm llvm-devel lld openblas*
sudo alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
sudo alternatives --set python3 /usr/bin/python3.11
sudo alternatives --set python /usr/bin/python3.11

准备代码仓库

克隆 pgml,并 检出指定版本

cd ~; git clone --recursive [email protected]:postgresml/postgresml.git; 
cd ~/postgresml && git checkout v2.9.3
cd ~/postgresml/pgml-extension

EL8专用编译说明

本节修改在 EL8 上进行,EL9 无需执行此操作。

sudo dnf install gcc-toolset-13
source /opt/rh/gcc-toolset-13/enable
source /opt/rh/gcc-toolset-13/enable
export CC=/opt/rh/gcc-toolset-13/root/usr/bin/gcc
export CXX=/opt/rh/gcc-toolset-13/root/usr/bin/g++
export LD_LIBRARY_PATH=/opt/rh/gcc-toolset-13/root/usr/lib64:$LD_LIBRARY_PATH

在 EL8 上构建时,需要修改 build.rs 文件,在合适的位置添加两行编译选项:

println!("cargo:rustc-link-lib=static=stdc++fs");
println!("cargo:rustc-link-search=native=/opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13");

整个文件应该是这样的:

fn main() {
    #[cfg(target_os = "macos")]
    {
        println!("cargo:rustc-link-search=/opt/homebrew/opt/openblas/lib");
        println!("cargo:rustc-link-search=/opt/homebrew/opt/libomp/lib");
    }

    // PostgreSQL is using dlopen(RTLD_GLOBAL). this will parse some
    // of symbols into the previous opened .so file, but the others will use a
    // relative offset in pgml.so, and will cause a null-pointer crash.
    //
    // hide all symbol to avoid symbol conflicts.
    //
    // append mode (link-args) only works with clang ld (lld)
    println!(
        "cargo:link-args=-Wl,--version-script={}/ld.map",
        std::env::current_dir().unwrap().to_string_lossy(),
    );

    println!("cargo:rustc-link-lib=static=stdc++fs");
    println!("cargo:rustc-link-search=native=/opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13");

    vergen::EmitBuilder::builder().all_git().emit().unwrap();
}

接着修改 Cargo.toml

[build-dependencies] 一节中添加:cc = "1.0"

[build-dependencies]
+++ cc = "1.0"

开始构建

针对 PostgreSQL 16, 15, 14 构建 PGML:

cd ~/postgresml/pgml-extension; pg16 build; pg15 build; pg14 build;

将构建产物放置于 ~/rpmbuild/SOURCES 目录备用

rm -rf ~/rpmbuild/SOURCES/pgml_16; cp -r ~/postgresml/pgml-extension/target/release/pgml-pg16 ~/rpmbuild/SOURCES/pgml_16;
rm -rf ~/rpmbuild/SOURCES/pgml_15; cp -r ~/postgresml/pgml-extension/target/release/pgml-pg15 ~/rpmbuild/SOURCES/pgml_15;
rm -rf ~/rpmbuild/SOURCES/pgml_14; cp -r ~/postgresml/pgml-extension/target/release/pgml-pg14 ~/rpmbuild/SOURCES/pgml_14;

使用 pgml.spec 执行 RPM 打包:

cd ~/rpmbuild/SPECS && make pgml

# 或手工进行构建:
rm -rf ~/rpmbuild/RPMS/x86_64/pgml*.rpm;
rpmbuild --without debuginfo --define "pgmajorversion 16" -ba ~/rpmbuild/SPECS/pgml.spec
rpmbuild --without debuginfo --define "pgmajorversion 15" -ba ~/rpmbuild/SPECS/pgml.spec
rpmbuild --without debuginfo --define "pgmajorversion 14" -ba ~/rpmbuild/SPECS/pgml.spec

4 - PLv8 构建指南

构建 Javascript 存储过程与编程语言支持扩展 PLv8

构建plv8

安装依赖 (EL):

sudo yum groupinstall --nobest -y 'Development Tools'; 
sudo yum install git cmake

克隆代码:

rpmdev-setuptree
cd ~/rpmbuild/SOURCES/
git clone [email protected]:plv8/plv8.git

cd plv8; git checkout v3.2.2
make -j16

基于第一段编译产物,针对不同 PG 大版本制作 RPM 包:

rpmbuild --define "pgmajorversion 16"  -ba ~/rpmbuild/SPECS/plv8.spec
rpmbuild --define "pgmajorversion 15"  -ba ~/rpmbuild/SPECS/plv8.spec
rpmbuild --define "pgmajorversion 14"  -ba ~/rpmbuild/SPECS/plv8.spec
rpmbuild --define "pgmajorversion 13"  -ba ~/rpmbuild/SPECS/plv8.spec
rpmbuild --define "pgmajorversion 12"  -ba ~/rpmbuild/SPECS/plv8.spec

或者:

cd ~/rpmbuild/SPECS && make plv8

5 - ParadeDB 构建指南

构建 ParadeDB 扩展 需要一些额外的注意事项

下面是构建 ParadeDB 扩展插件的教程:

首先,根据 RPM 构建环境 的说明,配置好环境与代理,安装 rustpgrx

安装时特别需要注意 pg_searchpg_lakehouse 使用的 pgrx 版本号

克隆 ParadeDB,并 检出最新版本,完成编译。

cd ~; git clone --recursive [email protected]:paradedb/paradedb.git;
cd ~/paradedb; git checkout v0.8.6

cd ~/paradedb/pg_search/
cargo update

# build pg_search
pg16 build
pg15 build
pg14 build
pg13 build
pg12 build

# move to rpmbuild SOURCES dir
rm -rf ~/rpmbuild/SOURCES/pg_search_16; cp -r ~/paradedb/target/release/pg_search-pg16 ~/rpmbuild/SOURCES/pg_search_16;
rm -rf ~/rpmbuild/SOURCES/pg_search_15; cp -r ~/paradedb/target/release/pg_search-pg15 ~/rpmbuild/SOURCES/pg_search_15;
rm -rf ~/rpmbuild/SOURCES/pg_search_14; cp -r ~/paradedb/target/release/pg_search-pg14 ~/rpmbuild/SOURCES/pg_search_14;
rm -rf ~/rpmbuild/SOURCES/pg_search_13; cp -r ~/paradedb/target/release/pg_search-pg13 ~/rpmbuild/SOURCES/pg_search_13;
rm -rf ~/rpmbuild/SOURCES/pg_search_12; cp -r ~/paradedb/target/release/pg_search-pg12 ~/rpmbuild/SOURCES/pg_search_12;

# packaging with rpmbuild
cd ~/rpmbuild/SPECS && make pg_search
rpmbuild --without debuginfo --define "pgmajorversion 16" -ba ~/rpmbuild/SPECS/pg_search.spec
rpmbuild --without debuginfo --define "pgmajorversion 15" -ba ~/rpmbuild/SPECS/pg_search.spec
rpmbuild --without debuginfo --define "pgmajorversion 14" -ba ~/rpmbuild/SPECS/pg_search.spec
rpmbuild --without debuginfo --define "pgmajorversion 13" -ba ~/rpmbuild/SPECS/pg_search.spec
rpmbuild --without debuginfo --define "pgmajorversion 12" -ba ~/rpmbuild/SPECS/pg_search.spec

pg_lakehouse

cd ~/paradedb/pg_lakehouse/
cargo update

# build pg_lakehouse
pg16 build
pg15 build

# move to rpmbuild SOURCES dir
rm -rf ~/rpmbuild/SOURCES/pg_lakehouse_16;  cp -r ~/paradedb/target/release/pg_lakehouse-pg16   ~/rpmbuild/SOURCES/pg_lakehouse_16;
rm -rf ~/rpmbuild/SOURCES/pg_lakehouse_15;  cp -r ~/paradedb/target/release/pg_lakehouse-pg15   ~/rpmbuild/SOURCES/pg_lakehouse_15;

# packaging with rpmbuild
cd ~/rpmbuild/SPECS && make pg_lakehouse
rpmbuild --without debuginfo --define "pgmajorversion 16" -ba ~/rpmbuild/SPECS/pg_lakehouse.spec
rpmbuild --without debuginfo --define "pgmajorversion 15" -ba ~/rpmbuild/SPECS/pg_lakehouse.spec

6 - DuckDB FDW 构建指南

如何构建 DuckDB FDW 及其依赖的 libduckdb.so 动态链接库。

DuckDB FDW 依赖 libduckdb.so 动态链接库。在 Ubuntu 与 Debian 上,可以直接使用由 DuckDB 官方提供的预编译二进制。

在 EL 系操作系统上,需要从头编译 libduckdb 并使用此版本编译 duckdb_fdw

Pigsty 的 github.com/pgsty/pgsql-rpm 仓库提供了预置的构建模板:

DuckDB 官方已经提供了 libduckdb-src.zip 源码,可以方便地进行构建。


构建注意事项

在 Ubuntu / Debian 上,可以直接使用 DuckDB 官方提供的预编译二进制 libduckdb.so

在 EL8 和 EL9 上需要从源码编译构建 libduckdb

要构建 libduckdb-src,你需要使用与构建 duckdb_fdw 一致的编译环境与参数:

clang++ -c -fPIC -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 duckdb.cpp -o duckdb.o
clang++ -shared -o libduckdb.so *.o

构建 libduckdb RPM 包,可以使用以下命令:

cd ~/rpmbuild/SPECS && make libduckdb

要构建 duckdb_fdw RPM 包,可以使用以下命令:

cd ~/rpmbuild/SPECS && make duckdb_fdw

7 - Parquet S3 FDW 构建指南

构建 Parquet S3 FDW 扩展,及其依赖 libarrow, libparquet, 以及 libaws-cpp 的过程

构建parquet_s3_fdw

扩展 parquet_s3_fdw 有两个主要依赖:arrowawssdk


构建arrow

克隆 arrow 仓库并使用 cmake 构建:

cd ~ ; git clone [email protected]:apache/arrow.git;
mkdir -p ~/arrow/cpp/release; cd ~/arrow/cpp/release;
cmake .. -DARROW_PARQUET=ON -DARROW_S3=ON; make -j8
sudo make install

构建libaws

libaws-cpp 里有许多服务的驱动,但我们只需要两个:cores3

# 安装依赖
sudo yum install libcurl-devel openssl-devel libuuid-devel pulseaudio-libs-devel
# sudo apt-get install libcurl4-openssl-dev libssl-dev uuid-dev libpulse-dev # debian/ubuntu

# 克隆 libaws 仓库 (很大!)
cd ~; git clone --recurse-submodules [email protected]:aws/aws-sdk-cpp.git

mkdir -p ~/aws-sdk-cpp/release; cd ~/aws-sdk-cpp/release;
cmake .. -DBUILD_ONLY="s3"; make -j20
sudo make install

构建libarrow-s3

收集生成的 .so 文件,然后将其打包为一个 RPM / DEB 包:

mkdir -p ~/libarrow-s3
cp -d ~/arrow/cpp/release/release/libarrow.so*                                     ~/libarrow-s3/
cp -d ~/arrow/cpp/release/release/libparquet.so*                                   ~/libarrow-s3/
cp -f ~/aws-sdk-cpp/release/generated/src/aws-cpp-sdk-s3/libaws-cpp-sdk-s3.so      ~/libarrow-s3/
cp -f ~/aws-sdk-cpp/release/src/aws-cpp-sdk-core/libaws-cpp-sdk-core.so            ~/libarrow-s3/
cp -d ~/aws-sdk-cpp/release/lib/libaws-c-event-stream.so*                          ~/libarrow-s3/
cp -d ~/aws-sdk-cpp/release/lib/libs2n.so*                                         ~/libarrow-s3/
cp -d ~/aws-sdk-cpp/release/crt/aws-crt-cpp/libaws-crt-cpp.so                        ~/libarrow-s3/
cp -d ~/aws-sdk-cpp/release/crt/aws-crt-cpp/crt/aws-c-common/libaws-c-common.so*     ~/libarrow-s3/
cp -d ~/aws-sdk-cpp/release/crt/aws-crt-cpp/crt/aws-checksums/libaws-checksums.so*   ~/libarrow-s3/
cp -d ~/aws-sdk-cpp/release/crt/aws-crt-cpp/crt/aws-c-io/libaws-c-io.so*             ~/libarrow-s3/
cp -d ~/aws-sdk-cpp/release/crt/aws-crt-cpp/crt/aws-c-mqtt/libaws-c-mqtt.so*         ~/libarrow-s3/
cp -d ~/aws-sdk-cpp/release/crt/aws-crt-cpp/crt/aws-c-cal/libaws-c-cal.so*           ~/libarrow-s3/
cp -d ~/aws-sdk-cpp/release/crt/aws-crt-cpp/crt/aws-checksums/libaws-checksums.so*   ~/libarrow-s3/
cp -d ~/aws-sdk-cpp/release/crt/aws-crt-cpp/crt/aws-c-s3/libaws-c-s3.so*             ~/libarrow-s3/
cp -d ~/aws-sdk-cpp/release/crt/aws-crt-cpp/crt/aws-c-common/libaws-c-common.so*     ~/libarrow-s3/
cp -d ~/aws-sdk-cpp/release/crt/aws-crt-cpp/crt/aws-c-http/libaws-c-http.so*         ~/libarrow-s3/
cp -d ~/aws-sdk-cpp/release/crt/aws-crt-cpp/crt/aws-c-sdkutils/libaws-c-sdkutils.so* ~/libarrow-s3/
cp -d ~/aws-sdk-cpp/release/crt/aws-crt-cpp/crt/aws-c-auth/libaws-c-auth.so*         ~/libarrow-s3/
cp -d ~/aws-sdk-cpp/release/crt/aws-crt-cpp/crt/aws-c-compression/libaws-c-compression.so* ~/libarrow-s3/

构建生成的 so 文件包含空 RPATH,使用 patchelf 去除 (EL系统):

cd ~/libarrow-s3/
patchelf --remove-rpath libarrow.so.1800.0.0
patchelf --remove-rpath libparquet.so.1800.0.0
patchelf --remove-rpath libaws-cpp-sdk-core.so
patchelf --remove-rpath libaws-cpp-sdk-s3.so

将这些 so 文件整体打包为一个 libarrow-s3 软件包:

cd ~/rpmbuild/SPECS
rpmbuild -ba ~/rpmbuild/SPECS/libarrow-s3.spec
sudo rpm -ivh ~/rpmbuild/RPMS/x86_64/libarrow-s3-17.0.0-1PIGSTY.*