From bd3cf7ac72a2c3e51cddcae29d2dc64ec95fe2e9 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Tue, 17 Nov 2015 15:49:21 -0800 Subject: [PATCH] a2server-2-tools: Use Debian's unar if available --- scripts/a2server-2-tools.txt | 62 ++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/scripts/a2server-2-tools.txt b/scripts/a2server-2-tools.txt index 8f6e8de..914c64a 100755 --- a/scripts/a2server-2-tools.txt +++ b/scripts/a2server-2-tools.txt @@ -65,7 +65,7 @@ fi # download and install The Unarchiver, for expanding Apple disk images # http://wakaba.c3.cx/s/apps/unarchiver.html -if [[ ! -f /usr/local/bin/unar ]]; then +if ! command -v unar >/dev/null; then echo "A2SERVER: Installing The Unarchiver..." @@ -75,34 +75,42 @@ if [[ ! -f /usr/local/bin/unar ]]; then touch /tmp/a2server-packageReposUpdated fi - if [[ $isRpi || $isDebian ]]; then - sudo apt-get -y install libgnustep-base1.22 - sudo apt-get clean - if [[ $isRpi ]]; then - wget -qO- "http://appleii.ivanx.com/a2server/files/unar-rpi.tgz" | sudo tar Pzx - elif [[ $isDebian ]]; then - wget -qO- "http://appleii.ivanx.com/a2server/files/unar-debian7_x86.tgz" | sudo tar Pzx + if apt-cache show unar &>/dev/null; then + # Debian package exists >= jessie. + sudo apt-get -y install unar + else + # Legacy binary tarballs for wheezy. + if [[ $isRpi || $isDebian ]]; then + sudo apt-get -y install libgnustep-base1.22 + sudo apt-get clean + if [[ $isRpi ]]; then + wget -qO- "http://appleii.ivanx.com/a2server/files/unar-rpi.tgz" | sudo tar Pzx + elif [[ $isDebian ]]; then + wget -qO- "http://appleii.ivanx.com/a2server/files/unar-debian7_x86.tgz" | sudo tar Pzx + fi fi + + # If all else fails, compile from source. + if ! command -v unar >/dev/null; then + sudo apt-get -y install build-essential + sudo apt-get -y install libgnustep-base-dev libz-dev libbz2-dev + sudo apt-get -y install libssl-dev libicu-dev unzip + sudo apt-get clean + rm -rf /tmp/unar &> /dev/null + mkdir /tmp/unar + cd /tmp/unar + wget -qO unar1.7_src.zip http://theunarchiver.googlecode.com/files/unar1.7_src.zip + unzip -o unar1.7_src.zip + cd The\ Unarchiver/XADMaster + make -f Makefile.linux + sudo mv lsar unar /usr/local/bin + cd ../Extra + sudo mv lsar.1 unar.1 /usr/local/man/man1 + cd + rm -rf /tmp/unar + fi + sudo mandb &> /dev/null fi - if [[ ! -f /usr/local/bin/unar ]]; then - sudo apt-get -y install build-essential - sudo apt-get -y install libgnustep-base-dev libz-dev libbz2-dev - sudo apt-get -y install libssl-dev libicu-dev unzip - sudo apt-get clean - rm -rf /tmp/unar &> /dev/null - mkdir /tmp/unar - cd /tmp/unar - wget -qO unar1.7_src.zip http://theunarchiver.googlecode.com/files/unar1.7_src.zip - unzip -o unar1.7_src.zip - cd The\ Unarchiver/XADMaster - make -f Makefile.linux - sudo mv lsar unar /usr/local/bin - cd ../Extra - sudo mv lsar.1 unar.1 /usr/local/man/man1 - cd - rm -rf /tmp/unar - fi - sudo mandb &> /dev/null else echo "A2SERVER: The Unarchiver has already been installed." fi