From ee8d6e2963bdc13faaad9cb7f49846730978407f Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Mon, 1 Jun 2026 16:28:55 +0800 Subject: [PATCH] =?UTF-8?q?fix=20tar=E8=BF=9B=E5=BA=A6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install_efka.sh | 28 ++++++++++++++++++++++++++-- install_iot.sh | 28 ++++++++++++++++++++++++++-- install_service.md | 2 +- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/install_efka.sh b/install_efka.sh index 533abaa..5285fe0 100755 --- a/install_efka.sh +++ b/install_efka.sh @@ -161,6 +161,31 @@ archive_name_from_url() { basename "$clean_url" } +tar_supports_checkpoint() { + local tar_help + + tar_help="$(tar --help 2>&1 || true)" + case "$tar_help" in + *--checkpoint*) return 0 ;; + *) return 1 ;; + esac +} + +extract_archive() { + local archive_path="$1" + local install_dir="$2" + + log "Extracting archive to $install_dir" + if tar_supports_checkpoint; then + log "Extraction progress: one dot per 100 archive records" + run_as_root tar -zxf "$archive_path" -C "$install_dir" --checkpoint=100 --checkpoint-action=dot + printf '\n' + else + log "tar checkpoint progress is not supported; extracting quietly" + run_as_root tar -zxf "$archive_path" -C "$install_dir" + fi +} + parse_args() { while [[ $# -gt 0 ]]; do case "$1" in @@ -431,8 +456,7 @@ install_program() { log "Creating install directory: $install_dir" run_as_root install -d -m 0755 "$install_dir" - log "Extracting archive to $install_dir" - run_as_root tar -zxvf "$archive_path" -C "$install_dir" + extract_archive "$archive_path" "$install_dir" log "Removing downloaded archive: $archive_path" run_as_root rm -f "$archive_path" diff --git a/install_iot.sh b/install_iot.sh index b38f61c..d51bb40 100755 --- a/install_iot.sh +++ b/install_iot.sh @@ -167,6 +167,31 @@ archive_name_from_url() { basename "$clean_url" } +tar_supports_checkpoint() { + local tar_help + + tar_help="$(tar --help 2>&1 || true)" + case "$tar_help" in + *--checkpoint*) return 0 ;; + *) return 1 ;; + esac +} + +extract_archive() { + local archive_path="$1" + local install_dir="$2" + + log "Extracting archive to $install_dir" + if tar_supports_checkpoint; then + log "Extraction progress: one dot per 100 archive records" + run_as_root tar -zxf "$archive_path" -C "$install_dir" --checkpoint=100 --checkpoint-action=dot + printf '\n' + else + log "tar checkpoint progress is not supported; extracting quietly" + run_as_root tar -zxf "$archive_path" -C "$install_dir" + fi +} + parse_args() { while [[ $# -gt 0 ]]; do case "$1" in @@ -497,8 +522,7 @@ install_program() { log "Creating install directory: $install_dir" run_as_root install -d -m 0755 "$install_dir" - log "Extracting archive to $install_dir" - run_as_root tar -zxvf "$archive_path" -C "$install_dir" + extract_archive "$archive_path" "$install_dir" log "Removing downloaded archive: $archive_path" run_as_root rm -f "$archive_path" diff --git a/install_service.md b/install_service.md index 6282297..4bd17be 100644 --- a/install_service.md +++ b/install_service.md @@ -138,7 +138,7 @@ Environment="KEY=value" 3. 下载压缩包到临时文件。 4. 保存压缩包到 `WORK_DIR`。 5. 创建安装目录。 -6. 解压压缩包。 +6. 解压压缩包。GNU tar 环境下显示 checkpoint 点状进度,不输出文件列表;不支持 checkpoint 的 tar 会安静解压。 7. 删除保存到 `WORK_DIR` 的压缩包。 8. 设置安装目录 owner。 9. 根据 `*_DIR_ENV_KEYS` 创建数据目录,并根据 `*_PARENT_DIR_ENV_KEYS` 创建文件路径父目录。