dd: 修复 alpine 的 file -z 无法看透部分镜像导致文件类型验证失败

This commit is contained in:
bin456789
2024-10-24 21:28:50 +08:00
parent a976efffb7
commit 8d1ee541e3
4 changed files with 104 additions and 78 deletions

View File

@ -1736,6 +1736,9 @@ EOF
# 安装系统
install_$distro
# 安装 arch 有 gpg-agent 进程驻留
pkill gpg-agent || true
# 初始化
if false; then
# preset-all 后多了很多服务内存占用多了几十M
@ -1825,20 +1828,26 @@ get_http_file_size() {
pipe_extract() {
# alpine busybox 自带 gzip但官方版也许性能更好
case "$img_type_warp" in
xz | gzip) apk add $img_type_warp ;;
'') ;;
xz | gzip | zstd)
apk add $img_type_warp
"$img_type_warp" -dc
;;
tar)
apk add tar
tar x -O
;;
tar.*)
type=$(echo "$img_type_warp" | cut -d. -f2)
apk add tar "$type"
tar x "--$type" -O
;;
'') cat ;;
*) error_and_exit "Not supported img_type_warp: $img_type_warp" ;;
esac
if [ -n "$img_type_warp" ]; then
"$img_type_warp" -dc
else
cat
fi
}
dd_gzip_xz_raw() {
info "dd gzip xz raw"
dd_raw_with_extract() {
info "dd raw"
# 用官方 wget一来带进度条二来自带重试功能
apk add wget
@ -4967,7 +4976,7 @@ trans() {
;;
raw)
# 暂时没用到 raw 格式的云镜像
dd_gzip_xz_raw
dd_raw_with_extract
resize_after_install_cloud_image
modify_os_on_disk linux
;;
@ -4975,7 +4984,7 @@ trans() {
elif [ "$distro" = "dd" ]; then
case "$img_type" in
raw)
dd_gzip_xz_raw
dd_raw_with_extract
if false; then
# linux 扩容后无法轻易缩小,例如 xfs
# windows 扩容在 windows 下完成