fix tar进度问题
This commit is contained in:
parent
719b539b3f
commit
ee8d6e2963
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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` 创建文件路径父目录。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user