ubuntu: 添加 26.04, 删除 16.04

This commit is contained in:
bin456789
2026-04-24 00:12:09 +08:00
parent ae3ad40c75
commit 22d7a9a238
4 changed files with 61 additions and 103 deletions

View File

@@ -51,7 +51,7 @@ The system requirements for the target system are as follows:
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB |
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ |
| <img width="16" height="16" src="https://github.com/bin456789/reinstall/assets/7548515/f74b3d5b-085f-4df3-bcc9-8a9bd80bb16d" /> Kali | Rolling | 256 MB | 1 ~ 1.5 GB ^ |
| <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 25.10 | 512 MB \* | 2 GB |
| <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 18.04 LTS - 26.04 LTS | 512 MB \* | 2 GB |
| <img width="16" height="16" src="https://img.alicdn.com/imgextra/i1/O1CN01oJnJZg1yK4RzI4Rx2_!!6000000006559-2-tps-118-118.png" /> Anolis | 7, 8, 23 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL &nbsp;<img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux &nbsp;<img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky &nbsp;<img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9, 10 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://opencloudos.org/qq.ico" /> OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB |
@@ -168,7 +168,7 @@ bash reinstall.sh anolis 7|8|23
alpine 3.20|3.21|3.22|3.23
opensuse 15.6|16.0|tumbleweed
openeuler 20.03|22.03|24.03|25.09
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
ubuntu 18.04|20.04|22.04|24.04|26.04 [--minimal]
kali
arch
gentoo

View File

@@ -51,7 +51,7 @@
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB |
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ |
| <img width="16" height="16" src="https://github.com/bin456789/reinstall/assets/7548515/f74b3d5b-085f-4df3-bcc9-8a9bd80bb16d" /> Kali | 滚动 | 256 MB | 1 ~ 1.5 GB ^ |
| <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 25.10 | 512 MB \* | 2 GB |
| <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 18.04 LTS - 26.04 LTS | 512 MB \* | 2 GB |
| <img width="16" height="16" src="https://img.alicdn.com/imgextra/i1/O1CN01oJnJZg1yK4RzI4Rx2_!!6000000006559-2-tps-118-118.png" /> Anolis | 7, 8, 23 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL &nbsp;<img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux &nbsp;<img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky &nbsp;<img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9, 10 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://opencloudos.org/qq.ico" /> OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB |
@@ -168,7 +168,7 @@ bash reinstall.sh anolis 7|8|23
alpine 3.20|3.21|3.22|3.23
opensuse 15.6|16.0|tumbleweed
openeuler 20.03|22.03|24.03|25.09
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
ubuntu 18.04|20.04|22.04|24.04|26.04 [--minimal]
kali
arch
gentoo

View File

