alpine: 适配 3.20

This commit is contained in:
bin456789 2024-05-22 21:53:32 +08:00
parent b1495cb4bd
commit 7c96c4682f
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
2 changed files with 17 additions and 9 deletions

View File

@ -2316,10 +2316,10 @@ EOF
}
mod_initrd_alpine() {
# hack 1 virt 内核添加 ipv6 模块
# hack 1 v3.19 和之前的 virt 内核添加 ipv6 模块
if virt_dir=$(ls -d $tmp_dir/lib/modules/*-virt 2>/dev/null); then
ipv6_dir=$virt_dir/kernel/net/ipv6
if ! [ -f $ipv6_dir/ipv6.ko ]; then
if ! [ -f $ipv6_dir/ipv6.ko ] || ! grep -q ipv6 $tmp_dir/lib/modules/*/modules.builtin; then
mkdir -p $ipv6_dir
modloop_file=$tmp/modloop_file
modloop_dir=$tmp/modloop_dir
@ -2337,7 +2337,7 @@ mod_initrd_alpine() {
fi
insert_into_file init after 'configure_ip\(\)' <<EOF
depmod
modprobe ipv6
[ -d /sys/module/ipv6 ] || modprobe ipv6
EOF
# hack 2 设置 ethx
@ -2701,8 +2701,8 @@ if is_netboot_xyz ||
}; }; then
setos nextos $distro $releasever
else
# alpine 作为中间系统时,使用 3.19
alpine_ver_for_trans=3.19
# alpine 作为中间系统时,使用 3.20
alpine_ver_for_trans=3.20
setos finalos $distro $releasever
setos nextos alpine $alpine_ver_for_trans
fi

View File

@ -156,8 +156,8 @@ update_part() {
udevadm settle
else
# busybox mdev
# -f 好像没用,而且 3.16 没有
mdev -s 2>/dev/null
# -f 好像没用
mdev -sf 2>/dev/null
fi
done
}
@ -1467,12 +1467,20 @@ mount_pseudo_fs() {
fi
}
get_yq_name() {
if grep -q '3\.1[6789]' /etc/alpine-release; then
echo yq
else
echo yq-go
fi
}
create_cloud_init_network_config() {
ci_file=$1
get_netconf_to ethx
get_netconf_to mac_addr
apk add yq
apk add "$(get_yq_name)"
# shellcheck disable=SC2154
yq -i ".network.version=1 |
@ -1550,7 +1558,7 @@ create_cloud_init_network_config() {
# 如果 network.config[1] 没有 address则删除避免低版本 cloud-init 报错
yq -i 'del(.network.config[1] | select(has("address") | not))' $ci_file
apk del yq
apk del "$(get_yq_name)"
}
truncate_machine_id() {