Building Environment

How to prepare VM env for building PostgreSQL RPM/DEB extensions, EL 8/9,Debian12,Ubuntu22。

VM

To build PGML RPM packages in EL / Debian environment, you need to prepare a virtual machine environment. Pigsty provides a ext.yml template that can be used to prepare the virtual machine environment required for building.

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

It will launch four virtual machines with EL8, EL9, Debian12, and Ubuntu22 respectively, and install the necessary dependencies for building.


Proxy

If you are in a network environment that requires a proxy, you need to configure the proxy environment variables.

Here we assume that you have a proxy server available in your local environment: http://192.168.0.106:8118 (replace with your OWN proxy server).

PROXY=http://192.168.0.106: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"

Adding the following lines to ~/.ssh/config will make git clone via HTTPS proxy (optional):

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

If the following command can connect to GitHub, then the proxy is correctly configured:

ssh -T git@github.com

Alias

You can use the following Alias to switch between different PG versions environment in the EL environment:

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

And the following Alias for Debian environment:

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

Tools

You’ll have to group install additional 'Development Tools' components in EL 8 / EL 9 environment. In EL8, you need to add the --nobest option to complete the installation due to dependency errors.

sudo yum groupinstall --nobest -y 'Development Tools';
rpmdev-setuptree  # setup rpmbuild environment

Last modified 2024-10-19: bump proxy example (25423493)