@@ -89,7 +89,7 @@ Usage: $reinstall_____ anolis 7|8|23
alpine 3.20|3.21|3.22|3.23
opensuse 15.6|16.0|tumbleweed
openeuler 20.03|22.03|24.03|25.09
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
ubuntu 18.04|20.04|22.04|24.04|26.04 [--minimal]
kali
arch
gentoo
@@ -1309,12 +1309,11 @@ Continue?
setos_ubuntu() {
case "$releasever" in
16.04) codename=xenial ;;
18.04) codename=bionic ;;
20.04) codename=focal ;;
22.04) codename=jammy ;;
24.04) codename=noble ;;
25.10) codename=questing ;; # non-lts
26.04) codename=resolute ;;
esac
if is_use_cloud_image; then
@@ -1338,24 +1337,19 @@ Continue?
[ "$basearch_alt" = amd64 ] || [ "${releasever%.*}" -ge 24 ]
}
get_suffix() {
if [ "$releasever" = 16.04 ]; then
if is_efi; then
echo -uefi1
else
echo -disk1
fi
fi
}
basearch_img=$basearch_alt
if [ "$basearch_alt" = amd64 ] && [ "${releasever%.*}" -ge 26 ] && is_cpu_supports_x86_64_v3; then
basearch_img=amd64v3
fi
if [ "$minimal" = 1 ]; then
if ! is_have_minimal_image; then
error_and_exit "Minimal cloud image is not available for $releasever $basearch_alt."
fi
eval ${step}_img="$ci_mirror/minimal/releases/$codename/release/ubuntu-$releasever-minimal-cloudimg-$basearch_alt$(get_suffix).img"
eval ${step}_img="$ci_mirror/minimal/releases/$codename/release/ubuntu-$releasever-minimal-cloudimg-$basearch_img.img"
else
# 用 codename 而不是 releasever可减少一次跳转
eval ${step}_img="$ci_mirror/releases/$codename/release/ubuntu-$releasever-server-cloudimg-$basearch_alt$(get_suffix).img"
eval ${step}_img="$ci_mirror/releases/$codename/release/ubuntu-$releasever-server-cloudimg-$basearch_img.img"
fi
else
# 传统安装
@@ -1926,7 +1920,7 @@ verify_os_name() {
'opensuse 15.6|16.0|tumbleweed' \
'alpine 3.20|3.21|3.22|3.23' \
'openeuler 20.03|22.03|24.03|25.09' \
'ubuntu 16.04|18.04|20.04|22.04|24.04|25.10' \
'ubuntu 18.04|20.04|22.04|24.04|26.04' \
'redhat' \
'kali' \
'arch' \

132
trans.sh
View File

@@ -4402,23 +4402,19 @@ chroot_apt_autoremove() {
change_confs() {
action=$1
# 只有 16.04 有 01autoremove-kernels
# 16.04 结束支持后删除
for conf in 01autoremove 01autoremove-kernels; do
file=$os_dir/etc/apt/apt.conf.d/$conf
case "$action" in
change)
if [ -f $file ]; then
sed -i.orig 's/VersionedKernelPackages/x/; s/NeverAutoRemove/x/' $file
fi
;;
restore)
if [ -f $file.orig ]; then
mv $file.orig $file
fi
;;
esac
done
file=$os_dir/etc/apt/apt.conf.d/01autoremove
case "$action" in
change)
if [ -f $file ]; then
sed -i.orig 's/VersionedKernelPackages/x/; s/NeverAutoRemove/x/' $file
fi
;;
restore)
if [ -f $file.orig ]; then
mv $file.orig $file
fi
;;
esac
}
change_confs change
@@ -4927,19 +4923,6 @@ EOF
done
fi
# 16.04 arm64 镜像没有 grub 引导文件
if is_efi && ! [ -d $os_dir/boot/efi/EFI/ubuntu ]; then
chroot_apt_install $os_dir efibootmgr shim "grub-efi-$(get_axx64)"
# 创建 ubuntu 文件夹和 grubaa64.efi
DEBIAN_FRONTEND=noninteractive chroot $os_dir dpkg-reconfigure "grub-efi-$(get_axx64)"
cat <<EOF >"$os_dir/boot/efi/EFI/ubuntu/grub.cfg"
search.fs_uuid $os_part_uuid root
set prefix=(\$root)'/boot/grub'
configfile \$prefix/grub.cfg
EOF
fi
# 避免 do-release-upgrade 时自动执行 dpkg-reconfigure grub-xx 但是 efi/biosgrub 分区不存在而导致报错
# shellcheck disable=SC2046
chroot_apt_remove $os_dir $(is_efi && echo 'grub-pc' || echo 'grub-efi*' 'shim*')
@@ -4995,43 +4978,31 @@ EOF
# 网络配置
# 18.04+ netplan
if is_have_cmd_on_disk $os_dir netplan; then
# 避免删除 cloud-init 后minimal 镜像的 netplan.io 被 autoremove
chroot $os_dir apt-mark manual netplan.io
# 避免删除 cloud-init 后minimal 镜像的 netplan.io 被 autoremove
chroot $os_dir apt-mark manual netplan.io
# 生成 cloud-init 网络配置
create_cloud_init_network_config $os_dir/net.cfg
# 生成 cloud-init 网络配置
create_cloud_init_network_config $os_dir/net.cfg
# ubuntu 18.04 cloud-init 版本 23.1.2,因此不用处理 onlink
# ubuntu 18.04 cloud-init 版本 23.1.2,因此不用处理 onlink
# 如果不是输出到 / 则不会生成 50-cloud-init.yaml
# 注意比较多了什么东西
if false; then
chroot $os_dir cloud-init devel net-convert \
-p /net.cfg -k yaml -d /out -D ubuntu -O netplan
sed -Ei "/^[[:space:]]+set-name:/d" $os_dir/out/etc/netplan/50-cloud-init.yaml
cp $os_dir/out/etc/netplan/50-cloud-init.yaml $os_dir/etc/netplan/
# 如果不是输出到 / 则不会生成 50-cloud-init.yaml
# 注意比较多了什么东西
if false; then
chroot $os_dir cloud-init devel net-convert \
-p /net.cfg -k yaml -d /out -D ubuntu -O netplan
sed -Ei "/^[[:space:]]+set-name:/d" $os_dir/out/etc/netplan/50-cloud-init.yaml
cp $os_dir/out/etc/netplan/50-cloud-init.yaml $os_dir/etc/netplan/
# 清理
rm -rf $os_dir/net.cfg $os_dir/out
else
chroot $os_dir cloud-init devel net-convert \
-p /net.cfg -k yaml -d / -D ubuntu -O netplan
sed -Ei "/^[[:space:]]+set-name:/d" $os_dir/etc/netplan/50-cloud-init.yaml
# 清理
rm -rf $os_dir/net.cfg
fi
# 清理
rm -rf $os_dir/net.cfg $os_dir/out
else
# 避免删除 cloud-init 后 ifupdown 被 autoremove
chroot $os_dir apt-mark manual ifupdown
chroot $os_dir cloud-init devel net-convert \
-p /net.cfg -k yaml -d / -D ubuntu -O netplan
sed -Ei "/^[[:space:]]+set-name:/d" $os_dir/etc/netplan/50-cloud-init.yaml
# 16.04 镜像用 ifupdown/networking 管理网络
# 要安装 resolveconf不然 /etc/resolv.conf 为空
chroot_apt_install $os_dir resolvconf
ln -sf /run/resolvconf/resolv.conf $os_dir/etc/resolv.conf.orig
create_ifupdown_config $os_dir/etc/network/interfaces
# 清理
rm -rf $os_dir/net.cfg
fi
# 自带的 60-cloudimg-settings.conf 禁止了 PasswordAuthentication
@@ -7337,32 +7308,25 @@ get_ubuntu_kernel_flavor() {
# https://github.com/systemd/systemd/blob/main/src/basic/virt.c
# https://github.com/canonical/cloud-init/blob/main/tools/ds-identify
# http://git.annexia.org/?p=virt-what.git;a=blob;f=virt-what.in;hb=HEAD
if [ "$releasever" = 16.04 ]; then
# 这里有坑
# $(get_cloud_vendor) 调用了 cache_dmi_and_virt
# 但是 $(get_cloud_vendor) 运行在 subshell 里面
# subshell 运行结束后里面的变量就消失了
# 因此先运行 cache_dmi_and_virt
cache_dmi_and_virt
vendor="$(get_cloud_vendor)"
case "$vendor" in
aws | gcp | oracle | azure | ibm) echo $vendor ;;
*)
is_ubuntu_lts && suffix=-hwe-$releasever || suffix=
if is_virt; then
echo virtual-hwe-$releasever
echo virtual$suffix
else
echo generic-hwe-$releasever
echo generic$suffix
fi
else
# 这里有坑
# $(get_cloud_vendor) 调用了 cache_dmi_and_virt
# 但是 $(get_cloud_vendor) 运行在 subshell 里面
# subshell 运行结束后里面的变量就消失了
# 因此先运行 cache_dmi_and_virt
cache_dmi_and_virt
vendor="$(get_cloud_vendor)"
case "$vendor" in
aws | gcp | oracle | azure | ibm) echo $vendor ;;
*)
is_ubuntu_lts && suffix=-hwe-$releasever || suffix=
if is_virt; then
echo virtual$suffix
else
echo generic$suffix
fi
;;
esac
fi
;;
esac
}
install_redhat_ubuntu() {