scripts/*.txt: Collapse multiple apt-gets in a row

As Debian has gone from large to huge, actions operating on the package
database have gotten slower and slower, so it's best to do them as few
times as possible.

Here we've got the trivial optimization.  A more complete optimization
requires a refactoring of code, and we're kind of in a 1.3.0 "freeze",
so let's not do that here and now.
This commit is contained in:
T. Joseph Carter 2015-12-21 16:17:13 -08:00
parent 0fffaf93cb
commit 06bc59ece7
3 changed files with 39 additions and 11 deletions

View File

@ -40,9 +40,10 @@ if ! command -v nulib2 > /dev/null; then
touch /tmp/a2server-packageReposUpdated touch /tmp/a2server-packageReposUpdated
fi fi
sudo apt-get -y install build-essential # Dependencies: build-dep for nulib
sudo apt-get -y install zlib1g-dev sudo apt-get -y install build-essential zlib1g-dev
sudo apt-get -y clean sudo apt-get -y clean
cd /tmp cd /tmp
rm -rf /tmp/nulib &> /dev/null rm -rf /tmp/nulib &> /dev/null
mkdir /tmp/nulib mkdir /tmp/nulib
@ -78,6 +79,7 @@ if ! command -v unar > /dev/null; then
touch /tmp/a2server-packageReposUpdated touch /tmp/a2server-packageReposUpdated
fi fi
# jessie and later: Just use the unar package
if [[ $isJessie ]]; then if [[ $isJessie ]]; then
sudo apt-get install -y unar sudo apt-get install -y unar
sudo apt-get clean sudo apt-get clean
@ -85,8 +87,11 @@ if ! command -v unar > /dev/null; then
if ! command -v unar > /dev/null; then if ! command -v unar > /dev/null; then
if [[ $isRpi || $isDebian ]]; then if [[ $isRpi || $isDebian ]]; then
# Dependencies: for unar
sudo apt-get -y install libgnustep-base1.22 sudo apt-get -y install libgnustep-base1.22
sudo apt-get clean sudo apt-get clean
if [[ $isRpi ]]; then if [[ $isRpi ]]; then
wget -qO- "http://appleii.ivanx.com/a2server/files/unar-rpi_wheezy.tgz" | sudo tar Pzx wget -qO- "http://appleii.ivanx.com/a2server/files/unar-rpi_wheezy.tgz" | sudo tar Pzx
elif [[ $isDebian ]]; then elif [[ $isDebian ]]; then
@ -96,10 +101,11 @@ if ! command -v unar > /dev/null; then
# If all else fails, compile from source. # If all else fails, compile from source.
if ! command -v unar >/dev/null; then 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 # Dependencies: build-deps for unar
sudo apt-get -y install libssl-dev libicu-dev unzip sudo apt-get -y install build-essential libgnustep-base-dev libz-dev libbz2-dev libssl-dev libicu-dev unzip
sudo apt-get clean sudo apt-get clean
rm -rf /tmp/unar &> /dev/null rm -rf /tmp/unar &> /dev/null
mkdir /tmp/unar mkdir /tmp/unar
cd /tmp/unar cd /tmp/unar
@ -121,7 +127,9 @@ fi
if ! command -v unzip >/dev/null; then if ! command -v unzip >/dev/null; then
echo "A2SERVER: Installing unzip..." echo "A2SERVER: Installing unzip..."
sudo apt-get -y install unzip
# Dependencies: unzip
sudo apt-get -y install unzip
else else
echo "A2SERVER: unzip has already been installed." echo "A2SERVER: unzip has already been installed."
fi fi

View File

@ -74,15 +74,19 @@ else
getOldPackage "http://ftp.debian.org/debian/pool/main/d/db/libdb5.1_5.1.29-5_i386.deb" getOldPackage "http://ftp.debian.org/debian/pool/main/d/db/libdb5.1_5.1.29-5_i386.deb"
fi fi
elif [[ $(apt-cache search '^libdb4.8$') ]]; then elif [[ $(apt-cache search '^libdb4.8$') ]]; then
# FIXME: Obsolete?
sudo apt-get -y install libdb4.8 sudo apt-get -y install libdb4.8
elif [[ $(apt-cache search '^libdb5.1$') ]]; then elif [[ $(apt-cache search '^libdb5.1$') ]]; then
# Dependencies: netatalk 2.2.4
sudo apt-get -y install libdb5.1 sudo apt-get -y install libdb5.1
else else
break break
fi fi
if [[ $(apt-cache search '^libssl1.0.0$') ]]; then if [[ $(apt-cache search '^libssl1.0.0$') ]]; then
# Dependencies: netatalk 2.2.4
sudo apt-get -y install libssl1.0.0 sudo apt-get -y install libssl1.0.0
elif [[ $(apt-cache search '^libssl0.9.8$') ]]; then elif [[ $(apt-cache search '^libssl0.9.8$') ]]; then
# FIXME: Obsolete?
sudo apt-get -y install libssl0.9.8 sudo apt-get -y install libssl0.9.8
else else
break break
@ -95,6 +99,7 @@ else
getOldPackage "http://ftp.debian.org/debian/pool/main/libg/libgcrypt11/libgcrypt11_1.5.0-5+deb7u3_i386.deb" getOldPackage "http://ftp.debian.org/debian/pool/main/libg/libgcrypt11/libgcrypt11_1.5.0-5+deb7u3_i386.deb"
fi fi
elif [[ $(apt-cache search '^libgcrypt11$') ]]; then elif [[ $(apt-cache search '^libgcrypt11$') ]]; then
# Dependencies: netatalk 2.2.4
sudo apt-get -y install libgcrypt11 sudo apt-get -y install libgcrypt11
else else
break break
@ -114,9 +119,8 @@ else
done done
if [[ $compileFromSource ]]; then if [[ $compileFromSource ]]; then
# Install development libraries needed by Netatalk # Dependencies: build-deps for netatalk 2.2.4
sudo apt-get -y install build-essential sudo apt-get -y install build-essential libssl-dev
sudo apt-get -y install libssl-dev
if [[ $isJessie ]]; then if [[ $isJessie ]]; then
if [[ $isRpi ]]; then if [[ $isRpi ]]; then
getOldPackage "http://mirrordirector.raspbian.org/raspbian/pool/main/d/db/libdb5.1-dev_5.1.29-5_armhf.deb" getOldPackage "http://mirrordirector.raspbian.org/raspbian/pool/main/d/db/libdb5.1-dev_5.1.29-5_armhf.deb"
@ -124,11 +128,14 @@ else
getOldPackage "http://ftp.us.debian.org/debian/pool/main/d/db/libdb5.1-dev_5.1.29-5_i386.deb" getOldPackage "http://ftp.us.debian.org/debian/pool/main/d/db/libdb5.1-dev_5.1.29-5_i386.deb"
fi fi
elif [[ $(apt-cache search '^libdb4.8-dev$') ]]; then elif [[ $(apt-cache search '^libdb4.8-dev$') ]]; then
# FIXME: Obsolete?
sudo apt-get -y install libdb4.8-dev sudo apt-get -y install libdb4.8-dev
elif [[ $(apt-cache search '^libdb5.1-dev$') ]]; then elif [[ $(apt-cache search '^libdb5.1-dev$') ]]; then
# Dependencies: build-deps for netatalk 2.2.4
sudo apt-get -y install libdb5.1-dev sudo apt-get -y install libdb5.1-dev
else else
echo "A2SERVER: WARNING: unknown version of libdb-dev is being installed." echo "A2SERVER: WARNING: unknown version of libdb-dev is being installed."
# Dependencies: build-deps for netatalk 2.2.4
sudo apt-get -y install libdb-dev sudo apt-get -y install libdb-dev
fi fi
if [[ $isJessie ]]; then if [[ $isJessie ]]; then
@ -139,9 +146,11 @@ else
getOldPackage "http://ftp.debian.org/debian/pool/main/libg/libgcrypt11/libgcrypt11-dev_1.5.0-5+deb7u3_i386.deb" getOldPackage "http://ftp.debian.org/debian/pool/main/libg/libgcrypt11/libgcrypt11-dev_1.5.0-5+deb7u3_i386.deb"
fi fi
elif [[ $(apt-cache search '^libgcrypt11-dev$') ]]; then elif [[ $(apt-cache search '^libgcrypt11-dev$') ]]; then
# Dependencies: build-deps for netatalk 2.2.4
sudo apt-get -y install libgcrypt11-dev sudo apt-get -y install libgcrypt11-dev
else else
echo "A2SERVER: WARNING: unknown version of libgcrypt-dev is being installed." echo "A2SERVER: WARNING: unknown version of libgcrypt-dev is being installed."
# Dependencies: build-deps for netatalk 2.2.4
sudo apt-get -y install $(apt-cache search '^libgcrypt.*dev$' | sort -r | head -1 | cut -d ' ' -f 1) sudo apt-get -y install $(apt-cache search '^libgcrypt.*dev$' | sort -r | head -1 | cut -d ' ' -f 1)
fi fi
sudo apt-get clean sudo apt-get clean
@ -276,6 +285,7 @@ if [[ -d /srv/A2SERVER/A2FILES && ! -d /srv/A2SERVER/.a2files ]]; then
sudo /etc/init.d/netatalk stop &> /dev/null sudo /etc/init.d/netatalk stop &> /dev/null
sudo /etc/init.d/samba stop &> /dev/null sudo /etc/init.d/samba stop &> /dev/null
if ! command -v getfattr &> /dev/null; then if ! command -v getfattr &> /dev/null; then
# Dependency: for ciopfs conversion (setfattr)
sudo apt-get -y install attr &> /dev/null sudo apt-get -y install attr &> /dev/null
sudo apt-get clean sudo apt-get clean
fi fi
@ -328,7 +338,10 @@ sudo sed -i \
if ! command -v ciopfs > /dev/null; then if ! command -v ciopfs > /dev/null; then
echo "A2SERVER: Installing ciopfs (case insensitive file system)..." echo "A2SERVER: Installing ciopfs (case insensitive file system)..."
cd /tmp cd /tmp
# Dependency: For ciopfs
sudo apt-get -y install fuse libglib2.0-0 libattr1 libfuse2 sudo apt-get -y install fuse libglib2.0-0 libattr1 libfuse2
if [[ $isRpi ]]; then if [[ $isRpi ]]; then
wget -qO- "http://appleii.ivanx.com/a2server/files/ciopfs-rpi.tgz" | sudo tar Pzx wget -qO- "http://appleii.ivanx.com/a2server/files/ciopfs-rpi.tgz" | sudo tar Pzx
elif [[ $isDebian_x86 ]]; then elif [[ $isDebian_x86 ]]; then
@ -346,9 +359,11 @@ if ! command -v ciopfs > /dev/null; then
sudo apt-get -y update sudo apt-get -y update
touch /tmp/a2server-packageReposUpdated touch /tmp/a2server-packageReposUpdated
fi fi
sudo apt-get -y install build-essential
sudo apt-get -y install libfuse-dev libglib2.0-dev libattr1-dev # Dependency: build-dep for ciopfs
sudo apt-get -y install build-essential libfuse-dev libglib2.0-dev libattr1-dev
sudo apt-get -y clean sudo apt-get -y clean
cd /tmp cd /tmp
rm -rf /tmp/ciopfs &> /dev/null rm -rf /tmp/ciopfs &> /dev/null
mkdir /tmp/ciopfs mkdir /tmp/ciopfs
@ -544,7 +559,10 @@ if [[ ! $(dpkg -l avahi-daemon 2> /dev/null | grep ^ii) || ! $(dpkg -l libnss-md
sudo apt-get -y update sudo apt-get -y update
touch /tmp/a2server-packageReposUpdated touch /tmp/a2server-packageReposUpdated
fi fi
# Dependency: Bonjour for netatalk
sudo apt-get -y install avahi-daemon libnss-mdns &> /dev/null sudo apt-get -y install avahi-daemon libnss-mdns &> /dev/null
fi fi
sudo sed -i 's/^\(hosts.*\)$/\1 mdns/' /etc/nsswitch.conf sudo sed -i 's/^\(hosts.*\)$/\1 mdns/' /etc/nsswitch.conf
if [[ ! -f /etc/avahi/services/afpd.service && ! -f /etc/avahi/services/afpd.service_disabled ]]; then if [[ ! -f /etc/avahi/services/afpd.service && ! -f /etc/avahi/services/afpd.service_disabled ]]; then

View File

@ -28,6 +28,8 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupWindowsSharing ]]; then
touch /tmp/a2server-packageReposUpdated touch /tmp/a2server-packageReposUpdated
fi fi
# Dependency: samba for Windows/modern Macs
# FIXME: Figure out when smbpasswd moved and adjust this as necessary
sudo apt-get -y install samba sudo apt-get -y install samba
command -v smbpasswd >/dev/null || sudo apt-get -y install samba-common-bin command -v smbpasswd >/dev/null || sudo apt-get -y install samba-common-bin
sudo apt-get clean sudo apt-get clean