Commit 3be67002 authored by Vitaly Lipatov's avatar Vitaly Lipatov

tools_erc: update to erc 1.1.3

parent 40db80a2
......@@ -74,6 +74,8 @@ pax
zst
zstd
exe
AppImage
appimage
EOF
}
......@@ -155,3 +157,14 @@ get_archive_type()
fi
return 1
}
extract_command() {
local cmd="$1"
local archive="$2"
if is_command tar; then
docmd $cmd "$archive"
else
docmd $HAVE_7Z x -so "$archive" | docmd $HAVE_7Z x -y -si -ttar
fi
}
......@@ -65,6 +65,8 @@ create_archive()
;;
*)
# TODO: fix symlinks support
# https://bugzilla.altlinux.org/49852
# FIXME: creating .tar.* (.tar.gz) is not supported
docmd $HAVE_7Z a -l "$arc" "$@"
#fatal "Not yet supported creating of $type archives"
;;
......@@ -76,24 +78,49 @@ extract_archive()
local arc="$1"
shift
local type="$(get_archive_type "$arc")"
[ -n "$type" ] || fatal "Can't recognize type of $arc."
# TODO: move to patool
if [ "$type" = "exe" ] ; then
docmd $HAVE_7Z x "$arc"
exit
fi
if [ "$type" = "AppImage" ] || [ "$type" = "appimage" ] ; then
docmd chmod u+x "$arc" || fatal "Can't set executable permission"
docmd "$(realpath $arc)" --appimage-extract
mv squashfs-root "$(basename "$(basename "$arc" .AppImage)" .appimage)"
exit
fi
if have_patool ; then
docmd patool $verbose extract "$arc" "$@"
return
fi
local type="$(get_archive_type "$arc")"
arc="$(realpath -s "$arc")"
tdir=$(mktemp -d $(pwd)/UXXXXXXXX) && cd "$tdir" || fatal
local TSUBDIR="$(basename "$arc" .$type)"
local TSUBDIR="$(basename "$arc" .$type | sed -e 's|^tar\.||')"
# TODO: check if there is only one file?
# use subdir if there is no subdir in archive
case "$type" in
tar.*|tgz)
# TODO: check if there is only one file?
# use subdir if there is no subdir in archive
TSUBDIR="$(basename "$arc" .$(echo $type | sed -e 's|^tar\.||') )"
docmd $HAVE_7Z x -so "$arc" | docmd $HAVE_7Z x -y -si -ttar
tar.gz|tgz)
is_command gzip || fatal "Could not find gzip package. Please install gzip package and retry."
extract_command "tar -xhzf" "$arc"
;;
tar.xz|txz|tar.lzma)
is_command xz || fatal "Could not find xz package. Please install xz package and retry."
extract_command "tar -xhJf" "$arc"
;;
tar.zst)
is_command zstd || fatal "Could not find zstd package. Please install zstd package and retry."
extract_command "tar -I zstd -xhf" "$arc"
;;
tar)
extract_command "tar -xhf" "$arc"
;;
*)
docmd $HAVE_7Z x -y "$arc" "$@"
......@@ -325,11 +352,6 @@ case $cmd in
create_archive "$target" "$@"
;;
e|x|-e|-x|u|-u|extract|unpack) # HELPCMD: extract files from archive
# TODO: move to patool
if [ "$(get_archive_type "$1" 2>/dev/null)" = "exe" ] ; then
docmd $HAVE_7Z x "$1"
exit
fi
extract_archive "$@"
;;
# TODO: implement deletion
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment