缘起:本人以前一直使用Debian和CentOS,习惯一apt和yum。由于商业发行版包括Loongnix的并不是完全开源的,所以最近一直在折腾孙老师的CLFS和Xen0n大神做的Gentoo。
由于Loongarch推上游的ABI一直在变化,想把现用的Gentoo升级到GLIBC2.36,遇到很多问题,一直没成功。然后在CLFS里面用bootstrap-prefix.sh来构建最新的Gentoo Stage3也一直在到了Stage3的时候遇到了一些自己不能解决的问题。
所以索性就折衷一下,偷个懒,尝试在CLFS里面安装Portage。以下是实现步骤:
一、获取Portage最新代码并安装
git clone https://anongit.gentoo.org/git/proj/portage.git
cd portage/
python3 setup.py build
python3 setup.py install --root=/ --prefix=/usr
二、获取Loongson-overlay
mkdir -pv /var/db/repos/
pushd /var/db/repos/
git clone --dep=1 https://github.com/xen0n/loongson-overlay loongson
popd
三、修改配置文件
mkdir -p /etc/portage/repos.conf
cp /usr/share/portage/config/repos.conf /etc/portage/repos.conf/gentoo.conf
更改为中科大的源
sed -i 's/gentoo.org/mirrors.ustc.edu.cn/g' /etc/portage/repos.conf/gentoo.conf
cat > /etc/portage/repos.conf/loongson.conf << "EOF"
[loongson]
location = /var/db/repos/loongson
sync-type = git
sync-uri = git://github.com/xen0n/loongson-overlay
EOF
cat > /etc/portage/make.conf << "EOF"
# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
COMMON_FLAGS="-O2 -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult https://wiki.gentoo.org/wiki/Changing_the_CHOST_variable before changing.
CHOST="loongarch64-unknown-linux-gnu"
GENTOO_MIRRORS="https://mirrors.ustc.edu.cn/gentoo/"
# NOTE: This stage was built with the bindist Use flag enabled
PORTDIR="/var/db/repos/gentoo"
DISTDIR="/var/cache/distfiles"
PKGDIR="/var/cache/binpkgs"
# This sets the language of build output to English.
# Please keep this setting intact when reporting bugs.
LC_MESSAGES=C
ACCEPT_LICENSE="*"
EOF
ln -sv /var/db/repos/loongson/profiles/default/linux/loong/21.0/lp64v100/lp64d/desktop/systemd/ /etc/portage/make.profile
四、更新仓库
emerge-webrsync
emerge --sync
五、安装软件
因为是在CLFS上安装的Portage,很多CLFS已经安装的软件在/var/db/pkg里面是没有的。所以可以加上--nodeps参数,不检查依赖。以下软件建议先安装
emerge --nodeps sys-apps/gentoo-functions
emerge --nodeps app-misc/pax-utils
参考资料:
https://ahelpme.com/linux/gentoo/fix-your-broken-or-old-portage-in-gentoo-fix-the-emerge-command/
https://bbs.loongarch.org/d/19-gentoo