1 编译安装Podman的前置条件
1.1 更新GCC(重要!)
sudo yum install centos-release-scl
sudo yum install devtoolset-8-gcc devtoolset-8-gcc-c++
scl enable devtoolset-8 bash
这个只会在当前会话中启用新版本的GCC。如果需要可以scl enable devtoolset-8 bash
命令添加到你的.bashrc
文件。
1.2 yum包更新
yum install -y epel-release
yum install -y "@Development Tools"
yum install -y curl gcc make device-mapper-devel git btrfs-progs-devel \
conmon containernetworking-plugins containers-common glib2-devel glibc-devel \
glibc-static golang-github-cpuguy83-md2man iptables libselinux-devel pkgconfig \
systemd-devel autoconf python3 python3-devel python3-pip yajl-devel libcap-devel
yum install -y libseccomp-devel
1.3 安装依赖
在gnupg官网找到以下几个包的最新版本源文件链接,并下载。注意是新版本。
Libgpg-error, Libassuan, nPth, Libgcrypt, Libksba, ntbTLS, GnuPG, GPGME。
注意!如果后文编译时报错发现没有某个lib包,首先要查看是否有下载安装,然后再查看环境变量。比如我已经安装好gpgme,但是编译podman时它仍然报错提示没有gpgme。这时就需要在变量$PKG_CONFIG_PATH添加对应的路径地址。
export PKG_CONFIG_PATH=/usr/local/gpgme/lib/pkgconfig:$PKG_CONFIG_PATH
按照该文podman的编译安装是需要添加如下,但是我在编译安装的过程中还是需要将安装好的库添加到系统环境变量中,否则会报错。但为了防止出错起见,先把下述工作做好。
mkdir /usr/local/pkgconfig
cd /usr/local/pkgconfig
ln -s /usr/local/gpgme/lib/pkgconfig/* ./
ln -s /usr/local/ntbtls/lib/pkgconfig/* ./
ln -s /usr/local/libksba/lib/pkgconfig/* ./
ln -s /usr/local/libgcrypt/lib/pkgconfig/* ./
ln -s /usr/local/libassuan/lib/pkgconfig/* ./
ln -s /usr/local/libgpg-error/lib/pkgconfig/* ./
1.3.1 编辑/etc/profile
注意 source /etc/profile
# PKGCONFIG
export PKG_CONFIG_PATH=/usr/local/pkgconfig
# Libgpg-error
# Libgpg-error
export LIBGPG_ERROR_HOME=/usr/local/libgpg-error
export PATH=$PATH:$LIBGPG_ERROR_HOME/bin
# Libassuan
export LIBASSUAN_HOME=/usr/local/libassuan
export PATH=$PATH:$LIBASSUAN_HOME/bin
# nPth
export NPTH_HOME=/usr/local/npth
export PATH=$PATH:$NPTH_HOME/bin
# Libgcrypt
export LIBGCRYPT_HOME=/usr/local/libgcrypt
export PATH=$PATH:$LIBGCRYPT_HOME/bin
# Libksba
export LIBKSBA_HOME=/usr/local/libksba
export PATH=$PATH:$LIBKSBA_HOME/bin
# ntbTLS
export NTBTLS_HOME=/usr/local/ntbtls
export PATH=$PATH:$NTBTLS_HOME/bin
# GnuPG
export GNUPG_HOME=/usr/local/gnupg
export PATH=$PATH:$GNUPG_HOME/bin
# GPGME
export GPGME_HOME=/usr/local/gpgme
export PATH=$PATH:$GPGME_HOME/bin
1.3.2 Libgpg-error
cd /usr/local/src
curl -LO "https://gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.48.tar.bz2"
tar xjvf libgpg-error-1.48.tar.bz2
cd libgpg-error-1.48
./configure --prefix=/usr/local/libgpg-error
make -j $(nproc)
make install
1.3.3 安装Libassuan
必须将configure的gpg-error-config更改为gpgrt-config。
cd /usr/local/src
curl -LO "https://gnupg.org/ftp/gcrypt/libassuan/libassuan-2.5.7.tar.bz2"
tar xjvf libassuan-2.5.7.tar.bz2
cd libassuan-2.5.7
sed -i 's/gpg-error-config/gpgrt-config/g' configure
./configure --prefix=/usr/local/libassuan \
--with-libgpg-error-prefix=/usr/local/libgpg-error
make -j $(nproc)
make install
1.3.4 安装nPth
这个不要安装1.7版本,会有问题(截至2023-3-15,不知道未来版本会不会有问题)。
注意编译安装后:
export LD_LIBRARY_PATH=/usr/local/npth/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=/usr/local/npth/lib/pkgconfig:$PKG_CONFIG_PATH
cd /usr/local/src
curl -LO "https://gnupg.org/ftp/gcrypt/npth/npth-1.6.tar.bz2"
tar xjvf npth-1.6.tar.bz2
cd npth-1.6
./configure --prefix=/usr/local/npth
make -j $(nproc)
make install
1.3.5 安装Libgcrypt
export PATH=$LIBGPG_ERROR_HOME/bin:$PATH
cd /usr/local/src
curl -LO "https://gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.10.3.tar.bz2"
tar xjvf libgcrypt-1.10.3.tar.bz2
cd libgcrypt-1.10.2
./configure --prefix=/usr/local/libgcrypt \
--with-libgpg-error-prefix=/usr/local/libgpg-error
make -j $(nproc)
make install
1.3.6 安装Libksba
cd /usr/local/src
curl -LO "https://gnupg.org/ftp/gcrypt/libksba/libksba-1.6.6.tar.bz2"
tar xjvf libksba-1.6.6.tar.bz2
cd libksba-1.6.6
./configure --prefix=/usr/local/libksba \
--with-libgpg-error-prefix=/usr/local/libgpg-error
make -j $(nproc)
make install
1.3.7 安装ntbTLS
cd /usr/local/src
curl -LO "https://gnupg.org/ftp/gcrypt/ntbtls/ntbtls-0.3.2.tar.bz2"
tar xjvf ntbtls-0.3.2.tar.bz2
cd ntbtls-0.3.2
./configure --prefix=/usr/local/ntbtls \
--with-ksba-prefix=/usr/local/libksba \
--with-libgcrypt-prefix=/usr/local/libgcrypt \
--with-libgpg-error-prefix=/usr/local/libgpg-error
make -j $(nproc)
make install
如果报错找不到zlib.h文件,就 yum install zlib-devel 。但是我没遇到这种情况。
1.3.8 安装 GnuPG (坑多)
cd /usr/local/src
curl -LO "https://gnupg.org/ftp/gcrypt/gnupg/gnupg-2.4.5.tar.bz2"
tar xjvf gnupg-2.4.5.tar.bz2
cd gnupg-2.4.5
./configure --prefix=/usr/local/gnupg \
--without-libintl-prefix \
--without-libiconv-prefix \
--with-npth-prefix=/usr/local/npth \
--with-ntbtls-prefix=/usr/local/ntbtls \
--with-ksba-prefix=/usr/local/libksba \
--with-libgcrypt-prefix=/usr/local/libgcrypt \
--with-libassuan-prefix=/usr/local/libassuan \
--with-libgpg-error-prefix=/usr/local/libgpg-error
make -j $(nproc)
make install
1.3.9 安装GPGME(就是因为centos自带的GPGME版本低,所以podman编译前要这么多前摇)
cd /usr/local/src
curl -LO "https://gnupg.org/ftp/gcrypt/gpgme/gpgme-1.23.2.tar.bz2"
tar xjvf gpgme-1.23.2.tar.bz2
vim /usr/local/src/gpgme-1.23.2/tests/gpg/gpg.conf # 注释掉第5行
export LD_LIBRARY_PATH=/usr/local/libksba/lib:/usr/local/libgcrypt/lib:/usr/local/npth/lib:/usr/local/libgpg-error/lib
cd gpgme-1.23.2
./configure --prefix=/usr/local/gpgme \
--with-libassuan-prefix=/usr/local/libassuan \
--with-libgpg-error-prefix=/usr/local/libgpg-error
make -j $(nproc)
make install
2 Podman安装
2.1 安装组件
2.1.1 安装golang
cd /usr/local/src
curl -LO "https://go.dev/dl/go1.22.1.linux-amd64.tar.gz"
tar xzvf go1.22.1.linux-amd64.tar.gz -C /usr/local/
mkdir /usr/local/gopath
在/etc/profile添加
export GO_HOME=/usr/local/go
export GOPATH=/usr/local/gopath
export PATH=$PATH:$GO_HOME/bin
source /etc/profile
2.1.2 安装runc (你也可以选择crun)
# git clone https://github.com/opencontainers/runc.git $GOPATH/src/github.com/opencontainers/runc
curl -LO https://github.com/opencontainers/runc/archive/refs/tags/v1.1.10.tar.gz
tar -xzvf v1.1.10.tar.gz -C $GOPATH/src/github.com/opencontainers
cd $GOPATH/src/github.com/opencontainers/runc
make BUILDTAGS="selinux seccomp"
sudo cp runc /usr/bin/runc
2.1.3 安装conmon
git clone https://github.com/containers/conmon.git /usr/local/src/conmon
cd /usr/local/src/conmon
export GOCACHE="$(mktemp -d)"
make -j $(nproc)
make install
2.1.4 安装criu
在Alibaba Cloud Linux 3.2104 LTS 64位操作系统,下述会有问题的。
yum install protobuf protobuf-c protobuf-c-devel protobuf-compiler protobuf-devel protobuf-python -y
yum install pkg-config python-ipaddr libbsd iproute2 libcap-devel libnet-devel libnl3-devel -y
yum install asciidoc xmlto -y
curl -LO https://github.com/checkpoint-restore/criu/releases/tag/v3.17.1
tar -zxvf v3.17.1.tar.gz -C /usr/local/src
cd /usr/local/src/criu-3.17.1
make && make install
2.2 编译安装Podman
curl -LO https://github.com/containers/podman/archive/refs/tags/v4.9.3.tar.g
tar -xzvf v4.9.3.tar.g -C /usr/local/src
cd /usr/local/src/podman-4.9.3
make -j $(nproc) BUILDTAGS="selinux seccomp"