3 # Copyright 2012 Universidad Nacional de Cordoba
4 # Written by Tomas Cohen Arazi
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
24 local scriptname=$(basename $0)
28 Query for missing dependencies. Print the install command for them if specified.
35 -r | --report Report the status of Koha's dependencies
36 -ic | --install-command Display the install command for the missing dependencies
37 -h | --help Display this help message
41 # Check if the package is installed
44 local package_status=`dpkg-query --showformat='${Status}' \
45 -W $package 2> /dev/null`
47 if [ "$package_status" == "install ok installed" ] ; then
54 # Get the installed package version
57 dpkg-query --showformat='${Version}' -W $package
60 # A parameter is required.
61 if [ "$#" -eq "0" ]; then
66 # Initialize variables
71 # Loop over parameters
77 -ic | --install-command )
90 if [ "$HELP" = "yes" ]; then
95 # Determine what directory this script is in, the packages files
96 # should be in the same path.
99 # Determine the Ubuntu release
100 UBUNTU_RELEASE=`lsb_release -r | cut -f2 -d' '`
101 UBUNTU_PACKAGES_FILE=$DIR/ubuntu.$UBUNTU_RELEASE.packages
103 # Check for the release-specific packages file. Default to the general one
104 # but warn the user about LTS releases recommended, if they are attempting
105 # to do an install command option.
106 if [ ! -e $UBUNTU_PACKAGES_FILE ]; then
107 UBUNTU_PACKAGES_FILE=$DIR/ubuntu.packages
108 if [ "$INSTALLCMD" == "yes" ]; then
109 echo "# There's no packages file for your distro/release"
110 echo "# WARNING! We strongly recommend an LTS release."
114 # We where asked to print the packages list and current versions (if any)
115 UBUNTU_PACKAGES=`awk '{print $1}' $UBUNTU_PACKAGES_FILE | grep -v '^\s*#' | grep -v '^\s*$'`
117 # Only output this on an install command option in order to maintain
118 # output equivalence to the former script, in the case of reporting
120 if [ "$INSTALLCMD" == "yes" ]; then
122 # Tell them which file being used to determine the output.
123 echo "# Using the $UBUNTU_PACKAGES_FILE file as source"
125 # Comment for skiping the dots if needed ....
126 if [ "$CHECK" == "no" ]; then
131 # Initialize variable to accumulate missing packages in.
134 # Loop used to accumulate the missing packages and display package information if requested to report.
135 for PACKAGE in $UBUNTU_PACKAGES; do
137 # If an install command option is running, but not a report option,
138 # There is no need to determine the version number. If it was
139 # This would run even slower!
141 # Test if the package is installed
142 PACKAGE_INSTALLED=`packageInstalled $PACKAGE`
144 # Determine the package version if it is installed.
145 if [ "$PACKAGE_INSTALLED" == "yes" ]; then
146 PACKAGE_VERSION=`getPackageVersion $PACKAGE`
148 # otherwise default to 'none'.
150 PACKAGE_VERSION="none"
151 MISSING_PACKAGES="$PACKAGE $MISSING_PACKAGES"
154 # If we are supposed to report...
155 if [ "$CHECK" == "yes" ]; then
158 # report the package name and version number.
159 echo "$PACKAGE = $PACKAGE_VERSION"
161 # Otherwise, we'll just echo a dot for the impatient.
168 # If we aren't reporting, then the last echo didn't have a newline.
169 if [ ! "$CHECK" == "yes" ]; then
173 # If the install command was requested...
174 if [ "$INSTALLCMD" == "yes" ]; then
176 # Give them a nicely indented command to copy, if dependencies are missing.
177 if [ "${#MISSING_PACKAGES}" -gt "0" ]; then
179 # Copy and paste the following command to install all Koha's dependencies on your system:
180 # Note: this command will run with admin privileges. Make sure your user has sudo rights
183 echo -e "\tsudo apt-get install $MISSING_PACKAGES"
185 # Otherwise tell them all is well.
187 echo -e "# All dependencies installed!"
188 echo -e "# Please confirm the version numbers are sufficient"
189 echo -e "# By running koha_perl_deps.pl -m -u."