我有 CentOS 7,并且想安装 OpenSUSE Leap 的 chroot 环境进行测试。
我怎么做?
答案1
yum install mock
mock -r opensuse-leap-15.3-x86_64 shell
或者如果你想为 Leap 构建包
mock -r opensuse-leap-15.3-x86_64 your_package.src.rpm
chroot 下可以使用的配置列表如下/etc/mock/
答案2
首先在 CentOS 中创建一个 repo 文件:
===> cat /etc/yum.repos.d/opensuse-leap-15.3.repo
[opensuse-leap-15.3]
name=OpenSUSE Leap 15.3
baseurl=https://download.opensuse.org/distribution/leap/15.3/repo/oss/
enabled=0
gpgcheck=0
#gpgkey=
创建 chroot 和 RPM 目录
mkdir /mnt/opensuse-leap-15.3
mkdir /mnt/opensuse-leap-15.3/var/lib/rpm -p
挂载 /dev、proc 和 sysfs
for i in proc sys dev; do
mkdir -p /mnt/opensuse-leap-15.3/$i
mount --bind /$i /mnt/opensuse-leap-15.3/$i
done
初始化 RPM 数据库
rpm --root /mnt/opensuse-leap-15.3 --initdb
部署!
yum --disablerepo=\* --enablerepo=opensuse-leap-15.3 --installroot=/mnt/opensuse-leap-15.3 install aaa_base rpm-repos-openSUSE-Leap bash zypper util-linux
进入 chroot:
chroot /mnt/opensuse-leap-15.3 /bin/su -
el7-dev:~ #
其余命令位于 chroot 内:
设置DNS:
echo nameserver 1.1.1.1 > /etc/resolv.conf
添加 zypper 存储库:
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-openSUSE
zypper ar -r /etc/yum.repos.d/opensuse-leap-oss.repo
以下是其他一些不错的软件包:
zypper install vim openssl ca-certificates wget curl
您可能希望导入 RPM 签名密钥:
rpm --import https://download.opensuse.org/distribution/leap/15.3/repo/oss/gpg-pubkey-3dbdc284-53674dd4.asc
rpm --import https://download.opensuse.org/distribution/leap/15.3/repo/oss/gpg-pubkey-39db7c82-5847eb1f.asc
rpm --import https://download.opensuse.org/distribution/leap/15.3/repo/oss/gpg-pubkey-307e3d54-5aaa90a5.asc
rpm --import https://download.opensuse.org/distribution/leap/15.3/repo/oss/gpg-pubkey-65176565-59787af5.asc