Merge pull request #147 from v2fly/develop

Replace `unzip` with `bsdtar`
pull/148/head
IceCodeNew 2020-09-27 22:54:48 +08:00 committed by GitHub
commit 9089b11d8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -104,22 +104,27 @@ identify_the_operating_system_and_architecture() {
PACKAGE_MANAGEMENT_INSTALL='apt -y --no-install-recommends install'
PACKAGE_MANAGEMENT_REMOVE='apt purge'
package_provide_tput='ncurses-bin'
package_provide_bsdtar='libarchive-tools'
elif [[ "$(type -P dnf)" ]]; then
PACKAGE_MANAGEMENT_INSTALL='dnf -y install'
PACKAGE_MANAGEMENT_REMOVE='dnf remove'
package_provide_tput='ncurses'
package_provide_bsdtar='bsdtar'
elif [[ "$(type -P yum)" ]]; then
PACKAGE_MANAGEMENT_INSTALL='yum -y install'
PACKAGE_MANAGEMENT_REMOVE='yum remove'
package_provide_tput='ncurses'
package_provide_bsdtar='bsdtar'
elif [[ "$(type -P zypper)" ]]; then
PACKAGE_MANAGEMENT_INSTALL='zypper install -y --no-recommends'
PACKAGE_MANAGEMENT_REMOVE='zypper remove'
package_provide_tput='ncurses-utils'
package_provide_bsdtar='bsdtar'
elif [[ "$(type -P pacman)" ]]; then
PACKAGE_MANAGEMENT_INSTALL='pacman -Syu --noconfirm'
PACKAGE_MANAGEMENT_REMOVE='pacman -Rsn'
package_provide_tput='ncurses'
package_provide_bsdtar='libarchive'
else
echo "error: The script does not support the package manager in this operating system."
exit 1
@ -291,7 +296,7 @@ download_v2ray() {
}
decompression() {
if ! unzip -q "$1" -d "$TMP_DIRECTORY"; then
if ! bsdtar -C "$TMP_DIRECTORY" -xf "$1"; then
echo 'error: V2Ray decompression failed.'
"rm" -r "$TMP_DIRECTORY"
echo "removed: $TMP_DIRECTORY"
@ -511,7 +516,7 @@ main() {
echo 'warn: Install V2Ray from a local file, but still need to make sure the network is available.'
echo -n 'warn: Please make sure the file is valid because we cannot confirm it. (Press any key) ...'
read
install_software 'unzip' 'unzip'
install_software "$package_provide_bsdtar" 'bsdtar'
decompression "$LOCAL_FILE"
else
# Normal way
@ -526,7 +531,7 @@ main() {
echo "removed: $TMP_DIRECTORY"
exit 0
fi
install_software 'unzip' 'unzip'
install_software "$package_provide_bsdtar" 'bsdtar'
decompression "$ZIP_FILE"
elif [[ "$NUMBER" -eq '1' ]]; then
echo "info: No new version. The current version of V2Ray is $CURRENT_VERSION ."