Commit 62bbe429 authored by Vitaly Lipatov's avatar Vitaly Lipatov

erc: add support for repack zip->tar with 7z

parent 08868772
...@@ -116,7 +116,7 @@ extract_archive() ...@@ -116,7 +116,7 @@ extract_archive()
fi fi
arc="$(realpath -s "$arc")" arc="$(realpath -s "$arc")"
tdir=$(mktemp -d $(pwd)/UXXXXXXXX) && cd "$tdir" || fatal tdir="$(mktemp -d "$(pwd)/UXXXXXXXX")" && cd "$tdir" || fatal
local TSUBDIR="$(basename "$arc" .$type | sed -e 's|^tar\.||')" local TSUBDIR="$(basename "$arc" .$type | sed -e 's|^tar\.||')"
...@@ -148,14 +148,17 @@ extract_archive() ...@@ -148,14 +148,17 @@ extract_archive()
;; ;;
esac esac
local res=$?
cd - >/dev/null cd - >/dev/null
# if only one dir in the subdir # if only one dir in the subdir
if [ -e "$(echo $tdir/*)" ] ; then if [ -e "$(echo $tdir/*)" ] ; then
mv $tdir/* . mv "$tdir"/* .
rmdir $tdir rmdir "$tdir"
else else
mv $tdir "$TSUBDIR" mv "$tdir" "$TSUBDIR"
fi fi
return $res
} }
list_archive() list_archive()
...@@ -210,6 +213,19 @@ test_archive() ...@@ -210,6 +213,19 @@ test_archive()
} }
__repack_zip_tar()
{
sfile="$(realpath -s "$1")"
dfile="$(realpath -s "$2")"
ddir="$(dirname "$dfile")"
tdir="$(mktemp -d "$ddir/UXXXXXXXX")" && cd "$tdir" || fatal
trap "rm -fr $tdir" EXIT
extract_archive "$sfile" || fatal
create_archive "$dfile" "."
#cd - >/dev/null
#rm -fr "$tdir"
}
repack_archive() repack_archive()
{ {
if have_patool ; then if have_patool ; then
...@@ -231,8 +247,11 @@ repack_archive() ...@@ -231,8 +247,11 @@ repack_archive()
tar.*-tar.*) tar.*-tar.*)
docmd $HAVE_7Z x -so "$1" | $HAVE_7Z a -si "$2" docmd $HAVE_7Z x -so "$1" | $HAVE_7Z a -si "$2"
;; ;;
zip-tar)
__repack_zip_tar "$1" "$2"
;;
*) *)
fatal "Not yet supported repack of $ftype-$ttype archives in 7z mode (try install patool)" fatal "Not yet supported repack $ftype to $ttype archives in 7z mode (try install patool)"
;; ;;
esac esac
...@@ -263,7 +282,7 @@ $(get_help HELPOPT) ...@@ -263,7 +282,7 @@ $(get_help HELPOPT)
print_version() print_version()
{ {
echo "Etersoft archive manager version @VERSION@" echo "Etersoft archive manager version @VERSION@"
echo "Copyright (c) Etersoft 2013-2023" echo "Copyright (c) Etersoft 2013-2025"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3." echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
} }
...@@ -410,7 +429,7 @@ case $cmd in ...@@ -410,7 +429,7 @@ case $cmd in
exit exit
fi fi
# add support for target zip: # add support for target like zip:
for i in "$@" ; do for i in "$@" ; do
[ "$i" = "$lastarg" ] && continue [ "$i" = "$lastarg" ] && continue
target="$(build_target_name "$i" "$lastarg")" target="$(build_target_name "$i" "$lastarg")"
......
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