Gentoo升级profile
大约两个月没有使用Gentoo,最近一次 Gentoo emerge 升级,发现提示有最新的profile需要切换:
!!! Your current profile is deprecated and not supported anymore.
!!! Use eselect profile to update your profile.
!!! Please upgrade to the following profile if possible:
default/linux/amd64/23.0/split-usr/no-multilib
To upgrade do the following steps:
A profile upgrade to version 23.0 is available for your architecture.
The new 23.0 profiles enable some toolchain hardening features and
performance enhancements by default, and standardize settings.
You can find the list of changes on the wiki tracking page [1].
Upgrade instructions
Note 1: If you have manually changed your CHOST to a value different from
what the stages and profiles set, you may have to do that in the future too.
In that case you should know what you are doing, hopefully; please read the
instructions with a critical eye then.
Note 2: In case you are already familiar with binary packages, you should be
able to add "--getbinpkg" to the emerge calls to speed things up.
The use of binary packages is completely optional though, and also not
as much tested as the source-based upgrade path yet.
1. Ensure your system backups are up to date. Please also update
your system fully and depclean before proceeding.
glibc older than 2.36 and musl older than 1.2.4 is not supported anymore.
2. If you are still using one of the long-deprecated amd64 17.0 profiles
(other than x32 or musl), then first complete the migration to the
corresponding 17.1 profile. Instructions can be found at [3].
3. If you are currently using systemd in a split-usr configuration, then first
complete the migration to the corresponding merged-usr profile of the
same profile version. Details on how to do this can be found in the news
item [4].
If you are currently using openrc, migrate to 23.0 first, keeping your disk
layout. If you want to move from split-usr to merged-usr, do that afterwards.
4. Run "emerge --info" and note down the value of the CHOST variable.
5. Edit /etc/portage/make.conf; if there is a line defining the CHOST variable,
remove it. Also delete all lines defining CHOST_... variables.
6. Select the 23.0 profile corresponding to your current profile, either using
"eselect profile" or by manually setting the profile symlink.
Note that old profiles are by default split-usr and the 23.0 profiles by
default merged-usr. Do NOT change directory scheme now, since this will
mess up your system!
Instead, make sure that the new profile has the same property: for example,
OLD default/linux/amd64/17.1
==> NEW default/linux/amd64/23.0/split-usr
(added "split-usr")
OLD default/linux/amd64/17.1/systemd/merged-usr
==> NEW default/linux/amd64/23.0/systemd
(removed "merged-usr")
A detailed table of the upgrade paths can be found at [5]. Please consult it.
In some cases (hppa, x86) the table will tell you to pick between two choices.
What you need should be obvious from your *old* CHOST value (from step 4).
7. Delete the contents of your binary package cache at ${PKGDIR}
rm -r /var/cache/binpkgs/*
8. In the file or directory /etc/portage/binrepos.conf (if existing), update
the URI in all configuration such that they point to 23.0 profile binhost
directories. The exact paths can be found in the table at [5], too.
9. Rebuild or reinstall from binary (if available) the following packages in
this order, with the same version as already active:
emerge --ask --oneshot sys-devel/binutils
(you may have to run binutils-config and re-select your binutils now)
emerge --ask --oneshot sys-devel/gcc
(IMPORTANT: If this command wants to rebuild glibc first, do *not* let it do
that; instead, abort and try again with --nodeps added to the command line.)
(you may have to run gcc-config and re-select your gcc now)
and the C library, i.e. for glibc-based systems
emerge --ask --oneshot sys-libs/glibc
or for musl-based systems
emerge --ask --oneshot sys-libs/musl
10. Re-run "emerge --info" and check if CHOST has changed compared to step 4.
If the CHOST has NOT changed, skip to step 13 (env-update). Otherwise,
11. Recheck with binutils-config and gcc-config that valid installed versions
of binutils and gcc are selected.
12. Check /etc/env.d, /etc/env.d/binutils, and /etc/env.d/gcc for files that
refer to the *OLD* CHOST value, and remove them.
Examples how to do this can be found in the similar procedure at [6].
13. Run env-update && source /etc/profile
14. Re-emerge libtool:
emerge --ask --oneshot libtool
15. Just for safety, delete the contents of your binary package cache at
${PKGDIR} again:
rm -r /var/cache/binpkgs/*
16. Rebuild world:
emerge --ask --emptytree @world
[1] https://wiki.gentoo.org/wiki/Project:Toolchain/23.0_profile_transition
[2] https://wiki.gentoo.org/wiki/Project:Toolchain/23.0_profile_timeline
[3] https://www.gentoo.org/support/news-items/2019-06-05-amd64-17-1-profiles-are-now-stable.html
[4] https://www.gentoo.org/support/news-items/2022-12-01-systemd-usrmerge.html
[5] https://wiki.gentoo.org/wiki/Project:Toolchain/23.0_update_table
[6] https://wiki.gentoo.org/wiki/Changing_the_CHOST_variable#Verifying_things_work
* IMPORTANT: 23 news items need reading for repository 'gentoo'.
* Use eselect news read to view new items.
* IMPORTANT: 6 config files in '/etc/portage' need updating.
* See the CONFIGURATION FILES and CONFIGURATION FILES UPDATE TOOLS
* sections of the emerge man page to learn how to update config files.
These are the packages that would be merged, in order:
Calculating dependencies... done!
Dependency resolution took 33.78 s (backtrack: 4/20).
[ebuild U ] sys-libs/ncurses-6.4_p20240414:0/6::gentoo [6.4_p20230401:0/6::gentoo] ...
...
备注
本文为一次profile实践笔记,作为大版本profile升级参考。具体升级方法,需要参考官方提示
升级profile提示概述
需要确保
CHOST
配置符合要求(默认配置不要修改)确保系统已经备份并且已经更新早最新版本: 不支持低于2.36版本的glibc和低于1.2.4的musl
如果仍然在使用已经长期废弃的amd 17.0 profiles(和x32或musl不同),则需要首先迁移到相应的17.1 profile
如果当前使用split-user配置的 Systemd进程管理器 ,则首先需要迁移到正确的 merged-usr prfile(相同的profile版本)
如果当前使用 OpenRC 则首先迁移到 23.0,如果想从split-usr改成merged-usr,需要在迁移23.0之后执行
检查
emerge --info
输出信息,查看CHOST
变量,我的输出是:CHOST="x86_64-pc-linux-gnu"
编辑
/etc/portage/make.conf
如果有 CHOST 变量,需要删除掉这个变量 也要删除掉所有定义CHOST_...
变量通过
eselect profile
选择(或者手工修改符号连接),但是需要注意旧版本profile默认是split-usr
,而 23.0 profile默认是merged-usr
: 请根据 Gentoo Project:Toolchain/23.0 update table 选择升级的profile,基本规律是如果是 Systemd进程管理器 系统,则需要先参考 /usr merge for systemd users 迁移到merged-user
,然后再做profile升级(需要执行merge-usr
工具)
备注
所谓 merged-usr
是指从 2023 年年中开始, Systemd进程管理器 不再支持 split-usr/unmerged-usr
系统,必须将原先的 /bin
, /sbin
, /lib
迁移到 /usr/bin
/usr/sbin
和 /usr/lib
目录。所有位于 /
目录下的系统目录则建立软链接。
确保新的profile使用了相同的属性: 例如旧版(这里以我自己的案例 eselect profile list
输出)
...
[10] default/linux/amd64/17.1/desktop/systemd/merged-usr (exp)
[11] default/linux/amd64/17.1/developer (exp)
[12] default/linux/amd64/17.1/no-multilib (exp) *
[13] default/linux/amd64/17.1/no-multilib/hardened (exp)
[14] default/linux/amd64/17.1/no-multilib/hardened/selinux (exp)
...
[27] default/linux/amd64/23.0/desktop/plasma (stable)
[28] default/linux/amd64/23.0/desktop/plasma/systemd (stable)
[29] default/linux/amd64/23.0/no-multilib (stable)
[30] default/linux/amd64/23.0/no-multilib/systemd (stable)
[31] default/linux/amd64/23.0/no-multilib/hardened (stable)
...
[47] default/linux/amd64/23.0/split-usr/desktop/gnome (stable)
[48] default/linux/amd64/23.0/split-usr/desktop/plasma (stable)
[49] default/linux/amd64/23.0/split-usr/no-multilib (stable)
[50] default/linux/amd64/23.0/split-usr/no-multilib/selinux (stable)
[51] default/linux/amd64/23.0/split-usr/no-multilib/hardened (stable)
...
则应该先升级到 23.0 的相同的 split-usr
(上述第16行): 对于 OpenRC 系统,没有类似 Systemd进程管理器 强制转换成 merged-usr
的要求,所以我的修订profile是:
# default/linux/amd64/17.1/no-multilib ==> default/linux/amd64/23.0/split-usr/no-multilib
eselect profile set 49
删除缓存目录的二进制包:
rm -r /var/cache/binpkgs/*
重新编译或者重新安装二进制包,顺序如下:
emerge --ask --oneshot sys-devel/binutils
# 注意,如果编译gcc的时候提示需要首先重建glibc,一定要避免,则加上 --nodeps 参数
#emerge --ask --oneshot sys-devel/gcc
# 我实践发现,确实默认会依赖先重建glibc,所以我的最终解决执行的命令是
emerge --ask --oneshot --nodeps sys-devel/gcc
# 然后再编译安装glibc
emerge --ask --oneshot sys-libs/glibc
# 对于musl系统,则使用
# emerge --ask --oneshot sys-libs/musl
重新运行
emerge --info
检查CHOST输出,看是否和前面执行这个命令的 CHOST 一致:如果一致,则直接执行
env-update && source /etc/profile
如果不一致,则需要(我没有实践,因为我检查前后两次
emerge --info
输出的CHOST
变量一致)重新检查
binutils-config
和gcc-config
验证安装的binutils和gcc版本检查
/etc/env.d
,/etc/env.d/binutils
和/etc/ev.d/gcc
确保没有 旧 的CHOST值引用,并移除
重新 Gentoo emerge
libtool
:
emerge --ask --oneshot libtool
出于安全考虑,删除缓存
${PKGDIR}
目录下的二进制软件包缓存:
rm -r /var/cache/binpkgs/*
最后,重建world:
emerge --ask --emptytree @world