From 53522b888c4e7920aa6c8a0a223e8474fb648458 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 27 Sep 2012 15:03:06 -0300 Subject: [PATCH] Bug 8840 - ubuntu-pkg-check.sh script doesn't work on non english setups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using dpkg to query for installed packages works in languages other than english. Added some switches to conveniently display the needed apt-get command for installing Koha's dependencies: -r | --report Report the status of Koha's dependencies -ic | --install-command Display the install command for the missing dependencies -h | --help Display this help message Regards To+ Sponsored-by: Universidad Nacional de Córdoba --- install_misc/ubuntu-packages.sh | 153 ++++++++++++++++++++++++++++++++++++++ install_misc/ubuntu-pkg-check.sh | 27 ------- 2 files changed, 153 insertions(+), 27 deletions(-) create mode 100755 install_misc/ubuntu-packages.sh delete mode 100755 install_misc/ubuntu-pkg-check.sh diff --git a/install_misc/ubuntu-packages.sh b/install_misc/ubuntu-packages.sh new file mode 100755 index 0000000..244877f --- /dev/null +++ b/install_misc/ubuntu-packages.sh @@ -0,0 +1,153 @@ +#!/bin/bash + +# Copyright 2012 Universidad Nacional de Cordoba +# Written by Tomas Cohen Arazi +# Mark Tompsett +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +usage() { + local scriptname=$(basename $0) + cat <1&> /dev/null ; then + return 0 + else + return 1 + fi +} + + +# Get the installed package version +getPackageVersion() { + local package=$1 + dpkg-query -W $package | cut -f2 +} + +# Loop over parameters +while (( "$#" )); do + case $1 in + -c | --check ) + CHECK=yes + ;; + -ic | --install-command ) + INSTALLCMD=yes + ;; + -h | --help) + HELP=yes + ;; + * ) + usage + exit 1 + esac + shift +done + +if [ "$HELP" = "yes" ]; then + usage + exit 0 +fi + +# Determine what directory this script is in, the packages files +# should be in the same path. +DIR=`dirname $0` + +# Determine the Ubuntu release +UBUNTU_RELEASE=`lsb_release -r | cut -f2 -d' '` +UBUNTU_PACKAGES_FILE=$DIR/ubuntu.$UBUNTU_RELEASE.packages + +# Check for the release-specific packages file. Default to the general one +# but warn the user about LTS releases recommended +if [ ! -e $UBUNTU_PACKAGES_FILE ]; then + UBUNTU_PACKAGES_FILE=$DIR/ubuntu.packages + + echo "# There's no packages file for your distro/release" + echo "# WARNING! We strongly recommend an LTS release." +fi + +echo "# Using the $UBUNTU_PACKAGES_FILE file as source" + +# We where asked to print the packages list and current versions (if any) +UBUNTU_PACKAGES=`awk '{print $1}' $UBUNTU_PACKAGES_FILE | grep -v '^\s*#' | grep -v '^\s*$'` + +MISSING_PACKAGES="" + +if [ "$CHECK" != "yes" ]; then + # Comment for skiping the dots if needed .... + echo -n "#" +fi + +for PACKAGE in $UBUNTU_PACKAGES +do + # Test if the package is installed + PACKAGE_INSTALLED="" + if packageInstalled $PACKAGE ; then + PACKAGE_INSTALLED=1 + else + # Not installed, accumulate for output + MISSING_PACKAGES="$MISSING_PACKAGES $PACKAGE" + fi + + if [ "$CHECK" = "yes" ]; then + if [ $PACKAGE_INSTALLED ]; then + PACKAGE_VERSION=`getPackageVersion $PACKAGE` + else + PACKAGE_VERSION="none" + fi + echo -e "$PACKAGE\t=\t$PACKAGE_VERSION" + else + # Echo a dot for the impatient + echo -n "." + fi + +done + +if [ "$CHECK" != "yes" ]; then + # newline + echo +fi + + +if [ "$INSTALLCMD" = "yes" ]; then + + cat < /dev/null | grep "Installed:"` - if [ "${#UBUNTU_PKG_POLICY}" -eq "0" ]; then - UBUNTU_PKG_POLICY="Installed: \(none\)\*" - fi - UBUNTU_PKG_VERSION=`echo $UBUNTU_PKG_POLICY | awk '{print $2}'` - echo "$F = $UBUNTU_PKG_VERSION" -done -- 1.7.9.5