bash : archive : add progress for extraction.
This commit is contained in:
parent
fd639dc055
commit
d3209a25ba
|
@ -144,15 +144,26 @@ unarchive()
|
||||||
saved="${saved%%.*}"
|
saved="${saved%%.*}"
|
||||||
|
|
||||||
# calculate actual hash.
|
# calculate actual hash.
|
||||||
local actual=$(sha1sum "${target}" | cut -d\ -f1)
|
local actual=$(pv "${target}" | sha1sum | cut -d\ -f1)
|
||||||
|
|
||||||
# extract if hash matched or show error if not.
|
# extract if hash matched or show error if not.
|
||||||
if [[ "${saved}" = "${actual}" ]]; then
|
if [[ "${saved}" = "${actual}" ]]; then
|
||||||
echo "${status}: OK."
|
echo "${status}: validation OK."
|
||||||
tar -xf "${target}"
|
case "${target##*.}" in
|
||||||
|
"xz")
|
||||||
|
pv "${target}" | xz -d | tar -xf -
|
||||||
|
;;
|
||||||
|
"gz")
|
||||||
|
pv "${target}" | gzip -d | tar -xf -
|
||||||
|
;;
|
||||||
|
esac
|
||||||
else
|
else
|
||||||
echo "${status}: failed."
|
echo "${status}: validation failed."
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# report extraction complete.
|
||||||
|
echo "${status}: done."
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue